Decompiled source of Chameleon v2.1.0

Chameleon.dll

Decompiled a day 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 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("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.1.0.0")]
[assembly: AssemblyInformationalVersion("2.1.0+cd97bffb76bf77e055b8cca73e0615bdf64152c3")]
[assembly: AssemblyProduct("Chameleon")]
[assembly: AssemblyTitle("Chameleon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.0.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 string interior;

		internal static LevelCosmeticInfo currentLevelCosmeticInfo;

		internal static GameObject artificeBlizzard;

		private static BreakerBox breakerBox;

		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()
		{
			object obj;
			if (!(((Object)StartOfRound.Instance.currentLevel).name != "CompanyBuildingLevel"))
			{
				obj = string.Empty;
			}
			else
			{
				RoundManager instance = RoundManager.Instance;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					RuntimeDungeon dungeonGenerator = instance.dungeonGenerator;
					if (dungeonGenerator == null)
					{
						obj = null;
					}
					else
					{
						DungeonGenerator generator = dungeonGenerator.Generator;
						if (generator == null)
						{
							obj = null;
						}
						else
						{
							DungeonFlow dungeonFlow = generator.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");
				}
			}
		}

		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 + "\""));
				}
			}
			Plugin.Logger.LogDebug((object)"Now assembling final weighted lists");
			AssembleWeightedList(ref RetextureCaverns.cavernWeightLists, ref Configuration.cavernMappings);
			AssembleWeightedList(ref ManorWindows.windowWeightLists, ref Configuration.windowMappings);
		}

		private static void AssembleWeightedList(ref Dictionary<string, IntWithRarity[]> weightLists, ref List<Configuration.MoonTypeMapping> mappings)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)))
					{
						list.Add(new IntWithRarity
						{
							id = item.type,
							rarity = item.weight
						});
						Plugin.Logger.LogDebug((object)$"{((Object)level).name} - {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> fancyEntranceDoors;

		internal static ConfigEntry<bool> recolorRandomRocks;

		internal static ConfigEntry<bool> doorLightColors;

		internal static ConfigEntry<bool> rainyMarch;

		internal static ConfigEntry<bool> eclipsesBlockMusic;

		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> fancyShrouds;

		internal static ConfigEntry<bool> fogReprojection;

		internal static ConfigEntry<bool> fixTitanVolume;

		internal static ConfigEntry<bool> fixArtificeVolume;

		internal static ConfigEntry<GordionStorms> stormyGordion;

		internal static ConfigEntry<FogQuality> fogQuality;

		internal static ConfigEntry<float> weatherAmbience;

		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.");
			fancyShrouds = configFile.Bind<bool>("Rendering", "FancyShrouds", true, "Applies FancyFoliage's changes to Vain Shrouds as well. (Really puts the \"vain\" in Vain Shrouds.)");
			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()
		{
			fancyEntranceDoors = configFile.Bind<bool>("Exterior", "FancyEntranceDoors", true, "Changes the front doors to match how they look on the inside when a manor interior generates. (Works for ONLY vanilla levels!)");
			recolorRandomRocks = configFile.Bind<bool>("Exterior", "RecolorRandomRocks", true, "Recolors the randomly spawning sandstone boulders to blend in better with different types of moons.");
			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.");
			eclipsesBlockMusic = configFile.Bind<bool>("Exterior", "EclipsesBlockMusic", true, "Prevents the morning/afternoon ambience music from playing during Eclipsed weather, which has its own ambient track.");
			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.5f, 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.");
			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.)" + ((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);
			}
		}

		private static void PopulateGlobalListWithType(int type, string customList, ref List<MoonTypeMapping> mappings, string listName)
		{
			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)
						{
							MoonTypeMapping moonTypeMapping = default(MoonTypeMapping);
							moonTypeMapping.moon = array2[0].ToLower();
							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 \"{item.type}\" 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:87");
			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, "Artifice:13");
			autoAdaptSnow = configFile.Bind<bool>("Interior.Mineshaft", "AutoAdaptSnow", true, "Automatically enable ice caverns on modded levels that are snowy.\nIf you have Artifice Blizzard installed, this will also change the caverns to ice specifically when the blizzard is active.");
		}

		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.)" + ((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);
			}
		}

		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);
			}
			if (fancyShrouds.Value)
			{
				if (!configFile.Bind<bool>("Exterior", "FancyShrouds", true, "Legacy setting, doesn't work").Value)
				{
					fancyShrouds.Value = false;
				}
				configFile.Remove(configFile["Exterior", "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.Save();
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.chameleon", "Chameleon", "2.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "butterystancakes.lethalcompany.chameleon";

		private const string PLUGIN_NAME = "Chameleon";

		private const string PLUGIN_VERSION = "2.1.0";

		internal static ManualLogSource Logger;

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

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			if (Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.artificeblizzard"))
			{
				Common.INSTALLED_ARTIFICE_BLIZZARD = true;
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Artifice Blizzard 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.1.0 loaded");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Chameleon";

		public const string PLUGIN_NAME = "Chameleon";

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

		private static Texture giantSnowy;

		private static Texture giantBurnt;

		[HarmonyPatch(typeof(ForestGiantAI), "Start")]
		[HarmonyPostfix]
		private static void ForestGiantAIPostStart(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).material.mainTexture;
				}
				((Renderer)val).material.mainTexture = giantSnowy;
			}
			Plugin.Logger.LogDebug((object)"Forest Keeper: Snow \"camouflage\"");
		}

		[HarmonyPatch(typeof(EnemyAI), "SwitchToBehaviourStateOnLocalClient")]
		[HarmonyPostfix]
		private static void PostSwitchToBehaviourStateOnLocalClient(EnemyAI __instance, int stateIndex)
		{
			if (__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 ForestGiantAIPostKillEnemy(ForestGiantAI __instance, float ___timeAtStartOfBurning)
		{
			if (Configuration.giantSkins.Value && (Object)(object)giantBurnt != (Object)null && ___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]
	internal class FoliagePatches
	{
		[HarmonyPatch(typeof(FoliageDetailDistance), "Start")]
		[HarmonyPostfix]
		private static void FoliageDetailDistancePostStart(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(typeof(MoldSpreadManager), "Start")]
		[HarmonyPostfix]
		private static void MoldSpreadManagerPostStart(MoldSpreadManager __instance)
		{
			if (Configuration.fancyShrouds.Value)
			{
				FoliageDiffuser.ApplyToRenderers(from rend in __instance.moldPrefab.GetComponentsInChildren<Renderer>()
					where ((Component)rend).gameObject.layer != 22
					select rend);
			}
		}
	}
	[HarmonyPatch]
	internal class GeneralPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void StartOfRoundPostStart()
		{
			Common.BuildWeightLists();
		}

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void PostFinishGeneratingNewLevelClientRpc(RoundManager __instance)
		{
			SceneOverrides.OverrideScene();
		}

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

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

		[HarmonyPatch(typeof(SoundManager), "PlayRandomOutsideMusic")]
		[HarmonyPrefix]
		private static bool PrePlayRandomOutsideMusic(SoundManager __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			if (Configuration.eclipsesBlockMusic.Value)
			{
				return (int)StartOfRound.Instance.currentLevel.currentWeather != 5;
			}
			return true;
		}

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

		[HarmonyPatch(typeof(RoundManager), "Update")]
		[HarmonyPostfix]
		private static void RoundManagerPostUpdate(RoundManager __instance)
		{
			if (__instance.powerOffPermanently)
			{
				BreakerBoxShutdown.ShutOff();
			}
		}
	}
	[HarmonyPatch]
	internal 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 StartOfRoundPostAwake(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 StartOfRoundPostLateUpdate(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 PostEndPlayersFiredSequenceClientRpc(StartOfRound __instance)
		{
			if ((Object)(object)sunlight != (Object)null)
			{
				((Behaviour)sunlight).enabled = true;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ChangePlanet")]
		[HarmonyPostfix]
		private static void PostChangePlanet(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")
			{
				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;
				}
			}
			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 && ((((Object)item.sharedMaterial).name.StartsWith("FancyManorTex") && (Object)(object)((Component)item).GetComponentInChildren<InteractTrigger>() != (Object)null) || ((Object)item.sharedMaterial).name.StartsWith("DoorWood")))
				{
					item.sharedMaterial.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 void Apply()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.fancyEntranceDoors.Value || ((Object)StartOfRound.Instance.currentLevel).name == "CompanyBuildingLevel" || Common.currentLevelCosmeticInfo == null)
			{
				return;
			}
			if (!string.IsNullOrEmpty(Common.currentLevelCosmeticInfo.planePath))
			{
				GameObject obj = GameObject.Find(Common.currentLevelCosmeticInfo.planePath);
				Transform val = ((obj != null) ? obj.transform : null);
				if ((Object)(object)val != (Object)null)
				{
					val.localPosition += Common.currentLevelCosmeticInfo.planeOffset;
					val.localScale = new Vector3(val.localScale.x + 0.047f, val.localScale.y, val.localScale.z + 0.237f);
					if ((Object)(object)Common.black != (Object)null)
					{
						((Component)val).GetComponent<Renderer>().sharedMaterial = Common.black;
					}
				}
			}
			if (string.IsNullOrEmpty(Common.interior) || (Common.interior != "Level2Flow" && Common.interior != "SDMLevel"))
			{
				return;
			}
			GameObject val2 = GameObject.Find(Common.currentLevelCosmeticInfo.fakeDoor1Path);
			GameObject val3 = GameObject.Find(Common.currentLevelCosmeticInfo.fakeDoor2Path);
			object obj3;
			if (!string.IsNullOrEmpty(Common.currentLevelCosmeticInfo.framePath))
			{
				GameObject obj2 = GameObject.Find(Common.currentLevelCosmeticInfo.framePath);
				obj3 = ((obj2 != null) ? obj2.transform : null);
			}
			else
			{
				obj3 = null;
			}
			Transform val4 = (Transform)obj3;
			if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (!string.IsNullOrEmpty(Common.currentLevelCosmeticInfo.framePath) && (Object)(object)val4 == (Object)null))
			{
				Plugin.Logger.LogWarning((object)"\"FancyEntranceDoors\" skipped because some GameObjects were missing.");
				return;
			}
			GameObject val5;
			try
			{
				AssetBundle obj4 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "fancyentrancedoors"));
				val5 = obj4.LoadAsset<GameObject>("WideDoorFrame");
				obj4.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)
			{
				Plugin.Logger.LogWarning((object)"\"FancyEntranceDoors\" skipped because fancy door asset was 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)"\"FancyEntranceDoors\" skipped because disposable prop container did not exist in scene.");
				return;
			}
			val2.SetActive(false);
			val3.SetActive(false);
			Transform transform = Object.Instantiate<GameObject>(val5, Common.currentLevelCosmeticInfo.fancyDoorPos, Common.currentLevelCosmeticInfo.fancyDoorRot, RoundManager.Instance.mapPropsContainer.transform).transform;
			if (Common.currentLevelCosmeticInfo.fancyDoorScalar != Vector3.one)
			{
				transform.localScale = Vector3.Scale(transform.localScale, Common.currentLevelCosmeticInfo.fancyDoorScalar);
			}
			if ((Object)(object)val4 != (Object)null)
			{
				val4.localScale = new Vector3(val4.localScale.x, val4.localScale.y + 0.05f, val4.localScale.z);
			}
		}
	}
	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(RockRecolorer.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;
			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 DiffusionProfile foliageDiffusionProfile;

		private static float foliageDiffusionProfileHash;

		internal static void ApplyToScene()
		{
			if (Configuration.fancyFoliage.Value)
			{
				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));
				}
			}
		}

		internal static void ApplyToRenderers(IEnumerable<Renderer> renderers)
		{
			if (!GetReferences())
			{
				return;
			}
			foreach (Renderer renderer in renderers)
			{
				Material sharedMaterial = renderer.sharedMaterial;
				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"));
				}
				Plugin.Logger.LogDebug((object)("Applied foliage diffusion to \"" + ((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");
					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.StartsWith("ForestTexture") && !((Object)rend.sharedMaterial).name.StartsWith("TreeFlat"))
				{
					return ((Object)rend.sharedMaterial).name.StartsWith("Leaves");
				}
				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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Invalid comparison between Unknown and I4
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.doorLightColors.Value || string.IsNullOrEmpty(Common.interior) || Common.interior == "Level2Flow")
			{
				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 ((int)StartOfRound.Instance.currentLevel.currentWeather == 3)
				{
					doorLightColor = DoorLightPalette.FOGGY_BACKGROUND;
				}
				else if (Queries.IsSnowLevel())
				{
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND;
				}
				else if (Common.currentLevelCosmeticInfo != null)
				{
					doorLightColor = Common.currentLevelCosmeticInfo.doorLightColor;
				}
				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
	{
		internal static Dictionary<string, IntWithRarity[]> windowWeightLists = new Dictionary<string, IntWithRarity[]>();

		private static Material fakeWindowOn = null;

		private static Material fakeWindowOff = null;

		private static List<(Renderer room, Light light)> windowTiles = new List<(Renderer, Light)>();

		internal static void Apply()
		{
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(Common.interior) || Common.interior != "Level2Flow")
			{
				return;
			}
			GameObject val = GameObject.Find("/Systems/LevelGeneration/LevelGenerationRoot");
			if ((Object)(object)val == (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 val2 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "windowvariants"));
				if (currentMoonWindows != WindowType.Pasture)
				{
					fakeWindowOn = val2.LoadAsset<Material>($"FakeWindowView{currentMoonWindows}");
					fakeWindowOff = ((value != null && !value.blackWhenOff) ? val2.LoadAsset<Material>($"FakeWindowView{currentMoonWindows}Off") : null);
				}
				else
				{
					fakeWindowOn = null;
					fakeWindowOff = val2.LoadAsset<Material>("FakeWindowViewOff");
				}
				val2.Unload(false);
			}
			catch
			{
				Plugin.Logger.LogError((object)"Encountered some error loading assets from bundle \"windowvariants\". Did you install the plugin correctly?");
				fakeWindowOn = null;
			}
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren)
			{
				if (!((Object)((Component)val3).transform.parent).name.StartsWith("WindowTile") || !(((Object)val3).name == "mesh") || val3.sharedMaterials.Length <= 5)
				{
					continue;
				}
				Material obj2 = val3.sharedMaterials[5];
				if (!(((obj2 != null) ? ((Object)obj2).name : null) == "FakeWindowView"))
				{
					continue;
				}
				if ((Object)(object)fakeWindowOn == (Object)null)
				{
					fakeWindowOn = val3.sharedMaterials[5];
				}
				Transform obj3 = ((Component)val3).transform.parent.Find("ScreenLight");
				Light val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<Light>() : null);
				if ((Object)(object)val4 != (Object)null)
				{
					if (value != null)
					{
						val4.colorTemperature = value.lightTemp;
						val4.color = value.filterColor;
					}
					windowTiles.Add((val3, val4));
					Plugin.Logger.LogDebug((object)"Cached window tile instance");
				}
			}
			if (windowTiles.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()
		{
			windowTiles.Clear();
			fakeWindowOn = null;
			fakeWindowOff = null;
			SceneOverrides.resetOverrides = (Action)Delegate.Remove(SceneOverrides.resetOverrides, new Action(Reset));
		}

		internal static void ToggleAll(bool powered)
		{
			if (windowTiles.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 (var windowTile in windowTiles)
			{
				Renderer item = windowTile.room;
				Light item2 = windowTile.light;
				Material[] sharedMaterials = item.sharedMaterials;
				sharedMaterials[5] = (powered ? fakeWindowOn : (fakeWindowOff ?? Common.black));
				item.sharedMaterials = sharedMaterials;
				((Behaviour)item2).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 vanilla windows)");
					}
				}
				else
				{
					Plugin.Logger.LogWarning((object)"An error occurred indexing a random window type. This shouldn't happen! (Falling back to vanilla windows)");
				}
			}
			else
			{
				Plugin.Logger.LogDebug((object)"No custom window weights were defined for the current moon. Falling back to vanilla windows");
			}
			return WindowType.Pasture;
		}
	}
	internal class RetextureCaverns
	{
		internal static Dictionary<string, IntWithRarity[]> cavernWeightLists = new Dictionary<string, IntWithRarity[]>();

		internal static void Apply()
		{
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(Common.interior) || Common.interior != "Level3Flow")
			{
				return;
			}
			CavernType currentMoonCaverns = GetCurrentMoonCaverns();
			if (currentMoonCaverns == CavernType.Vanilla)
			{
				return;
			}
			string text = currentMoonCaverns.ToString().ToLower() + "cave";
			Material val = null;
			Material val2 = null;
			try
			{
				AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), text));
				val = obj.LoadAsset<Material>("CaveRocks1");
				val2 = obj.LoadAsset<Material>("CoalMat");
				obj.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;
			}
			GameObject val3 = GameObject.Find("/Systems/LevelGeneration/LevelGenerationRoot");
			if ((Object)(object)val3 == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Skipping mineshaft retexture because there was an error finding the dungeon object tree.");
				return;
			}
			VanillaLevelsInfo.predefinedCaverns.TryGetValue(currentMoonCaverns, out var value);
			if (value == null)
			{
				Plugin.Logger.LogWarning((object)"Skipping mineshaft retexture because there was an error finding cavern specifications.");
				return;
			}
			Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>();
			foreach (Renderer val4 in componentsInChildren)
			{
				if (((Object)val4).name == "MineshaftStartTileMesh")
				{
					Material[] materials = val4.materials;
					materials[3] = val;
					val4.materials = materials;
				}
				else
				{
					if (!((Object)(object)val4.sharedMaterial != (Object)null))
					{
						continue;
					}
					if (((Object)val4.sharedMaterial).name.StartsWith(((Object)val).name))
					{
						val4.material = val;
						if (((Component)val4).CompareTag("Rock") && !string.IsNullOrEmpty(value.tag))
						{
							((Component)val4).tag = value.tag;
						}
					}
					else if (value.waterColor && ((Object)val4).name == "Water (1)" && ((Object)val4.sharedMaterial).name.StartsWith("CaveWater"))
					{
						val4.material.SetColor("Color_6a9a916e2c84442984edc20c082efe79", value.waterColorShallow);
						val4.sharedMaterial.SetColor("Color_c9a840f2115c4802ba54d713194f761d", value.waterColorDeep);
					}
					else if ((Object)(object)val2 != (Object)null && ((Object)val4.sharedMaterial).name.StartsWith(((Object)val2).name))
					{
						val4.material = val2;
					}
				}
			}
			if (!value.noDrips)
			{
				return;
			}
			LocalPropSet[] componentsInChildren2 = val3.GetComponentsInChildren<LocalPropSet>();
			foreach (LocalPropSet val5 in componentsInChildren2)
			{
				if (((Object)val5).name.StartsWith("WaterDrips"))
				{
					((Component)val5).gameObject.SetActive(false);
					Plugin.Logger.LogDebug((object)"Disabled water drips");
				}
			}
		}

		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 ice caverns");
				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;
		}
	}
	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()
		{
			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 || Common.interior != "Level3Flow"))
					{
						num2 *= 0.85f;
					}
					num2 = ((!(Common.interior == "Level3Flow") || !((Object)(object)rainInside.clip != (Object)(object)backgroundFlood)) ? (num2 * 0.84f) : (num2 * 0.7f));
					if (num)
					{
						blizzardInside.volume = num2;
						if (!blizzardInside.isPlaying && (Object)(object)blizzardInside.clip != (Object)null)
						{
							blizzardInside.Play();
						}
					}
					if ((Object)(object)rainInside.clip != (Object)null)
					{
						rainInside.volume = num2;
						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[30]
			{
				"CompanyPlanet/Cube", "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)", "CompanyPlanet/CatwalkChunk", "CompanyPlanet/CatwalkChunk.001",
				"CompanyPlanet/CatwalkStairTile", "CompanyPlanet/Cylinder", "CompanyPlanet/Cylinder.001", "CompanyPlanet/LargePipeSupportBeam", "CompanyPlanet/LargePipeSupportBeam.001", "CompanyPlanet/LargePipeSupportBeam.002", "CompanyPlanet/LargePipeSupportBeam.003", "CompanyPlanet/Scaffolding", "CompanyPlanet/Scaffolding.001", "GiantDrill/DrillMainBody"
			};
			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;
				}
			}
		}
	}
	internal class RockRecolorer
	{
		private static readonly Color ROCK_GRAY = new Color(209f / (326f * MathF.E), 209f / (326f * MathF.E), 209f / (326f * MathF.E));

		internal static void Apply()
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.recolorRandomRocks.Value || ((Object)StartOfRound.Instance.currentLevel).name == "CompanyBuildingLevel")
			{
				return;
			}
			bool flag = Queries.IsSnowLevel();
			bool flag2 = !flag && Common.currentLevelCosmeticInfo != null && Common.currentLevelCosmeticInfo.grayRocks;
			if (!flag && !flag2)
			{
				return;
			}
			object obj;
			if (!(((Object)StartOfRound.Instance.currentLevel).name == "EmbrionLevel"))
			{
				obj = null;
			}
			else
			{
				GameObject obj2 = GameObject.Find("/Environment/LargeRock3/rock.012 (2)");
				if (obj2 == null)
				{
					obj = null;
				}
				else
				{
					Renderer component = obj2.GetComponent<Renderer>();
					obj = ((component != null) ? component.sharedMaterial : null);
				}
			}
			Material val = (Material)obj;
			Random random = new Random(StartOfRound.Instance.randomMapSeed);
			if ((Object)(object)RoundManager.Instance.mapPropsContainer == (Object)null)
			{
				RoundManager.Instance.mapPropsContainer = GameObject.FindGameObjectWithTag("MapPropsContainer");
			}
			if (!((Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null))
			{
				return;
			}
			foreach (Transform item in RoundManager.Instance.mapPropsContainer.transform)
			{
				Transform val2 = item;
				if (!((Object)val2).name.StartsWith("LargeRock"))
				{
					continue;
				}
				bool flag3 = random.NextDouble() <= 0.6000000238418579;
				Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>();
				foreach (Renderer val3 in componentsInChildren)
				{
					if (flag)
					{
						val3.material.SetTexture("_MainTex", (Texture)null);
						val3.sharedMaterial.SetTexture("_BaseColorMap", (Texture)null);
					}
					else if (flag2)
					{
						if ((Object)(object)val != (Object)null && flag3)
						{
							val3.sharedMaterial = val;
							continue;
						}
						val3.material.SetTexture("_MainTex", (Texture)null);
						val3.sharedMaterial.SetTexture("_BaseColorMap", (Texture)null);
						val3.sharedMaterial.SetColor("_Color", ROCK_GRAY);
						val3.sharedMaterial.SetColor("_BaseColor", ROCK_GRAY);
						val3.sharedMaterial.SetFloat("_NormalScale", 0.95f);
					}
				}
			}
		}
	}
}
namespace Chameleon.Info
{
	internal enum CavernType
	{
		Vanilla = -1,
		Ice,
		Amethyst,
		Desert,
		Mesa,
		Gravel
	}
	internal class CavernInfo
	{
		internal string tag;

		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 static class DoorLightPalette
	{
		internal static readonly Color DEFAULT_BACKGROUND = new Color(0.490566f, 0.4165709f, 0.3355286f);

		internal static readonly Color WITCHES_BACKGROUND = new Color(0.4901961f, 0.4693464f, 32f / 85f);

		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 fakeDoor1Path = "/Environment/SteelDoorFake";

		internal string fakeDoor2Path = "/Environment/SteelDoorFake (1)";

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

		internal string planePath = "/Environment/Plane";

		internal Vector3 fancyDoorPos;

		internal Quaternion fancyDoorRot;

		internal Vector3 fancyDoorScalar = Vector3.one;

		internal Vector3 planeOffset = new Vector3(0f, -1f, 0f);

		internal Color doorLightColor = DoorLightPalette.DEFAULT_BACKGROUND;

		internal bool grayRocks;
	}
	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 class VanillaLevelsInfo
	{
		internal static Dictionary<string, LevelCosmeticInfo> predefinedLevels = new Dictionary<string, LevelCosmeticInfo>
		{
			{
				"ExperimentationLevel",
				new LevelCosmeticInfo
				{
					fakeDoor1Path = "/Environment/SteelDoor (6)",
					fakeDoor2Path = "/Environment/SteelDoor (5)",
					framePath = null,
					planePath = null,
					fancyDoorPos = new Vector3(-113.911f, 2.895f, -17.67f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 0f),
					fancyDoorScalar = new Vector3(1f, 1.07f, 1f)
				}
			},
			{
				"AssuranceLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(135.249f, 6.452f, 74.49f),
					fancyDoorRot = Quaternion.Euler(-90f, 180f, 0f),
					planeOffset = new Vector3(0f, -1f, -0.075f)
				}
			},
			{
				"VowLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-29.279f, -1.176f, 151.069f),
					fancyDoorRot = Quaternion.Euler(-90f, 90f, 0f),
					planeOffset = new Vector3(0.075f, -1f, 0f),
					grayRocks = true
				}
			},
			{
				"OffenseLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(128.936f, 16.35f, -53.713f),
					fancyDoorRot = Quaternion.Euler(-90f, 180f, -73.621f),
					planeOffset = new Vector3(0f, -1f, 0.027f)
				}
			},
			{
				"MarchLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-158.18f, -3.953f, 21.708f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 0f),
					planeOffset = new Vector3(-0.075f, -1f, 0f),
					grayRocks = true
				}
			},
			{
				"AdamanceLevel",
				new LevelCosmeticInfo
				{
					fakeDoor1Path = "/Environment/Teleports/EntranceTeleportA/SteelDoorFake",
					fakeDoor2Path = "/Environment/Teleports/EntranceTeleportA/SteelDoorFake (1)",
					framePath = "/Environment/Teleports/EntranceTeleportA/DoorFrame (1)",
					planePath = "/Environment/Teleports/EntranceTeleportA/Plane",
					fancyDoorPos = new Vector3(-122.032f, 1.843f, -3.617f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 0f),
					planeOffset = new Vector3(-0.0033637f, -0.069986f, -1.0246016f),
					doorLightColor = DoorLightPalette.WITCHES_BACKGROUND,
					grayRocks = true
				}
			},
			{
				"EmbrionLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-195.47f, 6.357f, -7.83f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 39.517f),
					planeOffset = new Vector3(-0.045f, -1f, -0.05513f),
					doorLightColor = DoorLightPalette.AMETHYST_BACKGROUND,
					grayRocks = true
				}
			},
			{
				"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.70987f, -16.337002f, -4.2681026f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 90.836f),
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND
				}
			},
			{
				"TitanLevel",
				new LevelCosmeticInfo
				{
					fancyDoorPos = new Vector3(-35.877f, 47.64f, 8.939f),
					fancyDoorRot = Quaternion.Euler(-90f, 0f, 35.333f),
					planeOffset = new Vector3(0.03f, -1f, 0.036f),
					doorLightColor = DoorLightPalette.BLIZZARD_BACKGROUND
				}
			},
			{
				"ArtificeLevel",
				new LevelCosmeticInfo
				{
					fakeDoor1Path = "/Environment/MainFactory/SteelDoorFake",
					fakeDoor2Path = "/Environment/MainFactory/SteelDoorFake (1)",
					framePath = "/Environment/MainFactory/DoorFrame (1)",
					planePath = "/Environment/MainFactory/Plane",
					fancyDoorPos = new Vector3(52.32f, -0.665f, -156.146f),
					fancyDoorRot = Quaternion.Euler(-90f, -90f, 0f),
					grayRocks = true
				}
			}
		};

		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)
				}
			},
			{
				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()
			},
			{
				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)
				}
			}
		};

		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)
		{
		}
	}
}
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 item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

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

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

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