method
World.despawn
World.despawn(entity)
Despawns an entity by id: it runs the entity's model @OnDespawn hook (with reason Despawned), sweeps any entity-scoped event listeners, and frees the slot back to the pool for reuse — the reflective, by-id form of the despawn statement. Use it from a system that has an entity id in hand (the engine world-bounds kill policy uses it, #84) or wherever you would write despawn e but only have the id.
Example
program Demo {
property Mob { hp: int = 0 }
model M { Mob }
entry {
spawn M { Mob { hp: 1 } }
let pm = World.prop_id("Mob")
let e = World.query_next(pm, 0)
World.despawn(e)
print(World.query_next(pm, 0)) # -1 — none left
}
}