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

◆ AI_007_TryForcingSitting()

void Terraria.NPC.AI_007_TryForcingSitting ( int homeFloorX,
int homeFloorY )
inlineprivate

Definition at line 46159 of file NPC.cs.

46160 {
46161 Tile tile = Main.tile[homeFloorX, homeFloorY - 1];
46162 bool flag = type != 638 && type != 656 && !NPCID.Sets.IsTownSlime[type] && ai[0] != 5f;
46163 if (flag)
46164 {
46165 flag &= tile != null && tile.active() && (tile.type == 15 || tile.type == 497);
46166 }
46167 if (flag)
46168 {
46169 flag &= tile.type != 15 || tile.frameY < 1080 || tile.frameY > 1098;
46170 }
46171 if (flag)
46172 {
46173 Point point = (base.Bottom + Vector2.UnitY * -2f).ToTileCoordinates();
46174 for (int i = 0; i < 200; i++)
46175 {
46176 if (Main.npc[i].active && Main.npc[i].aiStyle == 7 && Main.npc[i].townNPC && Main.npc[i].ai[0] == 5f && (Main.npc[i].Bottom + Vector2.UnitY * -2f).ToTileCoordinates() == point)
46177 {
46178 flag = false;
46179 break;
46180 }
46181 }
46182 }
46183 if (flag)
46184 {
46185 ai[0] = 5f;
46186 ai[1] = 900 + Main.rand.Next(10800);
46187 direction = ((tile.frameX != 0) ? 1 : (-1));
46188 base.Bottom = new Vector2(homeFloorX * 16 + 8 + 2 * direction, homeFloorY * 16);
46190 localAI[3] = 0f;
46191 netUpdate = true;
46192 }
46193 }
Vector2 velocity
Definition Entity.cs:16
static bool[] IsTownSlime
Definition NPCID.cs:4101
float[] localAI
Definition NPC.cs:449
float[] ai
Definition NPC.cs:447
int type
Definition NPC.cs:445
bool netUpdate
Definition NPC.cs:507

References Terraria.Tile.active(), Terraria.NPC.ai, Terraria.Entity.direction, Terraria.ID.NPCID.Sets.IsTownSlime, Terraria.NPC.localAI, Terraria.NPC.netUpdate, Terraria.Main.npc, Terraria.Main.rand, Terraria.Main.tile, Terraria.NPC.type, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI_007_TownEntities(), and Terraria.NPC.AI_007_TownEntities_TeleportToHome().