tModLoader v2024.10
A mod to make and play Terraria mods
GlobalPylon Class Reference

Global Type that exists for pylons that allows for modification of teleportation steps, map drawing, and other functionality for any pylon that exists, whether it be vanilla or modded. More...

Inherits ModType< TEntity, TModType >.

Public Member Functions

virtual void PostValidTeleportCheck (TeleportPylonInfo destinationPylonInfo, TeleportPylonInfo nearbyPylonInfo, ref bool destinationPylonValid, ref bool validNearbyPylonFound, ref string errorKey)
 Called after all checks have taken place for all vanilla and modded pylons when a teleportation request is sent (AKA when the player clicks on a pylon on the map). You can (for example) use this to allow teleportation to go through even if one the normal requirements haven't been met, or vice versa; to do this, change destinationPylonValid to true or false respectively (for the given example). More...
 
virtual ? bool PreCanPlacePylon (int x, int y, int tileType, TeleportPylonType pylonType)
 Called right before both modded and vanilla pylons determine whether or not they can be placed. Returning false will prevent vanilla checks from taking place, forcefully preventing the pylon from being placed. Returning null will enact vanilla behavior, and returning true will make the check forcefully succeed, regardless of vanilla behavior. Returns null by default. More...
 
virtual bool PreDrawMapIcon (ref MapOverlayDrawContext context, ref string mouseOverText, ref TeleportPylonInfo pylonInfo, ref bool isNearPylon, ref Color drawColor, ref float deselectedScale, ref float selectedScale)
 Called right before both modded and vanilla pylons draw their icons on the map. Returning false will prevent the passed in icon from being drawn on the map. Returns true by default. More...
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual ? bool ValidTeleportCheck_PreAnyDanger (TeleportPylonInfo pylonInfo)
 Called before Step 2 of the ValidTeleportCheck process. This is the second vanilla check that is called when the player attempts to teleport TO a Pylon. This method is called before both vanilla and modded pylons check their Danger requirements, and returning false will prevent those checks from taking place, forcefully failing the AnyDanger step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. More...
 
virtual ? bool ValidTeleportCheck_PreBiomeRequirements (TeleportPylonInfo pylonInfo, SceneMetrics sceneData)
 Called before Step 3 of the ValidTeleportCheck process. This is the fourth vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their Biome requirements, and returning false will prevent those checks from taking place, forcefully failing the BiomeRequirements step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. More...
 
virtual ? bool ValidTeleportCheck_PreNPCCount (TeleportPylonInfo pylonInfo, ref int defaultNecessaryNPCCount)
 Called before Step 1 of the ValidTeleportCheck process. This is the first vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their NPC requirements, and returning false will prevent those checks from taking place, forcefully failing the NPCCount step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default. More...
 
- Public Member Functions inherited from ModType< TEntity, TModType >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
 
abstract void Load (Mod mod)
 Called when loading the type. More...
 
abstract void Unload ()
 Called during unloading when needed. More...
 
- Public Member Functions inherited from ModType< TEntity >
virtual TModType Clone (TEntity newEntity)
 Create a copy of this instanced global. Called when an entity is cloned. More...
 
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual TModType NewInstance (TEntity entity)
 Create a new instance of this ModType for a specific entity More...
 
string PrettyPrintName ()
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Protected Member Functions

sealed override void Register ()
 If you make a new ModType, seal this override. More...
 
- Protected Member Functions inherited from ModType< TEntity, TModType >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 
- Protected Member Functions inherited from ModType< TEntity >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types More...
 
override void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
abstract void Register ()
 If you make a new ModType, seal this override. More...
 
virtual void ValidateType ()
 Check for the correct overrides of different hook methods and fields and properties More...
 

Additional Inherited Members

- Properties inherited from ModType< TEntity, TModType >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from IModType
string FullName [get]
 => $"{Mod.Name}/{Name}" More...
 
Mod Mod [get]
 The mod this belongs to. More...
 
string Name [get]
 The internal name of this instance. More...
 
- Properties inherited from ModType< TEntity >
virtual bool CloneNewInstances [get]
 Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor).
 
TEntity Entity [get, set]
 
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
virtual bool IsCloneable [get]
 Whether or not this type is cloneable. Cloning is supported if
all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference]
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 

Detailed Description

Global Type that exists for pylons that allows for modification of teleportation steps, map drawing, and other functionality for any pylon that exists, whether it be vanilla or modded.

Member Function Documentation

◆ PostValidTeleportCheck()

virtual void GlobalPylon.PostValidTeleportCheck ( TeleportPylonInfo  destinationPylonInfo,
TeleportPylonInfo  nearbyPylonInfo,
ref bool  destinationPylonValid,
ref bool  validNearbyPylonFound,
ref string  errorKey 
)
virtual

Called after all checks have taken place for all vanilla and modded pylons when a teleportation request is sent (AKA when the player clicks on a pylon on the map). You can (for example) use this to allow teleportation to go through even if one the normal requirements haven't been met, or vice versa; to do this, change destinationPylonValid to true or false respectively (for the given example).

