Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ isNearNPC()

bool Terraria.Player.isNearNPC ( int type,
float range = -1f )
inline

Definition at line 50332 of file Player.cs.

50333 {
50334 if (range == -1f)
50335 {
50336 range = NPC.sWidth;
50337 }
50338 if (NPC.npcsFoundForCheckActive[type])
50339 {
50340 for (int i = 0; i < 200; i++)
50341 {
50342 if (Main.npc[i].active && Main.npc[i].type == type && Vector2.Distance(Main.npc[i].Center, base.Center) < range)
50343 {
50344 return true;
50345 }
50346 }
50347 }
50348 return false;
50349 }
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Main.npc, Terraria.NPC.npcsFoundForCheckActive, Terraria.NPC.sWidth, and System.type.