Decompiled source of LegendWeathers v1.1.5

plugins/LegendWeathers.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Biodiversity.Creatures;
using Biodiversity.Creatures.MicBird;
using DigitalRuby.ThunderAndLightning;
using GameNetcodeStuff;
using HarmonyLib;
using LegendWeathers.BehaviourScripts;
using LegendWeathers.NetcodePatcher;
using LegendWeathers.Utils;
using LegendWeathers.WeatherSkyEffects;
using LegendWeathers.Weathers;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MrovLib;
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;

[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("WeatherRegistry")]
[assembly: AssemblyCompany("LegendWeathers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c9045fbc751db43d1cebcd5a8d7223193f8efe7b")]
[assembly: AssemblyProduct("LegendWeathers")]
[assembly: AssemblyTitle("LegendWeathers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
	}
}
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 bool WeatherRegisteryInstalled = false;

		public bool BiodiversityInstalled = false;

		public bool SurfacedInstalled = false;

		public bool PremiumScrapsInstalled = false;

		public readonly ConfigEntry<bool> majoraWeather;

		public readonly ConfigEntry<string> majoraMoonModel;

		public readonly ConfigEntry<bool> majoraMoonModelAutomatic;

		public readonly ConfigEntry<float> majoraMoonMusicVolume;

		public readonly ConfigEntry<bool> majoraOcarinaCompatible;

		public readonly ConfigEntry<string> majoraMaskValue;

		public (int, int) majoraMaskValueParsed;

		public Config(ConfigFile cfg)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			cfg.SaveOnConfigSet = false;
			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[6] { "3DS", "N64", "Faceless", "Boomy", "Owl", "Abibabou" }), 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.");
			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. You can customize the music volume here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			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.");
			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. The final value will be randomized between these 2 numbers, but not divided by any external factors.");
			cfg.Save();
			cfg.SaveOnConfigSet = true;
		}

		public void SetupCustomConfigs()
		{
			WeatherRegisteryInstalled = Chainloader.PluginInfos.ContainsKey("mrov.WeatherRegistry");
			BiodiversityInstalled = Chainloader.PluginInfos.ContainsKey("com.github.biodiversitylc.Biodiversity");
			SurfacedInstalled = Chainloader.PluginInfos.ContainsKey("Surfaced");
			PremiumScrapsInstalled = Chainloader.PluginInfos.ContainsKey("zigzag.premiumscraps");
			if (!WeatherRegisteryInstalled)
			{
				Plugin.logger.LogError((object)"WeatherRegistery is not installed! Please install WeatherRegistery before using this mod.");
			}
			ParseValues();
		}

		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);
			}
		}
	}
	[BepInPlugin("zigzag.legendweathers", "LegendWeathers", "1.1.5")]
	[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 = "1.1.5";

		public static Plugin instance;

		public static ManualLogSource logger;

		private readonly Harmony harmony = new Harmony("zigzag.legendweathers");

		public GameObject? majoraMoonObject;

		public GameObject? majoraSkyObject;

		public Item? majoraMaskItem;

		public Item? majoraMoonTearItem;

		internal static Config config { get; private set; }

		private void HarmonyPatchAll()
		{
			harmony.PatchAll();
		}

		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>(LegendWeather.WeatherInfo info) 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(info, weatherEffect);
		}

		private void RegisterWeather<T>(LegendWeather.WeatherInfo info) 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(info, weatherEffect);
		}

		private void RegisterWeather(LegendWeather.WeatherInfo info, ImprovedWeatherEffect weatherEffect)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			Weather val = new Weather(info.name, weatherEffect);
			((ConfigHandler<int, int>)(object)val.Config.DefaultWeight).DefaultValue = info.weight;
			((ConfigHandler<float, float>)(object)val.Config.ScrapAmountMultiplier).DefaultValue = info.scrapAmount;
			((ConfigHandler<float, float>)(object)val.Config.ScrapValueMultiplier).DefaultValue = info.scrapValue;
			((ConfigHandler<bool, bool>)(object)val.Config.FilteringOption).DefaultValue = false;
			((ConfigHandler<SelectableLevel[], string>)(object)val.Config.LevelFilters).DefaultValue = "Gordion;Galetry;Cosmocos;Black Mesa;";
			val.Color = info.color;
			WeatherManager.RegisterWeather(val);
		}

		private void RegisterMajora(AssetBundle bundle, string directory)
		{
			majoraMoonObject = bundle.LoadAsset<GameObject>(directory + "MajoraMoon/MajoraMoon.prefab");
			majoraSkyObject = bundle.LoadAsset<GameObject>(directory + "MajoraMoon/MajoraSky.prefab");
			majoraMaskItem = bundle.LoadAsset<Item>(directory + "MajoraMoon/Items/MajoraMask/MajoraMaskItem.asset");
			majoraMoonTearItem = bundle.LoadAsset<Item>(directory + "MajoraMoon/Items/MoonTear/MoonTearItem.asset");
			if (!config.majoraMoonModel.Value.Equals(((ConfigEntryBase)config.majoraMoonModel).DefaultValue))
			{
				MajoraMoon.CheckAndReplaceModel();
				if (config.majoraMoonModel.Value == "N64")
				{
					((Component)majoraMaskItem.spawnPrefab.transform.Find("Model/Model1")).gameObject.SetActive(true);
					((Component)majoraMaskItem.spawnPrefab.transform.Find("Model/Model2")).gameObject.SetActive(false);
					((Component)((HauntedMaskItem)majoraMaskItem.spawnPrefab.GetComponent<MajoraMaskItem>()).headMaskPrefab.transform.Find("Model/Model1")).gameObject.SetActive(true);
					((Component)((HauntedMaskItem)majoraMaskItem.spawnPrefab.GetComponent<MajoraMaskItem>()).headMaskPrefab.transform.Find("Model/Model2")).gameObject.SetActive(false);
				}
			}
			NetworkPrefabs.RegisterNetworkPrefab(majoraMoonObject);
			NetworkPrefabs.RegisterNetworkPrefab(majoraMaskItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(majoraMoonTearItem.spawnPrefab);
			Utilities.FixMixerGroups(majoraMaskItem.spawnPrefab);
			Utilities.FixMixerGroups(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>(MajoraMoonWeather.weatherInfo);
		}

		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 directory = "Assets/Data/_Misc/LegendWeathers/";
			config = new Config(((BaseUnityPlugin)this).Config);
			config.SetupCustomConfigs();
			Effects.SetupNetwork();
			if (config.majoraWeather.Value)
			{
				RegisterMajora(bundle, directory);
			}
			HarmonyPatchAll();
			logger.LogInfo((object)"LegendWeathers is loaded !");
		}
	}
}
namespace LegendWeathers.Weathers
{
	public class LegendWeather : MonoBehaviour
	{
		public class WeatherInfo
		{
			public string name;

