TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ FindTargetWithinRange()

NPC Terraria.Projectile.FindTargetWithinRange ( float maxRange,
bool checkCanHit = false )
inline

Definition at line 47342 of file Projectile.cs.

47343 {
47344 //IL_0054: Unknown result type (might be due to invalid IL or missing references)
47345 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
47346 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
47347 NPC result = null;
47348 float num = maxRange;
47349 for (int i = 0; i < 200; i++)
47350 {
47351 NPC nPC = Main.npc[i];
47352 if (nPC.CanBeChasedBy(this) && localNPCImmunity[i] == 0 && (!checkCanHit || Collision.CanHitLine(position, width, height, nPC.position, nPC.width, nPC.height)))
47353 {
47354 float num2 = Distance(nPC.Center);
47355 if (!(num <= num2))
47356 {
47357 num = num2;
47358 result = nPC;
47359 }
47360 }
47361 }
47362 return result;
47363 }
float Distance(Vector2 Other)
Definition Entity.cs:275
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51

References Terraria.Collision.CanHitLine(), and Terraria.Main.npc.

+ Here is the call graph for this function: