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

◆ GetNearbyResidentNPCs()

List< NPC > Terraria.GameContent.ShopHelper.GetNearbyResidentNPCs ( NPC npc,
out int npcsWithinHouse,
out int npcsWithinVillage )
inlineprivate

Definition at line 309 of file ShopHelper.cs.

310 {
311 List<NPC> list = new List<NPC>();
312 npcsWithinHouse = 0;
314 Vector2 value = new Vector2(npc.homeTileX, npc.homeTileY);
315 if (npc.homeless)
316 {
317 value = new Vector2(npc.Center.X / 16f, npc.Center.Y / 16f);
318 }
319 for (int i = 0; i < 200; i++)
320 {
321 if (i == npc.whoAmI)
322 {
323 continue;
324 }
325 NPC nPC = Main.npc[i];
326 if (nPC.active && nPC.townNPC && !IsNotReallyTownNPC(nPC) && !WorldGen.TownManager.CanNPCsLiveWithEachOther_ShopHelper(npc, nPC))
327 {
328 Vector2 value2 = new Vector2(nPC.homeTileX, nPC.homeTileY);
329 if (nPC.homeless)
330 {
331 value2 = nPC.Center / 16f;
332 }
333 float num = Vector2.Distance(value, value2);
334 if (num < 25f)
335 {
336 list.Add(nPC);
338 }
339 else if (num < 120f)
340 {
342 }
343 }
344 }
345 return list;
346 }
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.Entity.Center, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.NPC.homeless, Terraria.NPC.homeTileX, Terraria.NPC.homeTileY, Terraria.GameContent.ShopHelper.IsNotReallyTownNPC(), System.list, Terraria.Main.npc, Terraria.WorldGen.TownManager, System.value, Terraria.Entity.whoAmI, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.GameContent.ShopHelper.ProcessMood().