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

◆ meteor()

static bool Terraria.WorldGen.meteor ( int i,
int j,
bool ignorePlayers = false )
inlinestatic

Definition at line 3120 of file WorldGen.cs.

3121 {
3122 //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
3123 //IL_0161: Unknown result type (might be due to invalid IL or missing references)
3124 //IL_07e0: Unknown result type (might be due to invalid IL or missing references)
3125 if (i < 50 || i > Main.maxTilesX - 50)
3126 {
3127 return false;
3128 }
3129 if (j < 50 || j > Main.maxTilesY - 50)
3130 {
3131 return false;
3132 }
3133 int num = 35;
3134 Rectangle rectangle = default(Rectangle);
3135 ((Rectangle)(ref rectangle))._002Ector((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16);
3136 Rectangle value = default(Rectangle);
3137 for (int k = 0; k < 255; k++)
3138 {
3139 if (Main.player[k].active && !ignorePlayers)
3140 {
3141 ((Rectangle)(ref value))._002Ector((int)(Main.player[k].position.X + (float)(Main.player[k].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.player[k].position.Y + (float)(Main.player[k].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
3142 if (((Rectangle)(ref rectangle)).Intersects(value))
3143 {
3144 return false;
3145 }
3146 }
3147 }
3148 Rectangle value2 = default(Rectangle);
3149 for (int l = 0; l < 200; l++)
3150 {
3151 if (Main.npc[l].active)
3152 {
3153 ((Rectangle)(ref value2))._002Ector((int)Main.npc[l].position.X, (int)Main.npc[l].position.Y, Main.npc[l].width, Main.npc[l].height);
3154 if (((Rectangle)(ref rectangle)).Intersects(value2))
3155 {
3156 return false;
3157 }
3158 }
3159 }
3160 Tile tile;
3161 for (int m = i - num; m < i + num; m++)
3162 {
3163 for (int n = j - num; n < j + num; n++)
3164 {
3165 tile = Main.tile[m, n];
3166 if (!tile.active())
3167 {
3168 continue;
3169 }
3171 tile = Main.tile[m, n];
3172 if (!basicChest[tile.type])
3173 {
3174 bool[] tileDungeon = Main.tileDungeon;
3175 tile = Main.tile[m, n];
3176 if (!tileDungeon[tile.type])
3177 {
3178 tile = Main.tile[m, n];
3179 _ = ref tile.type;
3181 tile = Main.tile[m, n];
3182 if (avoidedByMeteorLanding[tile.type])
3183 {
3184 return false;
3185 }
3186 continue;
3187 }
3188 }
3189 return false;
3190 }
3191 }
3192 stopDrops = true;
3193 num = genRand.Next(17, 23);
3194 for (int num10 = i - num; num10 < i + num; num10++)
3195 {
3196 for (int num12 = j - num; num12 < j + num; num12++)
3197 {
3198 if (num12 <= j + Main.rand.Next(-2, 3) - 5)
3199 {
3200 continue;
3201 }
3202 double num17 = Math.Abs(i - num10);
3203 double num13 = Math.Abs(j - num12);
3204 if (Math.Sqrt(num17 * num17 + num13 * num13) < (double)num * 0.9 + (double)Main.rand.Next(-4, 5))
3205 {
3206 bool[] tileSolid = Main.tileSolid;
3207 tile = Main.tile[num10, num12];
3208 if (!tileSolid[tile.type])
3209 {
3210 tile = Main.tile[num10, num12];
3211 tile.active(active: false);
3212 }
3213 tile = Main.tile[num10, num12];
3214 tile.type = 37;
3215 }
3216 }
3217 }
3218 num = genRand.Next(8, 14);
3219 for (int num14 = i - num; num14 < i + num; num14++)
3220 {
3221 for (int num15 = j - num; num15 < j + num; num15++)
3222 {
3223 if (num15 > j + Main.rand.Next(-2, 3) - 4)
3224 {
3225 double num18 = Math.Abs(i - num14);
3226 double num16 = Math.Abs(j - num15);
3227 if (Math.Sqrt(num18 * num18 + num16 * num16) < (double)num * 0.8 + (double)Main.rand.Next(-3, 4))
3228 {
3229 tile = Main.tile[num14, num15];
3230 tile.active(active: false);
3231 }
3232 }
3233 }
3234 }
3235 num = genRand.Next(25, 35);
3236 for (int num2 = i - num; num2 < i + num; num2++)
3237 {
3238 for (int num3 = j - num; num3 < j + num; SquareTileFrame(num2, num3), SquareWallFrame(num2, num3), num3++)
3239 {
3240 double num19 = Math.Abs(i - num2);
3241 double num4 = Math.Abs(j - num3);
3242 if (Math.Sqrt(num19 * num19 + num4 * num4) < (double)num * 0.7)
3243 {
3245 tile = Main.tile[num2, num3];
3246 if (getsDestroyedForMeteors[tile.type])
3247 {
3248 KillTile(num2, num3);
3249 }
3250 tile = Main.tile[num2, num3];
3251 tile.liquid = 0;
3252 }
3253 tile = Main.tile[num2, num3];
3254 if (tile.type != 37)
3255 {
3256 continue;
3257 }
3258 if (!SolidTile(num2 - 1, num3) && !SolidTile(num2 + 1, num3) && !SolidTile(num2, num3 - 1) && !SolidTile(num2, num3 + 1))
3259 {
3260 tile = Main.tile[num2, num3];
3261 tile.active(active: false);
3262 continue;
3263 }
3264 tile = Main.tile[num2, num3];
3265 if (!tile.halfBrick())
3266 {
3267 tile = Main.tile[num2 - 1, num3];
3268 if (!tile.topSlope())
3269 {
3270 continue;
3271 }
3272 }
3273 if (!SolidTile(num2, num3 + 1))
3274 {
3275 tile = Main.tile[num2, num3];
3276 tile.active(active: false);
3277 }
3278 }
3279 }
3280 num = genRand.Next(23, 32);
3281 for (int num5 = i - num; num5 < i + num; num5++)
3282 {
3283 for (int num6 = j - num; num6 < j + num; num6++)
3284 {
3285 if (num6 <= j + genRand.Next(-3, 4) - 3)
3286 {
3287 continue;
3288 }
3289 tile = Main.tile[num5, num6];
3290 if (!tile.active() || Main.rand.Next(10) != 0)
3291 {
3292 continue;
3293 }
3294 double num20 = Math.Abs(i - num5);
3295 double num7 = Math.Abs(j - num6);
3296 if (Math.Sqrt(num20 * num20 + num7 * num7) < (double)num * 0.8)
3297 {
3299 tile = Main.tile[num5, num6];
3300 if (getsDestroyedForMeteors2[tile.type])
3301 {
3302 KillTile(num5, num6);
3303 }
3304 tile = Main.tile[num5, num6];
3305 tile.type = 37;
3307 }
3308 }
3309 }
3310 num = genRand.Next(30, 38);
3311 for (int num8 = i - num; num8 < i + num; num8++)
3312 {
3313 for (int num9 = j - num; num9 < j + num; num9++)
3314 {
3315 if (num9 <= j + genRand.Next(-2, 3))
3316 {
3317 continue;
3318 }
3319 tile = Main.tile[num8, num9];
3320 if (!tile.active() || Main.rand.Next(20) != 0)
3321 {
3322 continue;
3323 }
3324 double num21 = Math.Abs(i - num8);
3325 double num11 = Math.Abs(j - num9);
3326 if (Math.Sqrt(num21 * num21 + num11 * num11) < (double)num * 0.85)
3327 {
3329 tile = Main.tile[num8, num9];
3330 if (getsDestroyedForMeteors3[tile.type])
3331 {
3332 KillTile(num8, num9);
3333 }
3334 tile = Main.tile[num8, num9];
3335 tile.type = 37;
3337 }
3338 }
3339 }
3340 stopDrops = false;
3341 if (Main.netMode == 0)
3342 {
3343 Main.NewText(Lang.gen[59].Value, 50, byte.MaxValue, 130);
3344 }
3345 else if (Main.netMode == 2)
3346 {
3347 ChatHelper.BroadcastChatMessage(NetworkText.FromKey(Lang.gen[59].Key), new Color(50, 255, 130));
3348 }
3349 if (Main.netMode != 1)
3350 {
3351 NetMessage.SendTileSquare(-1, i, j, 40);
3352 }
3353 return true;
3354 }
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:51
static bool[] GetsDestroyedForMeteors
Definition TileID.cs:123
static bool[] AvoidedByMeteorLanding
Whether or not this tile prevents a meteor from landing near it.
Definition TileID.cs:457
static bool[] BasicChest
Definition TileID.cs:290
static NetworkText FromKey(string key, params object[] substitutions)
Creates a NetworkText object from a localization key and optional substitutions. The receiving client...
Represents text that will be sent over the network in multiplayer and displayed to the receiving user...
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static UnifiedRandom genRand
Definition WorldGen.cs:1455
static void SquareWallFrame(int i, int j, bool resetFrame=true)
static void SquareTileFrame(int i, int j, bool resetFrame=true)
static bool stopDrops
Definition WorldGen.cs:1242

References Terraria.Tile.active(), Terraria.ID.TileID.Sets.AvoidedByMeteorLanding, Terraria.ID.TileID.Sets.BasicChest, Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.Localization.NetworkText.FromKey(), Terraria.Lang.gen, Terraria.WorldGen.genRand, Terraria.ID.TileID.Sets.GetsDestroyedForMeteors, Terraria.Tile.halfBrick(), Terraria.WorldGen.KillTile(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.netMode, Terraria.Main.NewText(), Terraria.Main.npc, Terraria.Main.player, Terraria.Main.rand, Terraria.NPC.safeRangeX, Terraria.NPC.safeRangeY, Terraria.NetMessage.SendTileSquare(), Terraria.NPC.sHeight, Terraria.Enums.SolidTile, Terraria.WorldGen.SquareTileFrame(), Terraria.WorldGen.SquareWallFrame(), Terraria.WorldGen.stopDrops, Terraria.NPC.sWidth, Terraria.Main.tile, Terraria.Main.tileDungeon, Terraria.Main.tileSolid, Terraria.Tile.topSlope(), and Terraria.Tile.type.

Referenced by Terraria.WorldGen.dropMeteor().

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