Skip to content

System: status

Status effect management system.

This system manages the lifecycle of status effects applied to entities, including ticking down time limits, checking usage limits, and garbage collecting expired or orphaned effects.

cleanup_effect(effect_id, effect_ids)

Remove effect_id from status if present.

garbage_collect(state, time_limit, usage_limit, status)

Remove orphaned or expired effects from status and entity maps.

is_effect_expired(effect_id, time_limit, usage_limit)

Return True if effect's time or usage limit has reached zero.

status_gc_system(state)

Phase 2: prune orphaned / expired effects from statuses and entities.

status_system(state)

Run tick + GC phases for all statuses (public entry point).

status_tick_system(state, ctx)

Phase 1: decrement time limits for effects active at step start.

When an effect is collected/applied mid-step, it should not immediately lose one tick during the same step. We therefore tick using ctx.prev_status (a snapshot taken at the beginning of the step), not the possibly-updated state.status.

tick_time_limit(state, status, time_limit)

Decrement per-effect time limits present in status.