public void Set(AttributeType type, float value, EventOnAttributeChange onAttributeChange) { if (!attributes.ContainsKey(type)) { if (value != 0) { attributes.Add(type, value); onAttributeChange.Invoke(type, 0, value); } } else { float previousValue = attributes[type]; if (value != previousValue) { attributes[type] = value; onAttributeChange.Invoke(type, previousValue, value); } } }
public void Modify(AttributeType type, float value, EventOnAttributeChange onAttributeChange, int t = 1) { float previousValue; if (!attributes.ContainsKey(type)) { previousValue = 0; attributes.Add(type, value * t); } else { previousValue = attributes[type]; attributes[type] += value * t; } onAttributeChange.Invoke(type, previousValue, attributes[type]); }