实现

  1. GameplayAttribute为属性封装,有两个重要字段,BaseValue,基础值,不包含增减益数值,一般为初始属性;CurrentValue,通过Modifier之后的属性值,增减益效果后的最终值。可以被继承,扩展自定义属性,例如,将力量和攻击力两种属性相关联。
  2. Modifier和ModifierConfig,设计为可池化,减少gc压力。运行时对象,以及配置对象,通过配置对象产生运行时对象,Modifier会被保存在GameplayAttribute里,通过一系列计算(可重写CalcCurrentValue),得到了GameplayAttribute的CurrentValue。
  3. IModifierSource,属性修改源,用于储存被修改过的属性id,方便追踪修改,移除AttributeSet里的GameplayAttribute的Mofifier实例。
  4. GameplayAttributeSet为属性集,使用map保存属性对象,key为int类型的属性id,可以方便的使用enum。
  5. 新增CapturedAttributeSet、CapturedAttribute、CaptureAttributeDefs实现属性快照,通过调用CapturedAttributeSet:Capture方法可以让某一些属性不再变化,适用于一些dot类技能

参考