Decompiled source of Chameleon v2.3.3

Chameleon.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Chameleon.Info;
using Chameleon.Overrides;
using Chameleon.Overrides.Exterior;
using Chameleon.Overrides.Interior;
using Chameleon.Overrides.Rendering;
using DunGen;
using DunGen.Graph;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: AssemblyCompany("Chameleon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Changes visual elements of moons (interior/exterior) for more variety and cohesion")]
[assembly: AssemblyFileVersion("2.3.3.0")]
[assembly: AssemblyInformationalVersion("2.3.3+0e4f90e0374193c3160b724f37b14a5493d679b8")]
[assembly: AssemblyProduct("Chameleon")]
[assembly: AssemblyTitle("Chameleon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.3.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Chameleon
{
	internal class Common
	{
		internal static bool INSTALLED_ARTIFICE_BLIZZARD;

		internal static bool CAN_REPLACE_CAVE_TAGS;

		internal static string interior;

		internal static LevelCosmeticInfo currentLevelCosmeticInfo;

		internal static GameObject artificeBlizzard;

		private static BreakerBox breakerBox;

		internal static bool breakerBoxHasReset;

		internal static GameObject dungeonRoot;

		internal static Material black;

		internal static BreakerBox BreakerBox
		{
			get
			{
				if ((Object)(object)breakerBox == (Object)null)
				{
					breakerBox = Object.FindAnyObjectByType<BreakerBox>();
				}
				return breakerBox;
			}
		}

		internal static void GetReferences()
		{
			DungeonGenerator val = RoundManager.Instance?.dungeonGenerator?.Generator;
			object obj;
			if (!(((Object)StartOfRound.Instance.currentLevel).name != "CompanyBuildingLevel"))
			{
				obj = string.Empty;
			}
			else if (val == null)
			{
				obj = null;
			}
			else
			{
				DungeonFlow dungeonFlow = val.DungeonFlow;
				obj = ((dungeonFlow != null) ? ((Object)dungeonFlow).name : null);
			}
			interior = (string)obj;
			if (!VanillaLevelsInfo.predefinedLevels.TryGetValue(((Object)StartOfRound.Instance.currentLevel).name, out currentLevelCosmeticInfo))
			{
				currentLevelCosmeticInfo = null;
			}
			if (((Object)StartOfRound.Instance.currentLevel).name == "ArtificeLevel" && INSTALLED_ARTIFICE_BLIZZARD)
			{
				artificeBlizzard = GameObject.Find("/Systems/Audio/BlizzardAmbience");
				if ((Object)(object)artificeBlizzard != (Object)null)
				{
					Plugin.Logger.LogInfo((object)"Artifice Blizzard compatibility success");
				}
			}
			dungeonRoot = val?.Root ?? GameObject.Find("/Systems/LevelGeneration/LevelGenerationRoot");
		}

		internal static void BuildWeightLists()
		{
			Plugin.Logger.LogInfo((object)"List of all indexed moons (Use this to set up your config!):");
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (((Object)val).name != "CompanyBuildingLevel")
				{
					Plugin.Logger.LogInfo((object)("\"" + ((Object)val).name + "\""));
				}
			}
			RoundManager val2 = RoundManager.Instance ?? Object.FindAnyObjectByType<RoundManager>();
			if ((Object)(object)val2 != (Object)null)
			{
				Plugin.Logger.LogInfo((object)"List of all indexed interiors:");
				IndoorMapType[] dungeonFlowTypes = val2.dungeonFlowTypes;
				foreach (IndoorMapType val3 in dungeonFlowTypes)
				{
					if ((Object)(object)val3.dungeonFlow != (Object)null)
					{
						Plugin.Logger.LogInfo((object)("\"" + ((Object)val3.dungeonFlow).name + "\""));
					}
				}
			}
			Plugin.Logger.LogDebug((object)"Now assembling final weighted lists");
			AssembleWeightedList<CavernType>(ref RetextureCaverns.cavernWeightLists, ref Configuration.cavernMappings);
			AssembleWeightedList<WindowType>(ref ManorWindows.windowWeightLists, ref Configuration.windowMappings);
		}

		private static void AssembleWeightedList<T>(ref Dictionary<string, IntWithRarity[]> weightLists, ref List<Configuration.MoonTypeMapping> mappings)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			weightLists.Clear();
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel level in levels)
			{
				if (((Object)level).name == "CompanyBuildingLevel")
				{
					continue;
				}
				try
				{
					List<IntWithRarity> list = new List<IntWithRarity>();
					foreach (Configuration.MoonTypeMapping item in mappings.Where((Configuration.MoonTypeMapping x) => ((Object)level).name.ToLower().StartsWith(x.moon) || x.moon == "ALL"))
					{
						list.Add(new IntWithRarity(item.type, item.weight, (LevelAmbienceLibrary)null));
						Plugin.Logger.LogDebug((object)$"{((Object)level).name} - {(T)(object)item.type} @ {item.weight}");
					}
					if (list.Count > 0)
					{
						weightLists.Add(((Object)level).name, list.ToArray());
					}
				}
				catch
				{
					Plugin.Logger.LogError((object)"Failed to finish assembling weighted lists. If you are encountering this error, it's likely there is a problem with your config - look for warnings further up in your log!");
				}
			}
		}

		internal static void GetSharedAssets()
		{
			if ((Object)(object)black != (Object)null)
			{
				return;
			}
			try
			{
				AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "chameleon"));
				black = obj.LoadAsset<Material>("black");
				obj.Unload(false);
			}
			catch
			{
				Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"chameleon\". Did you install the plugin correctly?");
			}
		}
	}
	internal class Configuration
	{
		internal enum GordionStorms
		{
			Never = -1,
			Chance,
			Always
		}

		internal enum FogQuality
		{
			Default,
			Medium,
			High
		}

		internal struct MoonTypeMapping
		{
			internal string moon;

			internal int type;

			internal int weight;
		}

		private static ConfigFile configFile;

		internal static ConfigEntry<bool> doorLightColors;

		internal static ConfigEntry<bool> rainyMarch;

		internal static ConfigEntry<bool> autoAdaptSnow;

		internal static ConfigEntry<bool> powerOffBreakerBox;

		internal static ConfigEntry<bool> powerOffWindows;

		internal static ConfigEntry<bool> planetPreview;

		internal static ConfigEntry<bool> giantSkins;

		internal static ConfigEntry<bool> fixDoorMeshes;

		internal static ConfigEntry<bool> fancyFoliage;

		internal static ConfigEntry<bool> fogReprojection;

		internal static ConfigEntry<bool> fixTitanVolume;

		internal static ConfigEntry<bool> fixArtificeVolume;

		internal static ConfigEntry<bool> blackoutWindows;

		internal static ConfigEntry<bool> dontChangeCaveSteps;

		internal static ConfigEntry<bool> snowyCadavers;

		internal static ConfigEntry<GordionStorms> stormyGordion;

		internal static ConfigEntry<FogQuality> fogQuality;

		internal static ConfigEntry<float> weatherAmbience;

		internal static ConfigEntry<string> fancyEntrances;

		internal static List<MoonTypeMapping> cavernMappings = new List<MoonTypeMapping>();

		internal static List<MoonTypeMapping> windowMappings = new List<MoonTypeMapping>();

		internal static void Init(ConfigFile cfg)
		{
			configFile = cfg;
			RenderingConfig();
			ExteriorConfig();
			InteriorConfig();
			MigrateLegacyConfigs();
		}

		private static void RenderingConfig()
		{
			planetPreview = configFile.Bind<bool>("Rendering", "PlanetPreview", true, "The currently orbited planet is visible on the ship's external security camera while in space, as it used to be in v38.\nYou should disable this if you encounter lighting issues on the ship.");
			fancyFoliage = configFile.Bind<bool>("Rendering", "FancyFoliage", true, "Light passes and spreads through the foliage for nicer visuals. Performance impact is negligible.");
			fogQuality = configFile.Bind<FogQuality>("Rendering", "FogQuality", FogQuality.Default, "Controls the overall quality of the fog. Be aware that using anything other than \"Default\" will incur a performance penalty.");
			fogReprojection = configFile.Bind<bool>("Rendering", "FogReprojection", false, "Reduces the noise/\"graininess\" visible in fog, and improves the definition of light shapes. This will improve visuals without hitting performance as much as the FogQuality setting, but note that this will cause some strange artifacts, like flashlights leaving \"trails\" behind the beam.");
			fixTitanVolume = configFile.Bind<bool>("Rendering", "FixTitanVolume", true, "Fixes Titan's global volume erroneously using the default profile instead of the snowy moon profile. This mainly fixes the sky being too brightly visible.");
			fixArtificeVolume = configFile.Bind<bool>("Rendering", "FixArtificeVolume", true, "\"Fixes\" Artifice's global volume, which has the exact opposite issue of Titan. This is more of a subjective change, but makes Artifice look more vibrant.");
		}

		private static void ExteriorConfig()
		{
			fancyEntrances = configFile.Bind<string>("Exterior", "FancyEntrances", "Level2Flow,sdmFoyer,sdmBasement,SpookyManorFlow,AquaticDungeonFlow,MuseumInteriorFlow,CabinDungeonFlow,v62Mansion-Level2Flow", "Changes the front doors to match the manor entrance's doors when one of these interiors generates. Works for ONLY vanilla moons! Leave empty to disable.\nUpon hosting a lobby, the full list of interior names will be printed in the debug log, which you can use as a guide.");
			rainyMarch = configFile.Bind<bool>("Exterior", "RainyMarch", true, "March is constantly rainy, as described in its terminal page. This is purely visual and does not affect quicksand generation.");
			stormyGordion = configFile.Bind<GordionStorms>("Exterior", "StormyGordion", GordionStorms.Chance, "Allows for storms on Gordion, as described in its terminal page. This is purely visual and lightning does not strike at The Company.");
			giantSkins = configFile.Bind<bool>("Exterior", "GiantSkins", true, "When the surface is snowy, Forest Keepers will blend in a little better with the environment. They will also appear more charred after being burnt to death.\nIf you are experiencing issues with giants and have other skin mods installed, you should probably disable this setting.");
		}

		private static void InteriorConfig()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			doorLightColors = configFile.Bind<bool>("Interior", "DoorLightColors", true, "Dynamically adjust the color of the light behind the entrance doors depending on where you land, the current weather, and the current time of day.");
			powerOffBreakerBox = configFile.Bind<bool>("Interior", "PowerOffBreakerBox", true, "When the apparatus is unplugged, the light on the breaker box will turn off to indicate it is inactive.");
			fixDoorMeshes = configFile.Bind<bool>("Interior", "FixDoorMeshes", true, "Fixes the glass on the steel doors in factories (and some custom interiors) to show on both sides. Also fixes doorknobs looking incorrect on one side.");
			weatherAmbience = configFile.Bind<float>("Interior", "WeatherAmbience", 0.4f, new ConfigDescription("On moons where a blizzard or rainstorm is present, you will be able to hear it faintly while inside the building. Set volume from 0 (silent) to 1 (max).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			InteriorManorConfig();
			InteriorMineshaftConfig();
		}

		private static void InteriorManorConfig()
		{
			powerOffWindows = configFile.Bind<bool>("Interior.Manor", "PowerOffWindows", true, "When the breaker box is turned off, the \"fake window\" rooms will also turn off.");
			blackoutWindows = configFile.Bind<bool>("Interior.Manor", "BlackoutWindows", false, "When windows turn off, they will be solid black, instead of darkening the image they normally display.");
			PopulateWindowsList(WindowType.Pasture, "Vow:100,March:100,Adamance:100,Artifice:100");
			PopulateWindowsList(WindowType.Canyon, "Experimentation:100,Assurance:100,Offense:100,Titan:100");
			PopulateWindowsList(WindowType.Snowy, "Rend:100,Dine:100");
			PopulateWindowsList(WindowType.Flowery, "Embrion:100");
			PopulateWindowsList(WindowType.Beach, string.Empty);
			PopulateWindowsList(WindowType.HotSprings, string.Empty);
			PopulateWindowsList(WindowType.BrokenScreen, string.Empty);
		}

		private static void PopulateWindowsList(WindowType type, string defaultList)
		{
			string text = $"{type}WindowsList";
			string value = configFile.Bind<string>("Interior.Manor", text, defaultList, "A list of moons for which to assign \"" + Regex.Replace(type.ToString(), "([A-Z])", " $1").TrimStart() + "\" windows, with their respective weights." + ((type != WindowType.Pasture) ? " Leave empty to disable." : string.Empty) + "\nMoon names are not case-sensitive, and can be left incomplete (ex. \"as\" will map to both Assurance and Asteroid-13.) \"ALL\" will add that weight to every moon's pool." + ((type == WindowType.Pasture) ? "\nUpon hosting a lobby, the full list of moon names will be printed in the debug log, which you can use as a guide." : string.Empty)).Value;
			if (string.IsNullOrEmpty(value))
			{
				Plugin.Logger.LogDebug((object)("User has no " + text + " defined"));
			}
			else
			{
				PopulateGlobalListWithType((int)type, value, ref windowMappings, text, type.ToString());
			}
		}

		private static void PopulateGlobalListWithType(int type, string customList, ref List<MoonTypeMapping> mappings, string listName, string displayName)
		{
			if (string.IsNullOrEmpty(customList))
			{
				Plugin.Logger.LogDebug((object)("User has no " + listName + " defined"));
				return;
			}
			try
			{
				string[] array = customList.Split(',');
				foreach (string text in array)
				{
					string[] array2 = text.Split(':');
					int result = -1;
					if (array2.Length == 2 && int.TryParse(array2[1], out result))
					{
						if (result != 0)
						{
							string text2 = array2[0].ToLower();
							MoonTypeMapping moonTypeMapping = default(MoonTypeMapping);
							moonTypeMapping.moon = ((text2 == "all") ? "ALL" : text2);
							moonTypeMapping.type = type;
							moonTypeMapping.weight = (int)Mathf.Clamp((float)result, 1f, 99999f);
							MoonTypeMapping item = moonTypeMapping;
							mappings.Add(item);
							Plugin.Logger.LogDebug((object)$"Successfully added \"{item.moon}\" to \"{displayName}\" list with weight {item.weight}");
						}
						else
						{
							Plugin.Logger.LogDebug((object)("Skipping \"" + text + "\" in \"" + listName + "\" because weight is 0"));
						}
					}
					else
					{
						Plugin.Logger.LogWarning((object)("Encountered an error parsing entry \"" + text + "\" in the \"" + listName + "\" setting. It has been skipped"));
					}
				}
			}
			catch
			{
				Plugin.Logger.LogError((object)("Encountered an error parsing the \"" + listName + "\" setting. Please double check that your config follows proper syntax, then restart your game."));
			}
		}

		private static void InteriorMineshaftConfig()
		{
			PopulateCavernsList(CavernType.Vanilla, "Vow:100,March:100,Adamance:100,Artifice:100");
			PopulateCavernsList(CavernType.Mesa, "Experimentation:100,Titan:100");
			PopulateCavernsList(CavernType.Desert, "Assurance:100,Offense:100");
			PopulateCavernsList(CavernType.Ice, "Rend:100,Dine:100");
			PopulateCavernsList(CavernType.Amethyst, "Embrion:100");
			PopulateCavernsList(CavernType.Gravel, string.Empty);
			PopulateCavernsList(CavernType.Salt, string.Empty);
			PopulateCavernsList(CavernType.Slate, string.Empty);
			autoAdaptSnow = configFile.Bind<bool>("Interior.Mineshaft", "AutoAdaptSnow", false, "Automatically enable ice (or salt, without Buttery Fixes) caverns on modded levels that are snowy.\nIf you have Artifice Blizzard installed, this will also change the caverns specifically only when the blizzard is active.");
			dontChangeCaveSteps = configFile.Bind<bool>("Interior.Mineshaft", "DontChangeCaveSteps", false, "All variants of the cave use vanilla's footstep sounds and effects. This is basically identical to the behavior of the mod if you don't have Buttery Fixes installed.");
			snowyCadavers = configFile.Bind<bool>("Interior.Mineshaft", "SnowyCadavers", true, "Cadavers will appear with a unique frostbitten appearance in ice caverns.");
		}

		private static void PopulateCavernsList(CavernType type, string defaultList)
		{
			string text = $"{type}CavesList";
			string value = configFile.Bind<string>("Interior.Mineshaft", text, defaultList, string.Format("A list of moons for which to assign \"{0}\" caves, with their respective weights.{1}\n", type, (type != CavernType.Vanilla) ? " Leave empty to disable." : string.Empty) + "Moon names are not case-sensitive, and can be left incomplete (ex. \"as\" will map to both Assurance and Asteroid-13.) \"ALL\" will add that weight to every moon's pool." + ((type == CavernType.Vanilla) ? "\nUpon hosting a lobby, the full list of moon names will be printed in the debug log, which you can use as a guide." : string.Empty)).Value;
			if (string.IsNullOrEmpty(value))
			{
				Plugin.Logger.LogDebug((object)("User has no " + text + " defined"));
			}
			else
			{
				PopulateGlobalListWithType((int)type, value, ref cavernMappings, text, type.ToString());
			}
		}

		private static void MigrateLegacyConfigs()
		{
			string[] array = new string[6] { "IceCaves", "AmethystCave", "DesertCave", "MesaCave", "IcyTitan", "AdaptiveArtifice" };
			foreach (string text in array)
			{
				configFile.Bind<bool>("Interior", text, false, "Legacy setting, doesn't work");
				configFile.Remove(configFile["Interior", text].Definition);
			}
			if (fixDoorMeshes.Value)
			{
				if (!configFile.Bind<bool>("Interior", "FixDoors", true, "Legacy setting, doesn't work").Value)
				{
					fixDoorMeshes.Value = false;
				}
				configFile.Remove(configFile["Interior", "FixDoors"].Definition);
			}
			if (planetPreview.Value)
			{
				if (!configFile.Bind<bool>("Exterior", "PlanetPreview", true, "Legacy setting, doesn't work").Value)
				{
					planetPreview.Value = false;
				}
				configFile.Remove(configFile["Exterior", "PlanetPreview"].Definition);
			}
			if (fancyFoliage.Value)
			{
				if (!configFile.Bind<bool>("Exterior", "FancyFoliage", true, "Legacy setting, doesn't work").Value)
				{
					fancyFoliage.Value = false;
				}
				configFile.Remove(configFile["Exterior", "FancyFoliage"].Definition);
			}
			configFile.Bind<bool>("Exterior", "FancyShrouds", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Exterior", "FancyShrouds"].Definition);
			configFile.Bind<bool>("Rendering", "FancyShrouds", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Rendering", "FancyShrouds"].Definition);
			if (giantSkins.Value)
			{
				if (!configFile.Bind<bool>("Exterior", "SnowyGiants", true, "Legacy setting, doesn't work").Value)
				{
					giantSkins.Value = false;
				}
				configFile.Remove(configFile["Exterior", "SnowyGiants"].Definition);
			}
			configFile.Bind<bool>("Interior", "FixDoorSounds", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Interior", "FixDoorSounds"].Definition);
			configFile.Bind<bool>("Interior.Manor", "WindowVariants", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Interior.Manor", "WindowVariants"].Definition);
			configFile.Bind<bool>("Exterior", "FancyEntranceDoors", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Exterior", "FancyEntranceDoors"].Definition);
			configFile.Bind<bool>("Exterior", "EclipsesBlockMusic", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Exterior", "EclipsesBlockMusic"].Definition);
			configFile.Bind<bool>("Exterior", "ReworkFoggyWeather", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Exterior", "ReworkFoggyWeather"].Definition);
			configFile.Bind<bool>("Exterior", "RecolorRandomRocks", true, "Legacy setting, doesn't work");
			configFile.Remove(configFile["Exterior", "RecolorRandomRocks"].Definition);
			configFile.Save();
		}
	}
	internal static class LobbyCompatibility
	{
		internal static void Init()
		{
			PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.chameleon", Version.Parse("2.3.3"), (CompatibilityLevel)0, (VersionStrictness)0);
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.chameleon", "Chameleon", "2.3.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.chameleon";

		internal const string PLUGIN_NAME = "Chameleon";

		internal const string PLUGIN_VERSION = "2.3.3";

		internal static ManualLogSource Logger;

		private const string GUID_ARTIFICE_BLIZZARD = "butterystancakes.lethalcompany.artificeblizzard";

		private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";

		private const string GUID_BUTTERY_FIXES = "butterystancakes.lethalcompany.butteryfixes";

		private const string GUID_NO_LOST_SIGNAL = "Tomatobird.NoLostSignal";

		private void Awake()
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected");
				LobbyCompatibility.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.artificeblizzard"))
			{
				Common.INSTALLED_ARTIFICE_BLIZZARD = true;
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Artifice Blizzard detected");
			}
			if (Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.butteryfixes"))
			{
				Common.CAN_REPLACE_CAVE_TAGS = true;
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Buttery Fixes detected");
			}
			else if (Chainloader.PluginInfos.ContainsKey("Tomatobird.NoLostSignal"))
			{
				Common.CAN_REPLACE_CAVE_TAGS = true;
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - NoLostSignal detected");
			}
			Configuration.Init(((BaseUnityPlugin)this).Config);
			new Harmony("butterystancakes.lethalcompany.chameleon").PatchAll();
			SceneManager.sceneLoaded += SceneOverrides.LoadNewScene;
			SceneManager.sceneUnloaded += SceneOverrides.UnloadScene;
			SceneOverrides.Init();
			Logger.LogInfo((object)"Chameleon v2.3.3 loaded");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Chameleon";

		public const string PLUGIN_NAME = "Chameleon";

		public const string PLUGIN_VERSION = "2.3.3";
	}
}
namespace Chameleon.Patches
{
	[HarmonyPatch]
	internal static class EnemyPatches
	{
		private static Texture giantNormal;

		private static Texture giantSnowy;

		private static Texture giantBurnt;

		private static Texture cadaverSnowy;

		private static Material cadaverBloomPlantsSnowy;

		[HarmonyPatch(typeof(ForestGiantAI), "Start")]
		[HarmonyPostfix]
		private static void ForestGiantAI_Post_Start(ForestGiantAI __instance)
		{
			if (!Configuration.giantSkins.Value)
			{
				return;
			}
			if ((Object)(object)giantSnowy == (Object)null || (Object)(object)giantBurnt == (Object)null)
			{
				try
				{
					AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "enemyskins"));
					giantSnowy = obj.LoadAsset<Texture>("ForestGiantTexWithEyesSnowy");
					giantBurnt = obj.LoadAsset<Texture>("ForestGiantTexWithEyesBurnt");
					obj.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"enemyskins\". Did you install the plugin correctly?");
					return;
				}
			}
			if (!Queries.IsSnowLevel() || !((Object)(object)giantSnowy != (Object)null))
			{
				return;
			}
			SkinnedMeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if ((Object)(object)giantNormal == (Object)null)
				{
					giantNormal = ((Renderer)val).sharedMaterial.mainTexture;
				}
				((Renderer)val).material.mainTexture = giantSnowy;
			}
			Plugin.Logger.LogDebug((object)"Forest Keeper: Snow \"camouflage\"");
		}

		[HarmonyPatch(typeof(EnemyAI), "SwitchToBehaviourStateOnLocalClient")]
		[HarmonyPostfix]
		private static void EnemyAI_Post_SwitchToBehaviourStateOnLocalClient(EnemyAI __instance, int stateIndex)
		{
			if (stateIndex == 2 && __instance is ForestGiantAI && Configuration.giantSkins.Value && Queries.IsSnowLevel() && (Object)(object)giantNormal != (Object)null)
			{
				SkinnedMeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<SkinnedMeshRenderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Renderer)componentsInChildren[i]).material.mainTexture = giantNormal;
				}
				Plugin.Logger.LogDebug((object)"Forest Keeper: Snow burnt off");
			}
		}

		[HarmonyPatch(typeof(ForestGiantAI), "KillEnemy")]
		[HarmonyPostfix]
		private static void ForestGiantAI_Post_KillEnemy(ForestGiantAI __instance)
		{
			if (Configuration.giantSkins.Value && (Object)(object)giantBurnt != (Object)null && __instance.timeAtStartOfBurning > 0f)
			{
				SkinnedMeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<SkinnedMeshRenderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Renderer)componentsInChildren[i]).material.mainTexture = giantBurnt;
				}
				Plugin.Logger.LogDebug((object)"Forest Keeper: Reduced to charcoal");
			}
		}

		[HarmonyPatch(typeof(CadaverGrowthAI), "Start")]
		[HarmonyPostfix]
		private static void CadaverGrowthAI_Post_Start(CadaverGrowthAI __instance)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.snowyCadavers.Value || RetextureCaverns.Type != 0 || __instance.plantBatchers == null || __instance.plantBatchers.Length == 0)
			{
				return;
			}
			if ((Object)(object)cadaverBloomPlantsSnowy == (Object)null)
			{
				if ((Object)(object)cadaverSnowy == (Object)null)
				{
					try
					{
						AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "enemyskins"));
						cadaverSnowy = obj.LoadAsset<Texture>("CadaverBloomGrowthMegatextureV2_2_Chameleon2");
						obj.Unload(false);
					}
					catch
					{
						Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"enemyskins\". Did you install the plugin correctly?");
						return;
					}
				}
				cadaverBloomPlantsSnowy = Object.Instantiate<Material>(__instance.plantBatchers[0].material);
				cadaverBloomPlantsSnowy.mainTexture = cadaverSnowy;
				cadaverBloomPlantsSnowy.SetColor("_BaseColorMultiplier", new Color(0.85f, 0.85f, 0.85f));
			}
			BatchAllMeshChildren[] plantBatchers = __instance.plantBatchers;
			foreach (BatchAllMeshChildren val in plantBatchers)
			{
				val.material = cadaverBloomPlantsSnowy;
				Plugin.Logger.LogDebug((object)("Cadavers: Snow for " + ((Object)val.mesh).name));
			}
		}
	}
	[HarmonyPatch]
	internal static class FoliagePatches
	{
		[HarmonyPatch(typeof(FoliageDetailDistance), "Start")]
		[HarmonyPostfix]
		private static void FoliageDetailDistance_Post_Start(FoliageDetailDistance __instance)
		{
			if (Configuration.fancyFoliage.Value && __instance.allBushRenderers.Count > 0)
			{
				((Renderer)__instance.allBushRenderers[0]).sharedMaterial = __instance.highDetailMaterial;
				FoliageDiffuser.ApplyToRenderers(new <>z__ReadOnlySingleElementList<Renderer>((Renderer)(object)__instance.allBushRenderers[0]));
				__instance.highDetailMaterial = ((Renderer)__instance.allBushRenderers[0]).sharedMaterial;
			}
		}
	}
	[HarmonyPatch]
	internal static class GeneralPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void StartOfRound_Post_Start()
		{
			Common.BuildWeightLists();
		}

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		[HarmonyBefore(new string[] { "TonightWeDine" })]
		[HarmonyAfter(new string[] { "Sniper1_1.WaterAssetRestorer" })]
		private static void RoundManager_Post_FinishGeneratingNewLevelClientRpc(RoundManager __instance)
		{
			Common.breakerBoxHasReset = true;
			SceneOverrides.OverrideScene();
		}

		[HarmonyPatch(typeof(TimeOfDay), "Update")]
		[HarmonyPostfix]
		private static void TimeOfDay_Post_Update(TimeOfDay __instance)
		{
			SceneOverrides.Refresh();
		}

		[HarmonyPatch(typeof(TimeOfDay), "PlayTimeMusicDelayed")]
		[HarmonyPostfix]
		private static void TimeOFDay_Post_PlayTimeMusicDelayed(TimeOfDay __instance, AudioClip clip)
		{
			if ((Object)(object)clip == (Object)(object)StartOfRound.Instance.companyVisitMusic && FakeStorm.Enabled)
			{
				__instance.TimeOfDayMusic.volume = 1f;
			}
		}

		[HarmonyPatch(typeof(RoundManager), "TurnOnAllLights")]
		[HarmonyPostfix]
		private static void RoundManager_Post_TurnOnAllLights(RoundManager __instance, bool on)
		{
			ManorWindows.ToggleAll(on);
		}

		[HarmonyPatch(typeof(RoundManager), "Update")]
		[HarmonyPostfix]
		private static void RoundManager_Post_Update(RoundManager __instance)
		{
			if (__instance.powerOffPermanently && Common.breakerBoxHasReset)
			{
				BreakerBoxShutdown.ShutOff();
			}
		}

		[HarmonyPatch(typeof(EntranceTeleport), "PlayAudioAtTeleportPositions")]
		[HarmonyPrefix]
		private static bool EntranceTeleport_Pre_PlayAudioAtTeleportPositions(EntranceTeleport __instance)
		{
			if (string.IsNullOrEmpty(Configuration.fancyEntrances.Value))
			{
				return true;
			}
			float pitch = Random.Range(0.94f, 1.06f);
			if (__instance.entranceId != 0)
			{
				if (__instance.doorAudios == null || __instance.doorAudios.Length < 1)
				{
					return false;
				}
				AudioClip val = __instance.doorAudios[Random.Range(0, __instance.doorAudios.Length)];
				if ((Object)(object)__instance.entrancePointAudio != (Object)null)
				{
					__instance.entrancePointAudio.pitch = pitch;
					__instance.entrancePointAudio.PlayOneShot(val);
					WalkieTalkie.TransmitOneShotAudio(__instance.entrancePointAudio, val, 1f);
				}
				if ((Object)(object)__instance.exitScript?.entrancePointAudio != (Object)null)
				{
					__instance.exitScript.entrancePointAudio.pitch = pitch;
					__instance.exitScript.entrancePointAudio.PlayOneShot(val);
					WalkieTalkie.TransmitOneShotAudio(__instance.exitScript.entrancePointAudio, val, 1f);
				}
				return false;
			}
			AudioClip[] array = (EntranceDoorFancifier.Enabled ? StartOfRound.Instance.shutDoorWooden : StartOfRound.Instance.shutDoorMetal);
			AudioClip val2 = array[Random.Range(0, array.Length)];
			if ((Object)(object)__instance.entrancePointAudio != (Object)null)
			{
				__instance.entrancePointAudio.pitch = pitch;
				__instance.entrancePointAudio.PlayOneShot(val2);
				WalkieTalkie.TransmitOneShotAudio(__instance.entrancePointAudio, val2, 1f);
			}
			if ((Object)(object)__instance.exitScript?.entrancePointAudio != (Object)null)
			{
				__instance.exitScript.entrancePointAudio.pitch = pitch;
				__instance.exitScript.entrancePointAudio.PlayOneShot(val2);
				WalkieTalkie.TransmitOneShotAudio(__instance.exitScript.entrancePointAudio, val2, 1f);
			}
			return false;
		}

		[HarmonyPatch(typeof(EntranceTeleport), "PlayCreakSFX")]
		[HarmonyPrefix]
		private static bool EntranceTeleport_Pre_PlayCreakSFX(EntranceTeleport __instance)
		{
			if (string.IsNullOrEmpty(Configuration.fancyEntrances.Value))
			{
				return true;
			}
			float pitch = Random.Range(0.94f, 1.06f);
			AudioClip[] array = (EntranceDoorFancifier.Enabled ? StartOfRound.Instance.creakOpenDoorWooden : StartOfRound.Instance.creakOpenDoorMetal);
			AudioClip clip = array[Random.Range(0, array.Length)];
			__instance.playingCreakAudio = true;
			if ((Object)(object)__instance.entrancePointAudio != (Object)null)
			{
				__instance.entrancePointAudio.clip = clip;
				__instance.entrancePointAudio.pitch = pitch;
				__instance.entrancePointAudio.Play();
			}
			if ((Object)(object)__instance.exitScript?.thisEntranceAnimator != (Object)null && (Object)(object)__instance.exitScript.entrancePointAudio != (Object)null)
			{
				__instance.exitScript.entrancePointAudio.clip = clip;
				__instance.exitScript.entrancePointAudio.pitch = pitch;
				__instance.exitScript.entrancePointAudio.Play();
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class PlanetPreviewPatches
	{
		private static Animator shipAnimator;

		private static Light sunlight;

		private static Material artificeMat;

		private static Material embrionMat;

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_Awake(StartOfRound __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.planetPreview.Value || !((Object)(object)__instance.outerSpaceSunAnimator != (Object)null))
			{
				return;
			}
			sunlight = ((Component)__instance.outerSpaceSunAnimator).GetComponent<Light>();
			if ((Object)(object)sunlight != (Object)null)
			{
				((Behaviour)__instance.outerSpaceSunAnimator).enabled = false;
				((Component)__instance.outerSpaceSunAnimator).transform.rotation = Quaternion.Euler(10.560008f, 188.70499f, 173.56802f);
				((Behaviour)sunlight).enabled = true;
				shipAnimator = ((Component)__instance.shipAnimatorObject).GetComponent<Animator>();
			}
			if ((Object)(object)artificeMat == (Object)null || (Object)(object)embrionMat == (Object)null)
			{
				try
				{
					AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "planetpreview"));
					artificeMat = obj.LoadAsset<Material>("ArtificePlanet");
					embrionMat = obj.LoadAsset<Material>("EmbrionPlanet");
					obj.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"planetpreview\". Did you install the plugin correctly?");
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "LateUpdate")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_LateUpdate(StartOfRound __instance)
		{
			if (__instance.firingPlayersCutsceneRunning && (Object)(object)sunlight != (Object)null && (Object)(object)shipAnimator != (Object)null && shipAnimator.GetBool("AlarmRinging"))
			{
				((Behaviour)sunlight).enabled = false;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "EndPlayersFiredSequenceClientRpc")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_EndPlayersFiredSequenceClientRpc(StartOfRound __instance)
		{
			if ((Object)(object)sunlight != (Object)null)
			{
				((Behaviour)sunlight).enabled = true;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ChangePlanet")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_ChangePlanet(StartOfRound __instance)
		{
			if (!((Object)(object)sunlight != (Object)null) || !((Object)(object)__instance.currentPlanetPrefab != (Object)null))
			{
				return;
			}
			switch (((Object)__instance.currentLevel).name)
			{
			case "ArtificeLevel":
				if ((Object)(object)artificeMat != (Object)null && (!Common.INSTALLED_ARTIFICE_BLIZZARD || !Configuration.autoAdaptSnow.Value))
				{
					Renderer[] componentsInChildren = __instance.currentPlanetPrefab.GetComponentsInChildren<Renderer>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].material = artificeMat;
					}
				}
				break;
			case "EmbrionLevel":
				if ((Object)(object)embrionMat != (Object)null)
				{
					Renderer[] componentsInChildren = __instance.currentPlanetPrefab.GetComponentsInChildren<Renderer>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].material = embrionMat;
					}
				}
				break;
			case "CompanyBuildingLevel":
			{
				Renderer[] componentsInChildren = __instance.currentPlanetPrefab.GetComponentsInChildren<Renderer>();
				foreach (Renderer obj in componentsInChildren)
				{
					obj.enabled = false;
					obj.forceRenderingOff = true;
				}
				break;
			}
			}
		}
	}
}
namespace Chameleon.Overrides
{
	internal class DoorMaterialsFixer
	{
		private static Material helmetGlass;