Parameters
destinationPylonInfoThe pylon information for the DESTINATION pylon.
nearbyPylonInfoThe pylon information of the pylon the player in question is standing NEAR. This value is at its defaults if validNearbyPylonFound is false, but otherwise, will give information on the nearby pylon.
destinationPylonValidWhether or not the normal requirements were satisfied for the DESTINATION pylon. Set this to true if you want the teleportation request to succeed, false if not.
validNearbyPylonFoundWhether or not a valid pylon near the player satisfied its normal requirements.
errorKeyThe localization key that will be used to sent text to the player when destinationPylonValid is false. Note that this parameter will already have a value if the method is called with destinationPylonValid being false.

◆ PreCanPlacePylon()

virtual ? bool GlobalPylon.PreCanPlacePylon ( int  x,
int  y,
int  tileType,
TeleportPylonType  pylonType 
)
virtual

Called right before both modded and vanilla pylons determine whether or not they can be placed. Returning false will prevent vanilla checks from taking place, forcefully preventing the pylon from being placed. Returning null will enact vanilla behavior, and returning true will make the check forcefully succeed, regardless of vanilla behavior. Returns null by default.

Parameters
xThe current X position of where the tile in question is asking it can be placed.
yThe current Y position of where the tile in question is asking it can be placed.
tileTypeThe actual type of tile currently asking if it can be placed.
pylonTypeThe type of pylon belonging to this tile.

Note that in Multiplayer environments, this is called first on the client, and then is subsequently called & double checked on the server.
If the server disagrees with the client that the given pylon CANNOT be placed for any given reason, the server will reject the placement and subsequently break the associated tile.

◆ PreDrawMapIcon()

virtual bool GlobalPylon.PreDrawMapIcon ( ref MapOverlayDrawContext  context,
ref string  mouseOverText,
ref TeleportPylonInfo  pylonInfo,
ref bool  isNearPylon,
ref Color  drawColor,
ref float  deselectedScale,
ref float  selectedScale 
)
virtual

Called right before both modded and vanilla pylons draw their icons on the map. Returning false will prevent the passed in icon from being drawn on the map. Returns true by default.

Note that if you change the value of the isNearPylon parameter, the change will cascade and all pylons following this will be affected by the change.

Parameters
contextThe current map context on which you can draw.
mouseOverTextThe text that will overlay on the mouse when the icon is being hovered over.
pylonInfoThe pylon that is currently needing its icon to be drawn.
isNearPylonWhether or not the player is currently near a pylon.
drawColorThe draw color of the icon. This is bright white when the player is near a Pylon, but gray and translucent otherwise.
deselectedScaleThe scale of the icon if it is NOT currently being hovered over. In vanilla, this is 1f, or 100%.
selectedScaleThe scale of the icon if it IS currently being over. In vanilla, this is 2f, or 200%.

◆ Register()

sealed override void GlobalPylon.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements ModType< TEntity >.

◆ SetupContent()

sealed override void GlobalPylon.SetupContent ( )
virtual

If you make a new ModType, seal this override, and call SetStaticDefaults in it.

Reimplemented from ModType< TEntity >.

◆ ValidTeleportCheck_PreAnyDanger()

virtual ? bool GlobalPylon.ValidTeleportCheck_PreAnyDanger ( TeleportPylonInfo  pylonInfo)
virtual

Called before Step 2 of the ValidTeleportCheck process. This is the second vanilla check that is called when the player attempts to teleport TO a Pylon. This method is called before both vanilla and modded pylons check their Danger requirements, and returning false will prevent those checks from taking place, forcefully failing the AnyDanger step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default.

Note that it's important you put the right checks in the right ValidTeleportCheck step, as whatever one returns false (if any) will determine the error message sent to the player.

Parameters
pylonInfoThe internal information pertaining to the current pylon being teleported TO.

◆ ValidTeleportCheck_PreBiomeRequirements()

virtual ? bool GlobalPylon.ValidTeleportCheck_PreBiomeRequirements ( TeleportPylonInfo  pylonInfo,
SceneMetrics  sceneData 
)
virtual

Called before Step 3 of the ValidTeleportCheck process. This is the fourth vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their Biome requirements, and returning false will prevent those checks from taking place, forcefully failing the BiomeRequirements step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default.

Note that it's important you put the right checks in the right ValidTeleportCheck step, as whatever one returns false (if any) will determine the error message sent to the player.

Parameters
pylonInfoThe internal information pertaining to the current pylon being teleported to or from.
sceneDataThe scene metrics data AT THE LOCATION of the destination pylon, NOT the player.

◆ ValidTeleportCheck_PreNPCCount()

virtual ? bool GlobalPylon.ValidTeleportCheck_PreNPCCount ( TeleportPylonInfo  pylonInfo,
ref int  defaultNecessaryNPCCount 
)
virtual

Called before Step 1 of the ValidTeleportCheck process. This is the first vanilla check that is called when the player attempts to teleport FROM or TO a Pylon. This method is called before both vanilla and modded pylons check their NPC requirements, and returning false will prevent those checks from taking place, forcefully failing the NPCCount step. Returning null will enact vanilla behavior, and returning true will make the step succeed regardless. Returns null by default.

Note that you may also change the the default npc count value if for some reason you wish to change the default amount of NPCs required to satisfy ALL pylons (if they adhere to what value it is).

Parameters
pylonInfoThe internal information pertaining to the current pylon being teleported to or from.
defaultNecessaryNPCCountThe default amount of NPCs nearby required to satisfy a VANILLA pylon.