class LevelState : GameState
decision: ActionDecision?

The current decision being processed, if any.

level: Level

The level object representing the game environment.

display: Display

The display object used for rendering.

message: ActionMessage

The most recent action message.

geometer: EditorState

An editor state for debugging or managing geometry.

__new(self: LevelState, level: Level, display: Display)

Constructs a new LevelState. Sets up the game loop, initializes decision handlers, and binds custom callbacks for drawing.

Parameters:
  • level (Level) – The level object to be managed by this state.

  • display (Display) – The display object for rendering the level.

updateCoroutine: thread
time: number
shouldAdvance(self: LevelState) shouldAdvance: boolean | nil

Determines if the coroutine should proceed to the next step.

Returns:

shouldAdvance (boolean | nil) – True if the coroutine should advance; false otherwise.

handleMessage(self: LevelState, message: Message)

Handles incoming messages from the coroutine. Processes decisions, action messages, and debug messages as appropriate.

Parameters:

message (Message) – The message to handle.

getSenses(self: LevelState) primary: Senses[], secondary: Senses[]

Collects and returns all player controlled senses into a group of primary (active turn) and secondary (other player controlled actors).

updateDecision(self: LevelState, dt: number, actor: Actor, decision: ActionDecision)

This method is invoked each update when a decision exists and its response is not yet valid.. Override this method in subclasses to implement custom decision-handling logic.

Parameters:
  • dt (number) – The time delta since the last update.

  • actor (Actor) – The actor responsible for making the decision.

  • decision (ActionDecision) – The decision being updated.

transformMousePosition(self: LevelState, mx: number, my: number) mx: number, my: number

Compute a custom mouse transform for retrieving cells. This should return the mouse coordinates transformed to the display’s context. e.g. if you scale the display by 3x, this should scale it back down by 3x.

Parameters:
  • mx (number) – The X-coordinate of the mouse.

  • my (number) – The Y-coordinate of the mouse.

Returns:
  • mx (number) – The transformed X-coordinate.

  • my (number) – The transformed Y-coordinate.

getCellUnderMouse(self: LevelState) x?: integer, y?: integer, Cell?

Returns the X-coordinate, Y-coordinate, and cell the mouse is over, if the mouse is over a cell.

getCurrentActor(self: LevelState) Actor?

Gets the actor waiting for an action. Usually the player.