System: damage¶
Damage and lethal interaction system.
Resolves damage and lethal damage interactions between entities based on their positions and movement trails, applying health reductions and death status updates as appropriate.
Damage is applied if either of the following conditions are met between a target entity and a damager entity during the current turn: - There is an overlap between the target and damager positions. - There is a swap of positions between the target and damager. - Their trails intersect. - The target crosses into the damager's previous position (based on their movement trails).
Damage is NOT applied if: - The target steps onto the damager's just vacated origin tile without any other interaction evidence (no overlap, no swap, no trail intersections).
Damage is only applied once per (target, damager) pair per turn, and status effects such as immunity or phasing can prevent damage application.
damage_system(state, ctx)
¶
Resolve damage / lethal interactions for this turn.
O(H * D + T) where
H = # entities with health D = # entities with damage/lethal components T = total trail entries this action