Decompiled source of LegendWeathers v2.1.0
plugins/LegendWeathers.dll
Decompiled 2 days ago
            The result has been truncated due to the large size, download it to view full contents!
        
        
        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 Biodiversity.Creatures; using Biodiversity.Creatures.MicBird; using DigitalRuby.ThunderAndLightning; using GameNetcodeStuff; using HarmonyLib; using Imperium; using LegendWeathers.BehaviourScripts; using LegendWeathers.NetcodePatcher; using LegendWeathers.Patches; using LegendWeathers.Utils; using LegendWeathers.WeatherSkyEffects; using LegendWeathers.Weathers; using LethalCompanyHarpGhost.BagpipesGhost; using LethalCompanyHarpGhost.EnforcerGhost; using LethalCompanyHarpGhost.HarpGhost; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.VFX; using WeatherRegistry; using WeatherRegistry.Editor; [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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("com.github.biodiversitylc.Biodiversity")] [assembly: IgnoresAccessChecksTo("giosuel.Imperium")] [assembly: IgnoresAccessChecksTo("LethalCompanyHarpGhost")] [assembly: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: AssemblyCompany("LegendWeathers")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+bd197ad4568adbd7afda157ae45b7fcfc5b9a2e7")] [assembly: AssemblyProduct("LegendWeathers")] [assembly: AssemblyTitle("LegendWeathers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: NetcodePatchedAssembly] 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; } } } namespace LegendWeathers { internal class Config { public readonly ConfigEntry<bool> generalWeatherAlertsSaved; public readonly ConfigEntry<bool> majoraWeather; public readonly ConfigEntry<string> majoraMoonModel; public readonly ConfigEntry<bool> majoraMoonModelAutomatic; public readonly ConfigEntry<float> majoraMoonMusicVolume; public readonly ConfigEntry<bool> majoraMoonRemoveTimerDisplay; public readonly ConfigEntry<bool> majoraOcarinaCompatible; public readonly ConfigEntry<bool> majoraCompanyCompatible; public readonly ConfigEntry<string> majoraMaskValue; public (int, int) majoraMaskValueParsed; public readonly ConfigEntry<bool> bloodMoonWeather; public readonly ConfigEntry<string> bloodMoonTexture; public readonly ConfigEntry<float> bloodMoonSizeFactor; public readonly ConfigEntry<int> bloodMoonEffectsAbundance; public readonly ConfigEntry<float> bloodMoonEffectsVolume; public readonly ConfigEntry<float> bloodMoonIntroMusicVolume; public readonly ConfigEntry<float> bloodMoonAmbientMusicVolume; public readonly ConfigEntry<string> bloodMoonAmbientMusicType; public readonly ConfigEntry<float> bloodMoonResurrectWaitTime; public readonly ConfigEntry<bool> bloodMoonStoneItemSpawning; public readonly ConfigEntry<string> bloodMoonStoneSpawnBlacklistStr; public readonly ConfigEntry<string> bloodMoonDifficultyFactor; public readonly List<string> bloodMoonStoneSpawnBlacklist = new List<string>(); public Config(ConfigFile cfg) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Expected O, but got Unknown //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Expected O, but got Unknown //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Expected O, but got Unknown //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown cfg.SaveOnConfigSet = false; generalWeatherAlertsSaved = cfg.Bind<bool>("_General", "Weather alerts saved", true, "By default, weather alerts are shown once then saved so you'll never get them again just like the vanilla system.\nDisable this config if you prefer to see them during every ship landing."); majoraWeather = cfg.Bind<bool>("Majora Moon", "Enabled", true, "Enable the Majora Moon weather."); majoraMoonModel = cfg.Bind<string>("Majora Moon", "Model version", "3DS", new ConfigDescription("Choose the model version of the moon, if you want a more retro look try the N64 version.\nOther models are also available for fun !", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[10] { "3DS", "N64", "Faceless", "Vanilla", "Boomy", "Owl", "Abibabou", "Joy", "Dice", "Baldy" }), Array.Empty<object>())); majoraMoonModelAutomatic = cfg.Bind<bool>("Majora Moon", "Automatic model selection", false, "Allows the model to be automatically adjusted on moons based on certain conditions, this will vary depending on your installed mods.\nIf the 'Vanilla' model is selected however, this will allow this config to randomize the texture from one of your installed moons (only if an external mod like Chameleon is installed)."); majoraMoonMusicVolume = cfg.Bind<float>("Majora Moon", "Music volume", 0.9f, new ConfigDescription("When the moon is about to crash, the Final Hours music starts to play.\nYou can customize the music volume here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); majoraMoonRemoveTimerDisplay = cfg.Bind<bool>("Majora Moon", "Remove Timer UI", false, "If enabled, the timer UI during the Majora Moon crash sequence will not be displayed.\nThis is here for those who wants to have the sequence more immersive, but watch out since you will have no indication on the time you have left."); majoraOcarinaCompatible = cfg.Bind<bool>("Majora Moon", "Ocarina compatibility", true, "If you have the Ocarina item, playing Oath to Order while in altitude when the moon is about to crash will start a special animation.\nWill not work if ChillaxScraps is not installed."); majoraCompanyCompatible = cfg.Bind<bool>("Majora Moon", "Company Moon compatibility", false, "By default, the Majora Moon can't spawn on Company Moons but activating this config will make this a reality.\nYou may also need to remove the company moons in the MajoraMoon blacklist section in the WeatherRegistery config file."); majoraMaskValue = cfg.Bind<string>("Majora Moon", "Majora Mask Item value", "200,400", "The min,max scrap value of the Majora's Mask item, supposed to be very high.\nThe final value will be randomized between these 2 numbers, but not divided by any external factors."); bloodMoonWeather = cfg.Bind<bool>("Blood Moon", "Enabled", true, "Enable the Blood Moon weather."); bloodMoonTexture = cfg.Bind<string>("Blood Moon", "Moon texture", "Classic", new ConfigDescription("Choose the texture used for the Blood Moon material.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Classic", "Bright" }), Array.Empty<object>())); bloodMoonSizeFactor = cfg.Bind<float>("Blood Moon", "Moon size factor", 5.5f, new ConfigDescription("The size factor of the Blood Moon material compared to the size of the vanilla sun.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); bloodMoonEffectsAbundance = cfg.Bind<int>("Blood Moon", "Terrain effects abundance", 30, new ConfigDescription("The abundance of terrain effects during the Blood Moon weather.\nHigher values will spawn more effects but may impact performance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); bloodMoonEffectsVolume = cfg.Bind<float>("Blood Moon", "Terrain effects volume", 1f, new ConfigDescription("The Blood Moon's terrain effects all have small sfx coming from them. Those sfx volumes are not very high but if you really want to reduce it then this config is for you.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); bloodMoonIntroMusicVolume = cfg.Bind<float>("Blood Moon", "Intro music volume", 0.8f, new ConfigDescription("An introduction music is played when the Blood Moon is spawned on the planet, this will last 30s.\nYou can customize the music volume here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); bloodMoonAmbientMusicVolume = cfg.Bind<float>("Blood Moon", "Ambient music volume", 1f, new ConfigDescription("The volume for the Blood Moon ambient music when you are outside (similar to the vanilla Eclipsed ambient music).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); bloodMoonAmbientMusicType = cfg.Bind<string>("Blood Moon", "Ambient music type", "Blood Moon", new ConfigDescription("If you prefer to have the vanilla ambient Eclipsed music instead of the Blood Moon ambient custom music, then you can change it here.\nPlease note that the 'Ambient music volume' config will not apply if you select the Eclipsed music.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Blood Moon", "Eclipsed" }), Array.Empty<object>())); bloodMoonResurrectWaitTime = cfg.Bind<float>("Blood Moon", "Enemy resurrection wait time", 10f, new ConfigDescription("When an enemy is resurrected by the Blood Moon effect, this is the time in seconds it will take before it actually respawns.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); bloodMoonStoneItemSpawning = cfg.Bind<bool>("Blood Moon", "Blood Stone spawning", true, "Allow the spawning of the Blood Stone item during specific conditions."); bloodMoonStoneSpawnBlacklistStr = cfg.Bind<string>("Blood Moon", "Blood Stone spawning blacklist", "", "Comma separated list of enemy names that will never spawn Blood Stones when they are killed\nThis MouthDog,Crawler,Flowerman is a valid example, so make sure to only use internal enemies names here."); bloodMoonDifficultyFactor = cfg.Bind<string>("Blood Moon", "Difficulty", "Normal", new ConfigDescription("The difficulty factor of the Blood Moon effect, this will impact the number of spawned enemies during the weather.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Easy", "Normal", "Hard" }), Array.Empty<object>())); cfg.Save(); cfg.SaveOnConfigSet = true; } public void SetupCustomConfigs() { Compatibility.CheckInstalledPlugins(); if (!Compatibility.WeatherRegisteryInstalled) { Plugin.logger.LogError((object)"WeatherRegistery is not installed! Please install WeatherRegistery before using this mod."); } ParseValues(); PopulateList(); } private void ParseValues() { if (majoraMaskValue.Value == "") { majoraMaskValueParsed = (-1, -1); return; } string[] array = (from s in majoraMaskValue.Value.Split(',') select s.Trim()).ToArray(); int result; int result2; if (array.Count() != 2) { majoraMaskValueParsed = (-1, -1); } else if (!int.TryParse(array[0], out result) || !int.TryParse(array[1], out result2)) { majoraMaskValueParsed = (-1, -1); } else if (result > result2) { majoraMaskValueParsed = (-1, -1); } else { majoraMaskValueParsed = (result, result2); } } private void PopulateList() { if (string.IsNullOrWhiteSpace(bloodMoonStoneSpawnBlacklistStr.Value)) { return; } foreach (string item in from s in bloodMoonStoneSpawnBlacklistStr.Value.Split(',') select s.Trim()) { bloodMoonStoneSpawnBlacklist.Add(item.ToLower()); } } } [BepInPlugin("zigzag.legendweathers", "LegendWeathers", "2.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private const string GUID = "zigzag.legendweathers"; private const string NAME = "LegendWeathers"; private const string VERSION = "2.1.0"; public static Plugin instance; public static ManualLogSource logger; private readonly Harmony harmony = new Harmony("zigzag.legendweathers"); public WeatherDefinition? majoraMoonDefinition; public GameObject? majoraMoonObject; public GameObject? majoraSkyObject; public Item? majoraMaskItem; public Item? majoraMoonTearItem; public Sprite? vanillaItemIcon; public WeatherDefinition? bloodMoonDefinition; public GameObject? bloodMoonManagerObject; public GameObject? bloodSunObject; public GameObject? bloodTerrainEffectObject; public Item? bloodStoneItem; internal static Config config { get; private set; } private void HarmonyPatchAll() { harmony.CreateClassProcessor(typeof(WeatherAlertPatch), true).Patch(); harmony.CreateClassProcessor(typeof(MajoraMaskedPatch), true).Patch(); harmony.CreateClassProcessor(typeof(BloodMoonPatches), true).Patch(); if (Compatibility.HauntedHarpistInstalled) { harmony.CreateClassProcessor(typeof(BloodMoonHauntedHarpistPatches), true).Patch(); } } private GameObject GetEffect<T>() where T : Component { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(new GameObject(typeof(T).Name)); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<T>(); return val; } private void RegisterWeather<T, T2>(WeatherDefinition definition) where T : LegendWeather where T2 : SkyEffect { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown ImprovedWeatherEffect weatherEffect = new ImprovedWeatherEffect(GetEffect<T2>(), GetEffect<T>()); RegisterWeather(definition, weatherEffect); } private void RegisterWeather<T>(WeatherDefinition definition) where T : LegendWeather { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown ImprovedWeatherEffect weatherEffect = new ImprovedWeatherEffect((GameObject)null, GetEffect<T>()); RegisterWeather(definition, weatherEffect); } private void RegisterWeather(WeatherDefinition definition, ImprovedWeatherEffect weatherEffect) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Weather val = new Weather(definition.Name, weatherEffect) { Config = definition.Config.CreateFullConfig(), Color = definition.Color }; WeatherManager.RegisterWeather(val); } private void RegisterMajora(AssetBundle bundle, string directory) { majoraMoonDefinition = bundle.LoadAsset<WeatherDefinition>(directory + "MajoraMoonDefinition.asset"); majoraMoonObject = bundle.LoadAsset<GameObject>(directory + "MajoraMoon.prefab"); majoraSkyObject = bundle.LoadAsset<GameObject>(directory + "MajoraSky.prefab"); majoraMaskItem = bundle.LoadAsset<Item>(directory + "Items/MajoraMask/MajoraMaskItem.asset"); majoraMoonTearItem = bundle.LoadAsset<Item>(directory + "Items/MoonTear/MoonTearItem.asset"); vanillaItemIcon = bundle.LoadAsset<Sprite>(directory + "Items/MajoraMask/ScrapItemIcon2.png"); if (!config.majoraMoonModel.Value.Equals(((ConfigEntryBase)config.majoraMoonModel).DefaultValue)) { MajoraMoon.CheckAndReplaceModel(); MajoraMaskItem.CheckAndReplaceModel(); } NetworkPrefabs.RegisterNetworkPrefab(majoraMoonObject); NetworkPrefabs.RegisterNetworkPrefab(majoraMaskItem.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(majoraMoonTearItem.spawnPrefab); if (config.majoraMaskValueParsed.Item1 != -1) { majoraMaskItem.minValue = (int)((float)config.majoraMaskValueParsed.Item1 * 2.5f); majoraMaskItem.maxValue = (int)((float)config.majoraMaskValueParsed.Item2 * 2.5f); } Items.RegisterScrap(majoraMaskItem, 0, (LevelTypes)1); Items.RegisterScrap(majoraMoonTearItem, 0, (LevelTypes)1); RegisterWeather<MajoraMoonWeather, MajoraSkyEffect>(majoraMoonDefinition); } private void RegisterBloodMoon(AssetBundle bundle, string directory) { bloodMoonDefinition = bundle.LoadAsset<WeatherDefinition>(directory + "BloodMoonDefinition.asset"); bloodMoonManagerObject = bundle.LoadAsset<GameObject>(directory + "BloodMoonManager.prefab"); bloodSunObject = bundle.LoadAsset<GameObject>(directory + "SunBloodTexture.prefab"); bloodTerrainEffectObject = bundle.LoadAsset<GameObject>(directory + "BloodTerrainEffect.prefab"); bloodStoneItem = bundle.LoadAsset<Item>(directory + "StoneItem/BloodStoneItem.asset"); if (!config.bloodMoonTexture.Value.Equals(((ConfigEntryBase)config.bloodMoonTexture).DefaultValue)) { BloodSkyEffect.CheckAndReplaceMaterial(); } NetworkPrefabs.RegisterNetworkPrefab(bloodMoonManagerObject); NetworkPrefabs.RegisterNetworkPrefab(bloodStoneItem.spawnPrefab); Items.RegisterScrap(bloodStoneItem, 0, (LevelTypes)1); RegisterWeather<BloodMoonWeather, BloodSkyEffect>(bloodMoonDefinition); } private void Awake() { instance = this; logger = ((BaseUnityPlugin)this).Logger; string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "legendweathers"); AssetBundle bundle = AssetBundle.LoadFromFile(text); string text2 = "Assets/Data/_Misc/LegendWeathers/"; config = new Config(((BaseUnityPlugin)this).Config); config.SetupCustomConfigs(); Effects.SetupNetwork(); if (config.majoraWeather.Value) { RegisterMajora(bundle, text2 + "MajoraMoon/"); } if (config.bloodMoonWeather.Value) { RegisterBloodMoon(bundle, text2 + "BloodMoon/"); } HarmonyPatchAll(); logger.LogInfo((object)"LegendWeathers is loaded !"); } } } namespace LegendWeathers.Weathers { public class BloodMoonManager : NetworkBehaviour { [CompilerGenerated] private sealed class <CreateInvocationObject>d__36 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkObjectReference enemyRef; public Vector3 position; public BloodMoonManager <>4__this; private GameObject <enemyObject>5__1; private GameObject <burstObject>5__2; private GameObject <invocationObject>5__3; private NetworkObject <netObj>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CreateInvocationObject>d__36(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <enemyObject>5__1 = null; <burstObject>5__2 = null; <invocationObject>5__3 = null; <netObj>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <enemyObject>5__1 = NetworkObjectReference.op_Implicit(enemyRef); if ((Object)(object)<>4__this.resurrectEnemyInvocationObject == (Object)null || (Object)(object)<>4__this.resurrectEnemyBurstObject == (Object)null || (Object)(object)<enemyObject>5__1 == (Object)null) { return false; } <burstObject>5__2 = Object.Instantiate<GameObject>(<>4__this.resurrectEnemyBurstObject, position + Vector3.up * 0.9f, Quaternion.identity); <invocationObject>5__3 = Object.Instantiate<GameObject>(<>4__this.resurrectEnemyInvocationObject, position, Quaternion.identity); <>2__current = Effects.AnimateScaleDownObject(<enemyObject>5__1, 3f); <>1__state = 1; return true; case 1: <>1__state = -1; <burstObject>5__2.GetComponent<AudioSource>().Play(); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; case 2: <>1__state = -1; if ((Object)(object)<invocationObject>5__3 != (Object)null) { Object.Destroy((Object)(object)<invocationObject>5__3); } <>2__current = (object)new WaitForSeconds(2.4f); <>1__state = 3; return true; case 3: <>1__state = -1; if ((Object)(object)<burstObject>5__2 != (Object)null) { Object.Destroy((Object)(object)<burstObject>5__2); } if (((NetworkBehaviour)<>4__this).IsServer && (Object)(object)<enemyObject>5__1 != (Object)null) { <netObj>5__4 = <enemyObject>5__1.GetComponentInChildren<NetworkObject>(); if ((Object)(object)<netObj>5__4 != (Object)null && <netObj>5__4.IsSpawned) { <netObj>5__4.Despawn(true); } <netObj>5__4 = null; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <InitializeManager>d__39 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkObjectReference managerReference; public BloodMoonManager <>4__this; private NetworkObject <netObj>5__1; private float <startTime>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeManager>d__39(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <netObj>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <netObj>5__1 = null; <startTime>5__2 = Time.realtimeSinceStartup; goto IL_0064; case 1: <>1__state = -1; goto IL_0064; case 2: { <>1__state = -1; <>4__this.localPlayer = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)<>4__this.localPlayer != (Object)null && !<>4__this.localPlayer.isPlayerDead) { <>4__this.localPlayerIsInsideLastChecked = <>4__this.localPlayer.isInsideFactory; } if (<>4__this.localPlayerIsInsideLastChecked) { <>4__this.nextMoonSfxTime = <>4__this.moonSfxTimeIntervalInside; } <>4__this.StartInitialEffects(); <>4__this.isInitialized = true; return false; } IL_0064: if (Time.realtimeSinceStartup - <startTime>5__2 < 8f && !((NetworkObjectReference)(ref managerReference)).TryGet(ref <netObj>5__1, (NetworkManager)null)) { <>2__current = (object)new WaitForSeconds(0.03f); <>1__state = 1; return true; } if ((Object)(object)<netObj>5__1 == (Object)null) { Plugin.logger.LogError((object)"Error while trying to sync Blood Moon manager."); return false; } <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <StartAnimationThenResurrect>d__34 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemyAI enemy; public Vector3 originalPosition; public BloodMoonManager <>4__this; private Vector3 <spawnPosition>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StartAnimationThenResurrect>d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)enemy == (Object)null || Plugin.config.bloodMoonStoneSpawnBlacklist.Count == 0 || !Plugin.config.bloodMoonStoneSpawnBlacklist.Contains(enemy.enemyType.enemyName.ToLower())) { <>4__this.SpawnBloodStone(originalPosition); } <>2__current = (object)new WaitForSeconds(Plugin.config.bloodMoonResurrectWaitTime.Value); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)enemy == (Object)null || StartOfRound.Instance.inShipPhase || StartOfRound.Instance.shipIsLeaving) { return false; } <spawnPosition>5__1 = RoundManager.Instance.GetNavMeshPosition(originalPosition, default(NavMeshHit), 3f, -1); if (!RoundManager.Instance.GotNavMeshPositionResult) { <spawnPosition>5__1 = Effects.GetClosestAINodePosition(enemy.isOutside ? RoundManager.Instance.outsideAINodes : RoundManager.Instance.insideAINodes, originalPosition); } <>4__this.CreateInvocationObjectClientRpc(new NetworkObjectReference(((Component)enemy).gameObject), <spawnPosition>5__1); <>2__current = (object)new WaitForSeconds(3.05f); <>1__state = 2; return true; case 2: <>1__state = -1; if (!StartOfRound.Instance.inShipPhase) { if (Compatibility.BloodMoonSpawnEnemySpecific(enemy, <spawnPosition>5__1)) { return false; } RoundManager.Instance.SpawnEnemyGameObject(<spawnPosition>5__1, Random.Range(-90f, 90f), -1, enemy.enemyType); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public AudioSource introMusicAudio = null; public AudioSource sfxAudio = null; public AudioClip[] sfx = null; public GameObject bloodMoonVolumeObject = null; public GameObject bloodMoonParticlesObject = null; public GameObject resurrectEnemyInvocationObject = null; public GameObject resurrectEnemyBurstObject = null; public Material[] bloodMoonTextureMaterials = null; private bool isInitialized = false; private PlayerControllerB? localPlayer = null; private bool localPlayerIsInsideLastChecked = false; private GameObject? spawnedBloodVolume = null; private bool volumeCorrectlyRendered = false; private float volumeRenderingSafeCheckTimer = 0f; private bool vanillaFogVolumeComponentExists = false; private GameObject? spawnedBloodParticles = null; private readonly Vector3 bloodParticleOffset = Vector3.up * 7f; private float lastMoonSfxTime = 0f; private float nextMoonSfxTime = 63f; private readonly float moonSfxTimeIntervalInside = 10.8f; private readonly float moonSfxTimeIntervalOutside = 81.8f; private float lastThunderEventTime = 0f; private float nextThunderEventTime = 60f; private List<VisualEnvironment> visualEnvironments = new List<VisualEnvironment>(); private List<float> originalWindSpeeds = new List<float>(); private readonly int windSpeedFactor = 4; private static readonly Dictionary<string, bool> firstEnemiesRespawned = new Dictionary<string, bool>(); public void Update() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (isInitialized) { PerformRenderingSafeCheck(); Effects.StopVanillaMusic(); Effects.SetObjectPositionToLocalPlayer(spawnedBloodParticles, bloodParticleOffset); TryAndPlayThunderEvent(); if (introMusicAudio.isPlaying) { CheckIntroMusicState(); } else { TryAndPlayMoonSfx(); } } } private void CheckIntroMusicState() { if ((Object)(object)localPlayer == (Object)null || localPlayer.isPlayerDead || localPlayer.isInsideFactory) { introMusicAudio.Stop(); } } private void TryAndPlayMoonSfx() { if ((Object)(object)localPlayer == (Object)null) { return; } if (Effects.IsPlayerInsideFacilityAbsolute(localPlayer)) { if (!localPlayerIsInsideLastChecked) { lastMoonSfxTime = 0f; nextMoonSfxTime = moonSfxTimeIntervalInside; } localPlayerIsInsideLastChecked = true; } else { localPlayerIsInsideLastChecked = false; } if (localPlayerIsInsideLastChecked) { return; } lastMoonSfxTime += Time.deltaTime; if (lastMoonSfxTime >= nextMoonSfxTime) { lastMoonSfxTime = 0f; nextMoonSfxTime = moonSfxTimeIntervalOutside; if (Plugin.config.bloodMoonAmbientMusicType.Value == "Blood Moon") { sfxAudio.PlayOneShot(sfx[Random.Range(0, sfx.Length)], 0.5f * Plugin.config.bloodMoonAmbientMusicVolume.Value); } } } private void TryAndPlayThunderEvent() { if (!((NetworkBehaviour)this).IsServer) { return; } lastThunderEventTime += Time.deltaTime; if (lastThunderEventTime >= nextThunderEventTime) { lastThunderEventTime = 0f; nextThunderEventTime = Random.Range(50f, 70f); if (Random.Range(0, 10) == 0) { SpawnBloodStone(); } } } private void SpawnBloodStone(Vector3? originalPosition = null) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.instance.bloodStoneItem == (Object)null || !Plugin.config.bloodMoonStoneItemSpawning.Value) { return; } Vector3 strikePosition = ((!originalPosition.HasValue) ? Effects.GetRandomMoonPosition() : RoundManager.Instance.GetRandomNavMeshPositionInRadius(originalPosition.Value, 15f, default(NavMeshHit))); if (!originalPosition.HasValue) { Effects.SpawnBloodLightningBolt(ref strikePosition); SpawnLightningClientRpc(strikePosition); } GameObject val = Object.Instantiate<GameObject>(Plugin.instance.bloodStoneItem.spawnPrefab, strikePosition, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer); if ((Object)(object)val != (Object)null) { BloodStoneItem component = val.GetComponent<BloodStoneItem>(); ((Component)component).transform.rotation = Quaternion.Euler(((GrabbableObject)component).itemProperties.restingRotation); ((GrabbableObject)component).fallTime = 1f; ((GrabbableObject)component).hasHitGround = true; ((GrabbableObject)component).reachedFloorTarget = true; ((GrabbableObject)component).scrapValue = (int)((float)Random.Range(Plugin.instance.bloodStoneItem.minValue, Plugin.instance.bloodStoneItem.maxValue) * RoundManager.Instance.scrapValueMultiplier); if (!originalPosition.HasValue) { ((GrabbableObject)component).scrapValue = ((GrabbableObject)component).scrapValue * 4; } ((NetworkBehaviour)component).NetworkObject.Spawn(false); component.StartInvocationServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)component).NetworkObject), ((GrabbableObject)component).scrapValue, !originalPosition.HasValue); } else { Plugin.logger.LogError((object)"Failed to spawn the Blood Stone item on the server."); } } [ClientRpc] private void SpawnLightningClientRpc(Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4056806473u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4056806473u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!((NetworkBehaviour)this).IsServer) { Effects.SpawnBloodLightningBolt(ref position); } } } public void ResurrectEnemy(EnemyAI enemy) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { ((MonoBehaviour)this).StartCoroutine(StartAnimationThenResurrect(enemy, ((Component)enemy).transform.position)); } } [IteratorStateMachine(typeof(<StartAnimationThenResurrect>d__34))] private IEnumerator StartAnimationThenResurrect(EnemyAI enemy, Vector3 originalPosition) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StartAnimationThenResurrect>d__34(0) { <>4__this = this, enemy = enemy, originalPosition = originalPosition }; } [ClientRpc] private void CreateInvocationObjectClientRpc(NetworkObjectReference enemyRef, Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3171661224u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref enemyRef, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3171661224u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ((MonoBehaviour)this).StartCoroutine(CreateInvocationObject(enemyRef, position)); } } } [IteratorStateMachine(typeof(<CreateInvocationObject>d__36))] private IEnumerator CreateInvocationObject(NetworkObjectReference enemyRef, Vector3 position) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CreateInvocationObject>d__36(0) { <>4__this = this, enemyRef = enemyRef, position = position }; } [ServerRpc] public void InitializeManagerServerRpc(NetworkObjectReference managerReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2443070584u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref managerReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2443070584u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; InitializeManagerClientRpc(managerReference); } } [ClientRpc] private void InitializeManagerClientRpc(NetworkObjectReference managerReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(423066704u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref managerReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 423066704u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ((MonoBehaviour)this).StartCoroutine(InitializeManager(managerReference)); } } } [IteratorStateMachine(typeof(<InitializeManager>d__39))] private IEnumerator InitializeManager(NetworkObjectReference managerReference) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeManager>d__39(0) { <>4__this = this, managerReference = managerReference }; } private void StartInitialEffects() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bloodMoonVolumeObject != (Object)null) { spawnedBloodVolume = Object.Instantiate<GameObject>(bloodMoonVolumeObject); if ((Object)(object)spawnedBloodVolume != (Object)null) { if (Effects.SetupCustomSkyVolume(spawnedBloodVolume, out Volume _)) { volumeCorrectlyRendered = true; } } else { Plugin.logger.LogError((object)"Failed to instantiate Blood Moon Volume."); } } if ((Object)(object)localPlayer != (Object)null && (Object)(object)bloodMoonParticlesObject != (Object)null) { PlayerControllerB val = (PlayerControllerB)((!localPlayer.isPlayerDead) ? ((object)localPlayer) : ((object)localPlayer.spectatedPlayerScript)); spawnedBloodParticles = Object.Instantiate<GameObject>(bloodMoonParticlesObject, ((Component)val).transform.position + bloodParticleOffset, Quaternion.identity); if ((Object)(object)spawnedBloodParticles == (Object)null) { Plugin.logger.LogError((object)("Failed to instantiate Blood Moon Particles for player " + val.playerUsername + ".")); } } Effects.EnableVanillaVolumeFog(enabled: false, ref vanillaFogVolumeComponentExists); Effects.SetupWindSpeedComponents(ref visualEnvironments, ref originalWindSpeeds); Effects.IncreaseWindSpeed(visualEnvironments, windSpeedFactor); introMusicAudio.volume = Plugin.config.bloodMoonIntroMusicVolume.Value; introMusicAudio.Play(); } private void PerformRenderingSafeCheck() { if (volumeCorrectlyRendered || !((Object)(object)spawnedBloodVolume != (Object)null)) { return; } volumeRenderingSafeCheckTimer += Time.deltaTime; if (volumeRenderingSafeCheckTimer > 1f) { if (Effects.SetupCustomSkyVolume(spawnedBloodVolume, out Volume _)) { volumeCorrectlyRendered = true; volumeRenderingSafeCheckTimer = 0f; } else { Plugin.logger.LogError((object)"Failed to setup fog state for the Blood Moon Volume."); } } } internal static bool UpdateFirstEnemyRespawned(string enemyName, bool? overrideValue = null) { if (firstEnemiesRespawned.ContainsKey(enemyName)) { if (overrideValue.HasValue) { firstEnemiesRespawned[enemyName] = overrideValue.Value; } return firstEnemiesRespawned[enemyName]; } firstEnemiesRespawned[enemyName] = overrideValue.GetValueOrDefault(); return false; } public override void OnDestroy() { if (introMusicAudio.isPlaying) { introMusicAudio.Stop(); } if (sfxAudio.isPlaying) { sfxAudio.Stop(); } if ((Object)(object)spawnedBloodParticles != (Object)null) { Object.Destroy((Object)(object)spawnedBloodParticles); } if ((Object)(object)spawnedBloodVolume != (Object)null) { Object.Destroy((Object)(object)spawnedBloodVolume); } Effects.EnableVanillaVolumeFog(enabled: true, ref vanillaFogVolumeComponentExists); for (int i = 0; i < visualEnvironments.Count; i++) { if ((Object)(object)visualEnvironments[i] != (Object)null) { ((VolumeParameter<float>)(object)visualEnvironments[i].windSpeed).value = originalWindSpeeds[i]; } } visualEnvironments.Clear(); originalWindSpeeds.Clear(); firstEnemiesRespawned.Clear(); ((NetworkBehaviour)this).OnDestroy(); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(4056806473u, new RpcReceiveHandler(__rpc_handler_4056806473), "SpawnLightningClientRpc"); ((NetworkBehaviour)this).__registerRpc(3171661224u, new RpcReceiveHandler(__rpc_handler_3171661224), "CreateInvocationObjectClientRpc"); ((NetworkBehaviour)this).__registerRpc(2443070584u, new RpcReceiveHandler(__rpc_handler_2443070584), "InitializeManagerServerRpc"); ((NetworkBehaviour)this).__registerRpc(423066704u, new RpcReceiveHandler(__rpc_handler_423066704), "InitializeManagerClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_4056806473(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); target.__rpc_exec_stage = (__RpcExecStage)1; ((BloodMoonManager)(object)target).SpawnLightningClientRpc(position); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3171661224(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference enemyRef = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref enemyRef, default(ForNetworkSerializable)); Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); target.__rpc_exec_stage = (__RpcExecStage)1; ((BloodMoonManager)(object)target).CreateInvocationObjectClientRpc(enemyRef, position); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2443070584(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { NetworkObjectReference managerReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref managerReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((BloodMoonManager)(object)target).InitializeManagerServerRpc(managerReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_423066704(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference managerReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref managerReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((BloodMoonManager)(object)target).InitializeManagerClientRpc(managerReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "BloodMoonManager"; } } public class BloodMoonWeather : LegendWeather { public static string weatherAlert = "A crimson moon rises, bathing the land in danger. Be on your guard."; private GameObject? spawnedManager = null; public static ImprovedWeatherEffect? BloodMoonEffectReference { get; private set; } = null; public BloodMoonWeather() : base(Plugin.instance.bloodMoonDefinition) { } public override void OnEnable() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) base.OnEnable(); if (!WeatherManager.IsSetupFinished) { return; } if (NetworkManager.Singleton.IsServer) { spawnedManager = Object.Instantiate<GameObject>(Plugin.instance.bloodMoonManagerObject, Vector3.zero, Quaternion.identity); if ((Object)(object)spawnedManager != (Object)null) { NetworkObject component = spawnedManager.GetComponent<NetworkObject>(); component.Spawn(true); spawnedManager.GetComponent<BloodMoonManager>().InitializeManagerServerRpc(NetworkObjectReference.op_Implicit(component)); } else { Plugin.logger.LogError((object)("Failed to spawn " + weatherDefinition.Name + " on the server.")); } } BloodMoonEffectReference = ConfigHelper.ResolveStringToWeather("bloodmoon").Effect; UpdateSpawningVariables(update: true); EnableVanillaSun(enabled: false); } public override void OnDisable() { base.OnDisable(); if (!WeatherManager.IsSetupFinished) { return; } if (NetworkManager.Singleton.IsServer && (Object)(object)spawnedManager != (Object)null) { NetworkObject component = spawnedManager.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null && component.IsSpawned) { component.Despawn(true); } spawnedManager = null; } ImprovedWeatherEffect? bloodMoonEffectReference = BloodMoonEffectReference; if (bloodMoonEffectReference != null) { GameObject effectObject = bloodMoonEffectReference.EffectObject; if (effectObject != null) { effectObject.GetComponent<BloodSkyEffect>()?.ResetState(); } } BloodMoonEffectReference = null; UpdateSpawningVariables(update: false); EnableVanillaSun(enabled: true); } private void UpdateSpawningVariables(bool update) { SelectableLevel currentLevel = RoundManager.Instance.currentLevel; if ((Object)(object)currentLevel != (Object)null) { int num = (update ? GetDifficultyIndex() : 0); RoundManager.Instance.minOutsideEnemiesToSpawn = num; RoundManager.Instance.minEnemiesToSpawn = num; currentLevel.maxEnemyPowerCount += (update ? 5 : (-5)); currentLevel.maxOutsideEnemyPowerCount += (update ? 10 : (-10)); } } private int GetDifficultyIndex() { string value = Plugin.config.bloodMoonDifficultyFactor.Value; return (!(value == "Easy")) ? ((!(value == "Hard")) ? 1 : 2) : 0; } public BloodMoonManager? GetBloodMoonManager() { if ((Object)(object)spawnedManager != (Object)null) { return spawnedManager.GetComponent<BloodMoonManager>(); } return null; } } public class LegendWeather : MonoBehaviour { public readonly WeatherDefinition weatherDefinition; public LegendWeather(WeatherDefinition? definition) { if ((Object)(object)definition == (Object)null) { throw new NullReferenceException("WeatherDefinition is null."); } weatherDefinition = definition; } public virtual void OnEnable() { if (WeatherManager.IsSetupFinished) { Plugin.logger.LogInfo((object)(weatherDefinition.Name + " Weather is enabled !")); } } public virtual void OnDisable() { if (WeatherManager.IsSetupFinished) { Plugin.logger.LogInfo((object)(weatherDefinition.Name + " Weather is destroyed.")); } } public void EnableVanillaSun(bool enabled) { try { animatedSun val = Object.FindObjectOfType<animatedSun>(); if (!((Object)(object)val != (Object)null)) { return; } Transform val2 = ((Component)val).transform.Find("SunTexture"); if (val2 != null) { GameObject gameObject = ((Component)val2).gameObject; if (gameObject != null) { gameObject.SetActive(enabled); } } Transform val3 = ((Component)val).transform.Find("EclipseObject"); if (val3 != null) { GameObject gameObject2 = ((Component)val3).gameObject; if (gameObject2 != null) { gameObject2.SetActive(enabled); } } } catch (Exception) { Plugin.logger.LogInfo((object)("Failed to " + (enabled ? "enable" : "disable") + " vanilla sun. Probably not an error if the ship is going back in orbit.")); } } } public class MajoraMoon : NetworkBehaviour { [CompilerGenerated] private sealed class <InitializeMoon>d__83 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkObjectReference moonRef; public Vector3 nodeEndPosition; public MajoraMoon <>4__this; private NetworkObject <moonNetObj>5__1; private float <startTime>5__2; private float <moonRadiusOffset>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeMoon>d__83(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <moonNetObj>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <moonNetObj>5__1 = null; <startTime>5__2 = Time.realtimeSinceStartup; goto IL_0064; case 1: <>1__state = -1; goto IL_0064; case 2: { <>1__state = -1; if (((NetworkBehaviour)<>4__this).IsServer) { <>4__this.isRareTearEventDay = Random.Range(0, 100) == 0; } <>4__this.startPosition = ((Component)<>4__this).transform.position; <>4__this.startRotation = ((Component)<>4__this).transform.eulerAngles; <>4__this.startScale = ((Component)<>4__this).transform.localScale; <moonRadiusOffset>5__3 = (float)<>4__this.moonRadiusApprox * <>4__this.endSizeFactor; <>4__this.outsideNodeEndPosition = nodeEndPosition; <>4__this.endPosition = nodeEndPosition + Vector3.Normalize(((Component)<>4__this).transform.position - nodeEndPosition) * <moonRadiusOffset>5__3; <>4__this.endRotation = new Vector3(90f, ((Component)<>4__this).transform.eulerAngles.y, ((Component)<>4__this).transform.eulerAngles.z); <>4__this.endScale = ((Component)<>4__this).transform.localScale * <>4__this.endSizeFactor; if (Plugin.config.majoraMoonModelAutomatic.Value) { CheckAndReplaceModel(((Component)<>4__this).gameObject); } Effects.SetupWindSpeedComponents(ref <>4__this.visualEnvironments, ref <>4__this.originalWindSpeeds); <>4__this.shipLever = Object.FindObjectOfType<StartMatchLever>(); <>4__this.isInitialized = true; return false; } IL_0064: if (Time.realtimeSinceStartup - <startTime>5__2 < 8f && !((NetworkObjectReference)(ref moonRef)).TryGet(ref <moonNetObj>5__1, (NetworkManager)null)) { <>2__current = (object)new WaitForSeconds(0.03f); <>1__state = 1; return true; } if ((Object)(object)<moonNetObj>5__1 == (Object)null) { Plugin.logger.LogError((object)"Error while trying to sync Majora Moon."); return false; } <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <StartFinishing>d__72 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MajoraMoon <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StartFinishing>d__72(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase) { return false; } StartOfRound.Instance.shipLeftAutomatically = false; StartOfRound.Instance.shipIsLeaving = true; Effects.MessageComputer("The autopilot emergency code has been activated.", "You've met with a terrible fate, haven't you?"); <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; case 1: <>1__state = -1; ((Behaviour)HUDManager.Instance.shipLeavingEarlyIcon).enabled = false; if ((Object)(object)<>4__this.shipLever != (Object)null) { <>4__this.shipLever.triggerScript.animationString = "SA_PushLeverBack"; <>4__this.shipLever.leverHasBeenPulled = false; <>4__this.shipLever.triggerScript.interactable = false; <>4__this.shipLever.leverAnimatorObject.SetBool("pullLever", false); } StartOfRound.Instance.ShipLeave(); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(4f); <>1__state = 3; return true; case 3: <>1__state = -1; if ((Object)(object)<>4__this.impact != (Object)null) { Object.Destroy((Object)(object)<>4__this.impact); } <>4__this.impact = Object.Instantiate<GameObject>(<>4__this.impactObject, <>4__this.endPosition - Vector3.up * (float)<>4__this.impactGroundPosOffset, Quaternion.identity); <>4__this.DisableColliders(); <>4__this.impactStarted = true; <>2__current = Effects.ShakeCameraAdvanced((ScreenShakeType)3, 2); <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <StopMoonAnimation>d__78 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MajoraMoon <>4__this; private ImprovedWeatherEffect <majoraEffect>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StopMoonAnimation>d__78(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <majoraEffect>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; if (<>4__this.finalHoursPlayingMusic) { <>2__current = Effects.FadeOutAudio(<>4__this.finalHoursAudio, 1f); <>1__state = 2; return true; } goto IL_00ae; case 2: <>1__state = -1; goto IL_00ae; case 3: <>1__state = -1; <>4__this.burstParticles1.Play(); <>2__current = (object)new WaitForSeconds(3f); <>1__state = 4; return true; case 4: <>1__state = -1; <>4__this.burstParticles2.Stop(); <>4__this.DisableColliders(); <>4__this.burstVFX.Play(); <>4__this.burstAnimator.SetTrigger("Burst"); <>2__current = (object)new WaitForSeconds(8f); <>1__state = 5; return true; case 5: <>1__state = -1; <>4__this.crashAudio.PlayOneShot(<>4__this.stopMoonSfx); <>2__current = (object)new WaitForSeconds(15f); <>1__state = 6; return true; case 6: { <>1__state = -1; <>4__this.burstParticles1.Stop(); <majoraEffect>5__1 = Effects.GetWeatherEffect("majoramoon"); ImprovedWeatherEffect obj2 = <majoraEffect>5__1; if (obj2 != null) { GameObject effectObject2 = obj2.EffectObject; if (effectObject2 != null) { effectObject2.GetComponent<MajoraSkyEffect>()?.ReverseEffect(); } } <>2__current = (object)new WaitForSeconds(6f); <>1__state = 7; return true; } case 7: { <>1__state = -1; ImprovedWeatherEffect obj = <majoraEffect>5__1; if (obj != null) { GameObject effectObject = obj.EffectObject; if (effectObject != null) { effectObject.GetComponent<MajoraSkyEffect>()?.ResetState(); } } Effects.RemoveWeather("majoramoon"); return false; } IL_00ae: if (<>4__this.finalHoursAudio.volume > 0f) { <>4__this.finalHoursAudio.PlayOneShot(<>4__this.callOfTheGiantsMusic); } if (<>4__this.finalHoursPlayingParticles) { <>4__this.crashParticles1.Stop(true, (ParticleSystemStopBehavior)0); <>4__this.crashParticles2.Stop(true, (ParticleSystemStopBehavior)0); <>4__this.crashAudio.Stop(); } <>4__this.burstParticles2.Play(); <>2__current = (object)new WaitForSeconds(19f); <>1__state = 3; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public AudioSource finalHoursAudio = null; public AudioSource sfxAudio = null; public AudioSource crashAudio = null; public AudioClip[] sfx = null; public AudioClip callOfTheGiantsMusic = null; public AudioClip stopMoonSfx = null; public GameObject finalHoursTimer = null; public ParticleSystem crashParticles1 = null; public ParticleSystem crashParticles2 = null; public GameObject impactObject = null; public Transform tearPosition = null; public ParticleSystem burstParticles1 = null; public ParticleSystem burstParticles2 = null; public VisualEffect burstVFX = null; public Animator burstAnimator = null; public static string modelName = "3DS"; private readonly int moonRadiusApprox = 19; private readonly float endSizeFactor = 7.3f; private Vector3 startPosition; private Vector3 startRotation; private Vector3 startScale; private Vector3 endPosition; private Vector3 outsideNodeEndPosition; private Vector3 endRotation; private Vector3 endScale; private float startTime; private float endTime; private readonly float moonFallTimerOffset = 45f; private bool isInitialized = false; private float endTimeFactor = 1.8f; private float smoothTime = 0f; private Vector3 smoothPosVelocity; private Vector3 smoothRotVelocity; private Vector3 smoothScaVelocity; private float previousSpeedMultiplier = 1f; private float finalHoursTime; public bool finalHoursPlayingMusic = false; public bool finalHoursDisplayingTimer = false; public bool finalHoursPlayingParticles = false; public bool finalHoursFinishing = false; public bool oathToOrderStopingMoon = false; private List<VisualEnvironment> visualEnvironments = new List<VisualEnvironment>(); private List<float> originalWindSpeeds = new List<float>(); private readonly int windSpeedFactor = 17; private GameObject? timerUI; private TMP_Text? timerText; private bool lastMinute = false; private bool timerStarted = false; private GameObject? impact; private readonly float impactScaleFactor = 1.4f; private readonly int impactGroundPosOffset = 100; private bool impactStarted = false; private StartMatchLever? shipLever; private float lastRumbleEventTime = 0f; private float nextRumbleEventTime = 35f; private float lastTearEventTime = 0f; private float nextTearEventTime = 60f; private float lastBellSfxEvent = 0f; private bool isRareTearEventDay = false; private int rareTearEventDayNB = 0; private Coroutine? stopMoonCoroutine = null; private bool collidersDisabled = false; public bool AccelerateEndTimeFactor() { if (finalHoursPlayingParticles || oathToOrderStopingMoon) { return false; } endTimeFactor += (finalHoursPlayingMusic ? 0.3f : 0.6f); return true; } public float GetMoonFallAccelerateFactor(float timeFactor) { float num = endTimeFactor; if (1 == 0) { } float num2 = ((num == 2.1f) ? 0.05f : ((num != 2.4f) ? 0f : 0.09f)); if (1 == 0) { } return num2 + timeFactor; } public void StopMoonCrash() { if (!finalHoursFinishing && Plugin.config.majoraOcarinaCompatible.Value) { oathToOrderStopingMoon = true; if (stopMoonCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(stopMoonCoroutine); } stopMoonCoroutine = ((MonoBehaviour)this).StartCoroutine(StopMoonAnimation()); } } public void Update() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) if (!isInitialized) { return; } if (finalHoursPlayingMusic) { Effects.StopVanillaMusic(); } if (oathToOrderStopingMoon) { return; } if (Compatibility.IsMajoraActiveOnCompany) { smoothTime = Compatibility.GetCompanySmoothTime(Time.deltaTime); } else if (TimeOfDay.Instance.currentDayTimeStarted) { if (previousSpeedMultiplier != TimeOfDay.Instance.globalTimeSpeedMultiplier) { previousSpeedMultiplier = TimeOfDay.Instance.globalTimeSpeedMultiplier; smoothPosVelocity = default(Vector3); smoothRotVelocity = default(Vector3); smoothScaVelocity = default(Vector3); } if (startTime == 0f) { startTime = TimeOfDay.Instance.currentDayTime - moonFallTimerOffset; } endTime = TimeOfDay.Instance.globalTimeAtEndOfDay / endTimeFactor; smoothTime = (endTime - TimeOfDay.Instance.currentDayTime) / TimeOfDay.Instance.globalTimeSpeedMultiplier; finalHoursTime = endTime - 280f; } if (smoothTime != 0f && !Effects.IsTimePaused()) { if (Compatibility.IsMajoraActiveOnCompany) { ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, endPosition, ref smoothPosVelocity, smoothTime); ((Component)this).transform.eulerAngles = Vector3.SmoothDamp(((Component)this).transform.eulerAngles, endRotation, ref smoothRotVelocity, smoothTime); ((Component)this).transform.localScale = Vector3.SmoothDamp(((Component)this).transform.localScale, endScale, ref smoothScaVelocity, smoothTime); } else { float timeFactor = (TimeOfDay.Instance.currentDayTime - moonFallTimerOffset - startTime) / (endTime - startTime); ((Component)this).transform.position = Vector3.Lerp(startPosition, endPosition - Vector3.up * 4f, GetMoonFallAccelerateFactor(timeFactor)); ((Component)this).transform.eulerAngles = Vector3.Lerp(startRotation, endRotation, GetMoonFallAccelerateFactor(timeFactor)); ((Component)this).transform.localScale = Vector3.Lerp(startScale, endScale, GetMoonFallAccelerateFactor(timeFactor)); } } PlayRandomEvents(); FinalHours(); } private void FinalHours() { if (!finalHoursPlayingMusic && (Compatibility.IsMajoraActiveOnCompany || TimeOfDay.Instance.currentDayTime >= finalHoursTime + 30f)) { StartMusic(); finalHoursPlayingMusic = true; } if (!finalHoursDisplayingTimer && ((!Compatibility.IsMajoraActiveOnCompany && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 50f) || (Compatibility.IsMajoraActiveOnCompany && Compatibility.MajoraCompanyTimer <= 91f))) { StartTimer(); Effects.IncreaseWindSpeed(visualEnvironments, windSpeedFactor); finalHoursDisplayingTimer = true; } if (!finalHoursPlayingParticles && ((!Compatibility.IsMajoraActiveOnCompany && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 205f) || (Compatibility.IsMajoraActiveOnCompany && Compatibility.MajoraCompanyTimer <= 33f))) { StartParticles(); StartCrashAudio(); finalHoursPlayingParticles = true; } if (!finalHoursFinishing && ((!Compatibility.IsMajoraActiveOnCompany && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 235f) || (Compatibility.IsMajoraActiveOnCompany && Compatibility.MajoraCompanyTimer <= 18f))) { ((MonoBehaviour)this).StartCoroutine(StartFinishing()); finalHoursFinishing = true; } if (!finalHoursFinishing && StartOfRound.Instance.shipIsLeaving) { DisableColliders(disable: false); } UpdateTimer(smoothTime + ((!Compatibility.IsMajoraActiveOnCompany) ? (-21.9f) : (-8f))); UpdateImpact(); } private void StartMusic() { finalHoursAudio.volume = Plugin.config.majoraMoonMusicVolume.Value; if (finalHoursAudio.volume > 0f) { finalHoursAudio.Play(); } } private void StartTimer() { if (!Plugin.config.majoraMoonRemoveTimerDisplay.Value) { if ((Object)(object)timerUI != (Object)null) { Object.Destroy((Object)(object)timerUI); } timerUI = Object.Instantiate<GameObject>(finalHoursTimer); timerText = timerUI.GetComponentInChildren<TMP_Text>(); timerStarted = true; } } private void UpdateTimer(float timeBeforeEnd) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (timerStarted && (Object)(object)timerText != (Object)null && timeBeforeEnd >= 0f) { TimeSpan timeSpan = TimeSpan.FromSeconds(timeBeforeEnd); timerText.text = timeSpan.ToString("mm\\:ss\\:ff"); if (!lastMinute && timeSpan.Minutes <= 0) { lastMinute = true; ((Graphic)timerText).color = Color.red; } } } private void StartParticles() { crashParticles1.Play(); crashParticles2.Play(); } private void StartCrashAudio() { crashAudio.Play(); } [IteratorStateMachine(typeof(<StartFinishing>d__72))] private IEnumerator StartFinishing() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StartFinishing>d__72(0) { <>4__this = this }; } private void DisableColliders(bool disable = true) { if (collidersDisabled == disable) { return; } GameObject gameObject = ((Component)((Component)this).transform.Find("Models/" + modelName)).gameObject; if (!((Object)(object)gameObject == (Object)null)) { MeshCollider[] components = gameObject.GetComponents<MeshCollider>(); foreach (MeshCollider val in components) { ((Collider)val).enabled = !disable; } collidersDisabled = disable; } } private void UpdateImpact() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (impactStarted && (Object)(object)impact != (Object)null) { Transform transform = impact.transform; transform.localScale += Vector3.one * Time.deltaTime * impactScaleFactor; PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!localPlayerController.isPlayerDead && !localPlayerController.isInHangarShipRoom && !localPlayerController.isInElevator && Vector3.Distance(outsideNodeEndPosition, ((Component)localPlayerController).transform.position) <= impact.transform.localScale.x * (float)moonRadiusApprox * 0.9f) { Effects.Damage(localPlayerController, 99999, (CauseOfDeath)13, 6, criticalBlood: false); } } } private void PlayRandomEvents() { if (((NetworkBehaviour)this).IsServer) { lastRumbleEventTime += Time.deltaTime; lastTearEventTime += Time.deltaTime; if (lastRumbleEventTime >= nextRumbleEventTime) { int num = 0; lastRumbleEventTime = 0f; if (finalHoursDisplayingTimer) { if (!finalHoursPlayingParticles && Random.Range(0, 5) == 0) { num++; } nextRumbleEventTime = Random.Range(20 - num * 14, 35 - num * 30); } else { nextRumbleEventTime = Random.Range(35, 60); } PlayRandomEventsClientRpc(num); } if (!Compatibility.IsMajoraActiveOnCompany && lastTearEventTime >= nextTearEventTime && !finalHoursPlayingParticles) { lastTearEventTime = 0f; if (isRareTearEventDay) { nextTearEventTime = Random.Range(3, 6); rareTearEventDayNB++; if (rareTearEventDayNB >= 8) { isRareTearEventDay = false; } } else { nextTearEventTime = Random.Range(50, 60); } if (Random.Range(0, 10) <= (isRareTearEventDay ? 7 : (finalHoursDisplayingTimer ? 1 : 3))) { PlayMoonTearEvent(); } } } if (finalHoursPlayingParticles) { lastBellSfxEvent += Time.deltaTime; if (lastBellSfxEvent >= 3f) { lastBellSfxEvent = 0f; sfxAudio.PlayOneShot(sfx[2]); } } } [ClientRpc] private void PlayRandomEventsClientRpc(int eventID) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1254625525u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, eventID); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1254625525u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; switch (eventID) { case 0: { int num = ((!Effects.IsLocalPlayerInsideFacilityAbsolute()) ? 1 : 0); sfxAudio.PlayOneShot(sfx[num]); ((MonoBehaviour)this).StartCoroutine(Effects.ShakeCameraAdvanced((ScreenShakeType)2, finalHoursPlayingParticles ? 4 : 2)); break; } case 1: sfxAudio.PlayOneShot(sfx[2]); break; } } } private void PlayMoonTearEvent() { //IL_0020: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Plugin.instance.majoraMoonTearItem == (Object)null)) { Vector3 randomNavMeshPositionInRadius = RoundManager.Instance.GetRandomNavMeshPositionInRadius(outsideNodeEndPosition, 20f, default(NavMeshHit)); GameObject val = Object.Instantiate<GameObject>(Plugin.instance.majoraMoonTearItem.spawnPrefab, tearPosition.position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer); if ((Object)(object)val != (Object)null) { MoonTearItem component = val.GetComponent<MoonTearItem>(); ((Component)component).transform.rotation = Quaternion.Euler(((GrabbableObject)component).itemProperties.restingRotation); ((GrabbableObject)component).fallTime = 1f; ((GrabbableObject)component).hasHitGround = true; ((GrabbableObject)component).reachedFloorTarget = true; ((GrabbableObject)component).isInFactory = true; ((GrabbableObject)component).scrapValue = (int)((float)Random.Range(Plugin.instance.majoraMoonTearItem.minValue, Plugin.instance.majoraMoonTearItem.maxValue) * RoundManager.Instance.scrapValueMultiplier); ((NetworkBehaviour)component).NetworkObject.Spawn(false); component.StartFallingServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)component).NetworkObject), ((GrabbableObject)component).scrapValue, randomNavMeshPositionInRadius); } else { Plugin.logger.LogError((object)"Failed to spawn the Moon Tear item on the server."); } } } [IteratorStateMachine(typeof(<StopMoonAnimation>d__78))] private IEnumerator StopMoonAnimation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StopMoonAnimation>d__78(0) { <>4__this = this }; } public static void CheckAndReplaceModel(GameObject? moonInstanceObject = null) { string text = Plugin.config.majoraMoonModel.Value; GameObject val = moonInstanceObject ?? Plugin.instance.majoraMoonObject; if ((Object)(object)val == (Object)null) { Plugin.logger.LogError((object)"Failed to replace the Majora Moon model, moon object is null."); return; } if ((Object)(object)moonInstanceObject != (Object)null) { if (modelName == "Vanilla") { SwapVanillaPrefabTexture(val); } else if (Compatibility.CodeRebirthInstalled && Compatibility.IsMajoraCodeRebirthCompatible()) { text = "Baldy"; } else if (Compatibility.PremiumScrapsInstalled && Compatibility.IsMajoraPremiumScrapsCompatible()) { text = "Abibabou"; } else if (Compatibility.SurfacedInstalled && Compatibility.IsMajoraSurfacedCompatible()) { text = "Owl"; } else if (Compatibility.EmergencyDiceInstalled && Compatibility.IsMajoraEmergencyDiceCompatible()) { text = "Dice"; } else if (Compatibility.BiodiversityInstalled && Compatibility.IsMajoraBiodiversityCompatible()) { text = "Boomy"; } } if (!modelName.Equals(text)) { ((Component)val.transform.Find("Models/" + text)).gameObject.SetActive(true); ((Component)val.transform.Find("Models/" + modelName)).gameObject.SetActive(false); modelName = text; } } private static void SwapVanillaPrefabTexture(GameObject? moonObject) { if ((Object)(object)moonObject == (Object)null) { return; } Random random = new Random(StartOfRound.Instance.randomMapSeed); SelectableLevel val = StartOfRound.Instance.levels[random.Next(0, StartOfRound.Instance.levels.Length)]; if ((Object)(object)val == (Object)null || (Object)(object)val.planetPrefab == (Object)null) { return; } Material material = ((Renderer)((Component)moonObject.transform.Find("Models/Vanilla")).gameObject.GetComponent<MeshRenderer>()).material; if (val.planetPrefab.transform.childCount != 0) { MeshRenderer componentInChildren = ((Component)val.planetPrefab.transform.GetChild(0)).GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).material != (Object)null && (Object)(object)((Renderer)componentInChildren).material.mainTexture != (Object)null) { material.SetTexture("_Texture2D", ((Renderer)componentInChildren).material.mainTexture); return; } } MeshRenderer componentInChildren2 = val.planetPrefab.GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren2 != (Object)null && (Object)(object)((Renderer)componentInChildren2).material != (Object)null && (Object)(object)((Renderer)componentInChildren2).material.mainTexture != (Object)null) { material.SetTexture("_Texture2D", ((Renderer)componentInChildren2).material.mainTexture); } } [ServerRpc] public void InitializeMoonServerRpc(NetworkObjectReference moonRef, Vector3 nodeEndPosition) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3016260971u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref moonRef, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref nodeEndPosition); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3016260971u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; InitializeMoonClientRpc(moonRef, nodeEndPosition); } } [ClientRpc] private void InitializeMoonClientRpc(NetworkObjectReference moonRef, Vector3 nodeEndPosition) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBeha