Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using test;
- namespace Stats
- {
- class MoreStats
- {
- public interface HybridStat : IData
- {
- byte Decimals { get; }
- double DecimalFactor { get; }
- double DecimalPart { get; }
- }
- public abstract class LongHybridStat : NumericStat<long>, HybridStat
- {
- public static readonly byte MaxDecimals = 20;
- public byte Decimals { get; }
- public virtual long RawValue { get; protected set; }
- //these might need cached since Decimals never changes
- public override long MaxValue { get { return (long)(MaxLimit / DecimalFactor); } }
- public override long MinValue { get { return (long)(MinLimit / DecimalFactor); } }
- public virtual double DecimalFactor { get { return Math.Pow(10, Decimals); } }
- public virtual double DecimalPart { get { return (RawValue % DecimalFactor) / DecimalFactor; } }
- public override long Value
- {
- get { return (long)(RawValue / DecimalFactor); }
- protected set
- {
- RawValue = ClampValue((long)(value / DecimalFactor));
- }
- }
- protected override long ClampValue(long value)
- {
- return (value < MinValue) ? MinValue : ((value > MaxValue) ? MaxValue : value);
- }
- }
- public abstract class ULongHybridStat : NumericStat<ulong>, HybridStat
- {
- public static readonly byte MaxDecimals = 19;
- public byte Decimals { get; }
- public virtual ulong RawValue { get; protected set; }
- //these might need cached since Decimals never changes
- public override ulong MaxValue { get { return (ulong)(MaxLimit / DecimalFactor); } }
- public override ulong MinValue { get { return (ulong)(MinLimit / DecimalFactor); } }
- public virtual double DecimalFactor { get { return Math.Pow(10, Decimals); } }
- public virtual double DecimalPart { get { return (RawValue % DecimalFactor) / DecimalFactor; } }
- public override ulong Value
- {
- get { return (ulong)(RawValue / DecimalFactor); }
- protected set
- {
- RawValue = ClampValue((ulong)(value / DecimalFactor));
- }
- }
- protected override ulong ClampValue(ulong value)
- {
- return (value < MinValue) ? MinValue : ((value > MaxValue) ? MaxValue : value);
- }
- }
- //------------------
- //These will go in a mod
- //------------------
- //public class ResourceStat<T, U> : ULongStat
- // where T : ULongHybridStat
- // where U : ULongHybridStat
- //{
- // protected T BaseStat { get; set; }
- // public U CurrentStat { get; protected set; }
- // public override ulong Value
- // {
- // get { return BaseStat.Value; }
- // protected set { BaseStat.Set(value); }
- // }
- // public ulong Current
- // {
- // get { return CurrentStat.Value; }
- // protected set { CurrentStat.Set(value); }
- // }
- // public override ulong Use()
- // {
- // return BaseStat.Use();
- // }
- // [Obsolete("This version of Use does not work with a ResourceStat. Call Use(ulong) instead.", false)]
- // public override ulong Use(int amount)
- // {
- // throw new NotSupportedException("This version of Use does not work with a ResourceStat. Call Use(ulong) instead.");
- // }
- // public virtual ulong Use(ulong amount)
- // {
- // Set()
- // return BaseStat.Use(u);
- // }
- // public override ulong Set(ulong amount)
- // {
- // return CurrentStat.Set(amount);
- // }
- //}
- ////------------------
- ////These will go in a Renegade-specific mod
- ////------------------
- //public class EVStat : UnsignedHybridStat
- //{
- // public float ExcerciseAmount { get; }
- // public ulong UsageThreshold { get; }
- // public override ulong Use()
- // {
- // return Use(1L);
- // }
- // public override ulong Use(ulong u)
- // {
- // ulong oldValue = Value;
- // int count = Math.Max(u / UsageThreshold, 1);
- // Value = oldValue + (ExcerciseAmount * count);
- // return oldValue;
- // }
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment