CombatState derives its optimum range once the weapons' stats are known, and re-derives on loadout change

A zone-spawned ship's CombatState sampled in its constructor, before any weapon had evaluated its stats,
so the optimum range read 0 and never moved. It now marks the optimum stale on construction, on any
equipment add/remove and on a weapon's online change, and samples at the next Update once every active
weapon reports StatsKnown. ConsumableAiTests build the agent through Zone.Admit(piloted: true) and read
the optimum without re-sampling; new rows pin the hold scope, hull-heading source, mixed paints, sight
independence and the optimum across two guns and a refit.

Not yet verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-16 19:03:50 +02:00
commit bf32a82e32
3 changed files with 166 additions and 29 deletions

View file

@ -173,9 +173,13 @@ public abstract class Weapon : Behavior, IActivatedBehavior
Tracking = Evaluate(_data.Tracking);
}
// False until the first active tick has evaluated the stats above: before it they all read zero.
public bool StatsKnown { get; private set; }
public override bool Execute(float dt)
{
UpdateStats();
StatsKnown = true;
return true;
}