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

◆ DoesPositionHaveEnoughNPCs()

static bool Terraria.GameContent.TeleportPylonsSystem.DoesPositionHaveEnoughNPCs ( int necessaryNPCCount,
Point16 centerPoint )
inlinestatic

Definition at line 235 of file TeleportPylonsSystem.cs.

236 {
237 Rectangle rectangle = new Rectangle(centerPoint.X - Main.buffScanAreaWidth / 2, centerPoint.Y - Main.buffScanAreaHeight / 2, Main.buffScanAreaWidth, Main.buffScanAreaHeight);
238 int num = necessaryNPCCount;
239 for (int i = 0; i < 200; i++)
240 {
241 NPC nPC = Main.npc[i];
242 if (!nPC.active || !nPC.isLikeATownNPC || nPC.homeless || !rectangle.Contains(nPC.homeTileX, nPC.homeTileY))
243 {
244 continue;
245 }
246 Vector2 value = new Vector2(nPC.homeTileX, nPC.homeTileY);
247 Vector2 value2 = new Vector2(nPC.Center.X / 16f, nPC.Center.Y / 16f);
248 if (Vector2.Distance(value, value2) < 100f)
249 {
250 num--;
251 if (num == 0)
252 {
253 return true;
254 }
255 }
256 }
257 return false;
258 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.Main.buffScanAreaHeight, Terraria.Main.buffScanAreaWidth, System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), Microsoft.Xna.Framework.Vector2.Distance(), and Terraria.Main.npc.

Referenced by Terraria.GameContent.TeleportPylonsSystem.DoesPylonHaveEnoughNPCsAroundIt(), and Terraria.Chest.SetupShop().