Skip to content

System: locked

Locked / unlocking system.

Handles adjacent-tile interaction between an entity's inventory and any neighboring locked objects. When the correct key is found, removes both the Locked and optional Blocking components so passage is opened. Keys are single-use: they are removed from inventory (and key map) upon unlocking.

unlock(state, entity_id, next_pos)

Attempt to unlock all locked entities at next_pos.

Consumes matching key(s) from the entity's inventory; multiple locks in the same tile are processed sequentially.

unlock_system(state, entity_id)

Attempt to unlock all locks adjacent to the specified entity and on its own tile.

Parameters:

Name Type Description Default
state State

Current immutable state.

required
entity_id EntityID

Entity whose inventory is used to unlock adjacent locks.

required

Returns:

Name Type Description
State State

Updated state.