Fix nukies test

This commit is contained in:
Janet Blackquill
2025-09-30 00:07:24 -04:00
parent 3339d2d95c
commit 53a2b04077

View File

@@ -29,6 +29,7 @@ public sealed class WoundableSystem : EntitySystem
SubscribeLocalEvent<WoundableComponent, BeforeDamageCommitEvent>(OnBeforeDamageCommit); SubscribeLocalEvent<WoundableComponent, BeforeDamageCommitEvent>(OnBeforeDamageCommit);
SubscribeLocalEvent<WoundableComponent, DamageChangedEvent>(OnDamageChanged); SubscribeLocalEvent<WoundableComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<WoundableComponent, HealthBeingExaminedEvent>(OnHealthBeingExamined, before: [typeof(SharedBloodstreamSystem)]); SubscribeLocalEvent<WoundableComponent, HealthBeingExaminedEvent>(OnHealthBeingExamined, before: [typeof(SharedBloodstreamSystem)]);
SubscribeLocalEvent<WoundableComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<WoundComponent, StatusEffectRelayedEvent<WoundGetDamageEvent>>(OnWoundGetDamage); SubscribeLocalEvent<WoundComponent, StatusEffectRelayedEvent<WoundGetDamageEvent>>(OnWoundGetDamage);
SubscribeLocalEvent<WoundComponent, StatusEffectRelayedEvent<GetWoundsWithSpaceEvent>>(OnGetWoundsWithSpace); SubscribeLocalEvent<WoundComponent, StatusEffectRelayedEvent<GetWoundsWithSpaceEvent>>(OnGetWoundsWithSpace);
@@ -134,11 +135,11 @@ public sealed class WoundableSystem : EntitySystem
if (incoming is not null && incoming.DamageDict.TryGetValue(type, out var delta) && delta <= 0) if (incoming is not null && incoming.DamageDict.TryGetValue(type, out var delta) && delta <= 0)
{ {
DebugTools.AssertEqual(currentValue + delta, expectedValue, "wounds and damageable after delta don't line up"); DebugTools.AssertEqual(currentValue + delta, expectedValue, $"wounds and damageable after delta don't line up for {type}");
} }
else else
{ {
DebugTools.AssertEqual(currentValue, expectedValue, "wounds and damageable don't line up"); DebugTools.AssertEqual(currentValue, expectedValue, $"wounds and damageable don't line up for {type}");
} }
} }
#endif #endif
@@ -221,6 +222,13 @@ public sealed class WoundableSystem : EntitySystem
} }
} }
private void OnMapInit(Entity<WoundableComponent> ent, ref MapInitEvent args)
{
var damageable = Comp<DamageableComponent>(ent);
if (damageable.Damage.AnyPositive())
OnDamaged(ent, DamageSpecifier.GetPositive(damageable.Damage));
}
public void SetHealable(Entity<HealableWoundComponent> ent) public void SetHealable(Entity<HealableWoundComponent> ent)
{ {
ent.Comp.CanHeal = true; ent.Comp.CanHeal = true;
@@ -232,10 +240,13 @@ public sealed class WoundableSystem : EntitySystem
if (unique && _statusEffects.HasStatusEffect(ent, woundToSpawn)) if (unique && _statusEffects.HasStatusEffect(ent, woundToSpawn))
return false; return false;
if (!PredictedTrySpawnInContainer(woundToSpawn, PredictedTrySpawnInContainer(woundToSpawn,
ent, ent,
StatusEffectContainerComponent.ContainerId, StatusEffectContainerComponent.ContainerId,
out var wound)) out var wound);
DebugTools.Assert(wound is not null, "could not spawn wound in container");
if (wound is null)
return false; return false;
var comp = Comp<WoundComponent>(wound.Value); var comp = Comp<WoundComponent>(wound.Value);
@@ -268,6 +279,8 @@ public sealed class WoundableSystem : EntitySystem
if (delta.AnyPositive()) if (delta.AnyPositive())
OnDamaged(ent, DamageSpecifier.GetPositive(delta)); OnDamaged(ent, DamageSpecifier.GetPositive(delta));
ValidateWounds(ent, null);
} }
private void OnHealHealableWounds(Entity<HealableWoundComponent> ent, ref StatusEffectRelayedEvent<HealWoundsEvent> args) private void OnHealHealableWounds(Entity<HealableWoundComponent> ent, ref StatusEffectRelayedEvent<HealWoundsEvent> args)