tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.GlobalProjectile Class Reference

This class allows you to modify and use hooks for all projectiles, including vanilla projectiles. Create an instance of an overriding class then call Mod.AddGlobalProjectile to use this. More...

+ Collaboration diagram for Terraria.ModLoader.GlobalProjectile:

Public Member Functions

virtual void AI (Projectile projectile)
 Allows you to determine how any projectile behaves. This will only be called if PreAI returns true. More...
 
virtual bool Autoload (ref string name)
 Allows you to automatically load a GlobalProjectile instead of using Mod.AddGlobalProjectile. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name. More...
 
virtual ? bool CanCutTiles (Projectile projectile)
 Return true or false to specify if the projectile can cut tiles, like vines. Return null for vanilla decision. More...
 
virtual bool CanDamage (Projectile projectile)
 Whether or not the given projectile is capable of killing tiles (such as grass) and damaging NPCs/players. Return false to prevent it from doing any sort of damage. Returns true by default. More...
 
virtual ? bool CanHitNPC (Projectile projectile, NPC target)
 Allows you to determine whether a projectile can hit the given NPC. Return true to allow hitting the target, return false to block the projectile from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default. More...
 
virtual bool CanHitPlayer (Projectile projectile, Player target)
 Allows you to determine whether a hostile projectile can hit the given player. Return false to block the projectile from hitting the target. Returns true by default. More...
 
virtual bool CanHitPvp (Projectile projectile, Player target)
 Allows you to determine whether a projectile can hit the given opponent player. Return false to block the projectile from hitting the target. Returns true by default. More...
 
virtual ? bool CanUseGrapple (int type, Player player)
 Whether or not a grappling hook that shoots this type of projectile can be used by the given player. Return null to use the default code (whether or not the player is in the middle of firing the grappling hook). Returns null by default. More...
 
virtual GlobalProjectile Clone ()
 Returns a clone of this GlobalProjectile. By default this will return a memberwise clone; you will want to override this if your GlobalProjectile contains object references. Only called if CloneNewInstances && InstancePerEntity More...
 
virtual ? bool Colliding (Projectile projectile, Rectangle projHitbox, Rectangle targetHitbox)
 Allows you to use custom collision detection between a projectile and a player or NPC that the projectile can damage. Useful for things like diagonal lasers, projectiles that leave a trail behind them, etc. More...
 
virtual void CutTiles (Projectile projectile)
 Code ran when the projectile cuts tiles. Only runs if CanCutTiles() returns true. Useful when programming lasers and such. More...
 
virtual void DrawBehind (Projectile projectile, int index, List< int > drawCacheProjsBehindNPCsAndTiles, List< int > drawCacheProjsBehindNPCs, List< int > drawCacheProjsBehindProjectiles, List< int > drawCacheProjsOverWiresUI)
 When used in conjunction with "projectile.hide = true", allows you to specify that this projectile should be drawn behind certain elements. Add the index to one and only one of the lists. For example, the Nebula Arcanum projectile draws behind NPCs and tiles. More...
 
virtual ? Color GetAlpha (Projectile projectile, Color lightColor)
 Allows you to determine the color and transparency in which a projectile is drawn. Return null to use the default color (normally light and buff color). Returns null by default. More...
 
virtual void GrapplePullSpeed (Projectile projectile, Player player, ref float speed)
 The speed at which the grapple pulls the player after hitting something. Defaults to 11, but the Bat Hook uses 16. More...
 
virtual void GrappleRetreatSpeed (Projectile projectile, Player player, ref float speed)
 The speed at which the grapple retreats back to the player after not hitting anything. Defaults to 11, but vanilla hooks go up to 24. More...
 
virtual void GrappleTargetPoint (Projectile projectile, Player player, ref float grappleX, ref float grappleY)
 The location that the grappling hook pulls the player to. Defaults to the center of the hook projectile. More...
 
GlobalProjectile Instance (Projectile projectile)
 
virtual void Kill (Projectile projectile, int timeLeft)
 Allows you to control what happens when a projectile is killed (for example, creating dust or making sounds). More...
 
virtual bool MinionContactDamage (Projectile projectile)
 Whether or not a minion can damage NPCs by touching them. Returns false by default. Note that this will only be used if the projectile is considered a pet. More...
 
virtual void ModifyDamageHitbox (Projectile projectile, ref Rectangle hitbox)
 Allows you to change the hitbox used by a projectile for damaging players and NPCs. More...
 
virtual void ModifyHitNPC (Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 Allows you to modify the damage, knockback, etc., that a projectile does to an NPC. This method is only called for the owner of the projectile, meaning that in multi-player, projectiles owned by a player call this method on that client, and projectiles owned by the server such as enemy projectiles call this method on the server. More...
 
virtual void ModifyHitPlayer (Projectile projectile, Player target, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that a hostile projectile does to a player. More...
 
virtual void ModifyHitPvp (Projectile projectile, Player target, ref int damage, ref bool crit)
 Allows you to modify the damage, etc., that a projectile does to an opponent player. More...
 
virtual GlobalProjectile NewInstance (Projectile projectile)
 Create a new instance of this GlobalProjectile for a Projectile instance. Called at the end of Projectile.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields More...
 
virtual void NumGrappleHooks (Projectile projectile, Player player, ref int numHooks)
 How many of this type of grappling hook the given player can latch onto blocks before the hooks start disappearing. Change the numHooks parameter to determine this; by default it will be 3. More...
 
virtual void OnHitNPC (Projectile projectile, NPC target, int damage, float knockback, bool crit)
 Allows you to create special effects when a projectile hits an NPC (for example, inflicting debuffs). This method is only called for the owner of the projectile, meaning that in multi-player, projectiles owned by a player call this method on that client, and projectiles owned by the server such as enemy projectiles call this method on the server. More...
 
virtual void OnHitPlayer (Projectile projectile, Player target, int damage, bool crit)
 Allows you to create special effects when a hostile projectile hits a player. More...
 
virtual void OnHitPvp (Projectile projectile, Player target, int damage, bool crit)
 Allows you to create special effects when a projectile hits an opponent player. More...
 
virtual bool OnTileCollide (Projectile projectile, Vector2 oldVelocity)
 Allows you to determine what happens when a projectile collides with a tile. OldVelocity is the velocity before tile collision. The velocity that takes tile collision into account can be found with projectile.velocity. Return true to allow the vanilla tile collision code to take place (which normally kills the projectile). Returns true by default. More...
 
virtual void PostAI (Projectile projectile)
 Allows you to determine how any projectile behaves. This will be called regardless of what PreAI returns. More...
 
virtual void PostDraw (Projectile projectile, SpriteBatch spriteBatch, Color lightColor)
 Allows you to draw things in front of a projectile. This method is called even if PreDraw returns false. More...
 
virtual bool PreAI (Projectile projectile)
 Allows you to determine how any projectile behaves. Return false to stop the vanilla AI and the AI hook from being run. Returns true by default. More...
 
virtual bool PreDraw (Projectile projectile, SpriteBatch spriteBatch, Color lightColor)
 Allows you to draw things behind a projectile, or to modify the way the projectile is drawn. Return false to stop the game from drawing the projectile (useful if you're manually drawing the projectile). Returns true by default. More...
 
virtual bool PreDrawExtras (Projectile projectile, SpriteBatch spriteBatch)
 Allows you to draw things behind a projectile. Returns false to stop the game from drawing extras textures related to the projectile (for example, the chains for grappling hooks), useful if you're manually drawing the extras. Returns true by default. More...
 
virtual bool PreKill (Projectile projectile, int timeLeft)
 Allows you to determine whether the vanilla code for Kill and the Kill hook will be called. Return false to stop them from being called. Returns true by default. Note that this does not stop the projectile from dying. More...
 
virtual void SetDefaults (Projectile projectile)
 Allows you to set the properties of any and every projectile that gets created. More...
 
virtual bool ShouldUpdatePosition (Projectile projectile)
 Whether or not the given projectile should update its position based on factors such as its velocity, whether it is in liquid, etc. Return false to make its velocity have no effect on its position. Returns true by default. More...
 
virtual ? bool SingleGrappleHook (int type, Player player)
 Whether or not a grappling hook can only have one hook per player in the world at a time. Return null to use the vanilla code. Returns null by default. More...
 
virtual bool TileCollideStyle (Projectile projectile, ref int width, ref int height, ref bool fallThrough)
 Allows you to determine how a projectile interacts with tiles. Width and height determine the projectile's hitbox for tile collision, and default to -1. Leave them as -1 to use the projectile's real size. Fallthrough determines whether the projectile can fall through platforms, etc., and defaults to true. More...
 
virtual void UseGrapple (Player player, ref int type)
 This code is called whenever the player uses a grappling hook that shoots this type of projectile. Use it to change what kind of hook is fired (for example, the Dual Hook does this), to kill old hook projectiles, etc. More...
 

Properties

virtual bool CloneNewInstances [get]
 Whether instances of this GlobalProjectile are created through Clone or constructor (by default implementations of NewInstance and Clone()). Defaults to false (using default constructor). More...
 
virtual bool InstancePerEntity [get]
 Whether to create a new GlobalProjectile instance for every Projectile that exists. Useful for storing information on a projectile. Defaults to false. Return true if you need to store information (have non-static fields). More...
 
Mod mod [get, set]
 The mod to which this GlobalProjectile belongs. More...
 
string Name [get, set]
 The name of this GlobalProjectile instance. More...
 

Detailed Description

This class allows you to modify and use hooks for all projectiles, including vanilla projectiles. Create an instance of an overriding class then call Mod.AddGlobalProjectile to use this.

Definition at line 11 of file GlobalProjectile.cs.

Member Function Documentation

◆ AI()

virtual void Terraria.ModLoader.GlobalProjectile.AI ( Projectile  projectile)
virtual

Allows you to determine how any projectile behaves. This will only be called if PreAI returns true.

Parameters
projectile

Definition at line 101 of file GlobalProjectile.cs.

101 {
102 }

Referenced by Terraria.ModLoader.ProjectileLoader.AI().

+ Here is the caller graph for this function:

◆ Autoload()

virtual bool Terraria.ModLoader.GlobalProjectile.Autoload ( ref string  name)
virtual

Allows you to automatically load a GlobalProjectile instead of using Mod.AddGlobalProjectile. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name.

Parameters
name
Returns

Definition at line 37 of file GlobalProjectile.cs.

37 {
38 return mod.Properties.Autoload;
39 }
Mod mod
The mod to which this GlobalProjectile belongs.
ModProperties Properties
Definition: Mod.cs:52
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.GlobalProjectile.mod, and Terraria.ModLoader.Mod.Properties.

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalProjectile().

+ Here is the caller graph for this function:

◆ CanCutTiles()

virtual ? bool Terraria.ModLoader.GlobalProjectile.CanCutTiles ( Projectile  projectile)
virtual

Return true or false to specify if the projectile can cut tiles, like vines. Return null for vanilla decision.

Parameters
projectile
Returns

Definition at line 165 of file GlobalProjectile.cs.

165 {
166 return null;
167 }

Referenced by Terraria.ModLoader.ProjectileLoader.CanCutTiles().

+ Here is the caller graph for this function:

◆ CanDamage()

virtual bool Terraria.ModLoader.GlobalProjectile.CanDamage ( Projectile  projectile)
virtual

Whether or not the given projectile is capable of killing tiles (such as grass) and damaging NPCs/players. Return false to prevent it from doing any sort of damage. Returns true by default.

Parameters
projectile
Returns

Definition at line 181 of file GlobalProjectile.cs.

181 {
182 return true;
183 }

Referenced by Terraria.ModLoader.ProjectileLoader.CanDamage().

+ Here is the caller graph for this function:

◆ CanHitNPC()

virtual ? bool Terraria.ModLoader.GlobalProjectile.CanHitNPC ( Projectile  projectile,
NPC  target 
)
virtual

Allows you to determine whether a projectile can hit the given NPC. Return true to allow hitting the target, return false to block the projectile from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default.

Parameters
projectile
target
Returns

Definition at line 208 of file GlobalProjectile.cs.

208 {
209 return null;
210 }

Referenced by Terraria.ModLoader.ProjectileLoader.CanHitNPC().

+ Here is the caller graph for this function:

◆ CanHitPlayer()

virtual bool Terraria.ModLoader.GlobalProjectile.CanHitPlayer ( Projectile  projectile,
Player  target 
)
virtual

Allows you to determine whether a hostile projectile can hit the given player. Return false to block the projectile from hitting the target. Returns true by default.

Parameters
projectile
target
Returns

Definition at line 271 of file GlobalProjectile.cs.

271 {
272 return true;
273 }

Referenced by Terraria.ModLoader.ProjectileLoader.CanHitPlayer().

+ Here is the caller graph for this function:

◆ CanHitPvp()

virtual bool Terraria.ModLoader.GlobalProjectile.CanHitPvp ( Projectile  projectile,
Player  target 
)
virtual

Allows you to determine whether a projectile can hit the given opponent player. Return false to block the projectile from hitting the target. Returns true by default.

Parameters
projectile
target
Returns

Definition at line 241 of file GlobalProjectile.cs.

241 {
242 return true;
243 }

Referenced by Terraria.ModLoader.ProjectileLoader.CanHitPvp().

+ Here is the caller graph for this function:

◆ CanUseGrapple()

virtual ? bool Terraria.ModLoader.GlobalProjectile.CanUseGrapple ( int  type,
Player  player 
)
virtual

Whether or not a grappling hook that shoots this type of projectile can be used by the given player. Return null to use the default code (whether or not the player is in the middle of firing the grappling hook). Returns null by default.

Definition at line 361 of file GlobalProjectile.cs.

361 {
362 return null;
363 }

Referenced by Terraria.ModLoader.ProjectileLoader.CanUseGrapple().

+ Here is the caller graph for this function:

◆ Clone()

virtual GlobalProjectile Terraria.ModLoader.GlobalProjectile.Clone ( )
virtual

Returns a clone of this GlobalProjectile. By default this will return a memberwise clone; you will want to override this if your GlobalProjectile contains object references. Only called if CloneNewInstances && InstancePerEntity

Referenced by Terraria.ModLoader.GlobalProjectile.NewInstance().

+ Here is the caller graph for this function:

◆ Colliding()

virtual ? bool Terraria.ModLoader.GlobalProjectile.Colliding ( Projectile  projectile,
Rectangle  projHitbox,
Rectangle  targetHitbox 
)
virtual

Allows you to use custom collision detection between a projectile and a player or NPC that the projectile can damage. Useful for things like diagonal lasers, projectiles that leave a trail behind them, etc.

Parameters
projectile
projHitbox
targetHitbox
Returns

Definition at line 302 of file GlobalProjectile.cs.

302 {
303 return null;
304 }

Referenced by Terraria.ModLoader.ProjectileLoader.Colliding().

+ Here is the caller graph for this function:

◆ CutTiles()

virtual void Terraria.ModLoader.GlobalProjectile.CutTiles ( Projectile  projectile)
virtual

Code ran when the projectile cuts tiles. Only runs if CanCutTiles() returns true. Useful when programming lasers and such.

Parameters
projectile

Definition at line 173 of file GlobalProjectile.cs.

173 {
174 }

Referenced by Terraria.ModLoader.ProjectileLoader.CutTiles().

+ Here is the caller graph for this function:

◆ DrawBehind()

virtual void Terraria.ModLoader.GlobalProjectile.DrawBehind ( Projectile  projectile,
int  index,
List< int >  drawCacheProjsBehindNPCsAndTiles,
List< int >  drawCacheProjsBehindNPCs,
List< int >  drawCacheProjsBehindProjectiles,
List< int >  drawCacheProjsOverWiresUI 
)
virtual

When used in conjunction with "projectile.hide = true", allows you to specify that this projectile should be drawn behind certain elements. Add the index to one and only one of the lists. For example, the Nebula Arcanum projectile draws behind NPCs and tiles.

Parameters
projectile
index
drawCacheProjsBehindNPCsAndTiles
drawCacheProjsBehindNPCs
drawCacheProjsBehindProjectiles
drawCacheProjsOverWiresUI

Definition at line 355 of file GlobalProjectile.cs.

355 {
356 }

◆ GetAlpha()

virtual ? Color Terraria.ModLoader.GlobalProjectile.GetAlpha ( Projectile  projectile,
Color  lightColor 
)
virtual

Allows you to determine the color and transparency in which a projectile is drawn. Return null to use the default color (normally light and buff color). Returns null by default.

Parameters
projectile
lightColor
Returns

Definition at line 312 of file GlobalProjectile.cs.

312 {
313 return null;
314 }

Referenced by Terraria.ModLoader.ProjectileLoader.GetAlpha().

+ Here is the caller graph for this function:

◆ GrapplePullSpeed()

virtual void Terraria.ModLoader.GlobalProjectile.GrapplePullSpeed ( Projectile  projectile,
Player  player,
ref float  speed 
)
virtual

The speed at which the grapple pulls the player after hitting something. Defaults to 11, but the Bat Hook uses 16.

Definition at line 393 of file GlobalProjectile.cs.

393 {
394 }

Referenced by Terraria.ModLoader.ProjectileLoader.GrapplePullSpeed().

+ Here is the caller graph for this function:

◆ GrappleRetreatSpeed()

virtual void Terraria.ModLoader.GlobalProjectile.GrappleRetreatSpeed ( Projectile  projectile,
Player  player,
ref float  speed 
)
virtual

The speed at which the grapple retreats back to the player after not hitting anything. Defaults to 11, but vanilla hooks go up to 24.

Definition at line 387 of file GlobalProjectile.cs.

387 {
388 }

Referenced by Terraria.ModLoader.ProjectileLoader.GrappleRetreatSpeed().

+ Here is the caller graph for this function:

◆ GrappleTargetPoint()

virtual void Terraria.ModLoader.GlobalProjectile.GrappleTargetPoint ( Projectile  projectile,
Player  player,
ref float  grappleX,
ref float  grappleY 
)
virtual

The location that the grappling hook pulls the player to. Defaults to the center of the hook projectile.

Definition at line 399 of file GlobalProjectile.cs.

399 {
400 }

Referenced by Terraria.ModLoader.ProjectileLoader.GrappleTargetPoint().

+ Here is the caller graph for this function:

◆ Instance()

GlobalProjectile Terraria.ModLoader.GlobalProjectile.Instance ( Projectile  projectile)

Referenced by Terraria.ModLoader.ProjectileLoader.AI(), Terraria.ModLoader.ProjectileLoader.CanCutTiles(), Terraria.ModLoader.ProjectileLoader.CanDamage(), Terraria.ModLoader.ProjectileLoader.CanHitNPC(), Terraria.ModLoader.ProjectileLoader.CanHitPlayer(), Terraria.ModLoader.ProjectileLoader.CanHitPvp(), Terraria.ModLoader.ProjectileLoader.Colliding(), Terraria.ModLoader.ProjectileLoader.CutTiles(), Terraria.ModLoader.ProjectileLoader.GetAlpha(), Terraria.ModLoader.ProjectileLoader.GrapplePullSpeed(), Terraria.ModLoader.ProjectileLoader.GrappleRetreatSpeed(), Terraria.ModLoader.ProjectileLoader.GrappleTargetPoint(), Terraria.ModLoader.ProjectileLoader.Kill(), Terraria.ModLoader.ProjectileLoader.MinionContactDamage(), Terraria.ModLoader.ProjectileLoader.ModifyDamageHitbox(), Terraria.ModLoader.ProjectileLoader.ModifyHitNPC(), Terraria.ModLoader.ProjectileLoader.ModifyHitPlayer(), Terraria.ModLoader.ProjectileLoader.ModifyHitPvp(), Terraria.ModLoader.ProjectileLoader.NumGrappleHooks(), Terraria.ModLoader.ProjectileLoader.OnHitNPC(), Terraria.ModLoader.ProjectileLoader.OnHitPlayer(), Terraria.ModLoader.ProjectileLoader.OnHitPvp(), Terraria.ModLoader.ProjectileLoader.OnTileCollide(), Terraria.ModLoader.ProjectileLoader.PostAI(), Terraria.ModLoader.ProjectileLoader.PostDraw(), Terraria.ModLoader.ProjectileLoader.PreAI(), Terraria.ModLoader.ProjectileLoader.PreDraw(), Terraria.ModLoader.ProjectileLoader.PreDrawExtras(), Terraria.ModLoader.ProjectileLoader.PreKill(), Terraria.ModLoader.ProjectileLoader.ShouldUpdatePosition(), and Terraria.ModLoader.ProjectileLoader.TileCollideStyle().

+ Here is the caller graph for this function:

◆ Kill()

virtual void Terraria.ModLoader.GlobalProjectile.Kill ( Projectile  projectile,
int  timeLeft 
)
virtual

Allows you to control what happens when a projectile is killed (for example, creating dust or making sounds).

Parameters
projectile
timeLeft

Definition at line 157 of file GlobalProjectile.cs.

157 {
158 }

Referenced by Terraria.ModLoader.ProjectileLoader.Kill().

+ Here is the caller graph for this function:

◆ MinionContactDamage()

virtual bool Terraria.ModLoader.GlobalProjectile.MinionContactDamage ( Projectile  projectile)
virtual

Whether or not a minion can damage NPCs by touching them. Returns false by default. Note that this will only be used if the projectile is considered a pet.

Parameters
projectile
Returns

Definition at line 190 of file GlobalProjectile.cs.

190 {
191 return false;
192 }

Referenced by Terraria.ModLoader.ProjectileLoader.MinionContactDamage().

+ Here is the caller graph for this function:

◆ ModifyDamageHitbox()

virtual void Terraria.ModLoader.GlobalProjectile.ModifyDamageHitbox ( Projectile  projectile,
ref Rectangle  hitbox 
)
virtual

Allows you to change the hitbox used by a projectile for damaging players and NPCs.

Parameters
projectile
hitbox

Definition at line 199 of file GlobalProjectile.cs.

199 {
200 }

Referenced by Terraria.ModLoader.ProjectileLoader.ModifyDamageHitbox().

+ Here is the caller graph for this function:

◆ ModifyHitNPC()

virtual void Terraria.ModLoader.GlobalProjectile.ModifyHitNPC ( Projectile  projectile,
NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit,
ref int  hitDirection 
)
virtual

Allows you to modify the damage, knockback, etc., that a projectile does to an NPC. This method is only called for the owner of the projectile, meaning that in multi-player, projectiles owned by a player call this method on that client, and projectiles owned by the server such as enemy projectiles call this method on the server.

Parameters
projectile
target
damage
knockback
crit
hitDirection

Definition at line 221 of file GlobalProjectile.cs.

221 {
222 }

Referenced by Terraria.ModLoader.ProjectileLoader.ModifyHitNPC().

+ Here is the caller graph for this function:

◆ ModifyHitPlayer()

virtual void Terraria.ModLoader.GlobalProjectile.ModifyHitPlayer ( Projectile  projectile,
Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that a hostile projectile does to a player.

Parameters
projectile
target
damage
crit

Definition at line 282 of file GlobalProjectile.cs.

282 {
283 }

Referenced by Terraria.ModLoader.ProjectileLoader.ModifyHitPlayer().

+ Here is the caller graph for this function:

◆ ModifyHitPvp()

virtual void Terraria.ModLoader.GlobalProjectile.ModifyHitPvp ( Projectile  projectile,
Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that a projectile does to an opponent player.

Parameters
projectile
target
damage
crit

Definition at line 252 of file GlobalProjectile.cs.

252 {
253 }

Referenced by Terraria.ModLoader.ProjectileLoader.ModifyHitPvp().

+ Here is the caller graph for this function:

◆ NewInstance()

virtual GlobalProjectile Terraria.ModLoader.GlobalProjectile.NewInstance ( Projectile  projectile)
virtual

Create a new instance of this GlobalProjectile for a Projectile instance. Called at the end of Projectile.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields

Definition at line 69 of file GlobalProjectile.cs.

69 {
71 return Clone();
72 }
73 GlobalProjectile copy = (GlobalProjectile)Activator.CreateInstance(GetType());
74 copy.mod = mod;
75 copy.Name = Name;
76 copy.index = index;
77 copy.instanceIndex = instanceIndex;
78 return copy;
79 }
virtual bool CloneNewInstances
Whether instances of this GlobalProjectile are created through Clone or constructor (by default imple...
virtual GlobalProjectile Clone()
Returns a clone of this GlobalProjectile. By default this will return a memberwise clone; you will wa...
string Name
The name of this GlobalProjectile instance.

References Terraria.ModLoader.GlobalProjectile.Clone(), Terraria.ModLoader.GlobalProjectile.CloneNewInstances, Terraria.ModLoader.GlobalProjectile.mod, and Terraria.ModLoader.GlobalProjectile.Name.

+ Here is the call graph for this function:

◆ NumGrappleHooks()

virtual void Terraria.ModLoader.GlobalProjectile.NumGrappleHooks ( Projectile  projectile,
Player  player,
ref int  numHooks 
)
virtual

How many of this type of grappling hook the given player can latch onto blocks before the hooks start disappearing. Change the numHooks parameter to determine this; by default it will be 3.

Definition at line 381 of file GlobalProjectile.cs.

381 {
382 }

Referenced by Terraria.ModLoader.ProjectileLoader.NumGrappleHooks().

+ Here is the caller graph for this function:

◆ OnHitNPC()

virtual void Terraria.ModLoader.GlobalProjectile.OnHitNPC ( Projectile  projectile,
NPC  target,
int  damage,
float  knockback,
bool  crit 
)
virtual

Allows you to create special effects when a projectile hits an NPC (for example, inflicting debuffs). This method is only called for the owner of the projectile, meaning that in multi-player, projectiles owned by a player call this method on that client, and projectiles owned by the server such as enemy projectiles call this method on the server.

Parameters
projectile
target
damage
knockback
crit

Definition at line 232 of file GlobalProjectile.cs.

232 {
233 }

Referenced by Terraria.ModLoader.ProjectileLoader.OnHitNPC().

+ Here is the caller graph for this function:

◆ OnHitPlayer()

virtual void Terraria.ModLoader.GlobalProjectile.OnHitPlayer ( Projectile  projectile,
Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when a hostile projectile hits a player.

Parameters
projectile
target
damage
crit

Definition at line 292 of file GlobalProjectile.cs.

292 {
293 }

Referenced by Terraria.ModLoader.ProjectileLoader.OnHitPlayer().

+ Here is the caller graph for this function:

◆ OnHitPvp()

virtual void Terraria.ModLoader.GlobalProjectile.OnHitPvp ( Projectile  projectile,
Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when a projectile hits an opponent player.

Parameters
projectile
target
damage
crit

Definition at line 262 of file GlobalProjectile.cs.

262 {
263 }

Referenced by Terraria.ModLoader.ProjectileLoader.OnHitPvp().

+ Here is the caller graph for this function:

◆ OnTileCollide()

virtual bool Terraria.ModLoader.GlobalProjectile.OnTileCollide ( Projectile  projectile,
Vector2  oldVelocity 
)
virtual

Allows you to determine what happens when a projectile collides with a tile. OldVelocity is the velocity before tile collision. The velocity that takes tile collision into account can be found with projectile.velocity. Return true to allow the vanilla tile collision code to take place (which normally kills the projectile). Returns true by default.

Parameters
projectile
oldVelocity
Returns

Definition at line 138 of file GlobalProjectile.cs.

138 {
139 return true;
140 }

Referenced by Terraria.ModLoader.ProjectileLoader.OnTileCollide().

+ Here is the caller graph for this function:

◆ PostAI()

virtual void Terraria.ModLoader.GlobalProjectile.PostAI ( Projectile  projectile)
virtual

Allows you to determine how any projectile behaves. This will be called regardless of what PreAI returns.

Parameters
projectile

Definition at line 108 of file GlobalProjectile.cs.

108 {
109 }

Referenced by Terraria.ModLoader.ProjectileLoader.PostAI().

+ Here is the caller graph for this function:

◆ PostDraw()

virtual void Terraria.ModLoader.GlobalProjectile.PostDraw ( Projectile  projectile,
SpriteBatch  spriteBatch,
Color  lightColor 
)
virtual

Allows you to draw things in front of a projectile. This method is called even if PreDraw returns false.

Parameters
projectile
spriteBatch
lightColor

Definition at line 343 of file GlobalProjectile.cs.

343 {
344 }

Referenced by Terraria.ModLoader.ProjectileLoader.PostDraw().

+ Here is the caller graph for this function:

◆ PreAI()

virtual bool Terraria.ModLoader.GlobalProjectile.PreAI ( Projectile  projectile)
virtual

Allows you to determine how any projectile behaves. Return false to stop the vanilla AI and the AI hook from being run. Returns true by default.

Parameters
projectile
Returns

Definition at line 93 of file GlobalProjectile.cs.

93 {
94 return true;
95 }

Referenced by Terraria.ModLoader.ProjectileLoader.PreAI().

+ Here is the caller graph for this function:

◆ PreDraw()

virtual bool Terraria.ModLoader.GlobalProjectile.PreDraw ( Projectile  projectile,
SpriteBatch  spriteBatch,
Color  lightColor 
)
virtual

Allows you to draw things behind a projectile, or to modify the way the projectile is drawn. Return false to stop the game from drawing the projectile (useful if you're manually drawing the projectile). Returns true by default.

Parameters
projectile
spriteBatch
lightColor
Returns

Definition at line 333 of file GlobalProjectile.cs.

333 {
334 return true;
335 }

Referenced by Terraria.ModLoader.ProjectileLoader.PreDraw().

+ Here is the caller graph for this function:

◆ PreDrawExtras()

virtual bool Terraria.ModLoader.GlobalProjectile.PreDrawExtras ( Projectile  projectile,
SpriteBatch  spriteBatch 
)
virtual

Allows you to draw things behind a projectile. Returns false to stop the game from drawing extras textures related to the projectile (for example, the chains for grappling hooks), useful if you're manually drawing the extras. Returns true by default.

Parameters
projectile
spriteBatch
Returns

Definition at line 322 of file GlobalProjectile.cs.

322 {
323 return true;
324 }

Referenced by Terraria.ModLoader.ProjectileLoader.PreDrawExtras().

+ Here is the caller graph for this function:

◆ PreKill()

virtual bool Terraria.ModLoader.GlobalProjectile.PreKill ( Projectile  projectile,
int  timeLeft 
)
virtual

Allows you to determine whether the vanilla code for Kill and the Kill hook will be called. Return false to stop them from being called. Returns true by default. Note that this does not stop the projectile from dying.

Parameters
projectile
timeLeft
Returns

Definition at line 148 of file GlobalProjectile.cs.

148 {
149 return true;
150 }

Referenced by Terraria.ModLoader.ProjectileLoader.PreKill().

+ Here is the caller graph for this function:

◆ SetDefaults()

virtual void Terraria.ModLoader.GlobalProjectile.SetDefaults ( Projectile  projectile)
virtual

Allows you to set the properties of any and every projectile that gets created.

Parameters
projectile

Definition at line 85 of file GlobalProjectile.cs.

85 {
86 }

◆ ShouldUpdatePosition()

virtual bool Terraria.ModLoader.GlobalProjectile.ShouldUpdatePosition ( Projectile  projectile)
virtual

Whether or not the given projectile should update its position based on factors such as its velocity, whether it is in liquid, etc. Return false to make its velocity have no effect on its position. Returns true by default.

Parameters
projectile
Returns

Definition at line 116 of file GlobalProjectile.cs.

116 {
117 return true;
118 }

Referenced by Terraria.ModLoader.ProjectileLoader.ShouldUpdatePosition().

+ Here is the caller graph for this function:

◆ SingleGrappleHook()

virtual ? bool Terraria.ModLoader.GlobalProjectile.SingleGrappleHook ( int  type,
Player  player 
)
virtual

Whether or not a grappling hook can only have one hook per player in the world at a time. Return null to use the vanilla code. Returns null by default.

Definition at line 368 of file GlobalProjectile.cs.

368 {
369 return null;
370 }

Referenced by Terraria.ModLoader.ProjectileLoader.SingleGrappleHook().

+ Here is the caller graph for this function:

◆ TileCollideStyle()

virtual bool Terraria.ModLoader.GlobalProjectile.TileCollideStyle ( Projectile  projectile,
ref int  width,
ref int  height,
ref bool  fallThrough 
)
virtual

Allows you to determine how a projectile interacts with tiles. Width and height determine the projectile's hitbox for tile collision, and default to -1. Leave them as -1 to use the projectile's real size. Fallthrough determines whether the projectile can fall through platforms, etc., and defaults to true.

Parameters
projectile
width
height
fallThrough
Returns

Definition at line 128 of file GlobalProjectile.cs.

128 {
129 return true;
130 }

Referenced by Terraria.ModLoader.ProjectileLoader.TileCollideStyle().

+ Here is the caller graph for this function:

◆ UseGrapple()

virtual void Terraria.ModLoader.GlobalProjectile.UseGrapple ( Player  player,
ref int  type 
)
virtual

This code is called whenever the player uses a grappling hook that shoots this type of projectile. Use it to change what kind of hook is fired (for example, the Dual Hook does this), to kill old hook projectiles, etc.

Definition at line 375 of file GlobalProjectile.cs.

375 {
376 }

Referenced by Terraria.ModLoader.ProjectileLoader.UseGrapple().

+ Here is the caller graph for this function:

Property Documentation

◆ CloneNewInstances

virtual bool Terraria.ModLoader.GlobalProjectile.CloneNewInstances
get

Whether instances of this GlobalProjectile are created through Clone or constructor (by default implementations of NewInstance and Clone()). Defaults to false (using default constructor).

Definition at line 54 of file GlobalProjectile.cs.

Referenced by Terraria.ModLoader.GlobalProjectile.NewInstance().

◆ InstancePerEntity

virtual bool Terraria.ModLoader.GlobalProjectile.InstancePerEntity
get

Whether to create a new GlobalProjectile instance for every Projectile that exists. Useful for storing information on a projectile. Defaults to false. Return true if you need to store information (have non-static fields).

Definition at line 46 of file GlobalProjectile.cs.

◆ mod

Mod Terraria.ModLoader.GlobalProjectile.mod
getset

The mod to which this GlobalProjectile belongs.

Definition at line 16 of file GlobalProjectile.cs.

16 {
17 get;
18 internal set;
19 }

Referenced by Terraria.ModLoader.GlobalProjectile.Autoload(), and Terraria.ModLoader.GlobalProjectile.NewInstance().

◆ Name

string Terraria.ModLoader.GlobalProjectile.Name
getset

The name of this GlobalProjectile instance.

Definition at line 24 of file GlobalProjectile.cs.

24 {
25 get;
26 internal set;
27 }

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalProjectile(), and Terraria.ModLoader.GlobalProjectile.NewInstance().