		private static Material material001;

		internal static void Apply()
		{
			if (!Configuration.fixDoorMeshes.Value || ((Object)StartOfRound.Instance.currentLevel).name == "CompanyBuildingLevel" || Common.interior == "AquaticDungeonFlow")
			{
				return;
			}
			if ((Object)(object)helmetGlass == (Object)null || (Object)(object)material001 == (Object)null)
			{
				try
				{
					AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "doublesides"));
					helmetGlass = obj.LoadAsset<Material>("HelmetGlass 1");
					material001 = obj.LoadAsset<Material>("Material.001");
					obj.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"doublesides\". Did you install the plugin correctly?");
					return;
				}
			}
			MeshFilter val = default(MeshFilter);
			foreach (Renderer item in from rend in Object.FindObjectsByType<Renderer>((FindObjectsSortMode)0)
				where ((Object)rend).name == "DoorMesh"
				select rend)
			{
				if (item.sharedMaterials != null && item.sharedMaterials.Length == 7 && (Object)(object)item.sharedMaterials[2] != (Object)null && ((Object)item.sharedMaterials[2]).name.StartsWith("Material.001") && (Object)(object)item.sharedMaterials[5] != (Object)null && ((Object)item.sharedMaterials[5]).name.StartsWith("HelmetGlass"))
				{
					Material[] sharedMaterials = item.sharedMaterials;
					sharedMaterials[2] = material001;
					if ((Object)(object)((Component)item).GetComponentInChildren<InteractTrigger>() != (Object)null)
					{
						sharedMaterials[5] = helmetGlass;
					}
					item.sharedMaterials = sharedMaterials;
				}
				else if ((Object)(object)item.sharedMaterial != (Object)null && item.sharedMaterials.Length == 1 && ((Component)item).TryGetComponent<MeshFilter>(ref val) && ((Object)val.sharedMesh).name == "FancyDoor")
				{
					item.material.shader = material001.shader;
					item.sharedMaterial.doubleSidedGI = true;
					item.sharedMaterial.EnableKeyword("_DOUBLESIDED_ON");
					item.sharedMaterial.SetFloat("_CullMode", 0f);
					item.sharedMaterial.SetFloat("_CullModeForward", 0f);
					item.sharedMaterial.SetFloat("_DoubleSidedEnable", 1f);
				}
			}
		}
	}
	internal class EntranceDoorFancifier
	{
		internal static bool Enabled { get; private set; }

		internal static void Apply()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(Configuration.fancyEntrances.Value) || ((Object)StartOfRound.Instance.currentLevel).name == "CompanyBuildingLevel" || Common.currentLevelCosmeticInfo == null)
			{
				return;
			}
			GameObject obj = GameObject.Find(Common.currentLevelCosmeticInfo.planePath);
			Transform val = ((obj != null) ? obj.transform : null);
			if (!string.IsNullOrEmpty(Common.currentLevelCosmeticInfo.planePath) && (Object)(object)val != (Object)null)
			{
				if (StartOfRound.Instance.currentLevel.sceneName == "Level9Artifice")
				{
					val.SetLocalPositionAndRotation(new Vector3(67.955864f, 251.9486f, -136.27252f), Quaternion.Euler(-90f, 0f, 155.41f));
					val.localScale = new Vector3(0.29551032f, 0.124950044f, 0.30555016f);
				}
				if ((Object)(object)Common.black != (Object)null)
				{
					((Component)val).GetComponent<Renderer>().sharedMaterial = Common.black;
				}
			}
			if (string.IsNullOrEmpty(Common.interior))
			{
				return;
			}
			try
			{
				if (!Configuration.fancyEntrances.Value.Split(',').Contains(Common.interior))
				{
					return;
				}
			}
			catch
			{
				Plugin.Logger.LogError((object)"Encountered an error parsing the \"FancyEntrances\" setting. Please double check that your config follows proper syntax, then start another round.");
				if (RoundManager.Instance.currentDungeonType != 1)
				{
					return;
				}
			}
			GameObject obj3 = GameObject.Find(Common.currentLevelCosmeticInfo.doorsContainerPath);
			object obj5;
			if (!string.IsNullOrEmpty(Common.currentLevelCosmeticInfo.framePath))
			{
				GameObject obj4 = GameObject.Find(Common.currentLevelCosmeticInfo.framePath);
				obj5 = ((obj4 != null) ? obj4.transform : null);
			}
			else
			{
				obj5 = null;
			}
			Transform val2 = (Transform)obj5;
			Transform val3 = obj3.transform.Find("SteelDoorFake/DoorMesh");
			Transform val4 = obj3.transform.Find("SteelDoorFake (1)/DoorMesh");
			if ((Object)(object)obj3 == (Object)null || (!string.IsNullOrEmpty(Common.currentLevelCosmeticInfo.framePath) && (Object)(object)val2 == (Object)null) || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"\"FancyEntrances\" skipped because some GameObjects were missing.");
				return;
			}
			GameObject val5;
			GameObject val6;
			try
			{
				AssetBundle obj6 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "fancyentrancedoors"));
				val5 = obj6.LoadAsset<GameObject>("WideDoorFrame");
				val6 = obj6.LoadAsset<GameObject>("DoorMeshFake");
				obj6.Unload(false);
			}
			catch
			{
				Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"fancyentrancedoors\". Did you install the plugin correctly?");
				return;
			}
			if ((Object)(object)val5 == (Object)null || (Object)(object)val6 == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"\"FancyEntrances\" skipped because fancy door assets were missing.");
				return;
			}
			if ((Object)(object)RoundManager.Instance.mapPropsContainer == (Object)null)
			{
				RoundManager.Instance.mapPropsContainer = GameObject.FindGameObjectWithTag("MapPropsContainer");
			}
			if ((Object)(object)RoundManager.Instance.mapPropsContainer == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"\"FancyEntrances\" skipped because disposable prop container did not exist in scene.");
				return;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).gameObject.SetActive(false);
				Transform transform = Object.Instantiate<GameObject>(val5, Common.currentLevelCosmeticInfo.fancyDoorPos, Common.currentLevelCosmeticInfo.fancyDoorRot, RoundManager.Instance.mapPropsContainer.transform).transform;
				if (StartOfRound.Instance.currentLevel.sceneName == "Level6Dine")
				{
					transform.localScale = new Vector3(transform.localScale.x, 1f, transform.localScale.z);
				}
			}
			((Component)val3).gameObject.SetActive(false);
			Object.Instantiate<GameObject>(val6, val3.parent);
			((Component)val4).gameObject.SetActive(false);
			Object.Instantiate<GameObject>(val6, val4.parent).transform.SetLocalPositionAndRotation(new Vector3(0.14f, 0f, 0f), Quaternion.Euler(0f, 0f, -179f));
			Enabled = true;
			SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
		}

		private static void Reset()
		{
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
			Enabled = false;
		}
	}
	internal static class SceneOverrides
	{
		private static bool initialized;

		private static bool done;

		private static Action applyOverrides;

		internal static Action refreshOverrides;

		internal static Action resetOverrides;

		internal static void Init()
		{
			if (!initialized)
			{
				initialized = true;
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(EntranceDoorFancifier.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(DoorMaterialsFixer.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(GordionFixer.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(FakeStorm.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(FakeRain.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(WeatherAmbience.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(DoorLightColorer.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(RetextureCaverns.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(ManorWindows.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(BreakerBoxShutdown.Apply));
				applyOverrides = (Action)Delegate.Combine(applyOverrides, new Action(FoliageDiffuser.ApplyToScene));
			}
		}

		internal static void OverrideScene()
		{
			if (!done)
			{
				done = true;
				Common.GetReferences();
				Common.GetSharedAssets();
				applyOverrides?.Invoke();
			}
		}

		internal static void UnloadScene(Scene scene)
		{
			done = false;
			Common.breakerBoxHasReset = false;
			resetOverrides?.Invoke();
		}

		internal static void Refresh()
		{
			refreshOverrides?.Invoke();
		}

		internal static void LoadNewScene(Scene scene, LoadSceneMode mode)
		{
			VolumeOverrides.Apply();
		}
	}
}
namespace Chameleon.Overrides.Rendering
{
	internal class FoliageDiffuser
	{
		private static Material diffuseLeaves;

		private static Texture swampForestTextureMask;

		private static DiffusionProfile foliageDiffusionProfile;

		private static float foliageDiffusionProfileHash;

		internal static void ApplyToScene()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			if (!Configuration.fancyFoliage.Value)
			{
				return;
			}
			GameObject obj = GameObject.Find("/Environment/Map");
			Transform val = ((obj != null) ? obj.transform : null);
			if ((Object)(object)val != (Object)null)
			{
				ApplyToRenderers(((Component)val).GetComponentsInChildren<Renderer>().Where(FilterObjects));
			}
			if ((Object)(object)RoundManager.Instance.mapPropsContainer == (Object)null)
			{
				RoundManager.Instance.mapPropsContainer = GameObject.FindGameObjectWithTag("MapPropsContainer");
			}
			if ((Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null)
			{
				ApplyToRenderers(RoundManager.Instance.mapPropsContainer.GetComponentsInChildren<Renderer>().Where(FilterObjects));
			}
			if (RoundManager.Instance.currentDungeonType != 1 || !((Object)(object)Common.dungeonRoot != (Object)null))
			{
				return;
			}
			foreach (Transform item in Common.dungeonRoot.transform)
			{
				Transform val2 = item;
				if (((Object)val2).name.StartsWith("GreenhouseTile"))
				{
					ApplyToRenderers(((Component)val2).GetComponentsInChildren<Renderer>().Where(FilterObjects));
				}
			}
		}

		internal static void ApplyToRenderers(IEnumerable<Renderer> renderers)
		{
			if (!GetReferences())
			{
				return;
			}
			foreach (Renderer renderer in renderers)
			{
				Material sharedMaterial = renderer.sharedMaterial;
				Texture texture = sharedMaterial.GetTexture("_TransmissionMaskMap");
				if ((Object)(object)texture != (Object)null)
				{
					if (((Object)sharedMaterial).name.StartsWith("SwampForestTexture") && (Object)(object)texture != (Object)(object)swampForestTextureMask)
					{
						sharedMaterial.SetTexture("_TransmissionMaskMap", swampForestTextureMask);
						Plugin.Logger.LogDebug((object)("Fixed foliage diffusion for \"" + ((Object)sharedMaterial).name + "\" (" + ((Object)renderer).name + ")"));
					}
				}
				else if (sharedMaterial.GetFloat("_DiffusionProfileHash") != foliageDiffusionProfileHash || sharedMaterial.GetFloat("_MaterialID") != 5f)
				{
					int renderQueue = sharedMaterial.renderQueue;
					sharedMaterial.shader = diffuseLeaves.shader;
					sharedMaterial.renderQueue = renderQueue;
					sharedMaterial.SetFloat("_DiffusionProfileHash", foliageDiffusionProfileHash);
					sharedMaterial.shaderKeywords = sharedMaterial.shaderKeywords.Union(diffuseLeaves.shaderKeywords).ToArray();
					if (((Object)sharedMaterial).name.StartsWith("ForestTexture"))
					{
						sharedMaterial.SetTexture("_TransmissionMaskMap", diffuseLeaves.GetTexture("_TransmissionMaskMap"));
					}
					sharedMaterial.SetFloat("_MaterialID", 5f);
					Plugin.Logger.LogDebug((object)("Applied foliage diffusion to \"" + ((Object)sharedMaterial).name + "\" (" + ((Object)renderer).name + ")"));
				}
			}
		}

		private static bool GetReferences()
		{
			if ((Object)(object)diffuseLeaves == (Object)null)
			{
				try
				{
					AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "fancyfoliage"));
					diffuseLeaves = obj.LoadAsset<Material>("DiffuseLeaves");
					swampForestTextureMask = obj.LoadAsset<Texture>("SwampForestTextureMask");
					obj.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"fancyfoliage\". Did you install the plugin correctly?");
					return false;
				}
			}
			if (foliageDiffusionProfile == null)
			{
				foliageDiffusionProfile = ((IEnumerable<DiffusionProfileSettings>)((VolumeParameter<DiffusionProfileSettings[]>)(object)HDRenderPipelineGlobalSettings.instance.GetOrCreateDiffusionProfileList()?.diffusionProfiles).value).FirstOrDefault((Func<DiffusionProfileSettings, bool>)((DiffusionProfileSettings profile) => ((profile != null) ? ((Object)profile).name : null) == "Foliage Diffusion Profile"))?.profile;
				if (foliageDiffusionProfile != null)
				{
					foliageDiffusionProfileHash = BitConverter.Int32BitsToSingle((int)foliageDiffusionProfile.hash);
				}
			}
			if ((Object)(object)diffuseLeaves != (Object)null)
			{
				return foliageDiffusionProfile != null;
			}
			return false;
		}

		private static bool FilterObjects(Renderer rend)
		{
			if ((Object)(object)rend.sharedMaterial != (Object)null)
			{
				if (!((Object)rend.sharedMaterial).name.Contains("ForestTexture") && !((Object)rend.sharedMaterial).name.StartsWith("TreeFlat") && !((Object)rend.sharedMaterial).name.StartsWith("Leaves"))
				{
					return ((Object)rend.sharedMaterial).name.StartsWith("GreenhousePlantsMat");
				}
				return true;
			}
			return false;
		}
	}
	internal class VolumeOverrides
	{
		internal static void Apply()
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Invalid comparison between Unknown and I4
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			Volume[] array = Object.FindObjectsByType<Volume>((FindObjectsSortMode)0);
			Fog val3 = default(Fog);
			foreach (Volume val in array)
			{
				if (((Object)val).name == "Sky and Fog Global Volume")
				{
					string text = null;
					if (Configuration.fixTitanVolume.Value && StartOfRound.Instance.currentLevel.sceneName == "Level8Titan")
					{
						text = "SnowyFog";
					}
					else if (Configuration.fixArtificeVolume.Value && StartOfRound.Instance.currentLevel.sceneName == "Level9Artifice" && !Queries.IsSnowLevel())
					{
						text = "Sky and Fog Settings Profile";
					}
					if (!string.IsNullOrEmpty(text))
					{
						try
						{
							AssetBundle val2 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "volumetricprofiles"));
							val.sharedProfile = val2.LoadAsset<VolumeProfile>(text) ?? val.profile;
							Plugin.Logger.LogDebug((object)("Changed profile on \"" + ((Object)val).name + "\""));
							val2.Unload(false);
						}
						catch
						{
							Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"volumetricprofiles\". Did you install the plugin correctly?");
						}
					}
				}
				if (val.sharedProfile.TryGet<Fog>(ref val3))
				{
					if (Configuration.fogReprojection.Value && (int)((VolumeParameter)val3.denoisingMode).GetValue<FogDenoisingMode>() != 1)
					{
						((VolumeParameter)val3.denoisingMode).SetValue((VolumeParameter)new FogDenoisingModeParameter((FogDenoisingMode)1, true));
						((VolumeParameter)val3.denoisingMode).overrideState = true;
						Plugin.Logger.LogDebug((object)("Changed fog denoising mode on \"" + ((Object)val).name + "\""));
					}
					int? num = Configuration.fogQuality.Value switch
					{
						Configuration.FogQuality.Medium => 1, 
						Configuration.FogQuality.High => 2, 
						_ => null, 
					};
					if (num.HasValue)
					{
						((VolumeParameter<int>)(object)((VolumeComponentWithQuality)val3).quality).Override(num.Value);
						Plugin.Logger.LogDebug((object)$"Changed fog quality mode on \"{((Object)val).name}\" to \"{((VolumeParameter<int>)(object)((VolumeComponentWithQuality)val3).quality).value}\"");
					}
				}
			}
			if (!Configuration.fogReprojection.Value)
			{
				return;
			}
			HDAdditionalCameraData[] array2 = Object.FindObjectsByType<HDAdditionalCameraData>((FindObjectsSortMode)0);
			foreach (HDAdditionalCameraData val4 in array2)
			{
				if (val4.customRenderingSettings)
				{
					((BitArray128)(ref val4.renderingPathCustomFrameSettingsOverrideMask.mask))[29u] = true;
					((FrameSettings)(ref val4.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)29, true);
				}
			}
		}
	}
}
namespace Chameleon.Overrides.Interior
{
	internal class BreakerBoxShutdown
	{
		private static Material lightOff;

		private static bool done;

		internal static void Apply()
		{
			if ((Object)(object)lightOff == (Object)null)
			{
				try
				{
					AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lightmats"));
					lightOff = obj.LoadAsset<Material>("LEDLightYellowOff");
					obj.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"lightmats\". Did you install the plugin correctly?");
				}
			}
		}

		internal static void ShutOff()
		{
			if (done)
			{
				return;
			}
			done = true;
			SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
			if (!Configuration.powerOffBreakerBox.Value)
			{
				return;
			}
			if ((Object)(object)lightOff != (Object)null)
			{
				BreakerBox breakerBox = Common.BreakerBox;
				if (!((Object)(object)breakerBox != (Object)null))
				{
					return;
				}
				Transform val = ((Component)breakerBox).transform.Find("Light");
				Renderer component = ((Component)val).GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					Material[] sharedMaterials = component.sharedMaterials;
					if (sharedMaterials.Length != 2)
					{
						Plugin.Logger.LogWarning((object)"Breaker box materials are different than expected. Is this a custom interior?");
						return;
					}
					sharedMaterials[1] = lightOff;
					component.sharedMaterials = sharedMaterials;
					Transform obj = val.Find("RedLight");
					if (obj != null)
					{
						GameObject gameObject = ((Component)obj).gameObject;
						if (gameObject != null)
						{
							gameObject.SetActive(false);
						}
					}
					if ((Object)(object)breakerBox.breakerBoxHum != (Object)null)
					{
						breakerBox.breakerBoxHum.Stop();
						breakerBox.breakerBoxHum.mute = true;
					}
				}
				Plugin.Logger.LogDebug((object)"Breaker box light was turned off");
			}
			else
			{
				Plugin.Logger.LogWarning((object)"Can't disable breaker box light because material is missing. Asset bundle(s) were likely installed incorrectly");
			}
		}

		private static void Reset()
		{
			done = false;
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
		}
	}
	internal class DoorLightColorer
	{
		private static SpriteRenderer lightBehindDoor;

		private static Color doorLightColor = DoorLightPalette.DEFAULT_BACKGROUND;

		internal static void Apply()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Invalid comparison between Unknown and I4
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Invalid comparison between Unknown and I4
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.doorLightColors.Value || string.IsNullOrEmpty(Common.interior))
			{
				return;
			}
			lightBehindDoor = ((IEnumerable<SpriteRenderer>)Object.FindObjectsByType<SpriteRenderer>((FindObjectsSortMode)0)).FirstOrDefault((Func<SpriteRenderer, bool>)((SpriteRenderer spriteRenderer) => ((Object)spriteRenderer).name == "LightBehindDoor"));
			if ((Object)(object)lightBehindDoor != (Object)null)
			{
				if ((int)StartOfRound.Instance.currentLevel.currentWeather == 5)
				{
					doorLightColor = DoorLightPalette.ECLIPSE_BACKGROUND;
				}
				else if ((int)StartOfRound.Instance.currentLevel.currentWeather == 2 || (int)StartOfRound.Instance.currentLevel.currentWeather == 4)
				{
					doorLightColor = DoorLightPalette.CLOUDY_BACKGROUND;
				}
				else if (Common.currentLevelCosmeticInfo != null)
				{
					doorLightColor = (((int)StartOfRound.Instance.currentLevel.currentWeather == 3) ? Common.currentLevelCosmeticInfo.doorLightColorFoggy : Common.currentLevelCosmeticInfo.doorLightColor);
				}
				else if (Queries.IsSnowLevel())
				{
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND;
				}
				else
				{
					Plugin.Logger.LogDebug((object)"Could not recolor door light - No information exists for the current level (Are you playing a custom moon?)");
					doorLightColor = DoorLightPalette.DEFAULT_BACKGROUND;
				}
				lightBehindDoor.color = doorLightColor;
				SceneOverrides.refreshOverrides = (Action)Delegate.Combine(SceneOverrides.refreshOverrides, new Action(Refresh));
				SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
			}
			else
			{
				Plugin.Logger.LogDebug((object)"Could not recolor door light - GameObject \"LightBehindDoor\" was not found (Are you playing a custom interior?)");
			}
		}

		private static void Refresh()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lightBehindDoor != (Object)null && TimeOfDay.Instance.timeHasStarted && TimeOfDay.Instance.normalizedTimeOfDay > 0.63f)
			{
				lightBehindDoor.color = Color.Lerp(doorLightColor, Color.black, Mathf.InverseLerp(0.63f, 0.998f, TimeOfDay.Instance.normalizedTimeOfDay));
			}
		}

		private static void Reset()
		{
			SceneOverrides.refreshOverrides = (Action)Delegate.Remove(SceneOverrides.refreshOverrides, new Action(Refresh));
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
		}
	}
	internal class ManorWindows
	{
		private class WindowedTile
		{
			internal Renderer renderer;

			internal Light light;

			internal bool bedroom;
		}

		internal static Dictionary<string, IntWithRarity[]> windowWeightLists = new Dictionary<string, IntWithRarity[]>();

		private static Material fakeWindowOn = null;

		private static Material fakeWindowOff = null;

		private static Material fakeWindow2On = null;

		private static Material fakeWindow2Off = null;

		private static List<WindowedTile> allTiles = new List<WindowedTile>();

		internal static void Apply()
		{
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(Common.interior) || (Common.interior != "Level2Flow" && Common.interior != "v62Mansion-Level2Flow"))
			{
				return;
			}
			if ((Object)(object)Common.dungeonRoot == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Skipping manor search because there was an error finding the dungeon object tree.");
				return;
			}
			WindowType currentMoonWindows = GetCurrentMoonWindows();
			if (!VanillaLevelsInfo.windowVariants.TryGetValue(currentMoonWindows, out var value))
			{
				value = null;
			}
			try
			{
				AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "windowvariants"));
				if (currentMoonWindows != WindowType.Pasture)
				{
					fakeWindowOn = val.LoadAsset<Material>($"FakeWindowView{currentMoonWindows}");
					fakeWindowOff = ((value != null && !value.blackWhenOff) ? val.LoadAsset<Material>($"FakeWindowView{currentMoonWindows}Off") : null);
					if (currentMoonWindows == WindowType.Flowery && (Object)(object)fakeWindowOn != (Object)null && (Object)(object)fakeWindowOff != (Object)null)
					{
						fakeWindow2On = Object.Instantiate<Material>(fakeWindowOn);
						fakeWindow2Off = Object.Instantiate<Material>(fakeWindowOff);
						Vector2 val2 = default(Vector2);
						((Vector2)(ref val2))..ctor(0f, 0.73f);
						Material[] array = (Material[])(object)new Material[2] { fakeWindow2On, fakeWindow2Off };
						foreach (Material val3 in array)
						{
							string[] array2 = new string[4] { "_MainTex", "_BaseColorMap", "_EmissiveColorMap", "_UnlitColorMap" };
							foreach (string text in array2)
							{
								if (val3.HasTexture(text))
								{
									val3.SetTextureOffset(text, val2);
									Plugin.Logger.LogDebug((object)$"{((Object)val3).name}.{text}: {val2}");
								}
							}
						}
					}
					else
					{
						fakeWindow2On = fakeWindowOn;
						fakeWindow2Off = fakeWindowOff;
					}
				}
				else
				{
					fakeWindowOn = null;
					fakeWindowOff = val.LoadAsset<Material>("FakeWindowViewOff");
					fakeWindow2On = null;
					fakeWindow2Off = Object.Instantiate<Material>(fakeWindowOff);
					Vector2 val4 = default(Vector2);
					((Vector2)(ref val4))..ctor(0f, 0.42f);
					string[] array2 = new string[2] { "_MainTex", "_BaseColorMap" };
					foreach (string text2 in array2)
					{
						fakeWindow2Off.SetTextureOffset(text2, val4);
					}
				}
				val.Unload(false);
			}
			catch
			{
				Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"windowvariants\". Did you install the plugin correctly?");
				fakeWindowOn = null;
				fakeWindowOff = null;
				fakeWindow2On = null;
				fakeWindow2Off = null;
			}
			Renderer[] componentsInChildren = Common.dungeonRoot.GetComponentsInChildren<Renderer>();
			foreach (Renderer val5 in componentsInChildren)
			{
				if (((Object)((Component)val5).transform.parent).name.StartsWith("WindowTile") && ((Object)val5).name == "mesh" && val5.sharedMaterials.Length > 5)
				{
					Material obj2 = val5.sharedMaterials[5];
					if (((obj2 != null) ? ((Object)obj2).name : null) == "FakeWindowView")
					{
						if ((Object)(object)fakeWindowOn == (Object)null)
						{
							fakeWindowOn = val5.sharedMaterials[5];
						}
						Transform obj3 = ((Component)val5).transform.parent.Find("ScreenLight");
						Light val6 = ((obj3 != null) ? ((Component)obj3).GetComponent<Light>() : null);
						if ((Object)(object)val6 != (Object)null)
						{
							if (value != null)
							{
								val6.colorTemperature = value.lightTemp;
								val6.color = value.filterColor;
							}
							allTiles.Add(new WindowedTile
							{
								renderer = val5,
								light = val6
							});
							Plugin.Logger.LogDebug((object)"Cached window tile instance");
						}
						continue;
					}
				}
				if (!(((Object)val5).name == "BedroomWindow") || val5.sharedMaterials.Length < 2)
				{
					continue;
				}
				Material obj4 = val5.sharedMaterials[1];
				if (!(((obj4 != null) ? ((Object)obj4).name : null) == "FakeWindowView2"))
				{
					continue;
				}
				if ((Object)(object)fakeWindow2On == (Object)null)
				{
					fakeWindow2On = val5.sharedMaterials[1];
				}
				Transform obj5 = ((Component)val5).transform.Find("WindowLight");
				Light val7 = ((obj5 != null) ? ((Component)obj5).GetComponent<Light>() : null);
				if ((Object)(object)val7 != (Object)null)
				{
					if (value != null)
					{
						val7.colorTemperature = value.lightTemp;
						val7.color = value.filterColor;
					}
					allTiles.Add(new WindowedTile
					{
						renderer = val5,
						light = val7,
						bedroom = true
					});
					Plugin.Logger.LogDebug((object)"Cached bedroom tile instance");
				}
			}
			if (allTiles.Count > 0)
			{
				BreakerBox breakerBox = Common.BreakerBox;
				if (Configuration.powerOffWindows.Value && (Object)(object)breakerBox != (Object)null && breakerBox.leversSwitchedOff > 0)
				{
					ToggleAll(powered: false);
				}
				else if (currentMoonWindows != WindowType.Pasture)
				{
					ToggleAll(powered: true);
				}
			}
			SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
		}

		private static void Reset()
		{
			allTiles.Clear();
			fakeWindowOn = null;
			fakeWindowOff = null;
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
		}

		internal static void ToggleAll(bool powered)
		{
			if (allTiles.Count < 1)
			{
				return;
			}
			if (powered)
			{
				if ((Object)(object)fakeWindowOn == (Object)null)
				{
					return;
				}
			}
			else if (!Configuration.powerOffWindows.Value || ((Object)(object)fakeWindowOff == (Object)null && (Object)(object)Common.black == (Object)null))
			{
				return;
			}
			foreach (WindowedTile allTile in allTiles)
			{
				Material[] sharedMaterials = allTile.renderer.sharedMaterials;
				if (allTile.bedroom)
				{
					sharedMaterials[1] = (powered ? fakeWindow2On : (((Object)(object)fakeWindow2Off != (Object)null && !Configuration.blackoutWindows.Value) ? fakeWindow2Off : Common.black));
				}
				else
				{
					sharedMaterials[5] = (powered ? fakeWindowOn : (((Object)(object)fakeWindowOff != (Object)null && !Configuration.blackoutWindows.Value) ? fakeWindowOff : Common.black));
				}
				allTile.renderer.sharedMaterials = sharedMaterials;
				((Behaviour)allTile.light).enabled = powered;
			}
		}

		private static WindowType GetCurrentMoonWindows()
		{
			if (windowWeightLists.TryGetValue(((Object)StartOfRound.Instance.currentLevel).name, out var value))
			{
				int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(value.Select((IntWithRarity x) => x.rarity).ToArray(), new Random(StartOfRound.Instance.randomMapSeed));
				if (randomWeightedIndex >= 0 && randomWeightedIndex < value.Length)
				{
					int id = value[randomWeightedIndex].id;
					if (Enum.IsDefined(typeof(WindowType), id))
					{
						if (id > -1)
						{
							return (WindowType)id;
						}
					}
					else
					{
						Plugin.Logger.LogWarning((object)"Tried to assign an unknown window type. This shouldn't happen! (Falling back to pasture windows)");
					}
				}
				else
				{
					Plugin.Logger.LogWarning((object)"An error occurred indexing a random window type. This shouldn't happen! (Falling back to pasture windows)");
				}
			}
			else
			{
				Plugin.Logger.LogDebug((object)"No custom window weights were defined for the current moon. Falling back to pasture windows");
			}
			return WindowType.Pasture;
		}
	}
	internal class RetextureCaverns
	{
		internal static Dictionary<string, IntWithRarity[]> cavernWeightLists = new Dictionary<string, IntWithRarity[]>();

		internal static CavernType Type { get; private set; } = CavernType.Vanilla;


		internal static void Apply()
		{
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Invalid comparison between Unknown and I4
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(Common.interior) || !Queries.IsMineshaft())
			{
				return;
			}
			if ((Object)(object)Common.dungeonRoot == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Skipping mineshaft retexture because there was an error finding the dungeon object tree.");
				return;
			}
			Type = GetCurrentMoonCaverns();
			if (Type == CavernType.Vanilla)
			{
				return;
			}
			SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
			VanillaLevelsInfo.predefinedCaverns.TryGetValue(Type, out var value);
			if (value == null)
			{
				Plugin.Logger.LogWarning((object)"Skipping mineshaft retexture because there was an error finding cavern specifications.");
				return;
			}
			if (!string.IsNullOrEmpty(value.tag) && value.tag != "Rock" && !Common.CAN_REPLACE_CAVE_TAGS && !Configuration.dontChangeCaveSteps.Value)
			{
				Plugin.Logger.LogWarning((object)"A cavern type with custom footsteps has been selected, but Buttery Fixes is not installed - Footstep changes are not supported!");
			}
			Material val = null;
			Material val2 = null;
			Material val3 = null;
			if (!value.noRockMat)
			{
				string text = Type.ToString().ToLower() + "cave";
				try
				{
					AssetBundle val4 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), text));
					val = val4.LoadAsset<Material>("CaveRocks1");
					val2 = val4.LoadAsset<Material>("CoalMat");
					if (!string.IsNullOrEmpty(value.smallRockMat))
					{
						val3 = val4.LoadAsset<Material>(value.smallRockMat);
					}
					val4.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)("Encountered some error loading assets from bundle \"" + text + "\". Did you install the plugin correctly?"));
				}
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Logger.LogWarning((object)"Skipping mineshaft retexture because there was an error loading the replacement material.");
					return;
				}
			}
			Renderer[] componentsInChildren = Common.dungeonRoot.GetComponentsInChildren<Renderer>();
			foreach (Renderer val5 in componentsInChildren)
			{
				if (((Object)val5).name == "MineshaftStartTileMesh")
				{
					Material[] materials = val5.materials;
					if (!value.noRockMat)
					{
						materials[3] = val;
					}
					else
					{
						AdjustRockMaterial(materials[3], value);
					}
					val5.materials = materials;
				}
				else
				{
					if (!((Object)(object)val5.sharedMaterial != (Object)null))
					{
						continue;
					}
					if ((Object)(object)val3 != (Object)null && ((Object)val5).name.Contains("RockPile"))
					{
						val5.material = val3;
					}
					else if (((Object)val5.sharedMaterial).name.StartsWith("CaveRocks1"))
					{
						if (!value.noRockMat)
						{
							val5.material = val;
						}
						else
						{
							AdjustRockMaterial(val5.material, value);
						}
						if (((Component)val5).CompareTag("Rock") && !string.IsNullOrEmpty(value.tag) && Common.CAN_REPLACE_CAVE_TAGS && !Configuration.dontChangeCaveSteps.Value)
						{
							((Component)val5).tag = value.tag;
						}
					}
					else if (value.waterColor && ((Object)val5).name == "Water (1)" && ((Object)val5.sharedMaterial).name.StartsWith("CaveWater"))
					{
						val5.material.SetColor("Color_6a9a916e2c84442984edc20c082efe79", value.waterColorShallow);
						val5.sharedMaterial.SetColor("Color_c9a840f2115c4802ba54d713194f761d", value.waterColorDeep);
					}
					else if ((Object)(object)val2 != (Object)null && ((Object)val5.sharedMaterial).name.StartsWith(((Object)val2).name))
					{
						val5.material = val2;
					}
				}
			}
			if (value.noDrips && (int)StartOfRound.Instance.currentLevel.currentWeather != 4)
			{
				LocalPropSet[] componentsInChildren2 = Common.dungeonRoot.GetComponentsInChildren<LocalPropSet>();
				foreach (LocalPropSet val6 in componentsInChildren2)
				{
					if (((Object)val6).name.StartsWith("WaterDrips"))
					{
						((Component)val6).gameObject.SetActive(false);
						Plugin.Logger.LogDebug((object)"Disabled water drips");
					}
				}
			}
			if (string.IsNullOrEmpty(value.tag) || !(value.tag != "Rock") || !Common.CAN_REPLACE_CAVE_TAGS || Configuration.dontChangeCaveSteps.Value)
			{
				return;
			}
			Tile[] componentsInChildren3 = Common.dungeonRoot.GetComponentsInChildren<Tile>();
			foreach (Tile val7 in componentsInChildren3)
			{
				if (!((Object)val7).name.StartsWith("Cave"))
				{
					continue;
				}
				Collider[] componentsInChildren4 = ((Component)val7).GetComponentsInChildren<Collider>();
				foreach (Collider val8 in componentsInChildren4)
				{
					if (((Component)val8).CompareTag("Rock") && (StartOfRound.Instance.walkableSurfacesMask & (1 << ((Component)val8).gameObject.layer)) != 0)
					{
						((Component)val8).tag = value.tag;
					}
				}
			}
		}

		private static CavernType GetCurrentMoonCaverns()
		{
			if (Configuration.autoAdaptSnow.Value && Queries.IsSnowLevel() && (((Object)StartOfRound.Instance.currentLevel).name == "ArtificeLevel" || !VanillaLevelsInfo.predefinedLevels.ContainsKey(((Object)StartOfRound.Instance.currentLevel).name)))
			{
				Plugin.Logger.LogDebug((object)"Snow level detected, automatically enabling white caverns");
				if (!Common.CAN_REPLACE_CAVE_TAGS && !Configuration.dontChangeCaveSteps.Value)
				{
					return CavernType.Salt;
				}
				return CavernType.Ice;
			}
			if (cavernWeightLists.TryGetValue(((Object)StartOfRound.Instance.currentLevel).name, out var value))
			{
				int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(value.Select((IntWithRarity x) => x.rarity).ToArray(), new Random(StartOfRound.Instance.randomMapSeed));
				if (randomWeightedIndex >= 0 && randomWeightedIndex < value.Length)
				{
					int id = value[randomWeightedIndex].id;
					if (Enum.IsDefined(typeof(CavernType), id))
					{
						if (id > -1)
						{
							return (CavernType)id;
						}
					}
					else
					{
						Plugin.Logger.LogWarning((object)"Tried to assign an unknown cavern type. This shouldn't happen! (Falling back to vanilla caverns)");
					}
				}
				else
				{
					Plugin.Logger.LogWarning((object)"An error occurred indexing a random cavern type. This shouldn't happen! (Falling back to vanilla caverns)");
				}
			}
			else
			{
				Plugin.Logger.LogDebug((object)"No custom cave weights were defined for the current moon. Falling back to vanilla caverns");
			}
			return CavernType.Vanilla;
		}

		private static void AdjustRockMaterial(Material mat, CavernInfo info)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			mat.SetColor("_Color", info.rockColor);
			mat.SetColor("_BaseColor", info.rockColor);
			mat.SetTexture("_MainTex", (Texture)null);
			mat.SetTexture("_BaseColorMap", (Texture)null);
			mat.SetFloat("_NormalScale", info.rockNormals);
		}

		private static void Reset()
		{
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
			Type = CavernType.Vanilla;
		}
	}
	internal class WeatherAmbience
	{
		private static AudioSource blizzardInside;

		private static AudioSource rainInside;

		private static AudioClip backgroundStorm;

		private static AudioClip backgroundFlood;

		private static AudioClip backgroundRain;

		internal static void Apply()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected I4, but got Unknown
			if (!(Configuration.weatherAmbience.Value <= 0f))
			{
				Setup();
				AudioSource val = rainInside;
				LevelWeatherType currentWeather = StartOfRound.Instance.currentLevel.currentWeather;
				val.clip = (AudioClip)((currentWeather - 1) switch
				{
					1 => backgroundStorm, 
					3 => backgroundFlood, 
					0 => backgroundRain, 
					_ => null, 
				});
				if ((Object)(object)rainInside.clip == (Object)null && FakeRain.Enabled)
				{
					rainInside.clip = backgroundRain;
				}
				if (Queries.IsSnowLevel() || !((Object)(object)rainInside.clip == (Object)null))
				{
					SceneOverrides.refreshOverrides = (Action)Delegate.Combine(SceneOverrides.refreshOverrides, new Action(Refresh));
					SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
				}
			}
		}

		private static void Refresh()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)blizzardInside == (Object)null || (Object)(object)rainInside == (Object)null)
			{
				return;
			}
			if (Queries.IsCameraInside())
			{
				if (Configuration.weatherAmbience.Value > 0f)
				{
					bool num = Queries.IsSnowLevel();
					float num2 = Configuration.weatherAmbience.Value;
					if (num && ((Object)(object)rainInside.clip != (Object)null || Queries.IsMineshaft()))
					{
						num2 *= 0.85f;
					}
					bool flag = Queries.IsMineshaft();
					bool flag2 = flag && (Object)(object)RoundManager.Instance.currentMineshaftElevator != (Object)null && ((Component)GameNetworkManager.Instance.localPlayerController).transform.position.y < RoundManager.Instance.currentMineshaftElevator.elevatorTopPoint.position.y - 10f;
					num2 = ((!flag) ? (num2 * 0.84f) : (num2 * 0.7f));
					if (num)
					{
						blizzardInside.volume = num2;
						if (flag && !flag2)
						{
							AudioSource obj = blizzardInside;
							obj.volume *= 1.2f;
						}
						if (!blizzardInside.isPlaying && (Object)(object)blizzardInside.clip != (Object)null)
						{
							blizzardInside.Play();
						}
					}
					if ((Object)(object)rainInside.clip != (Object)null)
					{
						rainInside.volume = num2;
						if (flag && flag2 == ((Object)(object)rainInside.clip == (Object)(object)backgroundFlood))
						{
							AudioSource obj2 = rainInside;
							obj2.volume *= 1.2f;
						}
						if (!rainInside.isPlaying)
						{
							rainInside.Play();
						}
					}
				}
				else
				{
					blizzardInside.volume = 0f;
					rainInside.volume = 0f;
				}
			}
			else
			{
				if (blizzardInside.isPlaying)
				{
					blizzardInside.Stop();
				}
				if (rainInside.isPlaying)
				{
					rainInside.Stop();
				}
			}
		}

		private static void Reset()
		{
			if ((Object)(object)blizzardInside != (Object)null)
			{
				blizzardInside.Stop();
			}
			if ((Object)(object)rainInside != (Object)null)
			{
				rainInside.Stop();
			}
			SceneOverrides.refreshOverrides = (Action)Delegate.Remove(SceneOverrides.refreshOverrides, new Action(Refresh));
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
		}

		private static void Setup()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)blizzardInside == (Object)null || (Object)(object)rainInside == (Object)null)
			{
				if ((Object)(object)blizzardInside == (Object)null)
				{
					blizzardInside = new GameObject("Chameleon_BlizzardInside").AddComponent<AudioSource>();
					Object.DontDestroyOnLoad((Object)(object)((Component)blizzardInside).gameObject);
				}
				if ((Object)(object)rainInside == (Object)null)
				{
					rainInside = new GameObject("Chameleon_RainInside").AddComponent<AudioSource>();
					Object.DontDestroyOnLoad((Object)(object)((Component)rainInside).gameObject);
				}
				AudioSource[] array = (AudioSource[])(object)new AudioSource[2] { blizzardInside, rainInside };
				foreach (AudioSource obj in array)
				{
					obj.playOnAwake = false;
					obj.loop = true;
					obj.outputAudioMixerGroup = SoundManager.Instance.ambienceAudio.outputAudioMixerGroup;
				}
			}
			if ((Object)(object)blizzardInside.clip == (Object)null || (Object)(object)backgroundStorm == (Object)null || (Object)(object)backgroundFlood == (Object)null || (Object)(object)backgroundRain == (Object)null)
			{
				try
				{
					AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "weatherambience"));
					blizzardInside.clip = val.LoadAsset<AudioClip>("SnowOutside");
					backgroundStorm = val.LoadAsset<AudioClip>("StormOutside");
					backgroundFlood = val.LoadAsset<AudioClip>("FloodOutside");
					backgroundRain = val.LoadAsset<AudioClip>("RainOutside");
					val.Unload(false);
				}
				catch
				{
					Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"weatherambience\". Did you install the plugin correctly?");
				}
			}
		}
	}
}
namespace Chameleon.Overrides.Exterior
{
	internal class FakeRain
	{
		internal static bool Enabled { get; private set; }

