Zone.Entities read-only outside Zone: Admit and Remove are the only membership writers
Entities is a MemberView with no mutating member; Admit installs the death watch with the membership and refuses a member already present, Remove takes it away with the membership. The Reset and duplicate-Add bypass paths of the death watch cannot be spelled any more. Tests move to Admit/Remove; Admit also activates, so the explicit Activate calls that followed a raw Add are dropped. Unity call sites route through Zone.Remove. Builds: unverified at this commit (verified in the job at the head). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
38c2fcf6e4
commit
fa911f2d85
50 changed files with 206 additions and 320 deletions
|
|
@ -71,8 +71,7 @@ public sealed class StatResolverTests : IDisposable
|
|||
Assert.True(ship.TryEquip(Mint(cache, items, cache.GetByName<GearData>("Battery")), HardpointCell));
|
||||
if (withBooster)
|
||||
Assert.True(ship.TryEquip(Mint(cache, items, cache.GetByName<GearData>("Booster")), SecondHardpointCell));
|
||||
zone.Entities.Add(ship);
|
||||
ship.Activate();
|
||||
zone.Admit(ship, piloted: false);
|
||||
return ship;
|
||||
}
|
||||
|
||||
|
|
@ -287,9 +286,8 @@ public sealed class StatResolverTests : IDisposable
|
|||
var hullItem = Mint(cache, items, cache.GetByName<HullData>("Skiff"));
|
||||
var ship = new Ship(items, zone, hullItem, new EntitySettings());
|
||||
Assert.True(ship.TryEquip(Mint(cache, items, cache.GetByName<GearData>("Loop")), HardpointCell));
|
||||
zone.Entities.Add(ship);
|
||||
|
||||
var error = Assert.Throws<InvalidOperationException>(() => ship.Activate());
|
||||
var error = Assert.Throws<InvalidOperationException>(() => zone.Admit(ship, piloted: false));
|
||||
Assert.Contains(ship.Name, error.Message); // the entity, by name ("Skiff", HullData.Name)
|
||||
Assert.Contains(nameof(CapacitorData), error.Message);
|
||||
Assert.Contains(nameof(CapacitorData.Capacity), error.Message);
|
||||
|
|
@ -513,8 +511,7 @@ public sealed class StatResolverTests : IDisposable
|
|||
Assert.True(ship.TryEquip(boost, cells[i + 1]));
|
||||
}
|
||||
ship.OverrideShutdown = true;
|
||||
zone.Entities.Add(ship);
|
||||
ship.Activate();
|
||||
zone.Admit(ship, piloted: false);
|
||||
|
||||
Func<ConsumableItem> mint = null;
|
||||
if (consumable != null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue