tModLoader v2024.11
A mod to make and play Terraria mods
PlacementHook Struct Reference

Public Member Functions

 PlacementHook (Func< int, int, int, int, int, int, int > hook, int badReturn, int badResponse, bool processedCoordinates)
 Used by ObjectData.TileObjectData to provide custom logic to tile placement. hook : The method to call. The return value will be compared against badReturn if relevant. The parameters are: X tile coordinate, Y tile coordinate, tile type, tile style, direction, and alternate index. Use these parameters to execute extra logic for this tile placement. ModLoader.ModTileEntity has a few existing methods to use for various placement hooks. badReturn : Declares what return value from the hook should be interpreted as a failure. Typically -1. badResponse : Set to 0. processedCoordinates : If true, the top left corner coordinates of the tile will be passed into hook rather than the placement coordinate (the placement coordinate is where the mouse would be (Player.tileTargetX and Player.tileTargetY), accounting for the ObjectData.TileObjectData.Origin offset). Typically a true value will make all the logic in the hook method much simpler.
 
override bool Equals (object obj)
 
override int GetHashCode ()
 

Static Public Member Functions

static bool operator!= (PlacementHook first, PlacementHook second)
 
static bool operator== (PlacementHook first, PlacementHook second)
 

Public Attributes

int badResponse
 
int badReturn
 
Func< int, int, int, int, int, int, int > hook
 
bool processedCoordinates
 

Static Public Attributes

static PlacementHook Empty = new PlacementHook(null, 0, 0, processedCoordinates: false)
 
const int Response_AllInvalid = 0