			public int weight;

			public float scrapAmount;

			public float scrapValue;

			public Color color;

			public WeatherInfo(string name, int weight, float scrapAmount, float scrapValue, Color color)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				this.name = name;
				this.weight = weight;
				this.scrapAmount = scrapAmount;
				this.scrapValue = scrapValue;
				this.color = color;
			}
		}

		private readonly WeatherInfo weatherInfo;

		private bool fogVolumeComponentExists = false;

		public LegendWeather(WeatherInfo info)
		{
			weatherInfo = info;
		}

		public virtual void OnEnable()
		{
			if (WeatherManager.IsSetupFinished)
			{
				Plugin.logger.LogInfo((object)(weatherInfo.name + " Weather is enabled !"));
			}
		}

		public virtual void OnDisable()
		{
			if (WeatherManager.IsSetupFinished)
			{
				Plugin.logger.LogInfo((object)(weatherInfo.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);
					}
				}
			}
			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 void EnableVanillaVolumeFog(bool enabled)
		{
			//IL_004a: 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)
			try
			{
				if (enabled && !fogVolumeComponentExists)
				{
					return;
				}
				Volume[] array = Object.FindObjectsOfType<Volume>();
				foreach (Volume val in array)
				{
					if ((Object)(object)val == (Object)null || (Object)(object)val.profile == (Object)null)
					{
						continue;
					}
					Scene scene = ((Component)val).gameObject.scene;
					if (((Scene)(ref scene)).name != RoundManager.Instance.currentLevel.sceneName)
					{
						continue;
					}
					foreach (VolumeComponent component in val.profile.components)
					{
						if (component.active && component is Fog)
						{
							component.active = enabled;
							fogVolumeComponentExists = !enabled;
						}
					}
				}
			}
			catch (Exception)
			{
				Plugin.logger.LogWarning((object)("Failed to " + (enabled ? "enable" : "disable") + " vanilla volume fog."));
			}
		}
	}
	public class MajoraMoon : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <InitializeMoon>d__76 : 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__76(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<moonNetObj>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: 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_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: 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_01cb: 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;
						}
						<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);
						}
						<>4__this.SetupComponents();
						<>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__66 : 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__66(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Expected O, but got Unknown
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Expected O, but got Unknown
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: Expected O, but got Unknown
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					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__72 : 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__72(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_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Expected O, but got Unknown
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c9: Expected O, but got Unknown
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0205: Expected O, but got Unknown
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Expected O, but got Unknown
				//IL_0264: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: 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:
					<>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 outsideNodeEndPosition;

		private Vector3 endPosition;

		private Vector3 endRotation;

		private Vector3 endScale;

		private float endTime;

		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 readonly List<VisualEnvironment> visualEnvironments = new List<VisualEnvironment>();

		private readonly 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;

		public bool AccelerateEndTimeFactor()
		{
			if (finalHoursPlayingParticles || oathToOrderStopingMoon)
			{
				return false;
			}
			endTimeFactor += (finalHoursPlayingMusic ? 0.3f : 0.6f);
			return true;
		}

		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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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)
			if (!isInitialized)
			{
				return;
			}
			if (finalHoursPlayingMusic && SoundManager.Instance.musicSource.isPlaying)
			{
				SoundManager.Instance.musicSource.Stop();
			}
			if (oathToOrderStopingMoon)
			{
				return;
			}
			if (TimeOfDay.Instance.currentDayTimeStarted)
			{
				if (previousSpeedMultiplier != TimeOfDay.Instance.globalTimeSpeedMultiplier)
				{
					previousSpeedMultiplier = TimeOfDay.Instance.globalTimeSpeedMultiplier;
					smoothPosVelocity = default(Vector3);
					smoothRotVelocity = default(Vector3);
					smoothScaVelocity = default(Vector3);
				}
				endTime = TimeOfDay.Instance.globalTimeAtEndOfDay / endTimeFactor;
				smoothTime = (endTime - TimeOfDay.Instance.currentDayTime) / TimeOfDay.Instance.globalTimeSpeedMultiplier;
				finalHoursTime = endTime - 280f;
			}
			if (smoothTime != 0f)
			{
				((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);
			}
			PlayRandomEvents();
			FinalHours();
		}

		private void FinalHours()
		{
			if (!finalHoursPlayingMusic && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 30f)
			{
				StartMusic();
				finalHoursPlayingMusic = true;
			}
			if (!finalHoursDisplayingTimer && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 50f)
			{
				StartTimer();
				StartIncreasingWindSpeed();
				finalHoursDisplayingTimer = true;
			}
			if (!finalHoursPlayingParticles && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 205f)
			{
				StartParticles();
				StartCrashAudio();
				finalHoursPlayingParticles = true;
			}
			if (!finalHoursFinishing && TimeOfDay.Instance.currentDayTime >= finalHoursTime + 235f)
			{
				((MonoBehaviour)this).StartCoroutine(StartFinishing());
				finalHoursFinishing = true;
			}
			UpdateTimer(smoothTime - 20f);
			UpdateImpact();
		}

		private void StartMusic()
		{
			finalHoursAudio.volume = Plugin.config.majoraMoonMusicVolume.Value;
			finalHoursAudio.Play();
		}

		private void StartTimer()
		{
			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 StartIncreasingWindSpeed()
		{
			for (int i = 0; i < visualEnvironments.Count; i++)
			{
				if ((Object)(object)visualEnvironments[i] != (Object)null)
				{
					FloatParameter windSpeed = visualEnvironments[i].windSpeed;
					((VolumeParameter<float>)(object)windSpeed).value = ((VolumeParameter<float>)(object)windSpeed).value * (float)windSpeedFactor;
				}
			}
		}

		private void StartParticles()
		{
			crashParticles1.Play();
			crashParticles2.Play();
		}

		private void StartCrashAudio()
		{
			crashAudio.Play();
		}

		[IteratorStateMachine(typeof(<StartFinishing>d__66))]
		private IEnumerator StartFinishing()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StartFinishing>d__66(0)
			{
				<>4__this = this
			};
		}

		private void DisableColliders(bool disable = true)
		{
			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;
				}
			}
		}

		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 (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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (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 == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				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__72))]
		private IEnumerator StopMoonAnimation()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StopMoonAnimation>d__72(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 (Plugin.config.PremiumScrapsInstalled && Effects.IsMajoraPremiumScrapsCompatible())
				{
					text = "Abibabou";
				}
				else if (Plugin.config.SurfacedInstalled && Effects.IsMajoraSurfacedCompatible())
				{
					text = "Owl";
				}
				else if (Plugin.config.BiodiversityInstalled && Effects.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;
			}
		}

		[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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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))
			{
				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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1070354409u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref moonRef, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref nodeEndPosition);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1070354409u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(InitializeMoon(moonRef, nodeEndPosition));
				}
			}
		}

		[IteratorStateMachine(typeof(<InitializeMoon>d__76))]
		private IEnumerator InitializeMoon(NetworkObjectReference moonRef, Vector3 nodeEndPosition)
		{
			//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 <InitializeMoon>d__76(0)
			{
				<>4__this = this,
				moonRef = moonRef,
				nodeEndPosition = nodeEndPosition
			};
		}

		private void SetupComponents()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Volume[] array = Object.FindObjectsOfType<Volume>();
			foreach (Volume val in array)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)val.profile == (Object)null)
				{
					continue;
				}
				Scene scene = ((Component)val).gameObject.scene;
				if (((Scene)(ref scene)).name != RoundManager.Instance.currentLevel.sceneName)
				{
					continue;
				}
				foreach (VolumeComponent component in val.profile.components)
				{
					if (component.active)
					{
						VisualEnvironment val2 = (VisualEnvironment)(object)((component is VisualEnvironment) ? component : null);
						if (val2 != null && ((VolumeParameter)val2.windSpeed).overrideState)
						{
							visualEnvironments.Add(val2);
							originalWindSpeeds.Add(((VolumeParameter<float>)(object)val2.windSpeed).value);
						}
					}
				}
			}
			shipLever = Object.FindObjectOfType<StartMatchLever>();
		}

		public override void OnDestroy()
		{
			if (finalHoursPlayingMusic)
			{
				finalHoursAudio.Stop();
			}
			if (finalHoursDisplayingTimer)
			{
				if ((Object)(object)timerUI != (Object)null)
				{
					Object.Destroy((Object)(object)timerUI);
					timerUI = null;
					timerText = null;
				}
				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();
			}
			if (finalHoursPlayingParticles)
			{
				crashParticles1.Stop();
				crashParticles2.Stop();
				crashAudio.Stop();
			}
			if (finalHoursFinishing && (Object)(object)impact != (Object)null)
			{
				Object.Destroy((Object)(object)impact);
				impact = null;
			}
			if (sfxAudio.isPlaying)
			{
				sfxAudio.Stop();
			}
			if (oathToOrderStopingMoon)
			{
				burstParticles1.Stop();
				burstParticles2.Stop();
				burstVFX.Stop();
			}
			if (stopMoonCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(stopMoonCoroutine);
			}
			modelName = Plugin.config.majoraMoonModel.Value;
			((NetworkBehaviour)this).OnDestroy();
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MajoraMoon()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1254625525u, new RpcReceiveHandler(__rpc_handler_1254625525));
			NetworkManager.__rpc_func_table.Add(3016260971u, new RpcReceiveHandler(__rpc_handler_3016260971));
			NetworkManager.__rpc_func_table.Add(1070354409u, new RpcReceiveHandler(__rpc_handler_1070354409));
		}

		private static void __rpc_handler_1254625525(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int eventID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref eventID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MajoraMoon)(object)target).PlayRandomEventsClientRpc(eventID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3016260971(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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//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 moonRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref moonRef, default(ForNetworkSerializable));
				Vector3 nodeEndPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref nodeEndPosition);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MajoraMoon)(object)target).InitializeMoonServerRpc(moonRef, nodeEndPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1070354409(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 moonRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref moonRef, default(ForNetworkSerializable));
				Vector3 nodeEndPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref nodeEndPosition);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MajoraMoon)(object)target).InitializeMoonClientRpc(moonRef, nodeEndPosition);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MajoraMoon";
		}
	}
	public static class MajoraMoonPositions
	{
		private static readonly Dictionary<string, (Vector3, Vector3, Vector3)> positionInfo = new Dictionary<string, (Vector3, Vector3, Vector3)>
		{
			{
				"Experimentation",
				(new Vector3(-44f, 300f, 85f), new Vector3(45f, 180f, 0f), new Vector3(-46f, 0f, -14f))
			},
			{
				"Assurance",
				(new Vector3(25f, 300f, -50f), new Vector3(45f, 0f, 0f), new Vector3(32f, 0f, -40f))
			},
			{
				"Vow",
				(new Vector3(-186f, 300f, 100f), new Vector3(45f, 90f, 0f), new Vector3(-4f, -1f, 26f))
			},
			{
				"March",
				(new Vector3(-120f, 300f, 0f), new Vector3(45f, 90f, 0f), new Vector3(-65f, -10f, -9f))
			},
			{
				"Offense",
				(new Vector3(150f, 300f, -100f), new Vector3(45f, 270f, 0f), new Vector3(46f, 6f, -103f))
			},
			{
				"Adamance",
				(new Vector3(-200f, 250f, 100f), new Vector3(45f, 120f, 0f), new Vector3(-119f, 10f, 33f))
			},
			{
				"Rend",
				(new Vector3(100f, 290f, -80f), new Vector3(45f, 315f, 0f), new Vector3(3f, -10f, -92f))
			},
			{
				"Dine",
				(new Vector3(-100f, 290f, -100f), new Vector3(45f, 0f, 0f), new Vector3(-96f, -10f, -20f))
			},
			{
				"Titan",
				(new Vector3(50f, 330f, -50f), new Vector3(45f, 290f, 0f), new Vector3(-17f, 37f, -6f))
			},
			{
				"Artifice",
				(new Vector3(-100f, 300f, -100f), new Vector3(45f, 90f, 0f), new Vector3(34f, 3f, -71f))
			},
			{
				"Embrion",
				(new Vector3(-100f, 250f, -100f), new Vector3(45f, 0f, 0f), new Vector3(-87f, -5f, -21f))
			},
			{
				"Atlas Abyss",
				(new Vector3(-120f, 150f, -30f), new Vector3(45f, 90f, 0f), new Vector3(-80f, 10f, -24f))
			},
			{
				"Bozoros",
				(new Vector3(-100f, 300f, -100f), new Vector3(45f, 50f, 0f), new Vector3(-66f, 0f, -14f))
			},
			{
				"Desolation",
				(new Vector3(-77f, 298f, 75f), new Vector3(45f, 180f, 0f), new Vector3(-59f, 0f, 56f))
			},
			{
				"Infernis",
				(new Vector3(-100f, 297f, -92f), new Vector3(45f, 90f, 0f), new Vector3(-48f, 9f, -72f))
			},
			{
				"Solace",
				(new Vector3(0f, 300f, 150f), new Vector3(45f, 180f, 0f), new Vector3(-10f, -4f, 45f))
			},
			{
				"StarlancerZero",
				(new Vector3(-50f, 300f, -150f), new Vector3(45f, 0f, 0f), new Vector3(-66f, 0f, -120f))
			},
			{
				"Synthesis",
				(new Vector3(-100f, 300f, -10f), new Vector3(45f, 90f, 0f), new Vector3(-100f, 0f, -14f))
			},
			{
				"Arcadia",
				(new Vector3(-200f, 295f, -50f), new Vector3(45f, 90f, 0f), new Vector3(-115f, 0f, -26f))
			},
			{
				"Acidir",
				(new Vector3(-60f, 230f, 60f), new Vector3(45f, 90f, 0f), new Vector3(-48f, 0f, 23f))
			},
			{
				"Alcatras",
				(new Vector3(-150f, 300f, 100f), new Vector3(45f, 120f, 0f), new Vector3(-75f, -3f, 35f))
			},
			{
				"Asteroid-13",
				(new Vector3(-150f, 300f, -50f), new Vector3(45f, 90f, 0f), new Vector3(-126f, -5f, -63f))
			},
			{
				"Hyve",
				(new Vector3(-100f, 300f, 0f), new Vector3(45f, 90f, 0f), new Vector3(-77f, 2f, -10f))
			},
			{
				"Atlantica",
				(new Vector3(-100f, 298f, 0f), new Vector3(45f, 90f, 0f), new Vector3(-73f, 0f, 7f))
			},
			{
				"Calist",
				(new Vector3(66f, 305f, -80f), new Vector3(45f, 0f, 0f), new Vector3(37f, 1f, -52f))
			},
			{
				"Demetrica",
				(new Vector3(-100f, 298f, -11f), new Vector3(45f, 90f, 0f), new Vector3(-58f, 1f, 10f))
			},
			{
				"Empra",
				(new Vector3(-1300f, 400f, -17f), new Vector3(45f, 90f, 0f), new Vector3(-1298f, 0f, 0f))
			},
			{
				"Etern",
				(new Vector3(-50f, 300f, -50f), new Vector3(45f, 90f, 0f), new Vector3(-66f, 0f, -52f))
			},
			{
				"Filitrios",
				(new Vector3(43f, 299f, 53f), new Vector3(45f, 180f, 0f), new Vector3(11f, 0f, 21f))
			},
			{
				"Fission-C",
				(new Vector3(-34f, 298f, -90f), new Vector3(45f, 0f, 0f), new Vector3(-67f, 5f, -82f))
			},
			{
				"Gloom",
				(new Vector3(-100f, 150f, -10f), new Vector3(45f, 90f, 0f), new Vector3(-87f, -5f, -9f))
			},
			{
				"Gratar",
				(new Vector3(70f, 300f, -90f), new Vector3(45f, 0f, 0f), new Vector3(62f, 2f, -85f))
			},
			{
				"Junic",
				(new Vector3(131f, 298f, 0f), new Vector3(45f, 270f, 0f), new Vector3(99f, 0f, -7f))
			},
			{
				"Lecaro",
				(new Vector3(-50f, 300f, -80f), new Vector3(45f, 90f, 0f), new Vector3(-47f, 5f, -90f))
			},
			{
				"Motra",
				(new Vector3(51f, 328f, 13f), new Vector3(45f, 180f, 0f), new Vector3(48f, 30f, 33f))
			},
			{
				"Oldred",
				(new Vector3(37f, 305f, 103f), new Vector3(45f, 180f, 0f), new Vector3(33f, 4f, 101f))
			},
			{
				"Polarus",
				(new Vector3(-80f, 298f, -80f), new Vector3(45f, 45f, 0f), new Vector3(-79f, -30f, -74f))
			},
			{
				"Utril",
				(new Vector3(30f, 298f, 41f), new Vector3(45f, 180f, 0f), new Vector3(11f, 12f, 15f))
			},
			{
				"Baykal",
				(new Vector3(-35f, 295f, -100f), new Vector3(45f, 0f, 0f), new Vector3(-32f, -3f, -64f))
			},
			{
				"Flicker",
				(new Vector3(11f, 300f, -170f), new Vector3(45f, 0f, 0f), new Vector3(4f, -1f, -147f))
			},
			{
				"The Iris",
				(new Vector3(150f, 300f, 80f), new Vector3(45f, 250f, 0f), new Vector3(-25f, 0f, 58f))
			},
			{
				"Halation",
				(new Vector3(31f, 298f, 30f), new Vector3(45f, 270f, 0f), new Vector3(33f, -5f, 2f))
			},
			{
				"Lament",
				(new Vector3(-177f, 300f, 47f), new Vector3(45f, 90f, 0f), new Vector3(-177f, -25f, 47f))
			},
			{
				"Lithium",
				(new Vector3(-37f, 300f, -132f), new Vector3(45f, 330f, 0f), new Vector3(-37f, 0f, -132f))
			},
			{
				"Mazon",
				(new Vector3(-41f, 300f, 98f), new Vector3(45f, 90f, 0f), new Vector3(-41f, 0f, 98f))
			},
			{
				"Kaleidos",
				(new Vector3(177f, 300f, 39f), new Vector3(45f, 220f, 0f), new Vector3(177f, 0f, 39f))
			},
			{
				"Pandoramus",
				(new Vector3(-92f, 300f, 57f), new Vector3(45f, 150f, 0f), new Vector3(-92f, 0f, 57f))
			},
			{
				"Pareidolia",
				(new Vector3(75f, 300f, -149f), new Vector3(45f, 270f, 0f), new Vector3(75f, 0f, -149f))
			},
			{
				"Praetor",
				(new Vector3(-120f, 150f, -30f), new Vector3(45f, 90f, 0f), new Vector3(-58f, 0f, -25f))
			},
			{
				"Rockwell",
				(new Vector3(290f, 297f, 110f), new Vector3(45f, 180f, 0f), new Vector3(302f, 0f, 103f))
			},
			{
				"Ganimedes",
				(new Vector3(53f, 300f, 33f), new Vector3(45f, 180f, 0f), new Vector3(53f, 11f, 33f))
			},
			{
				"Prominence",
				(new Vector3(-55f, 300f, 103f), new Vector3(45f, 100f, 0f), new Vector3(-55f, -9f, 103f))
			},
			{
				"Sierra",
				(new Vector3(17f, 300f, -41f), new Vector3(45f, 0f, 0f), new Vector3(17f, 18f, -41f))
			},
			{
				"Temper",
				(new Vector3(-162f, 300f, -76f), new Vector3(45f, 90f, 0f), new Vector3(-162f, -8f, -76f))
			},
			{
				"Kast",
				(new Vector3(-39f, 295f, 30f), new Vector3(45f, 150f, 0f), new Vector3(-39f, -1f, 30f))
			},
			{
				"Secret Labs",
				(new Vector3(100f, 300f, 0f), new Vector3(45f, 290f, 0f), new Vector3(60f, 0f, 7f))
			},
			{
				"Sector-0",
				(new Vector3(60f, 300f, -60f), new Vector3(45f, 320f, 0f), new Vector3(20f, -2f, -64f))
			},
			{
				"Aquatis",
				(new Vector3(-83f, 300f, -12f), new Vector3(45f, 60f, 0f), new Vector3(-83f, -2f, -12f))
			},
			{
				"Orion",
				(new Vector3(-74f, 299f, 55f), new Vector3(45f, 180f, 0f), new Vector3(-74f, 1f, 55f))
			},
			{
				"Wither",
				(new Vector3(-60f, 330f, -100f), new Vector3(45f, 0f, 0f), new Vector3(-39f, 5f, -110f))
			},
			{
				"Bilge",
				(new Vector3(-117f, 297f, -23f), new Vector3(45f, 130f, 0f), new Vector3(-117f, -20f, -23f))
			},
			{
				"Chronos",
				(new Vector3(-37f, 300f, -78f), new Vector3(45f, 75f, 0f), new Vector3(-37f, -3f, -78f))
			},
			{
				"Acheron",
				(new Vector3(-67f, 295f, 56f), new Vector3(45f, 160f, 0f), new Vector3(-67f, -20f, 56f))
			},
			{
				"-Acheron",
				(new Vector3(-67f, 295f, 56f), new Vector3(45f, 160f, 0f), new Vector3(-67f, -20f, 56f))
			},
			{
				"Kanie",
				(new Vector3(-220f, 300f, -16f), new Vector3(45f, 50f, 0f), new Vector3(-220f, 1f, -16f))
			}
		};

		public static (Vector3, Vector3, Vector3) Get(string planetName, bool searchKnown = true)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			if (searchKnown)
			{
				string text = Regex.Replace(planetName, "^[0-9]+", string.Empty);
				if (text[0] == ' ')
				{
					string text2 = text;
					text = text2.Substring(1, text2.Length - 1);
				}
				if (positionInfo.ContainsKey(text))
				{
					return positionInfo[text];
				}
			}
			Vector3 val = default(Vector3);
			EntranceTeleport val2 = null;
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			if (array != null && array.Length != 0)
			{
				val2 = array.ToList().Find((EntranceTeleport e) => (Object)(object)e != (Object)null && ((Behaviour)e).enabled && e.isEntranceToBuilding && e.entranceId == 0);
				if ((Object)(object)val2 != (Object)null)
				{
					val = Effects.GetClosestAINodePosition(RoundManager.Instance.outsideAINodes, Vector3.Lerp(((Component)StartOfRound.Instance.middleOfShipNode).transform.position, ((Component)val2).transform.position, 0.5f));
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val = RoundManager.Instance.outsideAINodes[RoundManager.Instance.outsideAINodes.Length / 2].transform.position;
			}
			return (val + Vector3.up * 300f, new Vector3(45f, 90f, 0f), val);
		}
	}
	public class MajoraMoonWeather : LegendWeather
	{
		public static WeatherInfo weatherInfo = new WeatherInfo("Majora Moon", 50, 1.7f, 1f, new Color(0.7f, 0f, 0.8f, 1f));

		public static string weatherAlert = "The grimacing moon moves inexorably closer. Be quick!";

		private GameObject? spawnedMoon = null;

		private GameObject? spawnedMask = null;

		public MajoraMoonWeather()
			: base(weatherInfo)
		{
		}

		public override void OnEnable()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			base.OnEnable();
			if (!WeatherManager.IsSetupFinished)
			{
				return;
			}
			if (!RoundManager.Instance.currentLevel.planetHasTime)
			{
				Plugin.logger.LogError((object)(weatherInfo.name + " requires a planet with time."));
				return;
			}
			if (NetworkManager.Singleton.IsServer)
			{
				(Vector3, Vector3, Vector3) tuple = MajoraMoonPositions.Get(RoundManager.Instance.currentLevel.PlanetName);
				spawnedMoon = Object.Instantiate<GameObject>(Plugin.instance.majoraMoonObject, tuple.Item1, Quaternion.Euler(tuple.Item2));
				if ((Object)(object)spawnedMoon != (Object)null)
				{
					NetworkObject component = spawnedMoon.GetComponent<NetworkObject>();
					component.Spawn(true);
					spawnedMoon.GetComponent<MajoraMoon>().InitializeMoonServerRpc(NetworkObjectReference.op_Implicit(component), tuple.Item3);
				}
				else
				{
					Plugin.logger.LogError((object)("Failed to spawn " + weatherInfo.name + " on the server."));
				}
				if ((Object)(object)Plugin.instance.majoraMaskItem != (Object)null)
				{
					Vector3 position = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length - 1)].transform.position;
					spawnedMask = Object.Instantiate<GameObject>(Plugin.instance.majoraMaskItem.spawnPrefab, position + Vector3.up * 0.25f, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
					if ((Object)(object)spawnedMask != (Object)null)
					{
						MajoraMaskItem component2 = spawnedMask.GetComponent<MajoraMaskItem>();
						((Component)component2).transform.rotation = Quaternion.Euler(((GrabbableObject)component2).itemProperties.restingRotation);
						((GrabbableObject)component2).fallTime = 1f;
						((GrabbableObject)component2).hasHitGround = true;
						((GrabbableObject)component2).reachedFloorTarget = true;
						((GrabbableObject)component2).isInFactory = true;
						((GrabbableObject)component2).scrapValue = (int)((float)Random.Range(Plugin.instance.majoraMaskItem.minValue, Plugin.instance.majoraMaskItem.maxValue) * RoundManager.Instance.scrapValueMultiplier);
						((NetworkBehaviour)component2).NetworkObject.Spawn(false);
						component2.SyncMaskServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)component2).NetworkObject), ((GrabbableObject)component2).scrapValue);
					}
					else
					{
						Plugin.logger.LogError((object)"Failed to spawn the Majora Mask item on the server.");
					}
				}
			}
			EnableVanillaSun(enabled: false);
		}

		public override void OnDisable()
		{
			base.OnDisable();
			if (!WeatherManager.IsSetupFinished)
			{
				return;
			}
			if (NetworkManager.Singleton.IsServer)
			{
				if ((Object)(object)spawnedMoon != (Object)null)
				{
					NetworkObject component = spawnedMoon.GetComponent<NetworkObject>();
					if ((Object)(object)component != (Object)null && component.IsSpawned)
					{
						component.Despawn(true);
					}
					spawnedMoon = null;
				}
				if ((Object)(object)spawnedMask != (Object)null)
				{
					MajoraMaskItem component2 = spawnedMask.GetComponent<MajoraMaskItem>();
					NetworkObject component3 = spawnedMask.GetComponent<NetworkObject>();
					if ((Object)(object)component2 != (Object)null && !component2.hasBeenFound)
					{
						if ((Object)(object)component3 != (Object)null && component3.IsSpawned)
						{
							component3.Despawn(true);
						}
						spawnedMask = null;
					}
				}
			}
			EnableVanillaSun(enabled: true);
		}
	}
}
namespace LegendWeathers.WeatherSkyEffects
{
	public class MajoraSkyEffect : SkyEffect
	{
		[CompilerGenerated]
		private sealed class <ReverseEffectCoroutine>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MajoraSkyEffect <>4__this;

