Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.ProjectileLoader Class Reference

This serves as the central class from which projectile-related functions are carried out. It also stores a list of mod projectiles by ID. More...

+ Collaboration diagram for Terraria.ModLoader.ProjectileLoader:

Classes

class  HookList
 

Static Public Member Functions

static void AI (Projectile projectile)
 
static bool CanCutTiles (Projectile projectile)
 
static bool CanDamage (Projectile projectile)
 
static bool CanHitNPC (Projectile projectile, NPC target)
 
static bool CanHitPlayer (Projectile projectile, Player target)
 
static bool CanHitPvp (Projectile projectile, Player target)
 
static bool CanUseGrapple (int type, Player player)
 
static bool Colliding (Projectile projectile, Rectangle projHitbox, Rectangle targetHitbox)
 
static void CutTiles (Projectile projectile)
 
static void DrawHeldProjInFrontOfHeldItemAndArms (Projectile projectile, ref bool flag)
 
static void DrawOffset (Projectile projectile, ref int offsetX, ref int offsetY, ref float originX)
 
static Color GetAlpha (Projectile projectile, Color lightColor)
 
static ModProjectile GetProjectile (int type)
 Gets the ModProjectile instance corresponding to the specified type. More...
 
static bool GrappleOutOfRange (float distance, Projectile projectile)
 
static void GrapplePullSpeed (Projectile projectile, Player player, ref float speed)
 
static void GrappleRetreatSpeed (Projectile projectile, Player player, ref float speed)
 
static void Kill (Projectile projectile, int timeLeft)
 
static bool MinionContactDamage (Projectile projectile)
 
static void ModifyDamageHitbox (Projectile projectile, ref Rectangle hitbox)
 
