Exemple #1
0
        public void UpdateBiomesAlt(Player player)
        {
            Point point = player.Center.ToTileCoordinates();

            player.ZoneDungeon = false;
            if (Main.dungeonTiles >= 250 && player.Center.Y > Main.worldSurface * 16.0)
            {
                int num  = (int)player.Center.X / 16;
                int num2 = (int)player.Center.Y / 16;
                if (Main.wallDungeon[(int)Main.tile[num, num2].wall])
                {
                    player.ZoneDungeon = true;
                }
            }
            Tile tileSafely = Framing.GetTileSafely(player.Center);

            if (tileSafely != null)
            {
                player.behindBackWall = tileSafely.wall > 0;
            }
            if (Main.sandTiles > 1000 && player.Center.Y > 3200f)
            {
                if (WallID.Sets.Conversion.Sandstone[tileSafely.wall] || WallID.Sets.Conversion.HardenedSand[tileSafely.wall])
                {
                    player.ZoneUndergroundDesert = true;
                }
            }
            else
            {
                player.ZoneUndergroundDesert = false;
            }
            player.ZoneCorrupt          = Main.evilTiles >= 200;
            player.ZoneHoly             = Main.holyTiles >= 100;
            player.ZoneMeteor           = Main.meteorTiles >= 50;
            player.ZoneJungle           = Main.jungleTiles >= 80;
            player.ZoneSnow             = Main.snowTiles >= 300;
            player.ZoneCrimson          = Main.bloodTiles >= 200;
            player.ZoneWaterCandle      = Main.waterCandles > 0;
            player.ZonePeaceCandle      = Main.peaceCandles > 0;
            player.ZoneDesert           = Main.sandTiles > 1000;
            player.ZoneGlowshroom       = Main.shroomTiles > 100;
            player.ZoneUnderworldHeight = point.Y > Main.maxTilesY - 200;
            player.ZoneRockLayerHeight  = point.Y <= Main.maxTilesY - 200 && point.Y > Main.rockLayer;
            player.ZoneDirtLayerHeight  = point.Y <= Main.rockLayer && point.Y > Main.worldSurface;
            player.ZoneOverworldHeight  = point.Y <= Main.worldSurface && point.Y > Main.worldSurface * 0.34999999403953552;
            player.ZoneSkyHeight        = point.Y <= Main.worldSurface * 0.34999999403953552;
            player.ZoneBeach            = player.ZoneOverworldHeight && (point.X <380 || point.X> Main.maxTilesX - 380);
            player.ZoneRain             = Main.raining && point.Y <= Main.worldSurface;
            player.ZoneSandstorm        = point.Y <= Main.worldSurface && player.ZoneDesert && !player.ZoneBeach && Sandstorm.Happening;
            player.ZoneTowerSolar       = player.ZoneTowerVortex = (player.ZoneTowerNebula = (player.ZoneTowerStardust = false));
            player.ZoneOldOneArmy       = false;
            for (int i = 0; i < 200; i++)
            {
                if (Main.npc[i].active)
                {
                    if (Main.npc[i].type == NPCID.LunarTowerStardust)
                    {
                        if (player.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            player.ZoneTowerStardust = true;
                        }
                    }
                    else if (Main.npc[i].type == NPCID.LunarTowerNebula)
                    {
                        if (player.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            player.ZoneTowerNebula = true;
                        }
                    }
                    else if (Main.npc[i].type == NPCID.LunarTowerVortex)
                    {
                        if (player.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            player.ZoneTowerVortex = true;
                        }
                    }
                    else if (Main.npc[i].type == NPCID.LunarTowerSolar)
                    {
                        if (player.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            player.ZoneTowerSolar = true;
                        }
                    }
                    else if (Main.npc[i].type == NPCID.DD2LanePortal && player.Distance(Main.npc[i].Center) <= 4000f)
                    {
                        player.ZoneOldOneArmy = true;
                    }
                }
            }
            PlayerHooks.UpdateBiomes(player);

            //PlayerHooks.UpdateBiomeVisuals(player);

            /*
             *          if (!player.dead)
             *          {
             *                  if (player._funkytownCheckCD > 0)
             *                  {
             *                          player._funkytownCheckCD--;
             *                  }
             *          }
             *          else
             *          {
             *                  player._funkytownCheckCD = 100;
             *          }
             */
        }
        public void UpdateBiome()
        {
            Player self = Main.LocalPlayer;

            FieldInfo _strongBlizzardSoundInfo = typeof(Player).GetField("_strongBlizzardSound",
                                                                         BindingFlags.Static | BindingFlags.NonPublic);
            SlotId _strongBlizzardSound = (SlotId)_strongBlizzardSoundInfo.GetValue(null);

            FieldInfo _weakBlizzardSoundInfo = typeof(Player).GetField("_weakBlizzardSound",
                                                                       BindingFlags.Static | BindingFlags.NonPublic);
            SlotId _weakBlizzardSound = (SlotId)_weakBlizzardSoundInfo.GetValue(null);

            FieldInfo _insideBlizzardSoundInfo = typeof(Player).GetField("_insideBlizzardSound",
                                                                         BindingFlags.Static | BindingFlags.NonPublic);
            SlotId _insideBlizzardSound = (SlotId)_insideBlizzardSoundInfo.GetValue(null);

            FieldInfo _blizzardSoundVolumeInfo = typeof(Player).GetField("_blizzardSoundVolume",
                                                                         BindingFlags.Static | BindingFlags.NonPublic);
            float _blizzardSoundVolume = (float)_blizzardSoundVolumeInfo.GetValue(null);

            FieldInfo _shaderObstructionpublicValueInfo = typeof(Player).GetField("_shaderObstructionpublicValue",
                                                                                  BindingFlags.Instance | BindingFlags.NonPublic);
            float _shaderObstructionInternalValue = (float)_shaderObstructionpublicValueInfo.GetValue(self);

            FieldInfo _stormShaderObstructionInfo = typeof(Player).GetField("_stormShaderObstruction",
                                                                            BindingFlags.Instance | BindingFlags.NonPublic);
            float _stormShaderObstruction = (float)_stormShaderObstructionInfo.GetValue(self);


            Point point = self.Center.ToTileCoordinates();

            self.ZoneDungeon = false;
            if (Main.dungeonTiles >= 250 && (double)self.Center.Y > Main.worldSurface * 16.0)
            {
                int num  = (int)self.Center.X / 16;
                int num2 = (int)self.Center.Y / 16;
                if (Main.wallDungeon[(int)Main.tile[num, num2].wall])
                {
                    self.ZoneDungeon = true;
                }
            }
            //Tile tileSafely = Framing.GetTileSafely(self.Center);

            /*if (tileSafely != null)
             * {
             *  self.behindBackWall = (tileSafely.wall > 0);
             * }
             * if (Main.sandTiles > 1000 && self.Center.Y > 3200f)
             * {
             *  if (WallID.Sets.Conversion.Sandstone[(int)tileSafely.wall] || WallID.Sets.Conversion.HardenedSand[(int)tileSafely.wall])
             *  {
             *      self.ZoneUndergroundDesert = true;
             *  }
             * }
             * else
             * {
             *  self.ZoneUndergroundDesert = false;
             * }*/
            self.ZoneCorrupt     = (Main.evilTiles >= 200);
            self.ZoneHoly        = (Main.holyTiles >= 100);
            self.ZoneMeteor      = (Main.meteorTiles >= 50);
            self.ZoneJungle      = (Main.jungleTiles >= 80);
            self.ZoneSnow        = (Main.snowTiles >= 300);
            self.ZoneCrimson     = (Main.bloodTiles >= 200);
            self.ZoneWaterCandle = (Main.waterCandles > 0);
            self.ZonePeaceCandle = (Main.peaceCandles > 0);
            self.ZoneDesert      = (Main.sandTiles > 1000);
            self.ZoneGlowshroom  = (Main.shroomTiles > 100);
            //Main.NewText("Update biome Dim was succesfully injected");
            //self.ZoneUnderworldHeight = (point.Y > Main.maxTilesY - 200);
            self.ZoneRockLayerHeight = (point.Y <= Main.maxTilesY - 200 && (double)point.Y > Main.rockLayer);
            self.ZoneDirtLayerHeight = ((double)point.Y <= Main.rockLayer && (double)point.Y > Main.worldSurface);
            self.ZoneOverworldHeight = ((double)point.Y <= Main.worldSurface && (double)point.Y > Main.worldSurface * 0.34999999403953552);

            self.ZoneRain       = (Main.raining && (double)point.Y <= Main.worldSurface);
            self.ZoneSandstorm  = ((double)point.Y <= Main.worldSurface && self.ZoneDesert && !self.ZoneBeach && Sandstorm.Happening);
            self.ZoneTowerSolar = (self.ZoneTowerVortex = (self.ZoneTowerNebula = (self.ZoneTowerStardust = false)));
            self.ZoneOldOneArmy = false;
            Vector2 value  = Vector2.Zero;
            Vector2 value2 = Vector2.Zero;
            Vector2 value3 = Vector2.Zero;
            Vector2 value4 = Vector2.Zero;

            for (int i = 0; i < 200; i++)
            {
                if (Main.npc[i].active)
                {
                    if (Main.npc[i].type == 493)
                    {
                        if (self.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            self.ZoneTowerStardust = true;
                            value4 = Main.npc[i].Center;
                        }
                    }
                    else if (Main.npc[i].type == 507)
                    {
                        if (self.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            self.ZoneTowerNebula = true;
                            value3 = Main.npc[i].Center;
                        }
                    }
                    else if (Main.npc[i].type == 422)
                    {
                        if (self.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            self.ZoneTowerVortex = true;
                            value2 = Main.npc[i].Center;
                        }
                    }
                    else if (Main.npc[i].type == 517)
                    {
                        if (self.Distance(Main.npc[i].Center) <= 4000f)
                        {
                            self.ZoneTowerSolar = true;
                            value = Main.npc[i].Center;
                        }
                    }
                    else if (Main.npc[i].type == 549 && self.Distance(Main.npc[i].Center) <= 4000f)
                    {
                        self.ZoneOldOneArmy = true;
                        value = Main.npc[i].Center;
                    }
                }
            }
            bool flag  = self.ZoneRain && self.ZoneSnow;
            bool flag2 = point.Y > Main.maxTilesY - 320;
            bool flag3 = self.ZoneOverworldHeight && (point.X <380 || point.X> Main.maxTilesX - 380);

            // TODO, are these flags a problem?
            PlayerHooks.UpdateBiomes(self);
            self.ManageSpecialBiomeVisuals("Stardust", self.ZoneTowerStardust, value4 - new Vector2(0f, 10f));
            self.ManageSpecialBiomeVisuals("Nebula", self.ZoneTowerNebula, value3 - new Vector2(0f, 10f));
            self.ManageSpecialBiomeVisuals("Vortex", self.ZoneTowerVortex, value2 - new Vector2(0f, 10f));
            self.ManageSpecialBiomeVisuals("Solar", self.ZoneTowerSolar, value - new Vector2(0f, 10f));
            self.ManageSpecialBiomeVisuals("MoonLord", NPC.AnyNPCs(398), default);
            self.ManageSpecialBiomeVisuals("BloodMoon", Main.bloodMoon, default);
            self.ManageSpecialBiomeVisuals("Blizzard", Main.UseStormEffects && flag, default);
            self.ManageSpecialBiomeVisuals("HeatDistortion", Main.UseHeatDistortion && (flag2 || (point.Y < Main.worldSurface && self.ZoneDesert && !flag3 && !Main.raining && !Filters.Scene["Sandstorm"].IsActive())), default(Vector2));
            if (!Filters.Scene["WaterDistortion"].IsActive() && Main.WaveQuality > 0)
            {
                Filters.Scene.Activate("WaterDistortion", default, new object[0]);