PieceCreator

PieceCreator

Places an item or spawns an agent on the board when a matching color event is received. The piece is placed either at this decorator's cell or at the origin cell of the triggering event, depending on PieceCreator#atOrigin.

Typical use: spawn a reward or enemy at a fixed location when a puzzle is solved elsewhere — e.g. place a Key on a pedestal or summon a guardian when the player pulls a lever on the other side of the board.

Constructor

new PieceCreator(terrain, color, piece, atOrigin)

Source:
Parameters:
Name Type Description
terrain Terrain

The underlying terrain this decorator wraps.

color Color

The color event that triggers piece placement.

piece Item | Agent

The item or agent instance to place.

atOrigin boolean

When true, place at the event's origin cell instead of this cell.

Extends

Classes

PieceCreator

Members

terrain :Terrain

Source:
Overrides:
Type:

Methods

getProxiedTerrain()

Description:
  • Return the terrain being wrapped (TerrainProxy interface).

Source:
Overrides:

onColorEventInternal(event, color, cell)

Description:
  • Places PieceCreator#piece on the target cell when the received color matches PieceCreator#color. Items are added unconditionally; agents are only placed if the target cell has no existing agent.

Source:
Parameters:
Name Type Description
event GameEvent
color Color
cell Cell