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

◆ AI_007_FindGoodRestingSpot()

void Terraria.NPC.AI_007_FindGoodRestingSpot ( int myTileX,
int myTileY,
out int floorX,
out int floorY )
inlineprivate

Definition at line 56066 of file NPC.cs.

56067 {
56068 //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
56069 //IL_0177: Unknown result type (might be due to invalid IL or missing references)
56070 //IL_00da: Unknown result type (might be due to invalid IL or missing references)
56071 //IL_0160: Unknown result type (might be due to invalid IL or missing references)
56072 //IL_018e: Unknown result type (might be due to invalid IL or missing references)
56073 //IL_0194: Unknown result type (might be due to invalid IL or missing references)
56074 //IL_01f5: Unknown result type (might be due to invalid IL or missing references)
56075 //IL_01f6: Unknown result type (might be due to invalid IL or missing references)
56076 //IL_0204: Unknown result type (might be due to invalid IL or missing references)
56077 //IL_020a: Unknown result type (might be due to invalid IL or missing references)
56078 //IL_021b: Unknown result type (might be due to invalid IL or missing references)
56079 //IL_0221: Unknown result type (might be due to invalid IL or missing references)
56080 //IL_0238: Unknown result type (might be due to invalid IL or missing references)
56081 //IL_023d: Unknown result type (might be due to invalid IL or missing references)
56082 //IL_011c: Unknown result type (might be due to invalid IL or missing references)
56083 //IL_012a: Unknown result type (might be due to invalid IL or missing references)
56084 //IL_02d5: Unknown result type (might be due to invalid IL or missing references)
56085 //IL_02de: Unknown result type (might be due to invalid IL or missing references)
56086 //IL_029b: Unknown result type (might be due to invalid IL or missing references)
56087 //IL_02a0: Unknown result type (might be due to invalid IL or missing references)
56088 //IL_02aa: Unknown result type (might be due to invalid IL or missing references)
56089 //IL_02af: Unknown result type (might be due to invalid IL or missing references)
56090 //IL_02b4: Unknown result type (might be due to invalid IL or missing references)
56091 //IL_02b9: Unknown result type (might be due to invalid IL or missing references)
56092 floorX = homeTileX;
56093 floorY = homeTileY;
56094 if (floorX == -1 || floorY == -1)
56095 {
56096 return;
56097 }
56098 while (!WorldGen.SolidOrSlopedTile(floorX, floorY) && floorY < Main.maxTilesY - 20)
56099 {
56100 floorY++;
56101 }
56102 if (Main.dayTime || (ai[0] == 5f && Math.Abs(myTileX - floorX) < 7 && Math.Abs(myTileY - floorY) < 7))
56103 {
56104 return;
56105 }
56106 Point point = default(Point);
56107 ((Point)(ref point))._002Ector(floorX, floorY);
56108 Point point2 = default(Point);
56109 ((Point)(ref point2))._002Ector(-1, -1);
56110 int num = -1;
56111 if (type == 638 || type == 656 || NPCID.Sets.IsTownSlime[type] || ai[0] == 5f)
56112 {
56113 return;
56114 }
56115 int num2 = 7;
56116 int num3 = 6;
56117 int num4 = 1;
56118 int num5 = 1;
56119 int num6 = 1;
56120 for (int i = point.X - num2; i <= point.X + num2; i += num5)
56121 {
56122 for (int num7 = point.Y + num4; num7 >= point.Y - num3; num7 -= num6)
56123 {
56124 Tile tile = Main.tile[i, num7];
56125 if (tile != null && tile.active() && TileID.Sets.CanBeSatOnForNPCs[tile.type])
56126 {
56127 int num8 = Math.Abs(i - point.X) + Math.Abs(num7 - point.Y);
56128 if (num == -1 || num8 < num)
56129 {
56130 num = num8;
56131 point2.X = i;
56132 point2.Y = num7;
56133 }
56134 }
56135 }
56136 }
56137 if (num == -1)
56138 {
56139 return;
56140 }
56141 Tile tile2 = Main.tile[point2.X, point2.Y];
56142 if (tile2.type == 497 || tile2.type == 15)
56143 {
56144 if (tile2.frameY % 40 != 0)
56145 {
56146 point2.Y--;
56147 }
56148 point2.Y += 2;
56149 }
56150 else if (tile2.type >= TileID.Count)
56151 {
56152 TileRestingInfo info = new TileRestingInfo(this, point2, Vector2.Zero, direction);
56154 point2 = info.AnchorTilePosition;
56155 point2.Y++;
56156 }
56157 for (int j = 0; j < 200; j++)
56158 {
56159 if (Main.npc[j].active && Main.npc[j].aiStyle == 7 && Main.npc[j].townNPC && Main.npc[j].ai[0] == 5f && (Main.npc[j].Bottom + Vector2.UnitY * -2f).ToTileCoordinates() == point2)
56160 {
56161 return;
56162 }
56163 }
56164 floorX = point2.X;
56165 floorY = point2.Y;
56166 }
static bool[] IsTownSlime
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is categorized as a town slime....
Definition NPCID.cs:232
static bool[] CanBeSatOnForNPCs
Definition TileID.cs:181
static readonly ushort Count
Definition TileID.cs:1928
static void ModifySittingTargetInfo(int i, int j, int type, ref TileRestingInfo info)
This serves as the central class from which tile-related functions are supported and carried out.
Definition TileLoader.cs:23
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 homeTileX
Definition NPC.cs:1180
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
int homeTileY
Definition NPC.cs:1182
Holds data required for offsetting an entity when it rests on a tile (sitting/sleeping).

References Terraria.Tile.active(), Terraria.NPC.ai, Terraria.ID.TileID.Sets.CanBeSatOnForNPCs, Terraria.ID.TileID.Count, Terraria.Main.dayTime, Terraria.Entity.direction, Terraria.NPC.homeTileX, Terraria.NPC.homeTileY, Terraria.ID.NPCID.Sets.IsTownSlime, Terraria.Main.maxTilesY, Terraria.ModLoader.TileLoader.ModifySittingTargetInfo(), Terraria.Main.npc, Terraria.WorldGen.SolidOrSlopedTile(), Terraria.Main.tile, Terraria.NPC.type, and Terraria.Tile.type.

Referenced by Terraria.NPC.AI_007_TownEntities().

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