Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of InteriorFogConfig v1.2.0
Tomatobird.InteriorFogConfig.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 Unity.Netcode; 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.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+689e9afc08d0199502e2ba19a8bb3a9ced8c847e")] [assembly: AssemblyProduct("InteriorFogConfig")] [assembly: AssemblyTitle("Tomatobird.InteriorFogConfig")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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.2.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", "All:#261710FF", "Color of the interior fog. Set color to all moons example: All:#261710FF. Set color to specific moons by appending moon names to the config: All:#261710FF,Experimentation:#110502FF,Assurance:#21110BFF"); Patch(); Logger.LogInfo((object)"Tomatobird.InteriorFogConfig v1.2.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.2.0"; } } namespace InteriorFogConfig.Patches { [HarmonyPatch(typeof(NetworkManager))] internal static class RegisterNetworkPrefabPatch { private static readonly string MOD_GUID = "Tomatobird.InteriorFogConfig"; [HarmonyPatch("SetSingleton")] [HarmonyPostfix] private static void RegisterPrefab() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } [HarmonyPatch(typeof(RoundManager))] public class RoundManagerPatch { [HarmonyPatch("RefreshEnemiesList")] [HarmonyPostfix] private static void ApplyNewFogValues(RoundManager __instance) { //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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) { Dictionary<string, string> dictionary = (from part in InteriorFogConfig.fogColor.Value.ToLower().Split(',') select part.Split(':') into part where part.Length == 2 select part).ToDictionary((string[] sp) => sp[0], (string[] sp) => sp[1]); string text = new string(new ReadOnlySpan<char>(__instance.currentLevel.PlanetName.ToLower().SkipWhile((char c) => char.IsDigit(c) || char.IsWhiteSpace(c)).ToArray())); InteriorFogConfig.Logger.LogInfo((object)("Current planet name valid for InteriorFogConfig fog color configuration: " + text)); if (!dictionary.TryGetValue(text, out var value)) { InteriorFogConfig.Logger.LogInfo((object)("Color value not found for " + text + ". Using default.")); Color albedo = default(Color); if (!dictionary.TryGetValue("all", out var value2)) { InteriorFogConfig.Logger.LogWarning((object)"Couldn't get color value for specific moon nor default! Please define a color for all in the configuration to edit the fog colors."); } else if (!ColorUtility.TryParseHtmlString(value2, ref albedo)) { InteriorFogConfig.Logger.LogWarning((object)"Default color was defined but failed to be parsed. Check configuration for an example for the syntax."); } else { __instance.indoorFog.parameters.albedo = albedo; } return; } Color albedo2 = default(Color); if (!ColorUtility.TryParseHtmlString(value, ref albedo2)) { InteriorFogConfig.Logger.LogWarning((object)("Moon specific color for " + text + " was defined but failed to be parsed. Check configuration for an example for the syntax.")); return; } __instance.indoorFog.parameters.albedo = albedo2; } 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)); } } }