Decompiled source of InteriorFogConfig v1.1.0

Tomatobird.InteriorFogConfig.dll

Decompiled 17 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using InteriorFogConfig.Extensions;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.InteriorFogConfig")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+ec6eec0362c2a73e3fb55b8ffa552af8290ff763")]
[assembly: AssemblyProduct("InteriorFogConfig")]
[assembly: AssemblyTitle("Tomatobird.InteriorFogConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 InteriorFogConfig
{
	[BepInPlugin("Tomatobird.InteriorFogConfig", "InteriorFogConfig", "1.1.0")]
	public class InteriorFogConfig : BaseUnityPlugin
	{
		public static ConfigEntry<int> fogThinness;

		public static ConfigEntry<bool> randomFogThinness;

		public static ConfigEntry<int> minThinness;

		public static ConfigEntry<int> maxThinness;

		public static ConfigEntry<bool> changeFogColor;

		public static ConfigEntry<string> fogColor;

		public static InteriorFogConfig Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			fogThinness = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FogThinness", 5, "Control the density of the fog. Higher values make fog thinner. Ignored if RandomFogThinness is used.");
			randomFogThinness = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RandomFogThinness", false, "Make the density of the fog random per each round. Note that this isn't network synchronized and in multiplayer players will see different fog density.");
			minThinness = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinThinness", 3, "Minimum thinness of the fog. The densest the fog will get. Inclusive.");
			maxThinness = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxThinness", 8, "Maximum thinness of the fog. The least dense the fog will get. Exclusive. Set this higher than MinThinness");
			changeFogColor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ChangeFogColor", false, "Should the mod also change the color of the fog?");
			fogColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FogColor", "#261710FF", "Color of the interior fog.");
			Patch();
			Logger.LogInfo((object)"Tomatobird.InteriorFogConfig v1.1.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.InteriorFogConfig");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.InteriorFogConfig";

		public const string PLUGIN_NAME = "InteriorFogConfig";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace InteriorFogConfig.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManagerPatch
	{
		[HarmonyPatch("RefreshEnemiesList")]
		[HarmonyPostfix]
		private static void ApplyNewFogValues(RoundManager __instance)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.indoorFog == (Object)null)
			{
				return;
			}
			if (InteriorFogConfig.randomFogThinness.Value)
			{
				Random random = new Random(StartOfRound.Instance.randomMapSeed + 69);
				float meanFreePath = random.NextFloat(InteriorFogConfig.minThinness.Value, InteriorFogConfig.maxThinness.Value);
				InteriorFogConfig.Logger.LogInfo((object)("Random fog thinness value: " + meanFreePath));
				__instance.indoorFog.parameters.meanFreePath = meanFreePath;
			}
			else
			{
				__instance.indoorFog.parameters.meanFreePath = InteriorFogConfig.fogThinness.Value;
			}
			if (InteriorFogConfig.changeFogColor.Value)
			{
				Color albedo = default(Color);
				if (!ColorUtility.TryParseHtmlString(InteriorFogConfig.fogColor.Value, ref albedo))
				{
					return;
				}
				__instance.indoorFog.parameters.albedo = albedo;
			}
			InteriorFogConfig.Logger.LogInfo((object)"Indoor fog changes done.");
		}
	}
}
namespace InteriorFogConfig.Extensions
{
	public static class RandomExtensions
	{
		public static T NextEnum<T>(this Random random) where T : struct, Enum
		{
			Array values = Enum.GetValues(typeof(T));
			return (T)values.GetValue(random.Next(values.Length));
		}

		public static T NextItem<T>(this Random random, List<T> collection)
		{
			int index = random.Next(collection.Count);
			return collection[index];
		}

		public static T NextItem<T>(this Random random, T[] collection)
		{
			int num = random.Next(collection.Length);
			return collection[num];
		}

		public static double NextDouble(this Random random, double min, double max)
		{
			return random.NextDouble() * (max - min) + min;
		}

		public static float NextFloat(this Random random, float min, float max)
		{
			return (float)random.NextDouble(min, max);
		}

		public static bool NextBool(this Random random)
		{
			return random.Next(2) == 0;
		}

		public static int NextSign(this Random random)
		{
			return random.NextBool() ? 1 : (-1);
		}

		public static Quaternion NextQuaternion(this Random random)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			return Quaternion.Euler(random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), random.NextFloat(0f, 360f));
		}
	}
}