Tests: EB-1 structure damage/death, fortress targeting, persistence v3
10 new EditMode tests (312 total, all green): HealthApplyDamage destroys a Destructible at 0 + a wounded structure survives clamped; PickWeightedNearest x5 (player-only, structure-preferred-by-weight, player-in-the-way wins, raze undefended base, no targets); persistence (StructureSave.HP round-trip + writes v3, v2 in the load floor, SaveApply.ToPending maps the wounded HP - the staging-copy bug the pre-code review caught); + the StructureAggroWeight default pin. See DR-032. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -154,5 +154,45 @@ namespace ProjectM.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Lethal_Damage_Destroys_A_Destructible_Structure()
|
||||
{
|
||||
var (world, group) = MakeWorld("HealthApplyDamageDestructibleWorld");
|
||||
using (world)
|
||||
{
|
||||
var em = world.EntityManager;
|
||||
// EB-1: a structure = Health + DamageEvent + Destructible, NO EffectiveCharacterStats (clamps to 0).
|
||||
var e = em.CreateEntity(typeof(Health), typeof(DamageEvent), typeof(Destructible));
|
||||
em.SetComponentData(e, new Health { Current = 100f, Max = 100f });
|
||||
var dmg = em.GetBuffer<DamageEvent>(e);
|
||||
dmg.Add(new DamageEvent { Amount = 60f, SourceNetworkId = -1 });
|
||||
dmg.Add(new DamageEvent { Amount = 60f, SourceNetworkId = -1 }); // two Husk hits SUM (120 > 100)
|
||||
|
||||
group.Update();
|
||||
|
||||
Assert.IsFalse(em.Exists(e), "A Destructible at <=0 is destroyed exactly once (summed multi-hit, one DestroyEntity).");
|
||||
using var q = em.CreateEntityQuery(typeof(Destructible));
|
||||
Assert.AreEqual(0, q.CalculateEntityCount());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Wounded_Destructible_Survives_And_Clamps_To_Zero_Floor()
|
||||
{
|
||||
var (world, group) = MakeWorld("HealthApplyDamageWoundedStructureWorld");
|
||||
using (world)
|
||||
{
|
||||
var em = world.EntityManager;
|
||||
var e = em.CreateEntity(typeof(Health), typeof(DamageEvent), typeof(Destructible));
|
||||
em.SetComponentData(e, new Health { Current = 100f, Max = 100f });
|
||||
em.GetBuffer<DamageEvent>(e).Add(new DamageEvent { Amount = 35f, SourceNetworkId = -1 });
|
||||
|
||||
group.Update();
|
||||
|
||||
Assert.IsTrue(em.Exists(e), "A non-lethally-hit structure survives WOUNDED (the persisted state).");
|
||||
Assert.AreEqual(65f, em.GetComponentData<Health>(e).Current, 1e-4f, "No stats ceiling -> 100-35 = 65.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user