public bool RemoveAllModifiersFromSource(IFloatModifierSource source) { bool didRemove = false; for (int i = floatModifiers.Count - 1; i >= 0; i--) { if (floatModifiers[i].Source == source) { isDirty = true; didRemove = true; floatModifiers.RemoveAt(i); } } //CalculateFinalValue(); return(didRemove); }
// Requires Value, Type and Source. Sets Order to its default value: (int)Type public static FloatModifier CreateInstance(float _value, StatModType _type, IFloatModifierSource _source) { return(CreateInstance(_value, _type, (int)_type, _source)); }
//--- Constructors --- Use like: FloatModifier.CreateInstance(.....) --- // "Main" constructor. Requires all variables. public static FloatModifier CreateInstance(float _value, StatModType _type, int _order, IFloatModifierSource _source) { var instance = ScriptableObject.CreateInstance <FloatModifier>(); instance.value = _value; instance.type = _type; instance.order = _order; instance.source = _source; return(instance); }