The Scenario
- Spawn a creature in a dedicated test world
- Wait for it to initialize (health, stats, effects)
- Verify it is alive and at the correct tier
- Apply lethal damage
- Wait for death processing
- Collect and verify loot drops
Full Example
Step-by-Step Breakdown
Spawn
ctx.spawnEntity() creates the entity in the command buffer. The reference is immediately returned, but the entity is not yet fully initialized.Wait for Init
ctx.waitTicks(2) lets the world tick twice, allowing ECS processors to initialize health, stats, and transform components.Verify Alive
StatsAssert.assertAlive() checks that health is above zero and no DeathComponent is present. assertHealthAtMax() confirms full health.Apply Damage
Your damage logic executes. This may set health to zero, apply a
DeathComponent, or trigger other processors.Await Death
ctx.awaitCondition() polls every tick. As soon as the entity has a DeathComponent, it returns. If 100 ticks pass without death, the test fails.Parameterized Flow
Test the same flow across multiple creature types:Next Steps
- Writing Custom Flows - structure your own flow tests
- Async & Tick Waiting - tick-waiting primitives
- Inventory & Loot - loot assertion details