tModLoader v2024.02
A mod to make and play Terraria mods
ModMount Class Reference

This class serves as a place for you to place all your properties and hooks for each mount. Create instances of ModMoundData (preferably overriding this class) to pass as parameters to Mod.AddMount. Only one instance of ModMount will exist for each mount, so storing player specific data on the ModMount is not good. Modders can use player.mount._mountSpecificData or a ModPlayer class to store player specific data relating to a mount. Use SetMount to assign these fields. More...

Inherits ModType< Mount.MountData, ModMount >.

Public Member Functions

virtual void AimAbility (Player player, Vector2 mousePosition)
 Allows you to make things happen when the mount ability is aiming (while charging). More...
 
virtual void Dismount (Player player, ref bool skipDust)
 Allows you to make things happen when this mount is de-spawned. Useful for player-specific cleanup, see SetMount. Custom dust spawning logic is also possible via the skipDust parameter. More...
 
virtual bool Draw (List< DrawData > playerDrawData, int drawType, Player drawPlayer, ref Texture2D texture, ref Texture2D glowTexture, ref Vector2 drawPosition, ref Rectangle frame, ref Color drawColor, ref Color glowColor, ref float rotation, ref SpriteEffects spriteEffects, ref Vector2 drawOrigin, ref float drawScale, float shadow)
 Allows for complete customization of mount drawing. This method will be called once for each supported mount texture layer that exists. Use drawType to conditionally apply changes. drawType corresponds to the following: 0: backTexture, 1: backTextureExtra, 2: frontTexture. 3: frontTextureExtra Corresponding glow textures, such as backTextureGlow, are paired with their corresponding texture and passed into this method as well. Return false if you are manually adding DrawData to playerDrawData to replace the vanilla draw behavior, otherwise tweak ref variables to customize the drawing and add additional DrawData to playerDrawData. More...
 
virtual void JumpHeight (Player mountedPlayer, ref int jumpHeight, float xVelocity)
 Allows you to modify the mount's jump height based on its state. More...
 
virtual void JumpSpeed (Player mountedPlayer, ref float jumpSeed, float xVelocity)
 Allows you to modify the mount's jump speed based on its state. More...
 
override ModMount NewInstance (Mount.MountData entity)
 
virtual void SetMount (Player player, ref bool skipDust)
 Allows you to make things happen when this mount is spawned in. Useful for player-specific initialization, utilizing player.mount._mountSpecificData or a ModPlayer class since ModMount is shared between all players. Custom dust spawning logic is also possible via the skipDust parameter. More...
 
override void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. This is where you would set properties of this type of mount. More...
 
sealed override void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void UpdateEffects (Player player)
 Allows you to make things happen when mount is used (creating dust etc.) Can also be used for mount special abilities. More...
 
virtual bool UpdateFrame (Player mountedPlayer, int state, Vector2 velocity)
 Allows for manual updating of mount frame. Return false to stop the default frame behavior. Returns true by default. Possible values for state include:
0. Standing still on the ground or sliding
1. Moving on the ground
2. In the air, not flying. Hovering counts as this as well.
3. In the air, flying
4. Flying in water More...
 
virtual void UseAbility (Player player, Vector2 mousePosition, bool toggleOn)
 Allows you to make things happen while the mouse is pressed while the mount is active. Called each tick the mouse is pressed. More...
 
- Public Member Functions inherited from ModType< Mount.MountData, ModMount >
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...
 

Protected Member Functions

override Mount.MountData CreateTemplateEntity ()
 
virtual string GetExtraTexture (MountTextureType textureType)
 
sealed override void Register ()
 If you make a new ModType, seal this override. More...
 
- Protected Member Functions inherited from ModType< Mount.MountData, ModMount >
abstract TEntity CreateTemplateEntity ()
 
virtual void InitTemplateInstance ()
 Create dummy objects for instanced mod-types
 
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
 

Properties

Mount.MountData MountData [get]
 The vanilla MountData object that is controlled by this ModMount.
 
virtual string Texture [get]
 The file name of this type's texture file in the mod loader's file space.
 
int Type [get, set]
 The index of this ModMount in the Mount.mounts array.
 
- Properties inherited from ModType< Mount.MountData, ModMount >
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...
 

Detailed Description

This class serves as a place for you to place all your properties and hooks for each mount. Create instances of ModMoundData (preferably overriding this class) to pass as parameters to Mod.AddMount. Only one instance of ModMount will exist for each mount, so storing player specific data on the ModMount is not good. Modders can use player.mount._mountSpecificData or a ModPlayer class to store player specific data relating to a mount. Use SetMount to assign these fields.

Member Function Documentation

◆ AimAbility()

virtual void ModMount.AimAbility ( Player  player,
Vector2  mousePosition 
)
virtual

Allows you to make things happen when the mount ability is aiming (while charging).

Parameters
player
mousePosition

◆ CreateTemplateEntity()

override Mount.MountData ModMount.CreateTemplateEntity ( )
protectedvirtual

◆ Dismount()

virtual void ModMount.Dismount ( Player  player,
ref bool  skipDust 
)
virtual

Allows you to make things happen when this mount is de-spawned. Useful for player-specific cleanup, see SetMount. Custom dust spawning logic is also possible via the skipDust parameter.

Parameters
player
skipDustSet to true to skip the vanilla dust spawning logic

◆ Draw()

virtual bool ModMount.Draw ( List< DrawData playerDrawData,
int  drawType,
Player  drawPlayer,
ref Texture2D  texture,
ref Texture2D  glowTexture,
ref Vector2  drawPosition,
ref Rectangle  frame,
ref Color  drawColor,
ref Color  glowColor,
ref float  rotation,
ref SpriteEffects  spriteEffects,
ref Vector2  drawOrigin,
ref float  drawScale,
float  shadow 
)
virtual

Allows for complete customization of mount drawing. This method will be called once for each supported mount texture layer that exists. Use drawType to conditionally apply changes. drawType corresponds to the following: 0: backTexture, 1: backTextureExtra, 2: frontTexture. 3: frontTextureExtra Corresponding glow textures, such as backTextureGlow, are paired with their corresponding texture and passed into this method as well. Return false if you are manually adding DrawData to playerDrawData to replace the vanilla draw behavior, otherwise tweak ref variables to customize the drawing and add additional DrawData to playerDrawData.

Parameters
playerDrawData
drawTypeCorresponds to the following: 0: backTexture, 1: backTextureExtra, 2: frontTexture. 3: frontTextureExtra
drawPlayer
texture
glowTextureThe corresponding glow texture, if present
drawPosition
frame
drawColor
glowColor
rotation
spriteEffects
drawOrigin
drawScale
shadow
Returns

◆ JumpHeight()

virtual void ModMount.JumpHeight ( Player  mountedPlayer,
ref int  jumpHeight,
float  xVelocity 
)
virtual

Allows you to modify the mount's jump height based on its state.

Parameters
mountedPlayer
jumpHeight
xVelocity

◆ JumpSpeed()

virtual void ModMount.JumpSpeed ( Player  mountedPlayer,
ref float  jumpSeed,
float  xVelocity 
)
virtual

Allows you to modify the mount's jump speed based on its state.

Parameters
mountedPlayer
jumpSeed
xVelocity

◆ Register()

sealed override void ModMount.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements ModType< Mount.MountData, ModMount >.

◆ SetMount()

virtual void ModMount.SetMount ( Player  player,
ref bool  skipDust 
)
virtual

Allows you to make things happen when this mount is spawned in. Useful for player-specific initialization, utilizing player.mount._mountSpecificData or a ModPlayer class since ModMount is shared between all players. Custom dust spawning logic is also possible via the skipDust parameter.

Parameters
player
skipDustSet to true to skip the vanilla dust spawning logic

◆ SetStaticDefaults()

override void ModMount.SetStaticDefaults ( )
virtual

Allows you to modify the properties after initial loading has completed. This is where you would set properties of this type of mount.

Reimplemented from ModType< Mount.MountData, ModMount >.

◆ SetupContent()

sealed override void ModMount.SetupContent ( )
virtual

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

Reimplemented from ModType< Mount.MountData, ModMount >.

◆ UpdateEffects()

virtual void ModMount.UpdateEffects ( Player  player)
virtual

Allows you to make things happen when mount is used (creating dust etc.) Can also be used for mount special abilities.

Parameters
player

◆ UpdateFrame()

virtual bool ModMount.UpdateFrame ( Player  mountedPlayer,
int  state,
Vector2  velocity 
)
virtual

Allows for manual updating of mount frame. Return false to stop the default frame behavior. Returns true by default. Possible values for state include:
0. Standing still on the ground or sliding
1. Moving on the ground
2. In the air, not flying. Hovering counts as this as well.
3. In the air, flying
4. Flying in water

Parameters
mountedPlayer
state
velocity
Returns

◆ UseAbility()

virtual void ModMount.UseAbility ( Player  player,
Vector2  mousePosition,
bool  toggleOn 
)
virtual

Allows you to make things happen while the mouse is pressed while the mount is active. Called each tick the mouse is pressed.

Parameters
player
mousePosition
toggleOnDoes nothing yet