			private float <weight>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ReverseEffectCoroutine>d__9(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					if (!((Object)(object)<>4__this.spawnedSkyVolume != (Object)null))
					{
						goto IL_00e7;
					}
					<weight>5__1 = <>4__this.spawnedSkyVolume.weight;
				}
				if (<>4__this.spawnedSkyVolume.weight > <>4__this.minWeight)
				{
					if (!<>4__this.isCoroutineRunning)
					{
						return false;
					}
					Volume? spawnedSkyVolume = <>4__this.spawnedSkyVolume;
					spawnedSkyVolume.weight -= <weight>5__1 * Time.deltaTime / 5f;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<>4__this.spawnedSkyVolume.weight = <>4__this.minWeight;
				goto IL_00e7;
				IL_00e7:
				<>4__this.isCoroutineRunning = false;
				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();
			}
		}

		private readonly float minWeight = 0.05f;

		private readonly float maxWeight = 0.9f;

		private bool isReversed = false;

		private bool isCoroutineRunning = false;

		public MajoraSkyEffect()
			: base(Plugin.instance.majoraSkyObject)
		{
			overrideFogVolume = true;
		}

		public override void OnEnable()
		{
			if (WeatherManager.IsSetupFinished && RoundManager.Instance.currentLevel.planetHasTime)
			{
				base.OnEnable();
			}
		}

