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

◆ MechSpawn()

static bool Terraria.NPC.MechSpawn ( float x,
float y,
int type )
inlinestatic

Use to check if a mechanism is allowed to spawn an NPC of the provided type at the provided world coordinates. Checks nearby area to see if the Spawn Limitshave been reached.

Definition at line 2379 of file NPC.cs.

2380 {
2381 //IL_026c: Unknown result type (might be due to invalid IL or missing references)
2382 //IL_0285: Unknown result type (might be due to invalid IL or missing references)
2383 int num = 0;
2384 int num2 = 0;
2385 int num3 = 0;
2386 Vector2 vector = default(Vector2);
2387 for (int i = 0; i < 200; i++)
2388 {
2389 if (!Main.npc[i].active)
2390 {
2391 continue;
2392 }
2393 bool flag = false;
2394 if (Main.npc[i].type == type)
2395 {
2396 flag = true;
2397 }
2398 else if (type == 74 || type == 297 || type == 298)
2399 {
2400 if (Main.npc[i].type == 74 || Main.npc[i].type == 297 || Main.npc[i].type == 298)
2401 {
2402 flag = true;
2403 }
2404 }
2405 else if (type == 46 || type == 540 || type == 303 || type == 337)
2406 {
2407 if (Main.npc[i].type == 46 || Main.npc[i].type == 540 || Main.npc[i].type == 303 || Main.npc[i].type == 337)
2408 {
2409 flag = true;
2410 }
2411 }
2412 else if (type == 362 || type == 364)
2413 {
2414 if (Main.npc[i].type == 362 || Main.npc[i].type == 363 || Main.npc[i].type == 364 || Main.npc[i].type == 365)
2415 {
2416 flag = true;
2417 }
2418 }
2419 else if (type == 602)
2420 {
2421 if (Main.npc[i].type == 602 || Main.npc[i].type == 603)
2422 {
2423 flag = true;
2424 }
2425 }
2426 else if (type == 608)
2427 {
2428 if (Main.npc[i].type == 608 || Main.npc[i].type == 609)
2429 {
2430 flag = true;
2431 }
2432 }
2433 else if (type == 616 || type == 617)
2434 {
2435 if (Main.npc[i].type == 616 || Main.npc[i].type == 617)
2436 {
2437 flag = true;
2438 }
2439 }
2440 else if (type == 55 && Main.npc[i].type == 230)
2441 {
2442 flag = true;
2443 }
2444 else if (NPCID.Sets.IsDragonfly[type] && NPCID.Sets.IsDragonfly[Main.npc[i].type])
2445 {
2446 flag = true;
2447 }
2448 if (flag)
2449 {
2450 num++;
2451 ((Vector2)(ref vector))._002Ector(x, y);
2452 float num5 = Main.npc[i].position.X - vector.X;
2453 float num4 = Main.npc[i].position.Y - vector.Y;
2454 float num6 = (float)Math.Sqrt(num5 * num5 + num4 * num4);
2455 if (num6 < 200f)
2456 {
2457 num2++;
2458 }
2459 if (num6 < 600f)
2460 {
2461 num3++;
2462 }
2463 }
2464 }
2465 if (num2 >= 3 || num3 >= 6 || num >= 10)
2466 {
2467 return false;
2468 }
2469 return true;
2470 }
static bool[] IsDragonfly
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is categorized as a dragonfly....
Definition NPCID.cs:284
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990

References Terraria.ID.NPCID.Sets.IsDragonfly, Terraria.Main.npc, and Terraria.NPC.type.

Referenced by Terraria.Wiring.HitWireSingle().

+ Here is the caller graph for this function: