Merge origin/master into throttle-lock

This commit is contained in:
Meta Vens 2026-10-10 05:26:11 +02:00
commit 1be1023558
171 changed files with 8849 additions and 75 deletions

View file

@ -203,12 +203,10 @@ public abstract class Entity
return presencePermitted;
}), initialValue: true);
foreach (var item in Equipment)
foreach (var behavior in item.Behaviors)
{
if(behavior is IInitializableBehavior initializableBehavior)
initializableBehavior.Initialize();
}
// One initialiser for everything that computes targets here: gear and the effects still running, so a
// consumable active across a refit retargets to the new items exactly as gear does.
InitializeBehaviors(Equipment.SelectMany(item => item.Behaviors));
InitializeBehaviors(_activeConsumables.SelectMany(effect => effect.Behaviors));
foreach(var entity in Zone.Entities)
{
EntityInfoGathered[entity] = 0;
@ -860,7 +858,18 @@ public abstract class Entity
public void ActivateConsumable(ConsumableItem item)
{
_activeConsumables.Add(new ConsumableItemEffect(item, this));
var effect = new ConsumableItemEffect(item, this);
// The same hook Activate runs over Equipment: a behaviour that computes its targets there (StatModifier)
// would otherwise reach its second tick uninitialised.
InitializeBehaviors(effect.Behaviors);
_activeConsumables.Add(effect);
}
private static void InitializeBehaviors(IEnumerable<Behavior> behaviors)
{
foreach (var behavior in behaviors.ToList())
if (behavior is IInitializableBehavior initializable)
initializable.Initialize();
}
// Derived, never written: true iff an active consumable effect carries a ThrottleLock.
@ -1451,11 +1460,16 @@ public abstract class Entity
for (var i = 0; i < _activeConsumables.Count; i++)
{
_activeConsumables[i].Update(delta);
if (_activeConsumables[i].RemainingDuration < 0)
if (_activeConsumables[i].RemainingDuration <= 0)
{
// Cut 2 Gate 1 fix (docs/stats-and-power-cut.md): an expired consumable dropped out of this
// list without ever telling the resolver, leaving its generation/cache/modifier entries
// reachable (keyed by this ConsumableItemEffect instance) for the rest of the process.
// A StatModifier's attachments are keyed by its target items, not by the effect, so Forget alone
// leaves a boost attached to its targets: dispose each behaviour first.
foreach (var behavior in _activeConsumables[i].Behaviors)
if (behavior is IDisposable disposable)
disposable.Dispose();
Resolver.Forget(_activeConsumables[i]);
_activeConsumables.RemoveAt(i--);
}