State Machines

Enum-based guest states, transitions, dwell timers, dialog pauses.

stablegodotstate-machinenpc
On this page
Guest-accessible hallway while walking between stations
WALKING uses the navmesh; talking is a separate _in_conversation flag, not another enum value.

Implemented guest states

enum State { WAITING, WALKING, AT_STATION, DEAD }
StateBehavior
WAITINGSpawn / before schedule starts
WALKINGNavmesh steer toward stand
AT_STATIONIdle anim, interactable, maybe dwell timer
DEADRemoved from play after murder resolution

There is no TALKING state. Talking is _in_conversation: bool layered on top so possession / walk / station stay orthogonal.

Transitions

func move_to_station(new_station: Station) -> void:
	GuestManager.release_stand(self)
	# ...
	state = State.WALKING

func _arrive_at_destination() -> void:
	state = State.AT_STATION
	_maybe_start_dwell()

Front desk: advance schedule when dialog closes, not on a timer.

Other stations: create_timer(dwell_seconds) then advance, unless a conversation is open — then set _leave_when_dialog_closes.

Keep dialog out of the state enum

Dialog code should not invent POSSESSED_WALKING. Flag + data lookup is enough:

guest_data.dialog.get_conversation(period, day, is_possessed)

Simple pattern for jam games

enum State { IDLE, WALK, TALK }
var state := State.IDLE

func set_state(next: State) -> void:
	state = next
	# optional: enter/exit hooks

func _physics_process(delta: float) -> void:
	match state:
		State.IDLE: pass
		State.WALK: _steer(delta)
		State.TALK: velocity = Vector2.ZERO

Favor explicit match over a plugin framework at this scale.

Planned / not implemented as states

  • Formal ARRIVING / LEAVING (covered by WALKING + schedule index)
  • Combat / panic states
  • Shared hierarchical state-machine library

Recommended next step: if conversation blocking spreads, add enter_state / exit_state helpers — still enum-based.