using System; using UnityEngine; [Serializable] public class ValueModifier { static readonly byte _defaultOrder = 0; public enum Type : byte { LowestFlat = 8, GreatestFlat = 9, Flat = 10, AppendablePercent = 20, Percent = 30, Set = 40, } [SerializeField] Type _type; [SerializeField] float _value; [SerializeField] byte order; public Type type => _type; public float value => _value; public byte Order => order == _defaultOrder ? (byte)_type : order; public object From { get; set; } public ValueModifier(Type type, float value) { _type = type; _value = value; order = _defaultOrder; } public ValueModifier(Type type, float value, byte order) { _type = type; _value = value; this.order = order; } public override string ToString() { switch (type) { case Type.AppendablePercent: case Type.Percent: return $"{value}%"; } return value.ToString("F2"); } }