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

◆ GetFairyTreasureCoords()

bool Terraria.NPC.GetFairyTreasureCoords ( out Point treasureCoords)
inlineprivate

Definition at line 51183 of file NPC.cs.

51184 {
51185 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
51186 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
51187 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
51188 //IL_0012: Unknown result type (might be due to invalid IL or missing references)
51189 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
51190 //IL_001b: Unknown result type (might be due to invalid IL or missing references)
51191 //IL_0054: Unknown result type (might be due to invalid IL or missing references)
51192 //IL_0055: Unknown result type (might be due to invalid IL or missing references)
51193 //IL_0056: Unknown result type (might be due to invalid IL or missing references)
51194 //IL_005b: Unknown result type (might be due to invalid IL or missing references)
51195 //IL_018b: Unknown result type (might be due to invalid IL or missing references)
51196 treasureCoords = default(Point);
51197 Point point = base.Center.ToTileCoordinates();
51198 Rectangle value = default(Rectangle);
51199 ((Rectangle)(ref value))._002Ector(point.X, point.Y, 1, 1);
51200 ((Rectangle)(ref value)).Inflate(75, 50);
51201 int num = 40;
51202 Rectangle value2 = default(Rectangle);
51203 ((Rectangle)(ref value2))._002Ector(0, 0, Main.maxTilesX, Main.maxTilesY);
51204 ((Rectangle)(ref value2)).Inflate(-num, -num);
51205 value = Rectangle.Intersect(value, value2);
51206 int num2 = -1;
51207 float num3 = -1f;
51208 for (int i = ((Rectangle)(ref value)).Left; i <= ((Rectangle)(ref value)).Right; i++)
51209 {
51210 for (int j = ((Rectangle)(ref value)).Top; j <= ((Rectangle)(ref value)).Bottom; j++)
51211 {
51212 Tile tile = Main.tile[i, j];
51213 if (tile == null || !tile.active() || !TileID.Sets.FriendlyFairyCanLureTo[tile.type] || !SceneMetrics.IsValidForOreFinder(tile))
51214 {
51215 continue;
51216 }
51217 short num4 = Main.tileOreFinderPriority[tile.type];
51218 if (TileID.Sets.Ore[tile.type])
51219 {
51220 int num5 = 3;
51221 int num6 = 3;
51222 int num7 = 40;
51223 int num8 = 0;
51224 for (int k = i - num5; k <= i + num5; k++)
51225 {
51226 for (int l = j - num6; l <= j + num6; l++)
51227 {
51228 if (Main.tile[k, l].active() && Main.tile[k, l].type == tile.type)
51229 {
51230 num8++;
51231 }
51232 }
51233 }
51234 if (num8 < num7)
51235 {
51236 num4 = -1;
51237 }
51238 }
51239 if (num2 <= num4)
51240 {
51241 float num9 = Distance(new Vector2((float)(i * 16 + 8), (float)(j * 16 + 8)));
51242 if (num2 != num4 || !(num9 >= num3))
51243 {
51244 num2 = num4;
51245 num3 = num9;
51246 treasureCoords.X = i;
51247 treasureCoords.Y = j;
51248 }
51249 }
51250 }
51251 }
51252 return num2 != -1;
51253 }
Vector2 Bottom
Definition Entity.cs:170
float Distance(Vector2 Other)
Definition Entity.cs:275
Vector2 Right
Definition Entity.cs:104
static bool[] FriendlyFairyCanLureTo
Definition TileID.cs:389
static bool[] Ore
Indicates that the tile is an ore. Used in worldgen code for various purposes and by Fairies.
Definition TileID.cs:381
float value
How many copper coins the NPC will drop when killed (100 copper coins = 1 silver coin etc....
Definition NPC.cs:1156

References Terraria.Tile.active(), Terraria.Entity.Bottom, Terraria.Entity.Distance(), Terraria.ID.TileID.Sets.FriendlyFairyCanLureTo, Terraria.SceneMetrics.IsValidForOreFinder(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.ID.TileID.Sets.Ore, Terraria.Entity.Right, Terraria.Main.tile, Terraria.Main.tileOreFinderPriority, Terraria.Tile.type, and Terraria.NPC.value.

Referenced by Terraria.NPC.AI_112_FairyCritter().

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