Placement Handler

Each state described previously has an OnAction method that is triggered when you select a grid position while you are in one of those states.Those actions then call one method of the PlacementHandler which finalizes the action.The placement handler has 4 methods. The called method depends on the current state:

State
Called Method

PlacementState

PlaceObject

LoadObjectPlacementState

PlaceLoadedObject

MoveState

PlaceMovedObject

RemovStatee and RemoveAllState

RemoveObjectPositions

E.g. When you select an object from the shop UI you will enter the PlacementState which will allow you to place your object. Clicking the right mouse button on a grid cell will trigger the OnAction method of the PlacementState, which will then call PlaceObject from the placementHandler.

The PlaceObject() method then handles following things:

  • Initialize the object

  • Calculating pivot offset

  • Considering rotation

  • Considering scale if dynamicSize is activating

  • Calling ObjectGrouper to add the initialized object to the correct group

  • Adding a new script to the object called PlacedObject

Last updated