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

◆ CheckActive()

void Terraria.NPC.CheckActive ( )
inline

Definition at line 83487 of file NPC.cs.

83488 {
83489 //IL_0126: Unknown result type (might be due to invalid IL or missing references)
83490 //IL_012b: Unknown result type (might be due to invalid IL or missing references)
83491 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
83492 //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
83494 {
83495 return;
83496 }
83497 if (townNPC)
83498 {
83500 return;
83501 }
83503 bool flag2 = false;
83504 Rectangle rectangle = default(Rectangle);
83505 ((Rectangle)(ref rectangle))._002Ector((int)(position.X + (float)(width / 2) - (float)activeRangeX), (int)(position.Y + (float)(height / 2) - (float)activeRangeY), activeRangeX * 2, activeRangeY * 2);
83506 Rectangle rectangle2 = default(Rectangle);
83507 ((Rectangle)(ref rectangle2))._002Ector((int)((double)(position.X + (float)(width / 2)) - (double)sWidth * 0.5 - (double)width), (int)((double)(position.Y + (float)(height / 2)) - (double)sHeight * 0.5 - (double)height), sWidth + width * 2, sHeight + height * 2);
83508 for (int i = 0; i < 255; i++)
83509 {
83510 if (!Main.player[i].active)
83511 {
83512 continue;
83513 }
83514 Rectangle hitbox = Main.player[i].Hitbox;
83515 if (((Rectangle)(ref rectangle)).Intersects(hitbox))
83516 {
83517 flag2 = true;
83518 if (type != 25 && type != 30 && type != 33 && releaseOwner == 255 && lifeMax > 0)
83519 {
83520 if (Main.slimeRain && Main.slimeRainNPC[type])
83521 {
83522 Main.player[i].nearbyActiveNPCs += npcSlots * Main.slimeRainNPCSlots;
83523 }
83524 else
83525 {
83526 Main.player[i].nearbyActiveNPCs += npcSlots;
83527 }
83528 }
83529 }
83530 if (flag)
83531 {
83532 continue;
83533 }
83534 if (((Rectangle)(ref rectangle2)).Intersects(hitbox))
83535 {
83537 despawnEncouraged = false;
83538 if (i == Main.myPlayer && (type == 604 || type == 605))
83539 {
83540 LadyBugLuck(i, type == 605);
83541 }
83542 }
83543 if (boss)
83544 {
83545 flag2 = true;
83546 }
83547 switch (type)
83548 {
83549 case 7:
83550 case 10:
83551 case 13:
83552 case 35:
83553 case 36:
83554 case 39:
83555 case 87:
83556 case 127:
83557 case 128:
83558 case 129:
83559 case 130:
83560 case 131:
83561 case 392:
83562 case 393:
83563 case 394:
83564 case 491:
83565 case 492:
83566 flag2 = true;
83567 break;
83568 case 399:
83569 if (ai[0] == 2f || ai[0] == 1f)
83570 {
83572 }
83573 flag2 = true;
83574 break;
83575 case 583:
83576 case 584:
83577 case 585:
83578 if (!Main.dayTime && ai[2] == 0f)
83579 {
83580 flag2 = true;
83582 }
83583 break;
83584 }
83585 }
83586 if (flag)
83587 {
83588 return;
83589 }
83590 timeLeft--;
83591 if (timeLeft <= 0)
83592 {
83593 flag2 = false;
83594 }
83595 if (!flag2 && Main.netMode != 1 && !NPCLoader.SavesAndLoads(this))
83596 {
83597 noSpawnCycle = true;
83598 active = false;
83599 if (Main.netMode == 2)
83600 {
83601 netSkip = -1;
83602 life = 0;
83603 NetMessage.SendData(23, -1, -1, null, whoAmI);
83604 }
83605 if (extraValue > 0)
83606 {
83607 RevengeManager.CacheEnemy(this);
83608 }
83610 }
83611 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
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
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static bool SavesAndLoads(NPC npc)
static bool CheckActive(NPC npc)
Definition NPCLoader.cs:696
This serves as the central class from which NPC-related functions are carried out....
Definition NPCLoader.cs:26
bool boss
Set to true if the NPC is a boss. Prevents off-screen despawn. Bosses also need [AutoloadBossHead] an...
Definition NPC.cs:1141
int timeLeft
Definition NPC.cs:1017
static CoinLossRevengeSystem RevengeManager
Definition NPC.cs:976
static bool noSpawnCycle
Definition NPC.cs:635
bool DoesntDespawnToInactivity()
Definition NPC.cs:83381
int lifeMax
The maximum life of this NPC.
Definition NPC.cs:1077
bool despawnEncouraged
Definition NPC.cs:1217
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
int extraValue
Definition NPC.cs:1158
static int sWidth
Definition NPC.cs:608
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
bool DoesntDespawnToInactivityAndCountsNPCSlots()
Definition NPC.cs:83376
float npcSlots
Represents how much this npc counts towards the npc spawn limit. Small critters like worms or flies h...
Definition NPC.cs:633
static int activeRangeX
Definition NPC.cs:620
void CheckActive_WormSegments()
Definition NPC.cs:83613
void LadyBugLuck(int plr, bool GoldLadyBug=false)
Definition NPC.cs:92131
void AddIntoPlayersTownNPCSlots()
Definition NPC.cs:83639
short releaseOwner
Identifies the player who released this NPC into the world. Used mainly for released critters....
Definition NPC.cs:514
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
Definition NPC.cs:1072
static int activeTime
Definition NPC.cs:637
static int activeRangeY
Definition NPC.cs:622
int netSkip
Definition NPC.cs:594
bool townNPC
Definition NPC.cs:1174
static int sHeight
Definition NPC.cs:610

References Terraria.Entity.active, Terraria.NPC.activeRangeX, Terraria.NPC.activeRangeY, Terraria.NPC.activeTime, Terraria.NPC.AddIntoPlayersTownNPCSlots(), Terraria.NPC.ai, Terraria.NPC.boss, Terraria.ModLoader.NPCLoader.CheckActive(), Terraria.NPC.CheckActive_WormSegments(), Terraria.Main.dayTime, Terraria.NPC.despawnEncouraged, Terraria.NPC.DoesntDespawnToInactivity(), Terraria.NPC.DoesntDespawnToInactivityAndCountsNPCSlots(), Terraria.NPC.extraValue, Terraria.Entity.height, Terraria.NPC.LadyBugLuck(), Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netSkip, Terraria.NPC.noSpawnCycle, Terraria.NPC.npcSlots, Terraria.Main.player, Terraria.Entity.position, Terraria.NPC.releaseOwner, Terraria.NPC.RevengeManager, Terraria.ModLoader.NPCLoader.SavesAndLoads(), Terraria.NetMessage.SendData(), Terraria.NPC.sHeight, Terraria.Main.slimeRain, Terraria.Main.slimeRainNPC, Terraria.Main.slimeRainNPCSlots, Terraria.NPC.sWidth, Terraria.NPC.timeLeft, Terraria.NPC.townNPC, Terraria.NPC.type, Terraria.Entity.whoAmI, and Terraria.Entity.width.

+ Here is the call graph for this function: