tModLoader v2024.09
A mod to make and play Terraria mods
|
Contains tile properties for multitiles dictating how they are placed and how they behave. Multitiles are non-terrain tiles. TileObjectData supports alternate placements as well as tile style-specific behaviors. The TileObjectData section of the Basic Tile wiki guidehas visuals and guides teaching how to use the TileObjectData system. More...
Public Member Functions | |
TileObjectData (TileObjectData copyFrom=null) | |
int | CalculatePlacementStyle (int style, int alternate, int random) |
Calculates a placement style from a provided tile style and random style offset. A placement style is the tile style multiplied by StyleMultiplier plus the alternate and random placement style offsets. The alternate parameter is unused, but the Style of this TileObjectData (equivalent to the value passed into addAlternate(int)) is used to offset the style to account for alternate placements. As such, this method should be called on the alternate TileObjectData if applicable, not the root TileObjectData for this tile style. Do this by first retrieving it by calling the GetTileData(Tile) method. | |
void | CopyFrom (TileObjectData copy) |
Copies all tile object data from the copy to this TileObjectData except the subtiles. FullCopyFrom(TileObjectData) will additionally copy subtiles. Copying tile data will copy anchors, sizes, origin, and all other properties of the tile dictating their placement behavior. The most common usage is to copy the tile properties of one of the existing tile templates found in the TileObjectData class: TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); . After copying from a template, the properties would be further customized if desired. Another common usage would be to copy a vanilla furniture tile to easily create tiles matching the behavior of existing furniture: TileObjectData.newTile.CopyFrom(TileObjectData.GetTileData(TileID.OpenDoor, 0)); . CopyFrom is used instead of FullCopyFrom in this situation because copying subtiles would incorrectly copy over subtile specific behavior, such as lava immunity for some subtiles. One more usage is to copy over tile properties from newTile to either newAlternate or newSubTile: TileObjectData.newSubTile.CopyFrom(TileObjectData.newTile); . Copying tile properties is a good approach to writing clean code and avoiding hard to troubleshoot bugs. Make sure to call this method before modifying any other properties as this method will overwrite any changes made earlier in the code. More... | |
void | FullCopyFrom (TileObjectData copy) |
Similar to CopyFrom(TileObjectData), except subtile data will also be copied. This is useful for inheriting subtile specific data, such as how each herb tile type (ImmatureHerbs, MatureHerbs, BloomingHerbs) share the same water placement and lava death properties for their Fireblossom and Moonglow styles. More... | |
void | FullCopyFrom (ushort tileType) |
bool | isValidAlternateAnchor (int type) |
If the tile type is in AnchorAlternateTiles, returns true. | |
bool | isValidTileAnchor (int type) |
If the tile type is in AnchorInvalidTiles, returns false. If AnchorValidTiles exists and tile type isn't in it, returns false. Otherwise returns true. | |
bool | isValidWallAnchor (int type) |
bool | LiquidPlace (Tile checkTile, bool checkStay=false) |
Static Public Member Functions | |
static void | addAlternate (int baseStyle) |
Registers newAlternate as an alternate placement of newTile. The baseStyle parameter corresponds to which placement style sprite this alternate placement will use. This value will apply an offset to the tile style being placed. ExampleTorch, for example, shows alternate placements using the 0, 1, and 2 placement style sprites, showing how different anchors can result in different placements sprites. ExampleDoorClosed, on the other hand, adds multiple alternates all using the same 0 placement sprite but different Origin to allow the user an easier time placing the door in a doorway. StyleMultiplier is usually used to account for alternate placements to allow them to be considered the same tile style. If RandomStyleRange is used, the random style will be added after the alternate placement style has been applied, so usually multiples of RandomStyleRange would be used for each addAlternate parameter. (For example, if RandomStyleRange is 5 for a tile with left and right placements, addAlternate(5) could be used for the right facing placement and StyleMultiplier should be set to 10.) | |
static void | addBaseTile (out TileObjectData baseTile) |
Similar to addTile(int) except the TileObjectData is not registered to a specific tile type. Instead, the completed TileObjectData is assigned to baseTile . This can be used by modders to create their own tile templates. | |
static void | addSubTile (params int[] styles) |
static void | addTile (int tileType) |
Registers the current newTile with the supplied tile type. Make sure to call this method last after all edits to newTile, newAlternate, and newSubTile. | |
static bool | CallPostPlacementPlayerHook (int tileX, int tileY, int type, int style, int dir, int alternate, TileObject data) |
static bool | CheckLavaDeath (int type, int style) |
static bool | CheckLavaDeath (Tile checkTile) |
static bool | CheckLiquidPlacement (int type, int style, Tile checkTile) |
static bool | CheckWaterDeath (int type, int style) |
static bool | CheckWaterDeath (Tile checkTile) |
static bool | CustomPlace (int type, int style) |
static void | FixNewTile () |
static TileObjectData | GetTileData (int type, int style, int alternate=0) |
Retrieves the TileObjectData corresponding to the passed in tile type , tile style , and optional alternate parameter. Terrain tiles will return null. Note that the alternate parameter in this method retrieves the alternate TileObjectData according to the order that they were registered, not according to a calculated alternate placement style. This parameter counts from 1, not 0, so the default parameter value of 0 will not attempt to retrieve an alternate TileObjectData. As such, it is not suitable for retrieving the TileObjectData of a placed Tile, use GetTileData(Tile) for that. Other related methods include GetTileData(Tile), GetTileInfo(Tile, ref int, ref int), and GetTileStyle(Tile). | |
static TileObjectData | GetTileData (Tile getTile) |
Retrieves the TileObjectData corresponding to the passed in Tile. Empty tiles and terrain tiles will return null. Any individual Tile of the multitile works. Will correctly retrieve the style or alternate specific TileObjectData if it exists. Other related methods include GetTileData(int, int, int), GetTileInfo(Tile, ref int, ref int), and GetTileStyle(Tile). | |
static void | GetTileInfo (Tile getTile, ref int style, ref int alternate) |
Retrieves the tile style and alternate placement corresponding to the passed in Tile. Empty tiles and terrain tiles will return without setting the ref parameters. Any Tile of the multitile works. Other related methods include GetTileData(Tile), GetTileData(int, int, int), and GetTileStyle(Tile). | |
static int | GetTileStyle (Tile getTile) |
Retrieves the tile style corresponding to the passed in Tile. Empty tiles and terrain tiles will return -1. Any Tile of the multitile works. This is most useful in replacing hard-coded math where the tile style is calculated from Tile.TileFrameX and Tile.TileFrameY directly, such as mouse over icons and other tile style specific behaviors. Other related methods include GetTileData(Tile), GetTileData(int, int, int), and GetTileInfo(Tile, ref int, ref int). | |
static void | Initialize () |
static bool | LiquidPlace (int type, Tile checkTile) |
static void | OriginToTopLeft (int type, int style, ref Point16 baseCoords) |
static int | PlatformFrameWidth () |
static void | SyncObjectPlacement (int tileX, int tileY, int type, int style, int dir) |
Static Public Attributes | |
static TileObjectData | newAlternate |
Contains the tile properties specific to an alternate placement of the current newTile. Alternate placements allow each style to be placed in multiple ways, using alternate sprites or alternate anchors. Mostly useful for tiles that can anchor in multiple ways, such as how torches can anchor to tiles to the left, right, or bottom as well as to walls. The newAlternate section of the Tile wiki pagehas more information about alternate placements. Calling addAlternate(int) registers the alternate placement. If there are subtiles (addSubTile(int)) for this tile, make sure to do those after alternates are registered and to set LinkedAlternates to true on newSubTile after copying the base tile. | |
static TileObjectData | newSubTile |
Contains the tile properties specific to a subtile, also known as a tile style, of the current newTile. Subtiles allow placed tile styles to have specific behaviors. This is most commonly used to declare certain tile styles as immune to lava or water. Another common usage is to declare specific tiles a tile style can anchor to. The newSubTile section of the Tile wiki pagehas more information about subtiles. Calling addSubTile(int) registers the alternate placement. If there are alternate placements (addAlternate(int)) for this tile, make sure to register those first and to set LinkedAlternates to true after copying the base tile. | |
static TileObjectData | newTile |
Contains the tile properties for the current tile. This is used to control the behavior, size, and other properties of a non-terrain tiles. Tiles using a TileObjectData are referred to as multitiles. The Basic Tile Guide on the wikihas more information about multitiles. After all properties are set, call addTile(int) to register the data to the tile type. newSubTile and newAlternate are used to provide subtile and alternate-specific properties. Alternates should be setup before subtiles. | |
static TileObjectData | Style1x1 |
No anchors. | |
static TileObjectData | Style1x2 |
static TileObjectData | Style1x2Top |
Anchors to tiles above. | |
static TileObjectData | Style1xX |
Is 1x3. | |
static TileObjectData | Style2x1 |
static TileObjectData | Style2x2 |
static TileObjectData | Style2xX |
Is 2x3. | |
static TileObjectData | Style3x2 |
static TileObjectData | Style3x3 |
static TileObjectData | Style3x3Wall |
Anchors to walls. | |
static TileObjectData | Style3x4 |
static TileObjectData | Style4x2 |
Has left and right alternate placements. | |
static TileObjectData | Style5x4 |
static TileObjectData | Style6x3 |
static TileObjectData | StyleAlch |
static TileObjectData | StyleDye |
static TileObjectData | StyleOnTable1x1 |
static TileObjectData | StyleSmallCage |
static TileObjectData | StyleSwitch |
static TileObjectData | StyleTorch |
Properties | |
int | AlternatesCount [get] |
int[] | AnchorAlternateTiles [get, set] |
Tiles contained in this array are tiles that will satisfy the AnchorType.AlternateTile anchor type. This can be used to provide specific additional valid anchors for a specific alternate placement or tile style. | |
AnchorData | AnchorBottom [get, set] |
Defines the anchors needed below this tile. Defaults to null, but most template styles will have this set already if copied from. Most typical furniture will define an AnchorBottom spanning the width of the multitile requiring solid tiles: TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); Read the Anchor section of the Basic Tile Guide on the wikifor more information. | |
int[] | AnchorInvalidTiles [get, set] |
Dictates specific tile types that are not valid for anchoring to. | |
AnchorData | AnchorLeft [get, set] |
Defines the anchors needed to the left of this tile. Defaults to null. Read the Anchor section of the Basic Tile Guide on the wikifor more information. | |
AnchorData | AnchorRight [get, set] |
Defines the anchors needed to the right of this tile. Defaults to null. Read the Anchor section of the Basic Tile Guide on the wikifor more information. | |
AnchorData | AnchorTop [get, set] |
Defines the anchors needed above this tile. Defaults to null. Read the Anchor section of the Basic Tile Guide on the wikifor more information. | |
int[] | AnchorValidTiles [get, set] |
Limits which tile types are valid for anchoring to a specific set of types. | |
int[] | AnchorValidWalls [get, set] |
Unimplemented, has no effect. | |
bool | AnchorWall [get, set] |
If true, then this multitile requires walls behind each individual tile to place. Defaults to false. | |
int | CoordinateFullHeight [get] |
The full height of a multitile in terms of the spritesheet texture coordinates (NOT world coordinates). Used to determine which style and alternate placement a specific Tile with Tile.TileFrameX and Tile.TileFrameY values belongs to. Equal to CoordinateHeights.Sum() + (CoordinatePadding * Height) + CoordinatePaddingFix.Y . | |
int | CoordinateFullWidth [get] |
The full width of a multitile in terms of the spritesheet texture coordinates (NOT world coordinates). Used to determine which style and alternate placement a specific Tile with Tile.TileFrameX and Tile.TileFrameY values belongs to. Equal to (CoordinateWidth + CoordinatePadding) * Width + CoordinatePaddingFix.X . | |
int[] | CoordinateHeights [get, set] |
An array defining how tall each individual tile within this multitile is, in pixels. This array must have exactly Height elements in it. In most cases, all values should be 16, but sometimes 18 is suitable for the last value. For example, a 3 tile high multitile might set CoordinateHeights as follows: TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 18 }; . Read the CoordinateHeights section of the Basic Tile Guide on the wikifor more information and helpful visualizations. Defaults to new int[] { 16 } . If changing Height this must be changed as well. | |
int | CoordinatePadding [get, set] |
The number of empty padding pixels between each individual tile of a multitile in its spritesheet. All vanilla tiles set this to 2. While it may be possible to use a value of 0 to make it easier on artists, there are plenty of places in the Terraria code that still assume a padding of 2 so it is not recommended. The examples shown in the Basic Tile wiki guideshow what the padding looks like in practice. The community has made tools such as tSpritePadderto simplify adding padding pixels to tile sprites. Defaults to 0 but most templates default this to 2. | |
Point16 | CoordinatePaddingFix [get, set] |
The number of pixels between each tile placement style of a multitile in its spritesheet in addition to the normal CoordinatePadding between each individual tile. Can be used to give more or less room between tile styles for the artist's convenience. Defaults to (0, 0). | |
int | CoordinateWidth [get, set] |
How wide each individual tile within this multitile is, in pixels. This should almost always be 16 since each tile in the world is 16x16 pixels, but in rare situations a different value might be suitable, such as in this TileID.Coral example on the Basic Tile Guide on the wikiwhere the extra-wide tile will spill out and draw outside the normal tile bounds. Defaults to 0, but most templates default this to 16. If not copying from a template or existing tile be sure to set this to 16. | |
TileObjectDirection | Direction [get, set] |
The direction this TileObjectData will be eligible to be placed in. Many furniture tiles allow the player to place them facing right or left controlled by the players current direction. These tiles do this by having the base tile place in one direction while an alternate is added placing in the other direction. See ExampleChairfor an example of this approach. Defaults to TileObjectDirection.None. | |
bool | DrawFlipHorizontal [get, set] |
If true, the tile placement preview will draw this tile flipped horizontally at even X tile coordinates. This effect must be replicated in ModTile.SetSpriteEffects(int, int, ref Microsoft.Xna.Framework.Graphics.SpriteEffects) to work for the placed tile. The ExampleLamp.SetSpriteEffects methodshows an example of this required code. Use this for visual variety and to break up visual repetition. Tiles with normal left and right placements, such as ExampleChair, will use alternate placements influenced by the player direction rather than this. Note that this should only be used for multitiles that are 1 tile wide, the effect will not work correctly for wider tiles. Defaults to false. | |
bool | DrawFlipVertical [get, set] |
If true, the tile placement preview will draw this tile flipped vertically at even Y tile coordinates. This effect must be replicated in ModTile.SetSpriteEffects(int, int, ref Microsoft.Xna.Framework.Graphics.SpriteEffects) to work for the placed tile. The ExampleLamp.SetSpriteEffects methodshows an example of this required code, albeit the example is for DrawFlipHorizontal usage. Use this for visual variety and to break up visual repetition. Note that this should only be used for multitiles that are 1 tile high, the effect will not work correctly for taller tiles. Defaults to false. | |
int | DrawStepDown [get, set] |
Similar to DrawYOffset, this also offsets the drawing of this tile in the Y direction, but this offset will only be applied if there is a solid tile above this tile. Torches use this to shift the torch down 2 more pixels so it doesn't look like the roof is being burnt. This is only applied to the tile placement preview and ModTile.SetDrawPositions(int, int, ref int, ref int, ref int, ref short, ref short) must be used to replicate this behavior in the placed tile. While torches use this, torches don't actually show a placement preview in the first place. The ExampleTorch.SetDrawPositions methodshows an example of this. | |
int | DrawStyleOffset [get, set] |
Offsets the tile placement preview by a number of placement styles. This can be used for tiles that have custom draw code to show something resembling the final placed tile despite the actual placement sprite missing parts of the final visuals. TileID.Mannequin and TileID.GolfCupFlag use this. Defaults to 0. | |
int | DrawXOffset [get, set] |
Offsets the drawing of this tile in the X direction. Can be used to draw a tile at a location other than the default. One example is how TileID.Switches appear slightly embedded into the tile they are anchored to. Read this section on the wikifor a visual explanation of this. Defaults to 0. | |
int | DrawYOffset [get, set] |
Offsets the drawing of this tile in the Y direction. Can be used to draw a tile at a location other than the default. One example is how TileID.Switches appear slightly embedded into the tile they are anchored to. Another example is how the alternate placement of banners for platforms shifts the drawing up. Read this section on the wikifor a visual explanation of this. Defaults to 0. | |
bool | FlattenAnchors [get, set] |
If true, placing this tile will cause the anchored solid tiles to become unsloped. Otherwise, slopes on anchor tiles will prevent this tile from placing. TileID.Switches, TileID.Torches, and TileID.ProjectilePressurePad (partially) all use this, allowing these tiles to be placed more conveniently. Defaults to false. | |
int | Height [get, set] |
The height of this multitile in tile coordinates. For example, chests are 2 tiles high while grandfather clocks are 5 tiles high. Read the Height section of the Basic Tile Guide on the wikifor more information and helpful visualizations. Defaults to 1. When changing this CoordinateHeights must be changed as well. | |
PlacementHook | HookCheckIfCanPlace [get, set] |
Designates a method to call to determine if the tile can't be placed by the player at the location. This method is only called on the client placing the tile. This is used by chest tiles to see if the chest limit has been reached and by pylons to check if the pylon has already been placed. | |
PlacementHook | HookPlaceOverride [get, set] |
Designates a method that will run instead of the usual code that places each individual tile of a mutitile in the world. Used only be TileID.ChristmasTree due to its complicated logic. | |
PlacementHook | HookPostPlaceEveryone [get, set] |
Unused. | |
PlacementHook | HookPostPlaceMyPlayer [get, set] |
Designates a method to call after this tile is placed by a player. This method facilitates binding extra data to a placed tile. This method is only called on the client placing the tile. This is used by chest tiles to place the actual Chest and by other tiles to place a TileEntity. | |
bool | LavaDeath [get, set] |
If true, this tile will break when in contact with lava. This supersedes the Main.tileLavaDeath value. By assigning to this on newSubTile this can be used to allow specific tile styles to be immune to lava. Modders should try to keep this and Main.tileLavaDeath in sync and only deviate from that common value for specific tile styles that should behave differently if any. ExampleTorchserves as an example of this and the Conditional Behavior section of the Basic Tile wiki pagealso has more information on this concept. Defaults to false, but many of the templates default this to true. | |
LiquidPlacement | LavaPlacement [get, set] |
Controls if a tile can be placed in lava. Typically used in conjunction with LavaDeath for consistency. Aside from obsidian furniture, most tiles in the game can not be placed in lava. Many tiles can't be placed in lava but won't break in lava, while others will break. ExampleTorchhas a style that is specifically placeable in lava. Defaults to LiquidPlacement.NotAllowed. | |
bool | LinkedAlternates [get, set] |
Call on newSubTile only. If set to true, this subtile will be populated with its own copy of the Alternates data. This will allow changes made to this subtile to apply to alternate placements of this tile style as well. This must be set to true after TileObjectData.newSubTile.CopyFrom(TileObjectData.newTile); and before adjusting any other properties. This should always be set for any subtile of a tile that has alternate placements. Defaults to false. | |
Point16 | Origin [get, set] |
The tile coordinate from which this multitile is placed from. This affects the position of the tile in relation to the users mouse and also the placement of the tile when placed through code such as WorldGen.PlaceTile(int, int, int, bool, bool, int, int) The Origin section of the Basic Tile wiki guidehas more information and useful visualizations of this property. Defaults to Point16.Zero (0, 0), or the top left corner tile. | |
int | RandomStyleRange [get, set] |
Allows this tile to place a randomly selected placement style when placing. The placement preview will update randomly as the player attempts to place the tile. For example, the TileID.Coral tile uses a RandomStyleRange value of 6, allowing 6 different tile placement styles to be selected when placing. This can be used in conjunction with StyleMultiplier to ensure that each of these random placement styles are considered the same tile style, but sometimes they are not. One interesting advanced usage of this feature is the TileID.Painting2X3 tile. It uses RandomStyleRange only for tile style 15, which allows the ItemID.StrangeGrowth item to place one of four tile styles. If used with alternate placement styles, the random styles of a specific alternate should be located together on the spritesheet. The addAlternate(int) parameter should account for RandomStyleRange as well. Note that tiles placed with WorldGen.PlaceTile(int, int, int, bool, bool, int, int) won't randomize if StyleMultiplier is also used, but a specific random placement style choice can be passed into WorldGen.PlaceObject(int, int, int, bool, int, int, int, int). Defaults to 0. | |
int[] | SpecificRandomStyles [get, set] |
Similar to RandomStyleRange, except a random placement style is selected from a selection of random placement styles. This is unused by vanilla tiles, but should work as expected. | |
int | Style [get, set] |
Used by alternate placements to offset the calculated placement style. Equal to the value passed into addAlternate(int). Defaults to 0. | |
bool | StyleHorizontal [get, set] |
If true, tile styles are arranged one after the other horizontally in the spritesheet, otherwise they are arranged vertically. New lines of styles will roll over to the next row once StyleWrapLimit is reached, if defined. Some tiles keep this false but use a small StyleWrapLimit and StyleMultiplier value to provide space for alternate placements, resulting in the tile styles themselves appearing to be arranged horizontally in the resulting spritesheet with the alternate placements below. Defaults to false . | |
int | StyleLineSkip [get, set] |
How many lines (rows if StyleHorizontal is true, columns if StyleHorizontal is false) will be skipped between each line of styles when wrapping to the next line due to StyleWrapLimit. Skipping lines allows tile spritesheets to have space for animations or toggled states (manual changes to TileFrameX and TileFrameY). For example, ExampleCampfiresets this to 9 because it has 8 animation frames and an off state taking up additional lines. Failure to set this for a tile that can change states will result in tile drops being incorrectly calculated. Defaults to 1, meaning no lines are skipped. | |
int? | styleLineSkipVisualOverride [get, set] |
A hack used by some vanilla tiles, do not use. | |
int | StyleMultiplier [get, set] |
Applies a multiplier to style calculations to account for alternate placements (addAlternate(int)) and RandomStyleRange. For example, chair tiles can be placed facing left or right. These are intended to share the same style (Item.placeStyle) value, but will have different placement style values. The multiplier accounts for these alternate placements allowing tile styles to be properly determined and consequently the correct item to drop when the tile is destroyed. If tiles are mistakenly dropping items from different styles, StyleMultiplier might have the incorrect value. Defaults to 1. | |
int | StyleWrapLimit [get, set] |
Defines how many tile placement styles (Number of styles times StyleMultiplier) will fit into a line (row if StyleHorizontal is true, column if StyleHorizontal is false) of the spritesheet before wrapping to the next line. This is used for organizational purposes and to keep spritesheets easy to work with. Defaults to 0, which will be interpreted as 1. | |
int? | StyleWrapLimitVisualOverride [get, set] |
A hack used by some vanilla tiles, do not use. | |
bool | UsesCustomCanPlace [get, set] |
If true, this tile will use anchors to decide if the tile can be placed, otherwise it will fallback to being placed like a terrain tile. Aside from platforms and torches, all multitiles set this to true. Defaults to false, but most template styles set this to true. If not copying from a template style or existing tile be sure to set this to true. | |
bool | WaterDeath [get, set] |
If true, this tile will break when in contact with water. This supersedes the Main.tileWaterDeath value. By assigning to this on newSubTile this can be used to allow specific tile styles to be immune to water. Modders should try to keep this and Main.tileWaterDeath in sync and only deviate from that common value for specific tile styles that should behave differently if any. ExampleTorchserves as an example of this and the Conditional Behavior section of the Basic Tile wiki pagealso has more information on this concept. Defaults to false. | |
LiquidPlacement | WaterPlacement [get, set] |
Controls if a tile can be placed in water. Typically used in conjunction with WaterDeath for consistency. Many tiles with visual flames, for example, tend to not allow themselves to be placed in water. ExampleTorchhas an underwater style that is specifically placeable underwater. Defaults to LiquidPlacement.Allowed. | |
int | Width [get, set] |
The width of this multitile in tile coordinates. For example, chests are 2 tiles wide while furnaces are 3 tiles wide. Read the Width section of the Basic Tile Guide on the wikifor more information and helpful visualizations. Defaults to 1. | |
Contains tile properties for multitiles dictating how they are placed and how they behave. Multitiles are non-terrain tiles.
TileObjectData supports alternate placements as well as tile style-specific behaviors.
The TileObjectData section of the Basic Tile wiki guide
has visuals and guides teaching how to use the TileObjectData system.
void TileObjectData.CopyFrom | ( | TileObjectData | copy | ) |
Copies all tile object data from the copy to this TileObjectData except the subtiles. FullCopyFrom(TileObjectData) will additionally copy subtiles. Copying tile data will copy anchors, sizes, origin, and all other properties of the tile dictating their placement behavior. The most common usage is to copy the tile properties of one of the existing tile templates found in the TileObjectData class: TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4);
. After copying from a template, the properties would be further customized if desired. Another common usage would be to copy a vanilla furniture tile to easily create tiles matching the behavior of existing furniture: TileObjectData.newTile.CopyFrom(TileObjectData.GetTileData(TileID.OpenDoor, 0));
. CopyFrom is used instead of FullCopyFrom in this situation because copying subtiles would incorrectly copy over subtile specific behavior, such as lava immunity for some subtiles. One more usage is to copy over tile properties from newTile to either newAlternate or newSubTile: TileObjectData.newSubTile.CopyFrom(TileObjectData.newTile);
. Copying tile properties is a good approach to writing clean code and avoiding hard to troubleshoot bugs. Make sure to call this method before modifying any other properties as this method will overwrite any changes made earlier in the code.
copy |
void TileObjectData.FullCopyFrom | ( | TileObjectData | copy | ) |
Similar to CopyFrom(TileObjectData), except subtile data will also be copied. This is useful for inheriting subtile specific data, such as how each herb tile type (ImmatureHerbs, MatureHerbs, BloomingHerbs) share the same water placement and lava death properties for their Fireblossom and Moonglow styles.
copy |