Terraria ModLoader  0.11.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 182 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 283 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 327 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 365 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 446 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 411 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 555 of file ProjectileLoader.cs.

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

555  {
556  var flag = GetProjectile(type)?.CanUseGrapple(player);
557 
558  foreach (GlobalProjectile g in HookCanUseGrapple.arr) {
559  bool? canGrapple = g.CanUseGrapple(type, player);
560  if (canGrapple.HasValue) {
561  flag = canGrapple;
562  }
563  }
564  return flag;
565  }
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 481 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 295 of file ProjectileLoader.cs.

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

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

+ 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 491 of file ProjectileLoader.cs.

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

Definition at line 509 of file ProjectileLoader.cs.

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

Definition at line 499 of file ProjectileLoader.cs.

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

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

+ 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.

Referenced by Terraria.ModLoader.ModContent.MusicExists().

60  {
61  return type >= ProjectileID.Count && type < ProjectileCount ? projectiles[type - ProjectileID.Count] : null;
62  }

+ Here is the caller graph for this function:

static bool Terraria.ModLoader.ProjectileLoader.GrappleOutOfRange ( float  distance,
Projectile  projectile 
)
static

Definition at line 592 of file ProjectileLoader.cs.

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

Definition at line 621 of file ProjectileLoader.cs.

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

621  {
622  projectile.modProjectile?.GrapplePullSpeed(player, ref speed);
623 
624  foreach (GlobalProjectile g in HookGrapplePullSpeed.arr) {
625  g.Instance(projectile).GrapplePullSpeed(projectile, player, ref speed);
626  }
627  }

+ 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 610 of file ProjectileLoader.cs.

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

610  {
611  projectile.modProjectile?.GrappleRetreatSpeed(player, ref speed);
612 
613  foreach (GlobalProjectile g in HookGrappleRetreatSpeed.arr) {
614  g.Instance(projectile).GrappleRetreatSpeed(projectile, player, ref speed);
615  }
616  }

+ 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 639 of file ProjectileLoader.cs.

References Terraria.ModLoader.GlobalProjectile.InstancePerEntity.

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

Definition at line 317 of file ProjectileLoader.cs.

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

317  {
318  projectile.modProjectile?.Kill(timeLeft);
319 
320  foreach (GlobalProjectile g in HookKill.arr) {
321  g.Instance(projectile).Kill(projectile, timeLeft);
322  }
323  }

+ Here is the call graph for this function:

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

Definition at line 341 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 356 of file ProjectileLoader.cs.

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

356  {
357  projectile.modProjectile?.ModifyDamageHitbox(ref hitbox);
358  foreach (GlobalProjectile g in HookModifyDamageHitbox.arr) {
359  g.Instance(projectile).ModifyDamageHitbox(projectile, ref hitbox);
360  }
361  }

+ 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 391 of file ProjectileLoader.cs.

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

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

+ 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 461 of file ProjectileLoader.cs.

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

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

+ 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 426 of file ProjectileLoader.cs.

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

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

+ 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 599 of file ProjectileLoader.cs.

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

599  {
600  projectile.modProjectile?.NumGrappleHooks(player, ref numHooks);
601 
602  foreach (GlobalProjectile g in HookNumGrappleHooks.arr) {
603  g.Instance(projectile).NumGrappleHooks(projectile, player, ref numHooks);
604  }
605  }

+ 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 401 of file ProjectileLoader.cs.

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

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

+ 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 471 of file ProjectileLoader.cs.

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

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

+ 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 436 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 270 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 192 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 545 of file ProjectileLoader.cs.

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

545  {
546  projectile.modProjectile?.PostDraw(spriteBatch, lightColor);
547 
548  foreach (GlobalProjectile g in HookPostDraw.arr) {
549  g.Instance(projectile).PostDraw(projectile, spriteBatch, lightColor);
550  }
551  }

+ 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  bool result = true;
171  foreach (GlobalProjectile g in HookPreAI.arr) {
172  result &= g.Instance(projectile).PreAI(projectile);
173  }
174  if (result && projectile.modProjectile != null) {
175  return projectile.modProjectile.PreAI();
176  }
177  return result;
178  }

+ Here is the call graph for this function:

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

Definition at line 532 of file ProjectileLoader.cs.

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

532  {
533  bool result = true;
534  foreach (GlobalProjectile g in HookPreDraw.arr) {
535  result &= g.Instance(projectile).PreDraw(projectile, spriteBatch, lightColor);
536  }
537  if (result && projectile.modProjectile != null) {
538  return projectile.modProjectile.PreDraw(spriteBatch, lightColor);
539  }
540  return result;
541  }

+ Here is the call graph for this function:

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

Definition at line 519 of file ProjectileLoader.cs.

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

519  {
520  bool result = true;
521  foreach (GlobalProjectile g in HookPreDrawExtras.arr) {
522  result &= g.Instance(projectile).PreDrawExtras(projectile, spriteBatch);
523  }
524  if (result && projectile.modProjectile != null) {
525  return projectile.modProjectile.PreDrawExtras(spriteBatch);
526  }
527  return result;
528  }

+ Here is the call graph for this function:

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

Definition at line 304 of file ProjectileLoader.cs.

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

304  {
305  bool result = true;
306  foreach (GlobalProjectile g in HookPreKill.arr) {
307  result &= g.Instance(projectile).PreKill(projectile, timeLeft);
308  }
309  if (result && projectile.modProjectile != null) {
310  return projectile.modProjectile.PreKill(timeLeft);
311  }
312  return result;
313  }

+ 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 220 of file ProjectileLoader.cs.

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

Definition at line 228 of file ProjectileLoader.cs.

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

Definition at line 201 of file ProjectileLoader.cs.

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

Definition at line 240 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 569 of file ProjectileLoader.cs.

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

569  {
570  bool? flag = GetProjectile(type)?.SingleGrappleHook(player);
571 
572  foreach (GlobalProjectile g in HookSingleGrappleHook.arr) {
573  bool? singleHook = g.SingleGrappleHook(type, player);
574  if (singleHook.HasValue) {
575  flag = singleHook;
576  }
577  }
578  return flag;
579  }
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 255 of file ProjectileLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 584 of file ProjectileLoader.cs.

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

584  {
585  GetProjectile(type)?.UseGrapple(player, ref type);
586 
587  foreach (GlobalProjectile g in HookUseGrapple.arr) {
588  g.UseGrapple(player, ref type);
589  }
590  }
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 180 of file ProjectileLoader.cs.

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

Definition at line 281 of file ProjectileLoader.cs.

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

Definition at line 325 of file ProjectileLoader.cs.

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

Definition at line 363 of file ProjectileLoader.cs.

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

Definition at line 444 of file ProjectileLoader.cs.

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

Definition at line 409 of file ProjectileLoader.cs.

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

Definition at line 553 of file ProjectileLoader.cs.

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

Definition at line 479 of file ProjectileLoader.cs.

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

Definition at line 293 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 629 of file ProjectileLoader.cs.

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

Definition at line 497 of file ProjectileLoader.cs.

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

Definition at line 619 of file ProjectileLoader.cs.

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

Definition at line 608 of file ProjectileLoader.cs.

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

Definition at line 315 of file ProjectileLoader.cs.

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

Definition at line 339 of file ProjectileLoader.cs.

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

Definition at line 354 of file ProjectileLoader.cs.

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

Definition at line 389 of file ProjectileLoader.cs.

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

Definition at line 459 of file ProjectileLoader.cs.

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

Definition at line 424 of file ProjectileLoader.cs.

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

Definition at line 597 of file ProjectileLoader.cs.

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

Definition at line 399 of file ProjectileLoader.cs.

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

Definition at line 469 of file ProjectileLoader.cs.

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

Definition at line 434 of file ProjectileLoader.cs.

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

Definition at line 268 of file ProjectileLoader.cs.

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

Definition at line 190 of file ProjectileLoader.cs.

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

Definition at line 543 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 530 of file ProjectileLoader.cs.

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

Definition at line 517 of file ProjectileLoader.cs.

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

Definition at line 302 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 238 of file ProjectileLoader.cs.

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

Definition at line 567 of file ProjectileLoader.cs.

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

Definition at line 253 of file ProjectileLoader.cs.

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

Definition at line 582 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.