/// <summary> /// 移除一个数据修改器 /// </summary> /// <param name="modifierName">所归属修改器集合名称</param> /// <param name="dataModifier">要移除的修改器</param> /// <param name="numericType">如果不为Min说明需要直接去更新属性</param> public void RemoveDataModifier(string modifierName, ADataModifier dataModifier, NumericType numericType = NumericType.Min) { if (AllModifiers.TryGetValue(modifierName, out var modifiers)) { if (modifiers.Remove(dataModifier)) { if (numericType == NumericType.Min) { return; } this.Entity.GetComponent <NumericComponent>()[numericType] = this.BaptismData(modifierName, this.Entity.GetComponent <NumericComponent>().GetOriNum()[(int)numericType]); return; } } Log.Error($"目前数据修改器集合中没有名为:{modifierName}的集合"); }
/// <summary> /// 新增一个数据修改器 /// </summary> /// <param name="modifierName">所归属修改器集合名称</param> /// <param name="dataModifier">要添加的修改器</param> /// <param name="numericType">如果不为Min说明需要直接去更新属性</param> public void AddDataModifier(string modifierName, ADataModifier dataModifier, NumericType numericType = NumericType.Min) { if (AllModifiers.TryGetValue(modifierName, out var modifiers)) { modifiers.Add(dataModifier); } else { AllModifiers.Add(modifierName, new List <ADataModifier>() { dataModifier }); } if (numericType == NumericType.Min) { return; } this.Entity.GetComponent <NumericComponent>()[numericType] = this.BaptismData(modifierName, this.Entity.GetComponent <NumericComponent>()[numericType]); }