		internal static void Apply()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			if (!(((Object)StartOfRound.Instance.currentLevel).name != "MarchLevel") && Configuration.rainyMarch.Value && (int)StartOfRound.Instance.currentLevel.currentWeather == -1)
			{
				Enabled = true;
				SceneOverrides.refreshOverrides = (Action)Delegate.Combine(SceneOverrides.refreshOverrides, new Action(Refresh));
				SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
			}
		}

		private static void Refresh()
		{
			if (!Queries.IsCameraInside())
			{
				TimeOfDay.Instance.effects[1].effectEnabled = true;
			}
		}

		private static void Reset()
		{
			SceneOverrides.refreshOverrides = (Action)Delegate.Remove(SceneOverrides.refreshOverrides, new Action(Refresh));
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
			Enabled = false;
		}
	}
	internal class FakeStorm
	{
		private static GameObject storm;

		internal static bool Enabled { get; private set; }

		internal static void Apply()
		{
			if (((Object)StartOfRound.Instance.currentLevel).name != "CompanyBuildingLevel")
			{
				return;
			}
			if (Configuration.stormyGordion.Value == Configuration.GordionStorms.Always)
			{
				Enabled = true;
			}
			else if (Configuration.stormyGordion.Value == Configuration.GordionStorms.Chance && TimeOfDay.Instance.profitQuota > 130)
			{
				float num = 0.7f;
				int num2 = 0;
				GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
				foreach (GrabbableObject val in array)
				{
					if (val.itemProperties.isScrap)
					{
						num2 += val.scrapValue;
					}
				}
				if (TimeOfDay.Instance.daysUntilDeadline < 1)
				{
					if (num2 < 1)
					{
						num = 0.98f;
					}
					else if (num2 < TimeOfDay.Instance.profitQuota)
					{
						num += 0.17f;
					}
					else if (Mathf.FloorToInt((float)(num2 - TimeOfDay.Instance.profitQuota - 75) * 1.2f) + TimeOfDay.Instance.profitQuota >= 1500)
					{
						num *= 0.9f;
					}
				}
				if (num2 > TimeOfDay.Instance.profitQuota - 75 && !StartOfRound.Instance.levels.Any((SelectableLevel level) => (int)level.currentWeather != -1))
				{
					num *= 0.64f;
				}
				if (new Random(StartOfRound.Instance.randomMapSeed).NextDouble() < (double)num)
				{
					Enabled = true;
				}
			}
			if (Enabled)
			{
				storm = TimeOfDay.Instance.effects[2].effectObject;
				SceneOverrides.refreshOverrides = (Action)Delegate.Combine(SceneOverrides.refreshOverrides, new Action(Refresh));
				SceneOverrides.resetOverrides = (Action)Delegate.Combine(SceneOverrides.resetOverrides, new Action(Reset));
			}
		}

		private static void Refresh()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)storm == (Object)null))
			{
				Vector3 position = (GameNetworkManager.Instance.localPlayerController.isPlayerDead ? ((Component)StartOfRound.Instance.spectateCamera).transform : ((Component)GameNetworkManager.Instance.localPlayerController).transform).position;
				position.y = Mathf.Max(position.y, -24f);
				storm.transform.position = position;
				storm.SetActive(true);
				if (!TimeOfDay.Instance.insideLighting && ((Component)GameNetworkManager.Instance.localPlayerController).transform.position.y >= -5.5f && Vector3.Angle(((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward, Vector3.up) < 45f)
				{
					HUDManager.Instance.increaseHelmetCondensation = true;
				}
			}
		}

		private static void Reset()
		{
			SceneOverrides.refreshOverrides = (Action)Delegate.Remove(SceneOverrides.refreshOverrides, new Action(Refresh));
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
			Enabled = false;
		}
	}
	internal class GordionFixer
	{
		internal static void Apply()
		{
			if (((Object)StartOfRound.Instance.currentLevel).name != "CompanyBuildingLevel")
			{
				return;
			}
			GameObject obj = GameObject.Find("/Environment/Map");
			Transform val = ((obj != null) ? obj.transform : null);
			string[] array = new string[17]
			{
				"CompanyPlanet/Cube/Colliders/Cube", "CompanyPlanet/Cube/Colliders/Cube (2)", "CompanyPlanet/Cube/Colliders/Cube (3)", "CompanyPlanet/Cube.003", "CompanyPlanet/Cube.005", "CompanyPlanet/Elbow Joint.001", "ShippingContainers/ShippingContainer", "ShippingContainers/ShippingContainer (1)", "ShippingContainers/ShippingContainer (2)", "ShippingContainers/ShippingContainer (3)",
				"ShippingContainers/ShippingContainer (4)", "ShippingContainers/ShippingContainer (5)", "ShippingContainers/ShippingContainer (6)", "ShippingContainers/ShippingContainer (7)", "ShippingContainers/ShippingContainer (8)", "ShippingContainers/ShippingContainer (9)", "ShippingContainers/ShippingContainer (10)"
			};
			Renderer val3 = default(Renderer);
			foreach (string text in array)
			{
				Transform val2 = val.Find(text);
				if ((Object)(object)val2 != (Object)null)
				{
					if (((Component)val2).gameObject.layer == 11 && ((Component)val2).TryGetComponent<Renderer>(ref val3))
					{
						val3.enabled = false;
					}
					((Component)val2).gameObject.layer = 8;
				}
			}
		}
	}
}
namespace Chameleon.Info
{
	internal enum CavernType
	{
		Vanilla = -1,
		Ice,
		Amethyst,
		Desert,
		Mesa,
		Gravel,
		Salt,
		Slate
	}
	internal class CavernInfo
	{
		internal string tag;

		internal string smallRockMat;

		internal bool waterColor;

		internal Color waterColorShallow = new Color(0.3018868f, 0.24540168f, 0.22926308f, 0.972549f);

		internal Color waterColorDeep = new Color(27f / 106f, 0.2132654f, 0.17181382f, 84f / 85f);

		internal bool noDrips;

		internal bool noRockMat;

		internal Color rockColor;

		internal float rockNormals = 1f;
	}
	internal static class DoorLightPalette
	{
		internal static readonly Color DEFAULT_BACKGROUND = new Color(0.490566f, 0.4165709f, 0.3355286f);

		internal static readonly Color BLIZZARD_BACKGROUND = new Color(0.4845f, 0.4986666f, 0.51f);

		internal static readonly Color AMETHYST_BACKGROUND = new Color(0.4901961f, 0.3714178f, 0.3578431f);

		internal static readonly Color ECLIPSE_BACKGROUND = new Color(0.4901961f, 0.3336095f, 23f / 102f);

		internal static readonly Color CLOUDY_BACKGROUND = new Color(0.3f, 0.3f, 0.33f);

		internal static readonly Color FOGGY_BACKGROUND = new Color(0.42f, 0.42f, 0.42f);
	}
	internal class LevelCosmeticInfo
	{
		internal string doorsContainerPath = "/Environment/OutsideEntranceVisualDoorsContainer";

		internal string framePath = "/Environment/DoorFrame (1)";

		internal string planePath = "/Environment/Plane";

		internal Vector3 fancyDoorPos;

		internal Quaternion fancyDoorRot;

		internal Color doorLightColor = DoorLightPalette.DEFAULT_BACKGROUND;

		internal Color doorLightColorFoggy = DoorLightPalette.FOGGY_BACKGROUND;
	}
	internal class Queries
	{
		internal static bool IsSnowLevel()
		{
			if (StartOfRound.Instance.currentLevel.levelIncludesSnowFootprints)
			{
				if (!((Object)(object)Common.artificeBlizzard == (Object)null))
				{
					return Common.artificeBlizzard.activeSelf;
				}
				return true;
			}
			return false;
		}

		internal static bool IsCameraInside()
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return false;
			}
			if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				return GameNetworkManager.Instance.localPlayerController.isInsideFactory;
			}
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)
			{
				return GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript.isInsideFactory;
			}
			return false;
		}

		internal static bool IsMineshaft()
		{
			if (!(Common.interior == "Level3Flow"))
			{
				return Common.interior == "Level3ButCoolFlow";
			}
			return true;
		}
	}
	internal static class VanillaLevelsInfo
	{
		internal static Dictionary<string, LevelCosmeticInfo> predefinedLevels = new Dictionary<string, LevelCosmeticInfo>
		{
			{
				"ExperimentationLevel",
				new LevelCosmeticInfo
				{
					framePath = null,
					planePath = "/Environment/OutsideEntranceVisualDoorsContainer/Plane",
					fancyDoorPos = new Vector3(-113.911f, 2.895f, -17.67f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 0f)
				}
			},
			{
				"AssuranceLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(135.249f, 6.452f, 74.49f),
					fancyDoorRot = Quaternion.Euler(-90f, 180f, 0f)
				}
			},
			{
				"VowLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-29.279f, -1.29f, 151.06f),
					fancyDoorRot = Quaternion.Euler(-90f, 90f, 0f)
				}
			},
			{
				"OffenseLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(128.929f, 16.35f, -53.734f),
					fancyDoorRot = Quaternion.Euler(-90f, 180f, -73.60001f)
				}
			},
			{
				"MarchLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-109.93f, -1.82f, 21.275f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 0f),
					doorLightColor = new Color(0.4901961f, 0.4693464f, 32f / 85f)
				}
			},
			{
				"AdamanceLevel",
				new LevelCosmeticInfo
				{
					planePath = "/Environment/Teleports/EntranceTeleportA/Plane",
					fancyDoorPos = new Vector3(-122.032f, 1.83f, -3.617f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 0f),
					doorLightColor = DoorLightPalette.AMETHYST_BACKGROUND,
					doorLightColorFoggy = new Color(0.502183f, 0.4547059f, 0.5882353f)
				}
			},
			{
				"EmbrionLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-195.47f, 6.46f, -7.83f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 39.517f),
					doorLightColor = DoorLightPalette.AMETHYST_BACKGROUND
				}
			},
			{
				"RendLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(50.545f, -16.822502f, -152.71658f),
					fancyDoorRot = Quaternion.Euler(-90f, 180f, 64.342f),
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND
				}
			},
			{
				"DineLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-120.671f, -16.747f, -4.888f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 76.217f),
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND
				}
			},
			{
				"TitanLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-35.877f, 47.58f, 8.939f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 35.333f),
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND,
					doorLightColorFoggy = new Color(0.3921569f, 32f / 85f, 0.4705882f)
				}
			},
			{
				"ArtificeLevel",
				new LevelCosmeticInfo
				{
					doorsContainerPath = "/Environment/MainFactory/OutsideEntranceVisualDoorsContainer",
					framePath = "/Environment/MainFactory/DoorFrame (1)",
					planePath = "/Environment/MainFactory/Plane",
					fancyDoorPos = new Vector3(52.32f, -0.665f, -156.135f),
					fancyDoorRot = Quaternion.Euler(-90f, -90f, 0f)
				}
			}
		};

		internal static Dictionary<CavernType, CavernInfo> predefinedCaverns = new Dictionary<CavernType, CavernInfo>
		{
			{
				CavernType.Ice,
				new CavernInfo
				{
					tag = "Snow",
					waterColor = true,
					waterColorShallow = new Color(0f, 0.18982977f, 0.20754719f, 0.972549f),
					waterColorDeep = new Color(0.12259702f, 0.1792453f, 0.16491137f, 84f / 85f),
					smallRockMat = "CaveRocks1 1"
				}
			},
			{
				CavernType.Amethyst,
				new CavernInfo
				{
					noDrips = true,
					waterColor = true,
					waterColorShallow = new Color(0.2509804f, 0.2627451f, 0.2784314f, 0.972549f),
					waterColorDeep = new Color(14f / 85f, 0.14901961f, 0.17254902f, 84f / 85f)
				}
			},
			{
				CavernType.Desert,
				new CavernInfo
				{
					noDrips = true
				}
			},
			{
				CavernType.Mesa,
				new CavernInfo
				{
					tag = "Gravel"
				}
			},
			{
				CavernType.Gravel,
				new CavernInfo
				{
					tag = "Gravel",
					waterColor = true,
					waterColorShallow = new Color(0.2f, 0.2f, 0.2f, 0.972549f),
					waterColorDeep = new Color(0.15f, 0.15f, 0.15f, 84f / 85f)
				}
			},
			{
				CavernType.Salt,
				new CavernInfo
				{
					noRockMat = true,
					rockColor = new Color(0.827451f, 64f / 85f, 35f / 51f),
					rockNormals = 0.7f,
					waterColor = true,
					waterColorShallow = new Color(0.4313725f, 0.3843137f, 0.2156862f, 0.972549f),
					waterColorDeep = new Color(0.2980392f, 0.2313725f, 0.1294117f, 84f / 85f)
				}
			},
			{
				CavernType.Slate,
				new CavernInfo
				{
					noRockMat = true,
					rockColor = new Color(209f / (326f * MathF.E), 209f / (326f * MathF.E), 209f / (326f * MathF.E)),
					waterColor = true,
					waterColorShallow = new Color(0.254902f, 0.2627451f, 0.2901961f, 0.972549f),
					waterColorDeep = new Color(0.0627451f, 0.1372549f, 0.145098f, 84f / 85f)
				}
			}
		};

		internal static Dictionary<WindowType, WindowInfo> windowVariants = new Dictionary<WindowType, WindowInfo>
		{
			{
				WindowType.Canyon,
				new WindowInfo
				{
					lightTemp = 5500f
				}
			},
			{
				WindowType.Snowy,
				new WindowInfo()
			},
			{
				WindowType.Beach,
				new WindowInfo
				{
					lightTemp = 5835f
				}
			},
			{
				WindowType.Flowery,
				new WindowInfo
				{
					lightTemp = 8000f,
					filterColor = new Color(0.8862745f, 1f, 0.9137255f)
				}
			},
			{
				WindowType.HotSprings,
				new WindowInfo
				{
					lightTemp = 5500f
				}
			},
			{
				WindowType.BrokenScreen,
				new WindowInfo
				{
					lightTemp = 6500f,
					blackWhenOff = true
				}
			}
		};
	}
	internal enum WindowType
	{
		Pasture = -1,
		Canyon,
		Snowy,
		Flowery,
		Beach,
		HotSprings,
		BrokenScreen
	}
	internal class WindowInfo
	{
		internal float lightTemp = 8335f;

		internal Color filterColor = Color.white;

		internal bool blackWhenOff;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T