Terrain

Terrain

Base class for all terrain types.

Terrain occupies one cell and controls whether agents can enter/exit, and what happens when they do. All callback methods are no-ops by default; subclasses override only what they need.

The Java Terrain interface is an event-based protocol: each callback receives a GameEvent that can be cancelled to prevent the default action.

Constructor

new Terrain()

Source:

Methods

canEnter()

Description:
  • Can an agent (or player) enter this terrain from the given direction? Mirrors Java AbstractTerrain.canEnter, plus a Raft bypass: crossing onto AQUATIC terrain from a cell currently occupied by a Raft always succeeds (the raft floats the agent across). WATER_RESISTANT/FIRE_RESISTANT are scoped to the player only — Java handles that bypass in onEnter (which this port's canEnter absorbs, since canEnter here is also consulted for the player's own physical traversability check). Return false to unconditionally block movement — no side effects.

Source:

canExit()

Description:
  • Can a non-player agent exit this terrain in the given direction? Mirrors Java AbstractTerrain.canExit exactly (no resistance/raft bypass — those only apply to entering).

Source:

onAdjacentTo()

Description:
  • This terrain is now adjacent to the player. Called after each move. Use this to reveal secret passages, trigger proximity effects, etc.

Source:

onAgentEnter()

Description:
  • A non-player agent is entering this terrain. Cancel event to prevent the move.

Source:

onAgentExit()

Description:
  • A non-player agent is exiting this terrain.

Source:

onColorEvent()

Description:
  • A color event is being broadcast on this board. Implementations compare this.color to the event color parameter and react only when they match.

Source:

onDrop()

Description:
  • An item is being dropped onto this terrain. Cancel event to make the item disappear (e.g., dropping into lava).

Source:

onEnter()

Description:
  • The player is entering this terrain. Cancel event to prevent the move.

Source:

onExit()

Description:
  • The player is exiting this terrain. Cancel event to prevent the move.

Source:

onFlyOut(flier)

Description:
  • An in-flight item is leaving this terrain (about to enter the next cell). Override to destroy or absorb the item as it leaves (e.g., Waterfall).

Source:
Parameters:
Name Type Description
flier InFlightItem

onFlyOver()

Description:
  • An in-flight item is passing over this terrain. Cancel event to make the item land here instead of continuing.

Source:

onNotAdjacentTo()

Description:
  • This terrain is no longer adjacent to the player.

Source:

onPickup()

Description:
  • An agent is picking up an item from this terrain. Cancel event to prevent the pickup.

Source: