1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
4 using System.Collections.Generic;
30 internal int instanceIndex;
37 public virtual bool Autoload(ref
string name) {
38 return mod.Properties.Autoload;
46 public virtual bool InstancePerEntity =>
false;
48 public GlobalProjectile Instance(Projectile projectile) => InstancePerEntity ? projectile.globalProjectiles[instanceIndex] :
this;
54 public virtual bool CloneNewInstances =>
false;
70 if (CloneNewInstances) {
77 copy.instanceIndex = instanceIndex;
93 public virtual bool PreAI(Projectile projectile) {
101 public virtual void AI(Projectile projectile) {
108 public virtual void PostAI(Projectile projectile) {
128 public virtual bool TileCollideStyle(Projectile projectile, ref
int width, ref
int height, ref
bool fallThrough) {
138 public virtual bool OnTileCollide(Projectile projectile, Vector2 oldVelocity) {
148 public virtual bool PreKill(Projectile projectile,
int timeLeft) {
157 public virtual void Kill(Projectile projectile,
int timeLeft) {
173 public virtual void CutTiles(Projectile projectile) {
208 public virtual bool?
CanHitNPC(Projectile projectile, NPC target) {
221 public virtual void ModifyHitNPC(Projectile projectile, NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection) {
232 public virtual void OnHitNPC(Projectile projectile, NPC target,
int damage,
float knockback,
bool crit) {
241 public virtual bool CanHitPvp(Projectile projectile, Player target) {
252 public virtual void ModifyHitPvp(Projectile projectile, Player target, ref
int damage, ref
bool crit) {
262 public virtual void OnHitPvp(Projectile projectile, Player target,
int damage,
bool crit) {
271 public virtual bool CanHitPlayer(Projectile projectile, Player target) {
282 public virtual void ModifyHitPlayer(Projectile projectile, Player target, ref
int damage, ref
bool crit) {
292 public virtual void OnHitPlayer(Projectile projectile, Player target,
int damage,
bool crit) {
302 public virtual bool?
Colliding(Projectile projectile, Rectangle projHitbox, Rectangle targetHitbox) {
312 public virtual Color?
GetAlpha(Projectile projectile, Color lightColor) {
322 public virtual bool PreDrawExtras(Projectile projectile, SpriteBatch spriteBatch) {
333 public virtual bool PreDraw(Projectile projectile, SpriteBatch spriteBatch, Color lightColor) {
343 public virtual void PostDraw(Projectile projectile, SpriteBatch spriteBatch, Color lightColor) {
355 public virtual void DrawBehind(Projectile projectile,
int index, List<int> drawCacheProjsBehindNPCsAndTiles, List<int> drawCacheProjsBehindNPCs, List<int> drawCacheProjsBehindProjectiles, List<int> drawCacheProjsOverWiresUI) {
375 public virtual void UseGrapple(Player player, ref
int type) {
381 public virtual void NumGrappleHooks(Projectile projectile, Player player, ref
int numHooks) {
393 public virtual void GrapplePullSpeed(Projectile projectile, Player player, ref
float speed) {
399 public virtual void GrappleTargetPoint(Projectile projectile, Player player, ref
float grappleX, ref
float grappleY) {
string Name
The name of this GlobalProjectile instance.
virtual void Kill(Projectile projectile, int timeLeft)
Allows you to control what happens when a projectile is killed (for example, creating dust or making ...
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.
virtual void OnHitPvp(Projectile projectile, Player target, int damage, bool crit)
Allows you to create special effects when a projectile hits an opponent player.
virtual void OnHitPlayer(Projectile projectile, Player target, int damage, bool crit)
Allows you to create special effects when a hostile projectile hits a player.
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...
virtual bool CanCutTiles(Projectile projectile)
Return true or false to specify if the projectile can cut tiles, like vines. Return null for vanilla ...
virtual GlobalProjectile NewInstance(Projectile projectile)
Create a new instance of this GlobalProjectile for a Projectile instance. Called at the end of Projec...
virtual bool ShouldUpdatePosition(Projectile projectile)
Whether or not the given projectile should update its position based on factors such as its velocity...
virtual bool CanHitPvp(Projectile projectile, Player target)
Allows you to determine whether a projectile can hit the given opponent player. Return false to block...
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.
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...
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)...
virtual bool PreDrawExtras(Projectile projectile, SpriteBatch spriteBatch)
Allows you to draw things behind a projectile. Returns false to stop the game from drawing extras tex...
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 sh...
virtual void CutTiles(Projectile projectile)
Code ran when the projectile cuts tiles. Only runs if CanCutTiles() returns true. Useful when program...
virtual bool PreAI(Projectile projectile)
Allows you to determine how any projectile behaves. Return false to stop the vanilla AI and the AI ho...
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 projecti...
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 projec...
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...
virtual void AI(Projectile projectile)
Allows you to determine how any projectile behaves. This will only be called if PreAI returns true...
virtual bool PreKill(Projectile projectile, int timeLeft)
Allows you to determine whether the vanilla code for Kill and the Kill hook will be called...
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.
virtual bool CanDamage(Projectile projectile)
Whether or not the given projectile is capable of killing tiles (such as grass) and damaging NPCs/pla...
virtual void PostAI(Projectile projectile)
Allows you to determine how any projectile behaves. This will be called regardless of what PreAI retu...
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...
virtual bool OnTileCollide(Projectile projectile, Vector2 oldVelocity)
Allows you to determine what happens when a projectile collides with a tile. OldVelocity is the veloc...
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...
Mod mod
The mod to which this GlobalProjectile belongs.
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
virtual void ModifyDamageHitbox(Projectile projectile, ref Rectangle hitbox)
Allows you to change the hitbox used by a projectile for damaging players and NPCs.
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.
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 fal...
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 ...
virtual bool CanHitPlayer(Projectile projectile, Player target)
Allows you to determine whether a hostile projectile can hit the given player. Return false to block ...
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...
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.
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 project...
This class allows you to modify and use hooks for all projectiles, including vanilla projectiles...
virtual void SetDefaults(Projectile projectile)
Allows you to set the properties of any and every projectile that gets created.
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.
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.