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 TheFogWeatherSystem v1.0.0
BepInEx/plugins/weatherthefog/TheFogWeatherMod.dll
Decompiled 2 hours agousing 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TheFogWeatherMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TheFogWeatherMod")] [assembly: AssemblyTitle("TheFogWeatherMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 TheFogWeatherSystem { [BepInPlugin("com.kasik.thefogweather", "The Fog Weather System", "1.0.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.kasik.thefogweather").PatchAll(); } } [HarmonyPatch(typeof(StartOfRound))] public class RoundStartPatch { [HarmonyPatch("OnShipLandedMiscEvents")] [HarmonyPostfix] public static void Postfix() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameObject.Find("TheFogEventController") == (Object)null) { new GameObject("TheFogEventController").AddComponent<TheFogEventController>(); } TheFogEventController.Instance.SetupFogEventForToday(); } } public class TheFogEventController : MonoBehaviour { private struct FogWindow { public float startTime; public float endTime; public bool canSpawnMonster; public float fogDensity; } public static TheFogEventController Instance; private bool isEventActiveToday; private bool isFogCurrentlyOn; private bool hasMonsterSpawnedToday; private EnemyType fogMonsterType; private LocalVolumetricFog[] cachedFogs; private List<FogWindow> todaysFogWindows = new List<FogWindow>(); private void Awake() { Instance = this; } public void SetupFogEventForToday() { todaysFogWindows.Clear(); isFogCurrentlyOn = false; hasMonsterSpawnedToday = false; FindTheFogMonster(); cachedFogs = Object.FindObjectsOfType<LocalVolumetricFog>(true); if (!((Object)(object)RoundManager.Instance == (Object)null) && RoundManager.Instance.LevelRandom != null) { Random levelRandom = RoundManager.Instance.LevelRandom; float num = 0.15f; if ((float)levelRandom.NextDouble() <= num) { isEventActiveToday = true; todaysFogWindows.Add(new FogWindow { startTime = 0f, endTime = 0.4f, canSpawnMonster = false, fogDensity = 20f }); float startTime = 0.5f + (float)levelRandom.NextDouble() * 0.029999971f; float endTime = 0.82f + (float)levelRandom.NextDouble() * 0.04000002f; todaysFogWindows.Add(new FogWindow { startTime = startTime, endTime = endTime, canSpawnMonster = true, fogDensity = 2.5f }); } else { isEventActiveToday = false; } } } private void Update() { if (!isEventActiveToday || (Object)(object)TimeOfDay.Instance == (Object)null) { return; } if ((Object)(object)StartOfRound.Instance != (Object)null && (StartOfRound.Instance.shipIsLeaving || !StartOfRound.Instance.shipHasLanded)) { if (isFogCurrentlyOn) { isFogCurrentlyOn = false; ApplyFogDensity(100f); } isEventActiveToday = false; return; } float normalizedTimeOfDay = TimeOfDay.Instance.normalizedTimeOfDay; bool flag = false; FogWindow fogWindow = default(FogWindow); foreach (FogWindow todaysFogWindow in todaysFogWindows) { if (normalizedTimeOfDay >= todaysFogWindow.startTime && normalizedTimeOfDay <= todaysFogWindow.endTime) { flag = true; fogWindow = todaysFogWindow; break; } } if (flag) { ApplyFogDensity(fogWindow.fogDensity); if (isFogCurrentlyOn) { return; } isFogCurrentlyOn = true; if (fogWindow.canSpawnMonster && !hasMonsterSpawnedToday) { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("thefogiscoming", "thefogiscomingthefogiscomingthefogiscoming", true, false, "LC_Tip1"); } if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { SpawnFogMonster(); } hasMonsterSpawnedToday = true; } else if (!fogWindow.canSpawnMonster && (Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("Alert", "Strange fog activity was detected.", true, false, "LC_Tip1"); } } else if (isFogCurrentlyOn) { isFogCurrentlyOn = false; ApplyFogDensity(100f); } } private void ApplyFogDensity(float density) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_006b: Unknown result type (might be due to invalid IL or missing references) if (cachedFogs == null || cachedFogs.Length == 0) { return; } LocalVolumetricFog[] array = cachedFogs; foreach (LocalVolumetricFog val in array) { if (!((Object)(object)val == (Object)null)) { ((Component)val).gameObject.SetActive(true); ((Behaviour)val).enabled = true; val.parameters.meanFreePath = density; if (density < 5f) { val.parameters.albedo = new Color(0.35f, 0.38f, 0.35f); } else { val.parameters.albedo = new Color(0.75f, 0.75f, 0.75f); } } } } private void FindTheFogMonster() { if ((Object)(object)fogMonsterType != (Object)null) { return; } EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>(); foreach (EnemyType val in array) { if (val.enemyName == "TheFog" || ((Object)val).name.Contains("TheFog")) { fogMonsterType = val; break; } } } private void SpawnFogMonster() { //IL_005a: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0092: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)fogMonsterType == (Object)null) && !((Object)(object)RoundManager.Instance == (Object)null) && RoundManager.Instance.outsideAINodes != null && RoundManager.Instance.outsideAINodes.Length != 0) { int num = Random.Range(0, RoundManager.Instance.outsideAINodes.Length); Vector3 position = RoundManager.Instance.outsideAINodes[num].transform.position; Quaternion rotation = RoundManager.Instance.outsideAINodes[num].transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; RoundManager.Instance.SpawnEnemyGameObject(position, y, -1, fogMonsterType); } } } }