		public override void OnDisable()
		{
			if (WeatherManager.IsSetupFinished)
			{
				if (StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase)
				{
					isReversed = false;
				}
				isCoroutineRunning = false;
				base.OnDisable();
			}
		}

		public override void Update()
		{
			if (base.IsEffectActive && (Object)(object)spawnedSkyVolume != (Object)null && TimeOfDay.Instance.currentDayTimeStarted)
			{
				if (!isReversed && spawnedSkyVolume.weight < maxWeight)
				{
					float num = TimeOfDay.Instance.globalTimeAtEndOfDay / 2.1f;
					spawnedSkyVolume.weight = TimeOfDay.Instance.currentDayTime * maxWeight / num;
				}
				else if (isReversed && !isCoroutineRunning)
				{
					spawnedSkyVolume.weight = minWeight;
				}
			}
		}

		public void ReverseEffect()
		{
			if (base.IsEffectActive && (Object)(object)spawnedSkyVolume != (Object)null && TimeOfDay.Instance.currentDayTimeStarted)
			{
				isCoroutineRunning = true;
				((MonoBehaviour)this).StartCoroutine(ReverseEffectCoroutine());
			}
			isReversed = true;
		}

		[IteratorStateMachine(typeof(<ReverseEffectCoroutine>d__9))]
		private IEnumerator ReverseEffectCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ReverseEffectCoroutine>d__9(0)
			{
				<>4__this = this
			};
		}

		public void ResetState()
		{
			isReversed = false;
			isCoroutineRunning = false;
		}
	}
	public class SkyEffect : MonoBehaviour
	{
		private readonly GameObject effectGameObject;

		private readonly string effectName;

		private bool fogVolumeComponentExists = false;

		public GameObject? spawnedSky = null;

		public Volume? spawnedSkyVolume = null;

		public bool overrideFogVolume = false;

		public bool IsEffectActive { get; private set; } = false;


		public SkyEffect(GameObject? gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				throw new NullReferenceException("SkyEffect GameObject is null.");
			}
			effectGameObject = gameObject;
			effectName = ((Object)gameObject).name;
		}

		public virtual void OnEnable()
		{
			if (!WeatherManager.IsSetupFinished)
			{
				return;
			}
			spawnedSky = Object.Instantiate<GameObject>(effectGameObject);
			if ((Object)(object)spawnedSky != (Object)null)
			{
				if (spawnedSkyVolume == null)
				{
					spawnedSkyVolume = spawnedSky.GetComponent<Volume>();
				}
				foreach (VolumeComponent component in spawnedSkyVolume.profile.components)
				{
					if (component.active)
					{
						Fog val = (Fog)(object)((component is Fog) ? component : null);
						if (val != null)
						{
							((VolumeParameter<bool>)(object)val.enableVolumetricFog).value = false;
							((VolumeParameter)val.enableVolumetricFog).overrideState = true;
							IsEffectActive = true;
							break;
						}
					}
				}
			}
			else
			{
				Plugin.logger.LogError((object)("Failed to instantiate " + effectName + " Sky Effect."));
			}
			if (overrideFogVolume)
			{
				EnableVanillaVolumeFog(enabled: false);
			}
		}

		public virtual void OnDisable()
		{
			if (WeatherManager.IsSetupFinished)
			{
				if ((Object)(object)spawnedSky != (Object)null)
				{
					IsEffectActive = false;
					Object.Destroy((Object)(object)spawnedSky);
					spawnedSky = null;
					spawnedSkyVolume = null;
				}
				if (overrideFogVolume)
				{
					EnableVanillaVolumeFog(enabled: true);
				}
			}
		}

		public virtual void Update()
		{
		}

		private void EnableVanillaVolumeFog(bool enabled)
		{
			//IL_004a: 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)
			try
			{
				if (enabled && !fogVolumeComponentExists)
				{
					return;
				}
				Volume[] array = Object.FindObjectsOfType<Volume>();
				foreach (Volume val in array)
				{
					if ((Object)(object)val == (Object)null || (Object)(object)val.profile == (Object)null)
					{
						continue;
					}
					Scene scene = ((Component)val).gameObject.scene;
					if (((Scene)(ref scene)).name != RoundManager.Instance.currentLevel.sceneName)
					{
						continue;
					}
					foreach (VolumeComponent component in val.profile.components)
					{
						if (component.active && component is Fog)
						{
							component.active = enabled;
							fogVolumeComponentExists = !enabled;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)("Failed to " + (enabled ? "enable" : "disable") + " vanilla volume fog.\n" + ex.Message));
			}
		}
	}
}
namespace LegendWeathers.Utils
{
	internal class Effects
	{
		public enum DeathAnimation
		{
			Normal,
			NoHead1,
			Spring,
			Haunted,
			Mask1,
			Mask2,
			Fire,
			CutInHalf,
			NoHead2
		}

		public class ItemNetworkReference
		{
			public NetworkObjectReference netObjectRef;

			public int value;

			public int save;

			public ItemNetworkReference(NetworkObjectReference netObjectRef, int value, int save = 0)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				this.netObjectRef = netObjectRef;
				this.value = value;
				this.save = save;
			}
		}

		[CompilerGenerated]
		private sealed class <FadeOutAudio>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public AudioSource source;

			public float time;

			public bool specialStop;

			private float <volume>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FadeOutAudio>d__15(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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;
					<volume>5__1 = source.volume;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (source.volume > 0f)
				{
					AudioSource obj = source;
					obj.volume -= <volume>5__1 * Time.deltaTime / time;
					if (!specialStop || !(source.volume <= 0.04f))
					{
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
				}
				source.Stop();
				source.volume = <volume>5__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 <ShakeCameraAdvanced>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ScreenShakeType shakeType;

			public int repeat;

			public float inBetweenTimer;

			private int <i>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ShakeCameraAdvanced>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Invalid comparison between Unknown and I4
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Invalid comparison between Unknown and I4
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Invalid comparison between Unknown and I4
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_009a;
				}
				<>1__state = -1;
				if ((int)shakeType == 2 || (int)shakeType == 3)
				{
					<i>5__1 = 0;
					goto IL_00ab;
				}
				HUDManager.Instance.ShakeCamera(shakeType);
				goto IL_00d3;
				IL_00d3:
				return false;
				IL_009a:
				<i>5__1++;
				goto IL_00ab;
				IL_00ab:
				if (<i>5__1 < repeat)
				{
					HUDManager.Instance.playerScreenShakeAnimator.SetTrigger(((int)shakeType == 2) ? "longShake" : "veryStrongShake");
					if (repeat > 1)
					{
						<>2__current = (object)new WaitForSeconds(inBetweenTimer);
						<>1__state = 1;
						return true;
					}
					goto IL_009a;
				}
				goto IL_00d3;
			}

			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 <Status>d__33 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string text;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Status>d__33(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				HUDManager.Instance.DisplayStatusEffect(text);
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				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 <SyncItem>d__40 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkObjectReference itemRef;

			public int value;

			public int save;

			private NetworkObject <itemNetObject>5__1;

			private float <startTime>5__2;

			private GrabbableObject <component>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SyncItem>d__40(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<itemNetObject>5__1 = null;
				<component>5__3 = 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;
					<itemNetObject>5__1 = null;
					<startTime>5__2 = Time.realtimeSinceStartup;
					goto IL_0064;
				case 1:
					<>1__state = -1;
					goto IL_0064;
				case 2:
					{
						<>1__state = -1;
						<component>5__3 = ((Component)<itemNetObject>5__1).GetComponent<GrabbableObject>();
						<component>5__3.fallTime = 0f;
						if (<component>5__3.itemProperties.isScrap)
						{
							<component>5__3.SetScrapValue(value);
						}
						if (<component>5__3.itemProperties.saveItemVariable)
						{
							<component>5__3.LoadItemSaveData(save);
						}
						return false;
					}
					IL_0064:
					if (Time.realtimeSinceStartup - <startTime>5__2 < 8f && !((NetworkObjectReference)(ref itemRef)).TryGet(ref <itemNetObject>5__1, (NetworkManager)null))
					{
						<>2__current = (object)new WaitForSeconds(0.03f);
						<>1__state = 1;
						return true;
					}
					if ((Object)(object)<itemNetObject>5__1 == (Object)null)
					{
						Plugin.logger.LogError((object)"Error while trying to sync the item.");
						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();
			}
		}

		public static void SetupNetwork()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		public static List<PlayerControllerB> GetPlayers(bool includeDead = false, bool excludeOutsideFactory = false)
		{
			List<PlayerControllerB> list = StartOfRound.Instance.allPlayerScripts.ToList();
			List<PlayerControllerB> list2 = new List<PlayerControllerB>(list);
			foreach (PlayerControllerB item in list)
			{
				if (!((NetworkBehaviour)item).IsSpawned || !item.isPlayerControlled || (!includeDead && item.isPlayerDead) || (excludeOutsideFactory && !item.isInsideFactory))
				{
					list2.Remove(item);
				}
			}
			return list2;
		}

		public static List<PlayerControllerB> GetRandomPlayers(int numberToGet, bool shouldIgnoreOnePlayer = false, ulong playerIdToIgnore = 0uL)
		{
			List<PlayerControllerB> list = StartOfRound.Instance.allPlayerScripts.ToList();
			list.RemoveAll((PlayerControllerB p) => (Object)(object)p == (Object)null || !((NetworkBehaviour)p).IsSpawned || !p.isPlayerControlled || (shouldIgnoreOnePlayer && p.playerClientId == playerIdToIgnore));
			List<PlayerControllerB> list2 = new List<PlayerControllerB>();
			if (list.Count > numberToGet)
			{
				Random random = new Random();
				int num = list.Count;
				while (num > 1)
				{
					num--;
					int num2 = random.Next(num + 1);
					List<PlayerControllerB> list3 = list;
					int index = num;
					int index2 = num2;
					PlayerControllerB value = list[num2];
					PlayerControllerB value2 = list[num];
					list3[index] = value;
					list[index2] = value2;
				}
			}
			if (list.Count <= 1)
			{
				for (int i = 0; i < numberToGet; i++)
				{
					list2.Add((list.Count != 0) ? list[0] : StartOfRound.Instance.allPlayerScripts[0]);
				}
				return list2;
			}
			for (int j = 0; j < numberToGet; j++)
			{
				int index3 = ((j < list.Count) ? j : (j - list.Count));
				list2.Add(list[index3]);
			}
			return list2;
		}

		public static List<EnemyAI> GetEnemies(bool includeDead = false, bool includeCanDie = false, bool excludeDaytime = false)
		{
			List<EnemyAI> list = Object.FindObjectsOfType<EnemyAI>().ToList();
			List<EnemyAI> list2 = new List<EnemyAI>(list);
			if (includeDead)
			{
				return list2;
			}
			foreach (EnemyAI item in list)
			{
				if (!((NetworkBehaviour)item).IsSpawned || item.isEnemyDead || (!includeCanDie && !item.enemyType.canDie) || (excludeDaytime && item.enemyType.isDaytimeEnemy))
				{
					list2.Remove(item);
				}
			}
			return list2;
		}

		public static void Damage(PlayerControllerB player, int damageNb, CauseOfDeath cause = 0, int animation = 0, bool criticalBlood = true)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			damageNb = ((player.health > 100 && damageNb == 100) ? 900 : damageNb);
			if (criticalBlood && player.health - damageNb <= 20)
			{
				player.bleedingHeavily = true;
			}
			player.DamagePlayer(damageNb, true, true, cause, animation, false, default(Vector3));
		}

