public sealed class AttributeSetOne thing's stats: base values, the modifiers acting on them, and the results.
Remarks
The evaluation order is fixed and this class is where it is written down once (doc 28 § Attributes):
base → +flat → ×(1 + Σ additive%) → ×Π(1 + multiplicative%) → clamp → round
Removal is by source, and the value is recomputed rather than subtracted. Undoing a buff by adding its negation back is how a stat ends up at 99.9997 after ten cycles of a proc that grants and removes 15 %; recomputing from the survivors cannot drift, because the same set of modifiers always produces the same number.
Modifiers are held in a canonical order, not in the order they arrived. Float addition is not associative, so a client that applied a trinket before a raid buff and a realm that applied them the other way round would compute numbers that differ in the last bit — which prediction reports as a mismatch and a player sees as jitter. Sorting on (stat, bucket, source, value) costs an insertion memmove and removes the whole class.
Recomputation is dirty-flagged per stat and batched. Applying twelve modifiers marks the stats they touch and computes nothing; the first read, or the frame's Recompute, does the arithmetic once. What replicates is the result — a client is told a number, not a list of modifiers it would have to re-derive.
Fields and properties (4)
public AttributeLayout LayoutThe stats this set has.
public IReadOnlyList<Modifier> ModifiersEvery modifier currently applied, in canonical order.
public int DroppedModifiersHow many modifiers have been handed to Add for a stat this layout does not declare, and therefore dropped.
public bool HasChangesWhether anything at all has moved since ClearChanges was last called.
Methods (11)
public AttributeSet(AttributeLayout layout)Makes a set over a layout, every stat at its declared default.
public float BaseOf(AttributeId attribute)The unmodified value of a stat.
public bool SetBase(AttributeId attribute, float value)Sets the unmodified value of a stat.
public float ValueOf(AttributeId attribute)The value of a stat with every modifier applied.
public bool Add(in Modifier modifier)Applies a modifier.
public int AddRange(ReadOnlySpan<Modifier> span)Applies several modifiers.
public int RemoveBySource(ModifierSource source)Removes every modifier one source granted.
public void ClearModifiers()Removes every modifier, whatever granted it.
public int Recompute()Recomputes every stat a change has touched.
public bool HasChanged(AttributeId attribute)Whether a stat's value has moved since ClearChanges was last called.
public void ClearChanges()Forgets which stats moved. Called after the changes have been sent or drawn.
Used by (20)
- AbilityCasterVixen.Gameplay.Combat
- AbilityCasterTestsVixen.Gameplay.Combat.Tests
- AbilityLibraryTestsVixen.Gameplay.Combat.Tests
- AbilityTemplateVixen.Gameplay.Combat
- AttributeSetTestsVixen.Gameplay.Tests
- CombatModuleTestsVixen.Gameplay.Combat.Tests
- CombatResolverVixen.Gameplay.Combat
- CombatResolverTestsVixen.Gameplay.Combat.Tests
- CriticalStrikeRuleVixen.Gameplay.Combat
- DamageRuleTestsVixen.Gameplay.Combat.Tests
- EffectSetVixen.Gameplay
- EffectSetTestsVixen.Gameplay.Tests
- GameplaySubjectVixen.Gameplay
- GameplaySubjectTestsVixen.Gameplay.Tests
- HealthRuleVixen.Gameplay.Combat
- ItemStatsTestsVixen.Gameplay.Items.Tests
- ProgressionStateTestsVixen.Gameplay.Progression.Tests
- RequirementTestsVixen.Gameplay.Tests
- ResistanceRuleVixen.Gameplay.Combat
- ShieldAbsorbRuleVixen.Gameplay.Combat