protected override MutableObject Mutate(MutableObject mutable)
        {
            var entries = ValueField.GetEntries(mutable);

            if (entries.Count() < 1)
            {
                return(mutable);
            }

            float maxValue = ValueField.GetValue(entries.First());
            float minValue = maxValue;

            foreach (var entry in ValueField.GetEntries(mutable))
            {
                float foundValue = ValueField.GetValue(entry);

                if (maxValue < foundValue)
                {
                    maxValue = foundValue;
                }
                if (minValue > foundValue)
                {
                    minValue = foundValue;
                }
            }

            float range = Mathf.Abs(maxValue - minValue) < .00001f ? 1f : maxValue - minValue;

            foreach (var entry in ValueField.GetEntries(mutable))
            {
                float foundValue = ValueField.GetValue(entry);

                Proportion.SetValue((foundValue - minValue) / range, entry);
            }

            return(mutable);
        }
Exemple #2
0
 /// <summary>
 /// Get the value of the register via the reflected FieldInfo.
 /// </summary>
 /// <returns></returns>
 public object GetValue()
 {
     return(ValueField.GetValue(this));
 }