static void ModifyHitNPC (Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 
static void ModifyHitPlayer (Projectile projectile, Player target, ref int damage, ref bool crit)
 
static void ModifyHitPvp (Projectile projectile, Player target, ref int damage, ref bool crit)
 
static void NumGrappleHooks (Projectile projectile, Player player, ref int numHooks)
 
static void OnHitNPC (Projectile projectile, NPC target, int damage, float knockback, bool crit)
 
static void OnHitPlayer (Projectile projectile, Player target, int damage, bool crit)
 
static void OnHitPvp (Projectile projectile, Player target, int damage, bool crit)
 
static bool OnTileCollide (Projectile projectile, Vector2 oldVelocity)
 
static void PostAI (Projectile projectile)
 
static void PostDraw (Projectile projectile, SpriteBatch spriteBatch, Color lightColor)
 
static bool PreAI (Projectile projectile)
 
static bool PreDraw (Projectile projectile, SpriteBatch spriteBatch, Color lightColor)
 
static bool PreDrawExtras (Projectile projectile, SpriteBatch spriteBatch)
 
static bool PreKill (Projectile projectile, int timeLeft)
 
static void ProjectileAI (Projectile projectile)
 
static byte[] ReadExtraAI (BinaryReader reader, BitsByte flags)
 
static void ReceiveExtraAI (Projectile projectile, byte[] extraAI)
 
static byte[] SendExtraAI (Projectile projectile, ref BitsByte flags)
 
static bool ShouldUpdatePosition (Projectile projectile)
 
static bool SingleGrappleHook (int type, Player player)
 
static bool TileCollideStyle (Projectile projectile, ref int width, ref int height, ref bool fallThrough)
 
static void UseGrapple (Player player, ref int type)
 

Static Public Attributes

static int ProjectileCount => nextProjectile
 

Private Member Functions

delegate void DelegateGrapplePullSpeed (Projectile projectile, Player player, ref float speed)
 
delegate void DelegateGrappleRetreatSpeed (Projectile projectile, Player player, ref float speed)
 
delegate void DelegateModifyDamageHitbox (Projectile projectile, ref Rectangle hitbox)
 
delegate void DelegateModifyHitNPC (Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 
delegate void DelegateModifyHitPlayer (Projectile projectile, Player target, ref int damage, ref bool crit)
 
delegate void DelegateModifyHitPvp (Projectile projectile, Player target, ref int damage, ref bool crit)
 
delegate void DelegateNumGrappleHooks (Projectile projectile, Player player, ref int numHooks)
 
delegate bool DelegateTileCollideStyle (Projectile projectile, ref int width, ref int height, ref bool fallThrough)
 
delegate void DelegateUseGrapple (Player player, ref int type)
 

Static Private Member Functions

static HookList AddHook< F > (Expression< Func< GlobalProjectile, F >> func)
 
static bool HasMethod (Type t, string method, params Type[] args)
 

Static Private Attributes

static HookList HookAI = AddHook<Action<Projectile>>(g => g.AI)
 
static HookList HookCanCutTiles = AddHook<Func<Projectile, bool?>>(g => g.CanCutTiles)
 
static HookList HookCanDamage = AddHook<Func<Projectile, bool>>(g => g.CanDamage)
 
static HookList HookCanHitNPC = AddHook<Func<Projectile, NPC, bool?>>(g => g.CanHitNPC)
 
static HookList HookCanHitPlayer = AddHook<Func<Projectile, Player, bool>>(g => g.CanHitPlayer)
 
static HookList HookCanHitPvp = AddHook<Func<Projectile, Player, bool>>(g => g.CanHitPvp)
 
static HookList HookCanUseGrapple = AddHook<Func<int, Player, bool?>>(g => g.CanUseGrapple)
 
static HookList HookColliding = AddHook<Func<Projectile, Rectangle, Rectangle, bool?>>(g => g.Colliding)
 
static HookList HookCutTiles = AddHook<Action<Projectile>>(g => g.CutTiles)
 
static HookList HookDrawBehind = AddHook<Action<Projectile, int, List<int>, List<int>, List<int>, List<int>>>(g => g.DrawBehind)
 
static HookList HookGetAlpha = AddHook<Func<Projectile, Color, Color?>>(g => g.GetAlpha)
 
static HookList HookGrapplePullSpeed = AddHook<DelegateGrapplePullSpeed>(g => g.GrapplePullSpeed)
 
static HookList HookGrappleRetreatSpeed = AddHook<DelegateGrappleRetreatSpeed>(g => g.GrappleRetreatSpeed)
 
static HookList HookKill = AddHook<Action<Projectile, int>>(g => g.Kill)
 
static HookList HookMinionContactDamage = AddHook<Func<Projectile, bool>>(g => g.MinionContactDamage)
 
static HookList HookModifyDamageHitbox = AddHook<DelegateModifyDamageHitbox>(g => g.ModifyDamageHitbox)
 
static HookList HookModifyHitNPC = AddHook<DelegateModifyHitNPC>(g => g.ModifyHitNPC)
 
static HookList HookModifyHitPlayer = AddHook<DelegateModifyHitPlayer>(g => g.ModifyHitPlayer)
 
static HookList HookModifyHitPvp = AddHook<DelegateModifyHitPvp>(g => g.ModifyHitPvp)
 
static HookList HookNumGrappleHooks = AddHook<DelegateNumGrappleHooks>(g => g.NumGrappleHooks)
 
static HookList HookOnHitNPC = AddHook<Action<Projectile, NPC, int, float, bool>>(g => g.OnHitNPC)
 
static HookList HookOnHitPlayer = AddHook<Action<Projectile, Player, int, bool>>(g => g.OnHitPlayer)
 
static HookList HookOnHitPvp = AddHook<Action<Projectile, Player, int, bool>>(g => g.OnHitPvp)
 
static HookList HookOnTileCollide = AddHook<Func<Projectile, Vector2, bool>>(g => g.OnTileCollide)
 
static HookList HookPostAI = AddHook<Action<Projectile>>(g => g.PostAI)
 
static HookList HookPostDraw = AddHook<Action<Projectile, SpriteBatch, Color>>(g => g.PostDraw)
 
static HookList HookPreAI = AddHook<Func<Projectile, bool>>(g => g.PreAI)
 
static HookList HookPreDraw = AddHook<Func<Projectile, SpriteBatch, Color, bool>>(g => g.PreDraw)
 
static HookList HookPreDrawExtras = AddHook<Func<Projectile, SpriteBatch, bool>>(g => g.PreDrawExtras)
 
static HookList HookPreKill = AddHook<Func<Projectile, int, bool>>(g => g.PreKill)
 
static List< HookListhooks = new List<HookList>()
 
static HookList HookSetDefaults = AddHook<Action<Projectile>>(g => g.SetDefaults)
 
static HookList HookShouldUpdatePosition = AddHook<Func<Projectile, bool>>(g => g.ShouldUpdatePosition)
 
static HookList HookSingleGrappleHook = AddHook<Func<int, Player, bool?>>(g => g.SingleGrappleHook)
 
static HookList HookTileCollideStyle = AddHook<DelegateTileCollideStyle>(g => g.TileCollideStyle)
 
static HookList HookUseGrapple = AddHook<DelegateUseGrapple>(g => g.UseGrapple)
 
static int nextProjectile = ProjectileID.Count
 

Detailed Description

This serves as the central class from which projectile-related functions are carried out. It also stores a list of mod projectiles by ID.

Definition at line 18 of file ProjectileLoader.cs.

Member Function Documentation

static HookList Terraria.ModLoader.ProjectileLoader.AddHook< F > ( Expression< Func< GlobalProjectile, F >>  func)
staticprivate

Definition at line 39 of file ProjectileLoader.cs.

References Terraria.ModLoader.ModNet.AllowVanillaClients.

39  {
40  var hook = new HookList(ModLoader.Method(func));
41  hooks.Add(hook);
42  return hook;
43  }
static void Terraria.ModLoader.ProjectileLoader.AI ( Projectile  projectile)
static

Definition at line 183 of file ProjectileLoader.cs.

References Terraria.ModLoader.GlobalProjectile.AI(), Terraria.ModLoader.ProjectileLoader.HookList.arr, and Terraria.ModLoader.GlobalProjectile.Instance().

183  {
184  projectile.modProjectile?.AI();
185 
186  foreach (GlobalProjectile g in HookAI.arr) {
187  g.Instance(projectile).AI(projectile);
188  }
189  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.CanCutTiles ( Projectile  projectile)
static

Definition at line 285 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.CanCutTiles(), and Terraria.ModLoader.GlobalProjectile.Instance().

285  {
286  foreach (GlobalProjectile g in HookCanCutTiles.arr) {
287  bool? canCutTiles = g.Instance(projectile).CanCutTiles(projectile);
288  if (canCutTiles.HasValue) {
289  return canCutTiles.Value;
290  }
291  }
292  return projectile.modProjectile?.CanCutTiles();
293  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.CanDamage ( Projectile  projectile)
static

Definition at line 330 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.CanDamage(), and Terraria.ModLoader.GlobalProjectile.Instance().

330  {
331  if (projectile.modProjectile != null && !projectile.modProjectile.CanDamage()) {
332  return false;
333  }
334  foreach (GlobalProjectile g in HookCanDamage.arr) {
335  if (!g.Instance(projectile).CanDamage(projectile)) {
336  return false;
337  }
338  }
339  return true;
340  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.CanHitNPC ( Projectile  projectile,
NPC  target 
)
static

Definition at line 368 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.CanHitNPC(), and Terraria.ModLoader.GlobalProjectile.Instance().

368  {
369  bool? flag = null;
370  foreach (GlobalProjectile g in HookCanHitNPC.arr) {
371  bool? canHit = g.Instance(projectile).CanHitNPC(projectile, target);
372  if (canHit.HasValue && !canHit.Value) {
373  return false;
374  }
375  if (canHit.HasValue) {
376  flag = canHit.Value;
377  }
378  }
379  if (projectile.modProjectile != null) {
380  bool? canHit = projectile.modProjectile.CanHitNPC(target);
381  if (canHit.HasValue && !canHit.Value) {
382  return false;
383  }
384  if (canHit.HasValue) {
385  flag = canHit.Value;
386  }
387  }
388  return flag;
389  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.CanHitPlayer ( Projectile  projectile,
Player  target 
)
static

Definition at line 449 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.CanHitPlayer(), and Terraria.ModLoader.GlobalProjectile.Instance().

449  {
450  foreach (GlobalProjectile g in HookCanHitPlayer.arr) {
451  if (!g.Instance(projectile).CanHitPlayer(projectile, target)) {
452  return false;
453  }
454  }
455  if (projectile.modProjectile != null) {
456  return projectile.modProjectile.CanHitPlayer(target);
457  }
458  return true;
459  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.CanHitPvp ( Projectile  projectile,
Player  target 
)
static

Definition at line 414 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.CanHitPvp(), and Terraria.ModLoader.GlobalProjectile.Instance().

414  {
415  foreach (GlobalProjectile g in HookCanHitPvp.arr) {
416  if (!g.Instance(projectile).CanHitPvp(projectile, target)) {
417  return false;
418  }
419  }
420  if (projectile.modProjectile != null) {
421  return projectile.modProjectile.CanHitPvp(target);
422  }
423  return true;
424  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.CanUseGrapple ( int  type,
Player  player 
)
static

Definition at line 560 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, and Terraria.ModLoader.GlobalProjectile.CanUseGrapple().

560  {
561  var flag = GetProjectile(type)?.CanUseGrapple(player);
562 
563  foreach (GlobalProjectile g in HookCanUseGrapple.arr) {
564  bool? canGrapple = g.CanUseGrapple(type, player);
565  if (canGrapple.HasValue) {
566  flag = canGrapple;
567  }
568  }
569  return flag;
570  }
virtual bool CanUseGrapple(Player player)
This code is called whenever the player uses a grappling hook that shoots this type of projectile...
static ModProjectile GetProjectile(int type)
Gets the ModProjectile instance corresponding to the specified type.

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.Colliding ( Projectile  projectile,
Rectangle  projHitbox,
Rectangle  targetHitbox 
)
static

Definition at line 484 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Colliding(), and Terraria.ModLoader.GlobalProjectile.Instance().

484  {
485  foreach (GlobalProjectile g in HookColliding.arr) {
486  bool? colliding = g.Instance(projectile).Colliding(projectile, projHitbox, targetHitbox);
487  if (colliding.HasValue) {
488  return colliding.Value;
489  }
490  }
491  return projectile.modProjectile?.Colliding(projHitbox, targetHitbox);
492  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.CutTiles ( Projectile  projectile)
static

Definition at line 297 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.CutTiles(), and Terraria.ModLoader.GlobalProjectile.Instance().

297  {
298  foreach (GlobalProjectile g in HookCutTiles.arr) {
299  g.Instance(projectile).CutTiles(projectile);
300  }
301  projectile.modProjectile?.CutTiles();
302  }

+ Here is the call graph for this function:

delegate void Terraria.ModLoader.ProjectileLoader.DelegateGrapplePullSpeed ( Projectile  projectile,
Player  player,
ref float  speed 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateGrappleRetreatSpeed ( Projectile  projectile,
Player  player,
ref float  speed 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateModifyDamageHitbox ( Projectile  projectile,
ref Rectangle  hitbox 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateModifyHitNPC ( Projectile  projectile,
NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit,
ref int  hitDirection 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateModifyHitPlayer ( Projectile  projectile,
Player  target,
ref int  damage,
ref bool  crit 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateModifyHitPvp ( Projectile  projectile,
Player  target,
ref int  damage,
ref bool  crit 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateNumGrappleHooks ( Projectile  projectile,
Player  player,
ref int  numHooks 
)
private
delegate bool Terraria.ModLoader.ProjectileLoader.DelegateTileCollideStyle ( Projectile  projectile,
ref int  width,
ref int  height,
ref bool  fallThrough 
)
private
delegate void Terraria.ModLoader.ProjectileLoader.DelegateUseGrapple ( Player  player,
ref int  type 
)
private
static void Terraria.ModLoader.ProjectileLoader.DrawHeldProjInFrontOfHeldItemAndArms ( Projectile  projectile,
ref bool  flag 
)
static

Definition at line 494 of file ProjectileLoader.cs.

494  {
495  if (projectile.modProjectile != null) {
496  flag = projectile.modProjectile.drawHeldProjInFrontOfHeldItemAndArms;
497  }
498  }
static void Terraria.ModLoader.ProjectileLoader.DrawOffset ( Projectile  projectile,
ref int  offsetX,
ref int  offsetY,
ref float  originX 
)
static

Definition at line 512 of file ProjectileLoader.cs.

512  {
513  if (projectile.modProjectile != null) {
514  offsetX = projectile.modProjectile.drawOffsetX;
515  offsetY = -projectile.modProjectile.drawOriginOffsetY;
516  originX += projectile.modProjectile.drawOriginOffsetX;
517  }
518  }
static Color Terraria.ModLoader.ProjectileLoader.GetAlpha ( Projectile  projectile,
Color  lightColor 
)
static

Definition at line 502 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.GetAlpha(), and Terraria.ModLoader.GlobalProjectile.Instance().

502  {
503  foreach (GlobalProjectile g in HookGetAlpha.arr) {
504  Color? color = g.Instance(projectile).GetAlpha(projectile, lightColor);
505  if (color.HasValue) {
506  return color;
507  }
508  }
509  return projectile.modProjectile?.GetAlpha(lightColor);
510  }

+ Here is the call graph for this function:

static ModProjectile Terraria.ModLoader.ProjectileLoader.GetProjectile ( int  type)
static

Gets the ModProjectile instance corresponding to the specified type.

Parameters
typeThe type of the projectile
Returns
The ModProjectile instance in the projectiles array, null if not found.

Definition at line 60 of file ProjectileLoader.cs.

60  {
61  return type >= ProjectileID.Count && type < ProjectileCount ? projectiles[type - ProjectileID.Count] : null;
62  }
static bool Terraria.ModLoader.ProjectileLoader.GrappleOutOfRange ( float  distance,
Projectile  projectile 
)
static

Definition at line 597 of file ProjectileLoader.cs.

597  {
598  return distance > projectile.modProjectile?.GrappleRange();
599  }
static void Terraria.ModLoader.ProjectileLoader.GrapplePullSpeed ( Projectile  projectile,
Player  player,
ref float  speed 
)
static

Definition at line 626 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.GrapplePullSpeed(), and Terraria.ModLoader.GlobalProjectile.Instance().

626  {
627  projectile.modProjectile?.GrapplePullSpeed(player, ref speed);
628 
629  foreach (GlobalProjectile g in HookGrapplePullSpeed.arr) {
630  g.Instance(projectile).GrapplePullSpeed(projectile, player, ref speed);
631  }
632  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.GrappleRetreatSpeed ( Projectile  projectile,
Player  player,
ref float  speed 
)
static

Definition at line 615 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.GrappleRetreatSpeed(), and Terraria.ModLoader.GlobalProjectile.Instance().

615  {
616  projectile.modProjectile?.GrappleRetreatSpeed(player, ref speed);
617 
618  foreach (GlobalProjectile g in HookGrappleRetreatSpeed.arr) {
619  g.Instance(projectile).GrappleRetreatSpeed(projectile, player, ref speed);
620  }
621  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.HasMethod ( Type  t,
string  method,
params Type[]  args 
)
staticprivate

Definition at line 644 of file ProjectileLoader.cs.

References Terraria.ModLoader.GlobalProjectile.InstancePerEntity.

644  {
645  return t.GetMethod(method, args).DeclaringType != typeof(GlobalProjectile);
646  }
static void Terraria.ModLoader.ProjectileLoader.Kill ( Projectile  projectile,
int  timeLeft 
)
static

Definition at line 320 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.Kill().

320  {
321  projectile.modProjectile?.Kill(timeLeft);
322 
323  foreach (GlobalProjectile g in HookKill.arr) {
324  g.Instance(projectile).Kill(projectile, timeLeft);
325  }
326  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.MinionContactDamage ( Projectile  projectile)
static

Definition at line 344 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.MinionContactDamage().

344  {
345  if (projectile.modProjectile != null && projectile.modProjectile.MinionContactDamage()) {
346  return true;
347  }
348  foreach (GlobalProjectile g in HookMinionContactDamage.arr) {
349  if (g.Instance(projectile).MinionContactDamage(projectile)) {
350  return true;
351  }
352  }
353  return false;
354  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.ModifyDamageHitbox ( Projectile  projectile,
ref Rectangle  hitbox 
)
static

Definition at line 359 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.ModifyDamageHitbox().

359  {
360  projectile.modProjectile?.ModifyDamageHitbox(ref hitbox);
361  foreach (GlobalProjectile g in HookModifyDamageHitbox.arr) {
362  g.Instance(projectile).ModifyDamageHitbox(projectile, ref hitbox);
363  }
364  }

+ Here is the call graph for this function:

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

Definition at line 394 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.ModifyHitNPC().

394  {
395  projectile.modProjectile?.ModifyHitNPC(target, ref damage, ref knockback, ref crit, ref hitDirection);
396 
397  foreach (GlobalProjectile g in HookModifyHitNPC.arr) {
398  g.Instance(projectile).ModifyHitNPC(projectile, target, ref damage, ref knockback, ref crit, ref hitDirection);
399  }
400  }

+ Here is the call graph for this function:

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

Definition at line 464 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.ModifyHitPlayer().

464  {
465  projectile.modProjectile?.ModifyHitPlayer(target, ref damage, ref crit);
466 
467  foreach (GlobalProjectile g in HookModifyHitPlayer.arr) {
468  g.Instance(projectile).ModifyHitPlayer(projectile, target, ref damage, ref crit);
469  }
470  }

+ Here is the call graph for this function:

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

Definition at line 429 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.ModifyHitPvp().

429  {
430  projectile.modProjectile?.ModifyHitPvp(target, ref damage, ref crit);
431 
432  foreach (GlobalProjectile g in HookModifyHitPvp.arr) {
433  g.Instance(projectile).ModifyHitPvp(projectile, target, ref damage, ref crit);
434  }
435  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.NumGrappleHooks ( Projectile  projectile,
Player  player,
ref int  numHooks 
)
static

Definition at line 604 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.NumGrappleHooks().

604  {
605  projectile.modProjectile?.NumGrappleHooks(player, ref numHooks);
606 
607  foreach (GlobalProjectile g in HookNumGrappleHooks.arr) {
608  g.Instance(projectile).NumGrappleHooks(projectile, player, ref numHooks);
609  }
610  }

+ Here is the call graph for this function:

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

Definition at line 404 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.OnHitNPC().

404  {
405  projectile.modProjectile?.OnHitNPC(target, damage, knockback, crit);
406 
407  foreach (GlobalProjectile g in HookOnHitNPC.arr) {
408  g.Instance(projectile).OnHitNPC(projectile, target, damage, knockback, crit);
409  }
410  }

+ Here is the call graph for this function:

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

Definition at line 474 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.OnHitPlayer().

474  {
475  projectile.modProjectile?.OnHitPlayer(target, damage, crit);
476 
477  foreach (GlobalProjectile g in HookOnHitPlayer.arr) {
478  g.Instance(projectile).OnHitPlayer(projectile, target, damage, crit);
479  }
480  }

+ Here is the call graph for this function:

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

Definition at line 439 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.OnHitPvp().

439  {
440  projectile.modProjectile?.OnHitPvp(target, damage, crit);
441 
442  foreach (GlobalProjectile g in HookOnHitPvp.arr) {
443  g.Instance(projectile).OnHitPvp(projectile, target, damage, crit);
444  }
445  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.OnTileCollide ( Projectile  projectile,
Vector2  oldVelocity 
)
static

Definition at line 271 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.OnTileCollide().

271  {
272  foreach (GlobalProjectile g in HookOnTileCollide.arr) {
273  if (!g.Instance(projectile).OnTileCollide(projectile, oldVelocity)) {
274  return false;
275  }
276  }
277  if (projectile.modProjectile != null) {
278  return projectile.modProjectile.OnTileCollide(oldVelocity);
279  }
280  return true;
281  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.PostAI ( Projectile  projectile)
static

Definition at line 193 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.PostAI().

193  {
194  projectile.modProjectile?.PostAI();
195 
196  foreach (GlobalProjectile g in HookPostAI.arr) {
197  g.Instance(projectile).PostAI(projectile);
198  }
199  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.PostDraw ( Projectile  projectile,
SpriteBatch  spriteBatch,
Color  lightColor 
)
static

Definition at line 550 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.PostDraw().

550  {
551  projectile.modProjectile?.PostDraw(spriteBatch, lightColor);
552 
553  foreach (GlobalProjectile g in HookPostDraw.arr) {
554  g.Instance(projectile).PostDraw(projectile, spriteBatch, lightColor);
555  }
556  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.PreAI ( Projectile  projectile)
static

Definition at line 169 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.PreAI().

169  {
170  foreach (GlobalProjectile g in HookPreAI.arr) {
171  if (!g.Instance(projectile).PreAI(projectile)) {
172  return false;
173  }
174  }
175  if (projectile.modProjectile != null) {
176  return projectile.modProjectile.PreAI();
177  }
178  return true;
179  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.PreDraw ( Projectile  projectile,
SpriteBatch  spriteBatch,
Color  lightColor 
)
static

Definition at line 536 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.PreDraw().

536  {
537  foreach (GlobalProjectile g in HookPreDraw.arr) {
538  if (!g.Instance(projectile).PreDraw(projectile, spriteBatch, lightColor)) {
539  return false;
540  }
541  }
542  if (projectile.modProjectile != null) {
543  return projectile.modProjectile.PreDraw(spriteBatch, lightColor);
544  }
545  return true;
546  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.PreDrawExtras ( Projectile  projectile,
SpriteBatch  spriteBatch 
)
static

Definition at line 522 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.PreDrawExtras().

522  {
523  foreach (GlobalProjectile g in HookPreDrawExtras.arr) {
524  if (!g.Instance(projectile).PreDrawExtras(projectile, spriteBatch)) {
525  return false;
526  }
527  }
528  if (projectile.modProjectile != null) {
529  return projectile.modProjectile.PreDrawExtras(spriteBatch);
530  }
531  return true;
532  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.PreKill ( Projectile  projectile,
int  timeLeft 
)
static

Definition at line 306 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.PreKill().

306  {
307  foreach (GlobalProjectile g in HookPreKill.arr) {
308  if (!g.Instance(projectile).PreKill(projectile, timeLeft)) {
309  return false;
310  }
311  }
312  if (projectile.modProjectile != null) {
313  return projectile.modProjectile.PreKill(timeLeft);
314  }
315  return true;
316  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.ProjectileAI ( Projectile  projectile)
static

Definition at line 151 of file ProjectileLoader.cs.

151  {
152  if (PreAI(projectile)) {
153  int type = projectile.type;
154  bool useAiType = projectile.modProjectile != null && projectile.modProjectile.aiType > 0;
155  if (useAiType) {
156  projectile.type = projectile.modProjectile.aiType;
157  }
158  projectile.VanillaAI();
159  if (useAiType) {
160  projectile.type = type;
161  }
162  AI(projectile);
163  }
164  PostAI(projectile);
165  }
static void PostAI(Projectile projectile)
static void AI(Projectile projectile)
static bool PreAI(Projectile projectile)
static byte [] Terraria.ModLoader.ProjectileLoader.ReadExtraAI ( BinaryReader  reader,
BitsByte  flags 
)
static

Definition at line 221 of file ProjectileLoader.cs.

221  {
222  if (flags[Projectile.maxAI + 1]) {
223  return reader.ReadBytes(reader.ReadByte());
224  }
225  return new byte[0];
226  }
static void Terraria.ModLoader.ProjectileLoader.ReceiveExtraAI ( Projectile  projectile,
byte[]  extraAI 
)
static

Definition at line 229 of file ProjectileLoader.cs.

229  {
230  if (extraAI.Length > 0 && projectile.modProjectile != null) {
231  using (MemoryStream stream = new MemoryStream(extraAI)) {
232  using (BinaryReader reader = new BinaryReader(stream)) {
233  projectile.modProjectile.ReceiveExtraAI(reader);
234  }
235  }
236  }
237  }
static byte [] Terraria.ModLoader.ProjectileLoader.SendExtraAI ( Projectile  projectile,
ref BitsByte  flags 
)
static

Definition at line 202 of file ProjectileLoader.cs.

202  {
203  if (projectile.modProjectile != null) {
204  byte[] data;
205  using (MemoryStream stream = new MemoryStream()) {
206  using (BinaryWriter modWriter = new BinaryWriter(stream)) {
207  projectile.modProjectile.SendExtraAI(modWriter);
208  modWriter.Flush();
209  data = stream.ToArray();
210  }
211  }
212  if (data.Length > 0) {
213  flags[Projectile.maxAI + 1] = true;
214  }
215  return data;
216  }
217  return new byte[0];
218  }
static bool Terraria.ModLoader.ProjectileLoader.ShouldUpdatePosition ( Projectile  projectile)
static

Definition at line 241 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.ShouldUpdatePosition().

241  {
242  if (IsModProjectile(projectile) && !projectile.modProjectile.ShouldUpdatePosition()) {
243  return false;
244  }
245  foreach (GlobalProjectile g in HookShouldUpdatePosition.arr) {
246  if (!g.Instance(projectile).ShouldUpdatePosition(projectile)) {
247  return false;
248  }
249  }
250  return true;
251  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.SingleGrappleHook ( int  type,
Player  player 
)
static

Definition at line 574 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, and Terraria.ModLoader.GlobalProjectile.SingleGrappleHook().

574  {
575  bool? flag = GetProjectile(type)?.SingleGrappleHook(player);
576 
577  foreach (GlobalProjectile g in HookSingleGrappleHook.arr) {
578  bool? singleHook = g.SingleGrappleHook(type, player);
579  if (singleHook.HasValue) {
580  flag = singleHook;
581  }
582  }
583  return flag;
584  }
static ModProjectile GetProjectile(int type)
Gets the ModProjectile instance corresponding to the specified type.
virtual bool SingleGrappleHook(Player player)
Whether or not a grappling hook can only have one hook per player in the world at a time...

+ Here is the call graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.TileCollideStyle ( Projectile  projectile,
ref int  width,
ref int  height,
ref bool  fallThrough 
)
static

Definition at line 256 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, Terraria.ModLoader.GlobalProjectile.Instance(), and Terraria.ModLoader.GlobalProjectile.TileCollideStyle().

256  {
257  if (IsModProjectile(projectile) && !projectile.modProjectile.TileCollideStyle(ref width, ref height, ref fallThrough)) {
258  return false;
259  }
260 
261  foreach (GlobalProjectile g in HookTileCollideStyle.arr) {
262  if (!g.Instance(projectile).TileCollideStyle(projectile, ref width, ref height, ref fallThrough)) {
263  return false;
264  }
265  }
266  return true;
267  }

+ Here is the call graph for this function:

static void Terraria.ModLoader.ProjectileLoader.UseGrapple ( Player  player,
ref int  type 
)
static

Definition at line 589 of file ProjectileLoader.cs.

References Terraria.ModLoader.ProjectileLoader.HookList.arr, and Terraria.ModLoader.GlobalProjectile.UseGrapple().

589  {
590  GetProjectile(type)?.UseGrapple(player, ref type);
591 
592  foreach (GlobalProjectile g in HookUseGrapple.arr) {
593  g.UseGrapple(player, ref type);
594  }
595  }
static ModProjectile GetProjectile(int type)
Gets the ModProjectile instance corresponding to the specified type.
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...

+ Here is the call graph for this function:

Member Data Documentation

HookList Terraria.ModLoader.ProjectileLoader.HookAI = AddHook<Action<Projectile>>(g => g.AI)
staticprivate

Definition at line 181 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCanCutTiles = AddHook<Func<Projectile, bool?>>(g => g.CanCutTiles)
staticprivate

Definition at line 283 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCanDamage = AddHook<Func<Projectile, bool>>(g => g.CanDamage)
staticprivate

Definition at line 328 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCanHitNPC = AddHook<Func<Projectile, NPC, bool?>>(g => g.CanHitNPC)
staticprivate

Definition at line 366 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCanHitPlayer = AddHook<Func<Projectile, Player, bool>>(g => g.CanHitPlayer)
staticprivate

Definition at line 447 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCanHitPvp = AddHook<Func<Projectile, Player, bool>>(g => g.CanHitPvp)
staticprivate

Definition at line 412 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCanUseGrapple = AddHook<Func<int, Player, bool?>>(g => g.CanUseGrapple)
staticprivate

Definition at line 558 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookColliding = AddHook<Func<Projectile, Rectangle, Rectangle, bool?>>(g => g.Colliding)
staticprivate

Definition at line 482 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookCutTiles = AddHook<Action<Projectile>>(g => g.CutTiles)
staticprivate

Definition at line 295 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookDrawBehind = AddHook<Action<Projectile, int, List<int>, List<int>, List<int>, List<int>>>(g => g.DrawBehind)
staticprivate

Definition at line 634 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookGetAlpha = AddHook<Func<Projectile, Color, Color?>>(g => g.GetAlpha)
staticprivate

Definition at line 500 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookGrapplePullSpeed = AddHook<DelegateGrapplePullSpeed>(g => g.GrapplePullSpeed)
staticprivate

Definition at line 624 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookGrappleRetreatSpeed = AddHook<DelegateGrappleRetreatSpeed>(g => g.GrappleRetreatSpeed)
staticprivate

Definition at line 613 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookKill = AddHook<Action<Projectile, int>>(g => g.Kill)
staticprivate

Definition at line 318 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookMinionContactDamage = AddHook<Func<Projectile, bool>>(g => g.MinionContactDamage)
staticprivate

Definition at line 342 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookModifyDamageHitbox = AddHook<DelegateModifyDamageHitbox>(g => g.ModifyDamageHitbox)
staticprivate

Definition at line 357 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookModifyHitNPC = AddHook<DelegateModifyHitNPC>(g => g.ModifyHitNPC)
staticprivate

Definition at line 392 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookModifyHitPlayer = AddHook<DelegateModifyHitPlayer>(g => g.ModifyHitPlayer)
staticprivate

Definition at line 462 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookModifyHitPvp = AddHook<DelegateModifyHitPvp>(g => g.ModifyHitPvp)
staticprivate

Definition at line 427 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookNumGrappleHooks = AddHook<DelegateNumGrappleHooks>(g => g.NumGrappleHooks)
staticprivate

Definition at line 602 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookOnHitNPC = AddHook<Action<Projectile, NPC, int, float, bool>>(g => g.OnHitNPC)
staticprivate

Definition at line 402 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookOnHitPlayer = AddHook<Action<Projectile, Player, int, bool>>(g => g.OnHitPlayer)
staticprivate

Definition at line 472 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookOnHitPvp = AddHook<Action<Projectile, Player, int, bool>>(g => g.OnHitPvp)
staticprivate

Definition at line 437 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookOnTileCollide = AddHook<Func<Projectile, Vector2, bool>>(g => g.OnTileCollide)
staticprivate

Definition at line 269 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookPostAI = AddHook<Action<Projectile>>(g => g.PostAI)
staticprivate

Definition at line 191 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookPostDraw = AddHook<Action<Projectile, SpriteBatch, Color>>(g => g.PostDraw)
staticprivate

Definition at line 548 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookPreAI = AddHook<Func<Projectile, bool>>(g => g.PreAI)
staticprivate

Definition at line 167 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookPreDraw = AddHook<Func<Projectile, SpriteBatch, Color, bool>>(g => g.PreDraw)
staticprivate

Definition at line 534 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookPreDrawExtras = AddHook<Func<Projectile, SpriteBatch, bool>>(g => g.PreDrawExtras)
staticprivate

Definition at line 520 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookPreKill = AddHook<Func<Projectile, int, bool>>(g => g.PreKill)
staticprivate

Definition at line 304 of file ProjectileLoader.cs.

List<HookList> Terraria.ModLoader.ProjectileLoader.hooks = new List<HookList>()
staticprivate

Definition at line 37 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookSetDefaults = AddHook<Action<Projectile>>(g => g.SetDefaults)
staticprivate

Definition at line 128 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookShouldUpdatePosition = AddHook<Func<Projectile, bool>>(g => g.ShouldUpdatePosition)
staticprivate

Definition at line 239 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookSingleGrappleHook = AddHook<Func<int, Player, bool?>>(g => g.SingleGrappleHook)
staticprivate

Definition at line 572 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookTileCollideStyle = AddHook<DelegateTileCollideStyle>(g => g.TileCollideStyle)
staticprivate

Definition at line 254 of file ProjectileLoader.cs.

HookList Terraria.ModLoader.ProjectileLoader.HookUseGrapple = AddHook<DelegateUseGrapple>(g => g.UseGrapple)
staticprivate

Definition at line 587 of file ProjectileLoader.cs.

int Terraria.ModLoader.ProjectileLoader.nextProjectile = ProjectileID.Count
staticprivate

Definition at line 20 of file ProjectileLoader.cs.

int Terraria.ModLoader.ProjectileLoader.ProjectileCount => nextProjectile
static

Definition at line 53 of file ProjectileLoader.cs.