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

◆ ShouldFaceTarget()

bool Terraria.NPC.ShouldFaceTarget ( ref NPCUtils::TargetSearchResults searchResults,
NPCUtils::TargetType? overrideTargetType = null )
inline

Definition at line 83067 of file NPC.cs.

83068 {
83070 if (overrideTargetType.HasValue)
83071 {
83073 }
83074 switch (nearestTargetType)
83075 {
83076 case NPCUtils.TargetType.NPC:
83077 case NPCUtils.TargetType.TankPet:
83078 return true;
83079 case NPCUtils.TargetType.Player:
83080 {
83081 bool flag = true;
83082 Player nearestTankOwner = searchResults.NearestTankOwner;
83083 if (nearestTankOwner.dead || (nearestTankOwner.npcTypeNoAggro[type] && direction != 0))
83084 {
83085 flag = false;
83086 }
83087 if (!flag)
83088 {
83089 break;
83090 }
83091 float num = (float)(nearestTankOwner.width + nearestTankOwner.height + width + height) / 4f + 800f;
83092 if (nearestTankOwner.itemAnimation == 0 && nearestTankOwner.aggro < 0 && searchResults.NearestTankDistance > num)
83093 {
83094 if (oldTarget >= 0)
83095 {
83096 return oldTarget >= 255;
83097 }
83098 return true;
83099 }
83100 return true;
83101 }
83102 }
83103 return false;
83104 }
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
int oldTarget
Definition NPC.cs:1114
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.Entity.direction, Terraria.Entity.height, Terraria.NPC.oldTarget, Terraria.NPC.type, and Terraria.Entity.width.