Skip to main content
This page walks through a complete flow test that exercises the spawn-combat-loot pipeline. It demonstrates how to chain multiple steps with tick waiting and assert at each stage.

The Scenario

  1. Spawn a creature in a dedicated test world
  2. Wait for it to initialize (health, stats, effects)
  3. Verify it is alive and at the correct tier
  4. Apply lethal damage
  5. Wait for death processing
  6. Collect and verify loot drops

Full Example

Step-by-Step Breakdown

1

Spawn

ctx.spawnEntity() creates the entity in the command buffer. The reference is immediately returned, but the entity is not yet fully initialized.
2

Wait for Init

ctx.waitTicks(2) lets the world tick twice, allowing ECS processors to initialize health, stats, and transform components.
3

Verify Alive

StatsAssert.assertAlive() checks that health is above zero and no DeathComponent is present. assertHealthAtMax() confirms full health.
4

Apply Damage

Your damage logic executes. This may set health to zero, apply a DeathComponent, or trigger other processors.
5

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.
6

Collect Loot

Another awaitCondition() waits for loot entities to appear near the death location. Once found, LootAssert verifies the expected items.

Parameterized Flow

Test the same flow across multiple creature types:
Parameterized flows are powerful for regression testing across all entity types. If a content update breaks one creature’s loot table, the parameterized test will catch it.

Next Steps