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

◆ AI_007_TownEntities_GetWalkPrediction()

void Terraria.NPC.AI_007_TownEntities_GetWalkPrediction ( int myTileX,
int homeFloorX,
bool canBreathUnderWater,
bool currentlyDrowning,
int tileX,
int tileY,
out bool keepwalking,
out bool avoidFalling )
inlineprivate

Definition at line 59252 of file NPC.cs.

59253 {
59254 //IL_003d: Unknown result type (might be due to invalid IL or missing references)
59255 //IL_0043: Unknown result type (might be due to invalid IL or missing references)
59256 //IL_006d: Unknown result type (might be due to invalid IL or missing references)
59257 //IL_0072: Unknown result type (might be due to invalid IL or missing references)
59258 //IL_0142: Unknown result type (might be due to invalid IL or missing references)
59259 //IL_01e8: Unknown result type (might be due to invalid IL or missing references)
59260 //IL_01f0: Unknown result type (might be due to invalid IL or missing references)
59261 //IL_00de: Unknown result type (might be due to invalid IL or missing references)
59262 //IL_01f8: Unknown result type (might be due to invalid IL or missing references)
59263 //IL_0203: Unknown result type (might be due to invalid IL or missing references)
59264 //IL_021a: Unknown result type (might be due to invalid IL or missing references)
59265 //IL_021f: Unknown result type (might be due to invalid IL or missing references)
59266 //IL_0224: Unknown result type (might be due to invalid IL or missing references)
59267 //IL_0228: Unknown result type (might be due to invalid IL or missing references)
59268 keepwalking = false;
59269 avoidFalling = true;
59270 bool flag = myTileX >= homeFloorX - 35 && myTileX <= homeFloorX + 35;
59271 if (townNPC && ai[1] < 30f)
59272 {
59273 keepwalking = !Utils.PlotTileLine(base.Top, base.Bottom, width, DelegateMethods.SearchAvoidedByNPCs);
59274 if (!keepwalking)
59275 {
59276 Rectangle hitbox = base.Hitbox;
59277 hitbox.X -= 20;
59278 hitbox.Width += 40;
59279 for (int i = 0; i < 200; i++)
59280 {
59281 if (Main.npc[i].active && Main.npc[i].friendly && i != whoAmI && Main.npc[i].velocity.X == 0f && ((Rectangle)(ref hitbox)).Intersects(Main.npc[i].Hitbox))
59282 {
59283 keepwalking = true;
59284 break;
59285 }
59286 }
59287 }
59288 }
59290 {
59291 keepwalking = true;
59292 }
59294 {
59295 avoidFalling = false;
59296 }
59297 if (!avoidFalling)
59298 {
59299 return;
59300 }
59301 bool flag2 = false;
59302 Point p = default(Point);
59303 int num = 0;
59304 for (int j = -1; j <= 4; j++)
59305 {
59306 Tile tileSafely = Framing.GetTileSafely(tileX, tileY + j);
59307 if (tileSafely.liquid > 0)
59308 {
59309 num++;
59310 if (tileSafely.lava())
59311 {
59312 flag2 = true;
59313 break;
59314 }
59315 }
59316 if (tileSafely.nactive() && Main.tileSolid[tileSafely.type])
59317 {
59318 if (num > 0)
59319 {
59320 p.X = tileX;
59321 p.Y = tileY + j;
59322 }
59323 avoidFalling = false;
59324 break;
59325 }
59326 }
59328 double num2 = Math.Ceiling((float)height / 16f);
59329 if ((double)num >= num2)
59330 {
59331 avoidFalling = true;
59332 }
59333 if (!avoidFalling && p.X != 0 && p.Y != 0)
59334 {
59335 Vector2 vector = p.ToWorldCoordinates(8f, 0f) + new Vector2((float)(-width / 2), (float)(-height));
59336 avoidFalling = Collision.DrownCollision(vector, width, height, 1f);
59337 }
59338 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
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
static bool[] TownCritter
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is a critter that can spawn in town...
Definition NPCID.cs:409
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 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 townNPC
Definition NPC.cs:1174

References Terraria.NPC.ai, Terraria.Entity.direction, Terraria.Collision.DrownCollision(), Terraria.Framing.GetTileSafely(), Terraria.Entity.height, Terraria.Main.npc, Terraria.Utils.PlotTileLine(), Terraria.DelegateMethods.SearchAvoidedByNPCs(), Terraria.Main.tileSolid, Terraria.ID.NPCID.Sets.TownCritter, Terraria.NPC.townNPC, Terraria.NPC.type, Terraria.Entity.whoAmI, and Terraria.Entity.width.

Referenced by Terraria.NPC.AI_007_TownEntities().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: