Gate 2: Initialize owns detach/reattach; delete dead StatOwner (F8)
StatModifier.Initialize recomputed _targets fresh every (re)activation but never reset _applied, so after deactivate -> unequip the target -> equip a replacement -> activate, Update saw `_executed && _applied` (both still true from the stale attachment) and neither branch of its latch fired again -- the modifier silently stopped reaching anything. Differential evidence: the same scenario resolved 6 pre-cut and 1 at Cut 2's HEAD. Chose the ownership fix over the one-line flag reset: Initialize is the entity's own re-activation hook, called exactly once per (re)activation for every StatModifier on it, so it is the one place that already knows a transition is happening. Detaching whatever this modifier was attached to before recomputing _targets removes the split authority between Initialize (which decides targets) and Update (which was silently also deciding attachment state) instead of leaving Update to infer a transition it was never told about. F8: Behaviors.cs's `StatOwner` property had no production caller -- it was added only to make one mutation test's mutant expressible. Deleted; the mutation test now uses `Entity` (a real symbol) as its wrong-owner stand-in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
b0d3354357
commit
5581911fb3
2 changed files with 12 additions and 4 deletions
|
|
@ -21,10 +21,6 @@ public abstract class Behavior
|
|||
protected Entity Entity => Item?.Entity ?? Consumable.Entity;
|
||||
public float Temperature => Item?.Temperature ?? Consumable.Entity.MaxTemp;
|
||||
|
||||
// The StatResolver key for whichever of Item/Consumable this behaviour has -- the two owners a resolved stat
|
||||
// value or an attached modifier can belong to (StatResolver.cs, docs/stats-and-power-cut.md Cut 2).
|
||||
protected object StatOwner => (object) Item ?? Consumable;
|
||||
|
||||
public float3 Direction
|
||||
{
|
||||
get
|
||||
|
|
|
|||
Loading…
Reference in a new issue