		public static void Heal(ulong playerID, int health)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerID];
			val.health = ((val.health > 100) ? val.health : health);
			val.criticallyInjured = false;
			val.bleedingHeavily = false;
			val.playerBodyAnimator.SetBool("Limp", false);
		}

		public static void Teleportation(PlayerControllerB player, Vector3 position)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			player.averageVelocity = 0f;
			player.velocityLastFrame = Vector3.zero;
			player.TeleportPlayer(position, true, 0f, false, true);
			player.beamOutParticle.Play();
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
		}

		public static void SetPosFlags(ulong playerID, bool ship = false, bool exterior = false, bool interior = false)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerID];
			if (ship)
			{
				val.isInElevator = true;
				val.isInHangarShipRoom = true;
				val.isInsideFactory = false;
			}
			if (exterior)
			{
				val.isInElevator = false;
				val.isInHangarShipRoom = false;
				val.isInsideFactory = false;
			}
			if (interior)
			{
				val.isInElevator = false;
				val.isInHangarShipRoom = false;
				val.isInsideFactory = true;
			}
			GrabbableObject[] itemSlots = val.ItemSlots;
			foreach (GrabbableObject val2 in itemSlots)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.isInFactory = val.isInsideFactory;
					val2.isInElevator = val.isInElevator;
					val2.isInShipRoom = val.isInHangarShipRoom;
				}
			}
			if (GameNetworkManager.Instance.localPlayerController.playerClientId == val.playerClientId)
			{
				if (val.isInsideFactory)
				{
					TimeOfDay.Instance.DisableAllWeather(false);
				}
				else
				{
					ActivateWeatherEffect((LevelWeatherType)0);
				}
			}
		}

		[IteratorStateMachine(typeof(<ShakeCameraAdvanced>d__10))]
		public static IEnumerator ShakeCameraAdvanced(ScreenShakeType shakeType, int repeat = 1, float inBetweenTimer = 0.5f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ShakeCameraAdvanced>d__10(0)
			{
				shakeType = shakeType,
				repeat = repeat,
				inBetweenTimer = inBetweenTimer
			};
		}

		public static bool IsPlayerFacingObject<T>(PlayerControllerB player, out T obj, float distance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(new Ray(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward), ref val, distance, 2816))
			{
				obj = ((Component)((RaycastHit)(ref val)).transform).GetComponent<T>();
				if (obj != null)
				{
					return true;
				}
			}
			obj = default(T);
			return false;
		}

		public static bool IsPlayerNearObject<T>(PlayerControllerB player, out T obj, float distance) where T : Component
		{
			//IL_0013: 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)
			T[] array = Object.FindObjectsByType<T>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if (Vector3.Distance(((Component)player).transform.position, ((Component)array[i]).transform.position) <= distance)
				{
					obj = array[i];
					return true;
				}
			}
			obj = default(T);
			return false;
		}

		public static Vector3 GetClosestAINodePosition(GameObject[] nodes, Vector3 position)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			return nodes.OrderBy((GameObject x) => Vector3.Distance(position, x.transform.position)).ToArray()[0].transform.position;
		}

		public static void Knockback(Vector3 position, float range, int damage = 0, float physicsForce = 30f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Landmine.SpawnExplosion(position, false, 0f, range, damage, physicsForce, (GameObject)null, false);
		}

		[IteratorStateMachine(typeof(<FadeOutAudio>d__15))]
		public static IEnumerator FadeOutAudio(AudioSource source, float time, bool specialStop = true)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeOutAudio>d__15(0)
			{
				source = source,
				time = time,
				specialStop = specialStop
			};
		}

		public static void SetCameraEndOfRound(PlayerControllerB player)
		{
			StartOfRound.Instance.SetSpectateCameraToGameOverMode(true, (PlayerControllerB)null);
			if (player.isPlayerDead)
			{
				player.SetSpectatedPlayerEffects(true);
			}
		}

		public static bool IsLocalPlayerInsideFacilityAbsolute()
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return false;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return false;
			}
			if (!localPlayerController.isPlayerDead)
			{
				return localPlayerController.isInsideFactory;
			}
			if ((Object)(object)localPlayerController.spectatedPlayerScript == (Object)null)
			{
				return false;
			}
			return localPlayerController.spectatedPlayerScript.isInsideFactory;
		}

		public static void ChangeWeather(LevelWeatherType weather)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			LevelWeatherType currentWeather = StartOfRound.Instance.currentLevel.currentWeather;
			StartOfRound.Instance.currentLevel.currentWeather = weather;
			if (Plugin.config.WeatherRegisteryInstalled)
			{
				ChangeWeatherWR(weather);
				return;
			}
			RoundManager.Instance.SetToCurrentLevelWeather();
			TimeOfDay.Instance.SetWeatherBasedOnVariables();
			if (!GameNetworkManager.Instance.localPlayerController.isInsideFactory)
			{
				ActivateWeatherEffect(currentWeather);
			}
		}

		public static void ActivateWeatherEffect(LevelWeatherType originalWeather = 0)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Invalid comparison between Unknown and I4
			for (int i = 0; i < TimeOfDay.Instance.effects.Length; i++)
			{
				WeatherEffect val = TimeOfDay.Instance.effects[i];
				bool flag = (val.effectEnabled = (int)StartOfRound.Instance.currentLevel.currentWeather == i);
				if ((Object)(object)val.effectPermanentObject != (Object)null)
				{
					val.effectPermanentObject.SetActive(flag);
				}
				if ((Object)(object)val.effectObject != (Object)null)
				{
					val.effectObject.SetActive(flag);
				}
				if ((Object)(object)TimeOfDay.Instance.sunAnimator != (Object)null)
				{
					if (flag && !string.IsNullOrEmpty(val.sunAnimatorBool))
					{
						TimeOfDay.Instance.sunAnimator.SetBool(val.sunAnimatorBool, true);
						continue;
					}
					TimeOfDay.Instance.sunAnimator.Rebind();
					TimeOfDay.Instance.sunAnimator.Update(0f);
				}
			}
			if ((int)originalWeather == 4)
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				localPlayerController.isUnderwater = false;
				localPlayerController.sourcesCausingSinking = Mathf.Clamp(localPlayerController.sourcesCausingSinking - 1, 0, 100);
				localPlayerController.isMovementHindered = Mathf.Clamp(localPlayerController.isMovementHindered - 1, 0, 100);
				localPlayerController.hinderedMultiplier = 1f;
			}
		}

		public static void ChangeWeatherWR(LevelWeatherType weather)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost)
			{
				WeatherController.SetWeatherEffects(weather);
			}
		}

		public static bool IsWeatherEffectPresent(string weatherNameResolvable)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return IsWeatherEffectPresent(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType);
		}

		public static bool IsWeatherEffectPresent(LevelWeatherType weatherType)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing r