Decompiled source of Meteor Showers as a Weather v1.0.0

net.babybluesheep.MeteorsWeather.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MeteorsWeather.Utils;
using MeteorsWeather.Weather;
using MeteorsWeather.Weather.Patches;
using Microsoft.CodeAnalysis;
using MrovLib.Events;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using WeatherRegistry;
using WeatherRegistry.Utils;
using net.babybluesheep.MeteorsWeather.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("net.babybluesheep.MeteorsWeather")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a50dc11b875d7613557a4b92c94807dc3c1889f6")]
[assembly: AssemblyProduct("net.babybluesheep.MeteorsWeather")]
[assembly: AssemblyTitle("Meteor Showers as a Weather")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class ExtensionMarkerAttribute : Attribute
	{
		private readonly string <Name>k__BackingField;

		public string Name => <Name>k__BackingField;

		public ExtensionMarkerAttribute(string name)
		{
			<Name>k__BackingField = name;
		}
	}
}
[HarmonyPatch(typeof(StartOfRound), "Awake")]
internal static class InstantiateSpawnSyncer
{
	[HarmonyPostfix]
	private static void Postfix()
	{
		if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
		{
			GameObject val = Object.Instantiate<GameObject>(MeteorWeatherRegistry.SpawnSyncer);
			Object.DontDestroyOnLoad((Object)(object)val);
			val.GetComponent<NetworkObject>().Spawn(false);
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace MeteorsWeather
{
	public class MeteorWeathersConfig
	{
		public enum VanillaMeteorEventStatus
		{
			Enabled,
			EnabledOutsideMeteorShowerWeather,
			Disabled
		}

		public enum LoggingLevels
		{
			WarnError,
			Info,
			Debug
		}

		public ConfigEntry<LoggingLevels> LoggingLevel { get; }

		public ConfigEntry<VanillaMeteorEventStatus> IsMeteorsEventEnabled { get; }

		public ConfigEntry<string> LandStartTime { get; }

		public ConfigEntry<string> LandEndTime { get; }

		public ConfigEntry<float> LandDuration { get; }

		public ConfigEntry<float> LandSpeed { get; }

		public ConfigEntry<float> MeteorSpawnIntervalAverage { get; }

		public ConfigEntry<float> MeteorSpawnIntervalDeviation { get; }

		public ConfigEntry<string> MeteorScales { get; }

		public MeteorWeathersConfig(ConfigFile configFile)
		{
			configFile.SaveOnConfigSet = false;
			string text = "Valid formats are {HH}:{MM}AM or {HH}:{MM}PM e.g. 10:45AM, 6:00PM";
			string text2 = "\"Landing\" refers to meteors landing before getting close to the surface. \"Falling\" refers to meteors falling after getting close to the surface.";
			LoggingLevel = configFile.Bind<LoggingLevels>("General", "LoggingLevel", LoggingLevels.Info, "Controls the verbosity of logs.");
			IsMeteorsEventEnabled = configFile.Bind<VanillaMeteorEventStatus>("General", "IsMeteorShowerEventEnabled", VanillaMeteorEventStatus.Disabled, "Controls whether the vanilla meteor event is enabled or not.\r\n            Mods that force the meteor event to happen are unaffected.");
			LandStartTime = configFile.Bind<string>("Weather", "StartingTimeForLanding", "8:30AM", "The time at which meteor landings will start.\r\n            " + text + "\r\n            Values earlier than 8:00AM are allowed, and meteors will land as the day begins.\r\n            " + text2);
			LandEndTime = configFile.Bind<string>("Weather", "EndingTimeForLanding", "9:30PM", "The total time a meteor will take to land.\r\n            " + text + "\r\n            The value will be set to the value of " + ((ConfigEntryBase)LandStartTime).Definition.Key + " if it is lower than it.\r\n            Values earlier than 8:00AM may not work as expected, and continue landing for several minutes after the ending time.\r\n            " + text2);
			LandDuration = configFile.Bind<float>("Weather", "LandingDuration", 1f, "The total time a meteor will take to land, in hours.\r\n            " + text2);
			LandSpeed = configFile.Bind<float>("Weather", "FallingSpeed", 0.6f, "The speed at which meteors will fall.\r\n            " + text2);
			MeteorSpawnIntervalAverage = configFile.Bind<float>("Weather", "MeteorSpawnIntervalAverage", 5f, "The average interval of time between meteors spawning, roughly in seconds.");
			MeteorSpawnIntervalDeviation = configFile.Bind<float>("Weather", "MeteorSpawnIntervalDeviation", 3f, "The deviation of the interval of time between meteors spawning, roughly in seconds.");
			MeteorScales = configFile.Bind<string>("Weather", "MeteorScales", "8:2:100;16:4:50;16:8:20", "A list of meteor scale configurations, consisting of the average scale, scale deviation and the weight of the configuration.\r\n            The list is semicolon-separated, and the configurations are colon-separated e.g. \"8:2:100;16:4:20\"");
			ClearOrphanedEntries(configFile);
			configFile.Save();
			configFile.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile configFile)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(configFile);
			dictionary.Clear();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("net.babybluesheep.MeteorsWeather", "Meteor Showers as a Weather", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("net.babybluesheep.MeteorsWeather");

		public const string Id = "net.babybluesheep.MeteorsWeather";

		internal static ManualLogSource Logger { get; private set; }

		public static MeteorWeathersConfig MeteorWeathersConfig { get; private set; }

		public static string Name => "Meteor Showers as a Weather";

		public static string Version => "1.0.0";

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			MeteorWeathersConfig = new MeteorWeathersConfig(((BaseUnityPlugin)this).Config);
			MeteorWeatherRegistry.Register();
			MeteorWeatherPatchLoader.Load(_harmony);
			PatchNetcodeMethods();
			Logger.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void PatchNetcodeMethods()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace MeteorsWeather.Weather
{
	public class MeteorInstance : IDisposable
	{
		private bool _isNear;

		private float _landingTime;

		private bool _wasFarPreviously;

		private bool _wasNearPreviously;

		private bool _wasVeryNearPreviously;

		private bool _hasLanded;

		private Vector3 _positionAtStartOfLandingPhase;

		private readonly ParticleSystem _breakAtmosphereFireA;

		private readonly ParticleSystem _breakAtmosphereFireB;

		private static readonly WaitForSeconds _waitForSeconds0_05 = new WaitForSeconds(0.05f);

		private static readonly WaitForSeconds _waitForSeconds0_6 = new WaitForSeconds(0.6f);

		public static float StartingHeightInSky => 2700f;

		public static GameObject VanillaMeteorPrefab { get; set; } = null;

		public static GameObject VanillaDistantSpritePrefab { get; set; } = null;

		public static GameObject VanillaMeteorLandingExplosionPrefab { get; set; } = null;

		public static AudioClip VanillaInsideFactoryMeteorClip { get; set; } = null;

		public Vector3 LandingPosition { get; set; }

		public Vector3 SkyDirection { get; set; }

		public float LandingSpeed { get; set; }

		public Ray SkyRay => new Ray(LandingPosition, SkyDirection);

		public float Scale { get; set; }

		public float NormalizedTimeToLandAt { get; set; }

		public float NormalizedTimeOfSpawning { get; set; }

		public GameObject MeteorPrefab { get; private set; }

		public GameObject DistantSpritePrefab { get; private set; }

		public GameObject LandingExplosionPrefab { get; private set; }

		public bool HasGivenAwayLandingExplosion { get; set; }

		public bool ShouldBeRemoved { get; set; }

		public bool IsDisposed { get; private set; }

		public MeteorInstance(Vector3 landingPosition, Vector3 skyDirection, float landingSpeed, float scale, float normalizedSpawnTime, float normalizedLandTime)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			LandingPosition = landingPosition;
			SkyDirection = skyDirection;
			Scale = scale;
			NormalizedTimeOfSpawning = normalizedSpawnTime;
			NormalizedTimeToLandAt = normalizedLandTime;
			LandingSpeed = landingSpeed;
			Ray skyRay = SkyRay;
			MeteorPrefab = Object.Instantiate<GameObject>(VanillaMeteorPrefab, ((Ray)(ref skyRay)).GetPoint(800f), Quaternion.LookRotation(LandingPosition - ((Ray)(ref skyRay)).GetPoint(800f)), RoundManager.Instance.mapPropsContainer.transform);
			ParticleSystem[] componentsInChildren = MeteorPrefab.GetComponentsInChildren<ParticleSystem>();
			_breakAtmosphereFireA = componentsInChildren[0];
			_breakAtmosphereFireB = componentsInChildren[1];
			DistantSpritePrefab = Object.Instantiate<GameObject>(VanillaDistantSpritePrefab, MeteorPrefab.transform.position, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform);
			LandingExplosionPrefab = null;
		}

		public void Update()
		{
			float num = MathUtils.InverseLerpUnclamped(NormalizedTimeOfSpawning, NormalizedTimeToLandAt, TimeOfDay.Instance.normalizedTimeOfDay);
			if (_isNear)
			{
				UpdateNear();
			}
			else
			{
				UpdateFar(num);
			}
			_isNear = num >= 1f;
		}

		private void UpdateFar(float travelProgress)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			Ray skyRay = SkyRay;
			if (!_wasFarPreviously)
			{
				AudioSource[] componentsInChildren = MeteorPrefab.GetComponentsInChildren<AudioSource>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if (!((Component)componentsInChildren[i]).CompareTag("Aluminum"))
					{
						componentsInChildren[i].Play();
					}
				}
				_wasFarPreviously = true;
			}
			Vector3 val = Vector3.Lerp(((Ray)(ref skyRay)).GetPoint(StartingHeightInSky), ((Ray)(ref skyRay)).GetPoint(150f), travelProgress);
			MeteorPrefab.transform.position = Vector3.Lerp(MeteorPrefab.transform.position, val, 5f * deltaTime);
			if (DistantSpritePrefab.activeSelf)
			{
				Vector3 position = ((Component)StartOfRound.Instance.audioListener).transform.position;
				Ray val2 = default(Ray);
				((Ray)(ref val2))..ctor(position, MeteorPrefab.transform.position - position);
				DistantSpritePrefab.transform.LookAt(position, Vector3.up);
				DistantSpritePrefab.transform.localScale = Vector3.one * Mathf.Lerp(0.3f, Scale, travelProgress * 2f);
				DistantSpritePrefab.transform.position = ((Ray)(ref val2)).GetPoint(380f);
				MeteorPrefab.transform.localScale = 0.25f * Scale * Vector3.one;
				if (Vector3.Distance(position, MeteorPrefab.transform.position) < Vector3.Distance(position, DistantSpritePrefab.transform.position) && travelProgress > 0.75f)
				{
					DistantSpritePrefab.SetActive(false);
					PlayNonWhistleSounds();
				}
			}
			else
			{
				MeteorPrefab.transform.localScale = Vector3.Lerp(MeteorPrefab.transform.localScale, Vector3.one * Mathf.Lerp(Scale * 0.25f, Scale, travelProgress), 5f * Time.deltaTime);
			}
			Transform transform = ((Component)_breakAtmosphereFireA).transform;
			Vector3 localScale = MeteorPrefab.transform.localScale;
			localScale.z = MeteorPrefab.transform.localScale.z * 0.72f;
			transform.localScale = localScale;
			((Component)_breakAtmosphereFireB).transform.localScale = ((Component)_breakAtmosphereFireA).transform.localScale;
		}

		private void UpdateNear()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0137: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			bool flag = _landingTime > 0.4f;
			if (!_wasNearPreviously || (flag && !_wasVeryNearPreviously))
			{
				DistantSpritePrefab.SetActive(false);
				AudioSource[] componentsInChildren = MeteorPrefab.GetComponentsInChildren<AudioSource>();
				if (!componentsInChildren[0].isPlaying)
				{
					PlayNonWhistleSounds();
				}
				if (!flag)
				{
					_positionAtStartOfLandingPhase = MeteorPrefab.transform.position;
				}
				_wasNearPreviously = true;
				if (flag)
				{
					_wasVeryNearPreviously = true;
				}
			}
			_landingTime = Mathf.Min(_landingTime + Time.deltaTime * LandingSpeed, 1.3f);
			MeteorPrefab.transform.localScale = Vector3.one * Scale;
			Transform transform = ((Component)_breakAtmosphereFireA).transform;
			Vector3 localScale = MeteorPrefab.transform.localScale;
			localScale.z = MeteorPrefab.transform.localScale.z * 0.72f;
			transform.localScale = localScale;
			((Component)_breakAtmosphereFireB).transform.localScale = ((Component)_breakAtmosphereFireA).transform.localScale;
			MeteorPrefab.transform.position = Vector3.LerpUnclamped(_positionAtStartOfLandingPhase, LandingPosition, _landingTime);
			Transform transform2 = MeteorPrefab.transform;
			localScale = MeteorPrefab.transform.position;
			localScale.y = Mathf.Max(MeteorPrefab.transform.position.y, -80f);
			transform2.position = localScale;
			if (_landingTime >= 0.4f && !flag && !GameNetworkManager.Instance.localPlayerController.isInsideFactory)
			{
				AudioSource[] componentsInChildren2 = MeteorPrefab.GetComponentsInChildren<AudioSource>();
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					if (((Component)componentsInChildren2[i]).CompareTag("Aluminum"))
					{
						componentsInChildren2[i].pitch = Random.Range(0.84f, 1.16f);
						componentsInChildren2[i].Play();
						break;
					}
				}
			}
			if (_landingTime >= 1f && !_hasLanded)
			{
				_hasLanded = true;
				((MonoBehaviour)TimeOfDay.Instance).StartCoroutine(Land());
			}
		}

		private void PlayNonWhistleSounds()
		{
			AudioSource[] componentsInChildren = MeteorPrefab.GetComponentsInChildren<AudioSource>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].Play();
			}
			if (Scale > 25f)
			{
				componentsInChildren = MeteorPrefab.GetComponentsInChildren<AudioSource>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					AudioSource obj = componentsInChildren[j];
					obj.pitch *= 0.5f;
					AudioSource obj2 = componentsInChildren[j];
					obj2.maxDistance += 120f;
				}
			}
		}

		private IEnumerator Land()
		{
			yield return _waitForSeconds0_05;
			LandingExplosionPrefab = Object.Instantiate<GameObject>(VanillaMeteorLandingExplosionPrefab, LandingPosition, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform);
			LandingExplosionPrefab.transform.localScale = Vector3.one * Scale;
			AudioSource[] componentsInChildren = LandingExplosionPrefab.GetComponentsInChildren<AudioSource>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (GameNetworkManager.Instance.localPlayerController.isInsideFactory)
				{
					componentsInChildren[i].spatialBlend = 0f;
					componentsInChildren[i].clip = VanillaInsideFactoryMeteorClip;
					componentsInChildren[i].pitch = Random.Range(0.9f, 1.1f);
					componentsInChildren[i].volume = Random.Range(0.2f, 0.8f);
					componentsInChildren[i].Play();
					break;
				}
				componentsInChildren[i].pitch = Random.Range(0.9f, 1.1f);
				componentsInChildren[i].Play();
				WalkieTalkie.TransmitOneShotAudio(componentsInChildren[i], componentsInChildren[i].clip, 1f);
			}
			ParticleSystem[] componentsInChildren2 = LandingExplosionPrefab.GetComponentsInChildren<ParticleSystem>();
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				((Component)componentsInChildren2[j]).transform.localScale = LandingExplosionPrefab.transform.localScale * 0.12f;
			}
			Vector3 position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
			bool flag = Scale > 36.666668f;
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, LandingPosition);
			Landmine.SpawnExplosion(LandingPosition, false, Scale, Mathf.Min(Scale * 1.4f, Scale + 12f), 40, 50f, (GameObject)null, false);
			RoundManager.Instance.DestroyTreeAtPosition(LandingPosition, Scale);
			if (num < Mathf.Max(Scale * 1.5f, 35f) || (flag && num < Mathf.Max(Scale * 2f, 90f)))
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				localPlayerController.externalForceAutoFade += Vector3.Normalize(position - (LandingPosition - Vector3.up * 25f)) * 110f / num;
			}
			else if (num < Mathf.Max(Scale * 2f, 60f) || (flag && num < Mathf.Max(Scale * 2.5f, 150f)))
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
				PlayerControllerB localPlayerController2 = GameNetworkManager.Instance.localPlayerController;
				localPlayerController2.externalForceAutoFade += Vector3.Normalize(position - (LandingPosition - Vector3.up * 20f)) * 85f / num;
			}
			yield return _waitForSeconds0_6;
			ShouldBeRemoved = true;
		}

		private void Dispose(bool disposing)
		{
			if (!IsDisposed)
			{
				Object.Destroy((Object)(object)MeteorPrefab);
				Object.Destroy((Object)(object)DistantSpritePrefab);
				if (!HasGivenAwayLandingExplosion)
				{
					Object.Destroy((Object)(object)LandingExplosionPrefab);
				}
				IsDisposed = true;
			}
		}

		~MeteorInstance()
		{
			Dispose(disposing: false);
		}

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}
	}
	public record MeteorScales(float Average, float Deviation, float Weight);
	public static class MeteorScalesUtils
	{
		public static bool IsValidList(string scalesList)
		{
			string[] array = scalesList.Split(";");
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(':');
				if (array3.Length != 3)
				{
					return false;
				}
				if (!float.TryParse(array3[0], out var result))
				{
					return false;
				}
				if (!float.TryParse(array3[1], out var result2))
				{
					return false;
				}
				if (!float.TryParse(array3[2], out var result3))
				{
					return false;
				}
				if (result <= 0f)
				{
					return false;
				}
				if (result2 <= 0f)
				{
					return false;
				}
				if (result - result2 <= 0f)
				{
					return false;
				}
				if (result3 <= 0f)
				{
					return false;
				}
			}
			return true;
		}

		public static List<MeteorScales> StringToList(string scalesList)
		{
			List<MeteorScales> list = new List<MeteorScales>();
			string[] array = scalesList.Split(";");
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(':');
				float average = float.Parse(array3[0]);
				float deviation = float.Parse(array3[1]);
				float weight = float.Parse(array3[2]);
				list.Add(new MeteorScales(average, deviation, weight));
			}
			return list;
		}
	}
	internal class MeteorSpawnSyncer : NetworkBehaviour
	{
		public static MeteorSpawnSyncer Instance { get; private set; }

		public void Awake()
		{
			Instance = this;
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		public void ReceiveMeteorRpc(Vector3 landingPosition, Vector3 skyDirection, float landingSpeed, float scale, float normalizedSpawnTime, float normalizedLandTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Invalid comparison between Unknown and I4
			//IL_0043: 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_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1)
				{
					RpcAttributeParams val = new RpcAttributeParams
					{
						RequireOwnership = false
					};
					RpcParams val3 = default(RpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1355420093u, val3, val, (SendTo)6, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref landingPosition);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref skyDirection);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref landingSpeed, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref normalizedSpawnTime, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref normalizedLandTime, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendRpc(ref val2, 1355420093u, val3, val, (SendTo)6, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1)
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					MeteorInstance meteor = new MeteorInstance(landingPosition, skyDirection, landingSpeed, scale, normalizedSpawnTime, normalizedLandTime);
					MeteorWeatherRegistry.MeteorShowerWeather.Effect.WorldObject.GetComponent<MeteorWeatherMeteorsWorld>().AddMeteor(meteor);
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1355420093u, new RpcReceiveHandler(__rpc_handler_1355420093), "ReceiveMeteorRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1355420093(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 landingPosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref landingPosition);
				Vector3 skyDirection = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref skyDirection);
				float landingSpeed = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref landingSpeed, default(ForPrimitives));
				float scale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives));
				float normalizedSpawnTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref normalizedSpawnTime, default(ForPrimitives));
				float normalizedLandTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref normalizedLandTime, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MeteorSpawnSyncer)(object)target).ReceiveMeteorRpc(landingPosition, skyDirection, landingSpeed, scale, normalizedSpawnTime, normalizedLandTime);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MeteorSpawnSyncer";
		}
	}
	public class MeteorWeatherMeteorsWorld : MonoBehaviour
	{
		private Random _random;

		private readonly List<MeteorInstance> _fallingMeteors = new List<MeteorInstance>();

		private readonly List<GameObject> _explosions = new List<GameObject>();

		private readonly List<GameObject> _outsideAiNodes = new List<GameObject>();

		private List<MeteorScales> _meteorScaleConfigurations = new List<MeteorScales>();

		private float _meteorSpawnTimer;

		private float _meteorSpawnStartTimer;

		private float _meteorSpawnEndTimer;

		private bool _hasLoggedStartOfShower;

		private bool _hasLoggedEndOfShower;

		public static float SkyAngularTilt => 0.5f;

		public static float HourAmountToLand
		{
			get
			{
				float value = Plugin.MeteorWeathersConfig.LandDuration.Value;
				if (value <= 0f)
				{
					float result = (float)((ConfigEntryBase)Plugin.MeteorWeathersConfig.LandDuration).DefaultValue;
					LogUtils.LogWarn(string.Format("{0} has an invalid value of {1}. Using default value.", "Key", value));
					return result;
				}
				return value;
			}
		}

		public static float NormalizedTimeAmountToLand => HourAmountToLand * TimeOfDay.Instance.lengthOfHours / TimeOfDay.Instance.totalTime;

		public bool HasSetUpForThisDay { get; set; }

		public void SetUpForThisDay()
		{
			string text = Plugin.MeteorWeathersConfig.LandStartTime.Value;
			string text2 = Plugin.MeteorWeathersConfig.LandEndTime.Value;
			if (!TimeUtils.IsValidClock(text))
			{
				LogUtils.LogWarn("Key has an invalid value of " + text + ". Using default value.");
				text = (string)((ConfigEntryBase)Plugin.MeteorWeathersConfig.LandStartTime).DefaultValue;
			}
			if (!TimeUtils.IsValidClock(text2))
			{
				LogUtils.LogWarn("Key has an invalid value of " + text2 + ". Using default value.");
				text2 = (string)((ConfigEntryBase)Plugin.MeteorWeathersConfig.LandEndTime).DefaultValue;
			}
			_meteorSpawnStartTimer = TimeUtils.ClockToTime(text);
			_meteorSpawnEndTimer = TimeUtils.ClockToTime(text2);
			_meteorSpawnStartTimer = Mathf.Clamp(_meteorSpawnStartTimer, 0f, 1f);
			_meteorSpawnEndTimer = Mathf.Clamp(_meteorSpawnEndTimer, 0f, 1f);
			if (_meteorSpawnEndTimer < _meteorSpawnStartTimer)
			{
				_meteorSpawnEndTimer = _meteorSpawnStartTimer;
			}
			_meteorSpawnTimer = _meteorSpawnStartTimer - NormalizedTimeAmountToLand;
			_random = new Random(StartOfRound.Instance.randomMapSeed + 12);
			_hasLoggedStartOfShower = false;
			_hasLoggedEndOfShower = false;
			foreach (MeteorInstance fallingMeteor in _fallingMeteors)
			{
				fallingMeteor.Dispose();
			}
			_fallingMeteors.Clear();
			foreach (GameObject explosion in _explosions)
			{
				Object.Destroy((Object)(object)explosion);
			}
			_explosions.Clear();
			GenerateMeteorScales();
			FindMeteorLandSpots();
		}

		private void FindMeteorLandSpots()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			foreach (MeteorScales meteorScaleConfiguration in _meteorScaleConfigurations)
			{
				float num4 = meteorScaleConfiguration.Average + meteorScaleConfiguration.Deviation;
				num += num4 * meteorScaleConfiguration.Weight;
				if (num2 <= num4)
				{
					num2 = num4;
				}
				num3 += meteorScaleConfiguration.Weight;
			}
			num /= num3;
			_outsideAiNodes.Clear();
			Vector3 val = RoundManager.FindMainEntrancePosition(true, true);
			Vector3 position = StartOfRound.Instance.shipLandingPosition.position;
			GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
			foreach (GameObject val2 in outsideAINodes)
			{
				Vector3 position2 = val2.transform.position;
				if (!(Vector3.Distance(position2, position) < num2 * 2f) && !(Vector3.Distance(position2, val) < num2 + 24f))
				{
					_outsideAiNodes.Add(val2);
				}
			}
		}

		private void GenerateMeteorScales()
		{
			_meteorScaleConfigurations.Clear();
			string text = Plugin.MeteorWeathersConfig.MeteorScales.Value;
			if (!MeteorScalesUtils.IsValidList(text))
			{
				LogUtils.LogWarn("Key has an invalid value of " + text + ". Using default value.");
				text = (string)((ConfigEntryBase)Plugin.MeteorWeathersConfig.MeteorScales).DefaultValue;
			}
			_meteorScaleConfigurations = MeteorScalesUtils.StringToList(text);
		}

		public void TrySpawningMeteors(float totalTime, float currentNormalizedTime)
		{
			float num = _meteorSpawnTimer + NormalizedTimeAmountToLand;
			if (num > _meteorSpawnEndTimer)
			{
				MeteorWeathersConfig.LoggingLevels value = Plugin.MeteorWeathersConfig.LoggingLevel.Value;
				if (value >= MeteorWeathersConfig.LoggingLevels.Info && !_hasLoggedEndOfShower)
				{
					LogUtils.LogInfo("Reached the ending time for landing. Stopping meteor showers for today.");
					_hasLoggedEndOfShower = true;
				}
				return;
			}
			while (_meteorSpawnTimer < currentNormalizedTime)
			{
				if (!_hasLoggedStartOfShower)
				{
					LogUtils.LogInfo("Reached the starting time for landing. Starting meteor showers for today.");
					_hasLoggedStartOfShower = true;
				}
				LogUtils.LogDebug($"Generating meteor to land at {HUDManager.Instance.GetClockTimeFormatted(_meteorSpawnTimer, (float)TimeOfDay.Instance.numberOfHours, false)} ({_meteorSpawnTimer}).");
				GenerateMeteorToSendRpc(_meteorSpawnTimer);
				float num2 = Plugin.MeteorWeathersConfig.MeteorSpawnIntervalAverage.Value;
				if (num2 <= 0f)
				{
					LogUtils.LogWarn(string.Format("{0} has an invalid value of {1}. Using default value.", "Key", num2));
					num2 = (float)((ConfigEntryBase)Plugin.MeteorWeathersConfig.MeteorSpawnIntervalAverage).DefaultValue;
				}
				float num3 = Plugin.MeteorWeathersConfig.MeteorSpawnIntervalDeviation.Value;
				if (num3 < 0f)
				{
					LogUtils.LogWarn(string.Format("{0} has an invalid value of {1}. Using default value.", "Key", num3));
					num3 = (float)((ConfigEntryBase)Plugin.MeteorWeathersConfig.MeteorSpawnIntervalDeviation).DefaultValue;
				}
				float num4 = num2;
				num4 += _random.NextFloat(0f - num3, num3);
				if (num4 <= 0.1f)
				{
					LogUtils.LogWarn("The interval for meteor landing ended up being too small.");
					num4 = 0.1f;
				}
				float num5 = num4 / totalTime;
				_meteorSpawnTimer += num5;
				if (num > _meteorSpawnEndTimer)
				{
					break;
				}
			}
		}

		private void GenerateMeteorToSendRpc(float spawnTime)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(_outsideAiNodes[_random.Next(_outsideAiNodes.Count)].transform.position, 15f, default(NavMeshHit), _random, -273, 1f);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 100f, Vector3.down, ref val2, 150f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			Vector3 skyDirection = Vector3.up * 10f + new Vector3(_random.NextFloat(-10f, 10f) * SkyAngularTilt, 0f, _random.NextFloat(-10f, 10f) * SkyAngularTilt);
			float num = 0f;
			for (int i = 0; i < _meteorScaleConfigurations.Count; i++)
			{
				num += _meteorScaleConfigurations[i].Weight;
			}
			float num2 = _random.NextFloat(num);
			MeteorScales meteorScales = _meteorScaleConfigurations[0];
			float num3 = 0f;
			for (int j = 0; j < _meteorScaleConfigurations.Count; j++)
			{
				MeteorScales meteorScales2 = _meteorScaleConfigurations[j];
				num3 += meteorScales2.Weight;
				if (num2 < num3)
				{
					meteorScales = meteorScales2;
					break;
				}
			}
			float scale = meteorScales.Average + _random.NextFloat(0f - meteorScales.Deviation, meteorScales.Deviation);
			float num4 = Plugin.MeteorWeathersConfig.LandSpeed.Value;
			if (num4 <= 0f)
			{
				LogUtils.LogWarn(string.Format("{0} has an invalid value of {1}. Using default value.", "Key", num4));
				num4 = (float)((ConfigEntryBase)Plugin.MeteorWeathersConfig.LandSpeed).DefaultValue;
			}
			float normalizedLandTime = spawnTime + NormalizedTimeAmountToLand;
			MeteorSpawnSyncer.Instance.ReceiveMeteorRpc(val, skyDirection, num4, scale, spawnTime, normalizedLandTime);
		}

		public void AddMeteor(MeteorInstance meteor)
		{
			_fallingMeteors.Add(meteor);
		}

		public void Update()
		{
			UpdateMeteors();
		}

		public void UpdateMeteors()
		{
			for (int num = _fallingMeteors.Count - 1; num >= 0; num--)
			{
				MeteorInstance meteorInstance = _fallingMeteors[num];
				meteorInstance.Update();
				if (meteorInstance.ShouldBeRemoved)
				{
					_explosions.Add(meteorInstance.LandingExplosionPrefab);
					meteorInstance.HasGivenAwayLandingExplosion = true;
					_fallingMeteors.RemoveAt(num);
					meteorInstance.Dispose();
				}
			}
		}

		public void OnDisable()
		{
			foreach (MeteorInstance fallingMeteor in _fallingMeteors)
			{
				fallingMeteor.Dispose();
			}
			_fallingMeteors.Clear();
			foreach (GameObject explosion in _explosions)
			{
				Object.Destroy((Object)(object)explosion);
			}
			_explosions.Clear();
		}

		public void OnDestroy()
		{
			foreach (MeteorInstance fallingMeteor in _fallingMeteors)
			{
				fallingMeteor.Dispose();
			}
			_fallingMeteors.Clear();
			foreach (GameObject explosion in _explosions)
			{
				Object.Destroy((Object)(object)explosion);
			}
			_explosions.Clear();
		}
	}
	internal static class MeteorWeatherPatchLoader
	{
		internal static void Load(Harmony harmony)
		{
			harmony.PatchAll(typeof(RegisterNetworkPrefabs));
			harmony.PatchAll(typeof(InstantiateSpawnSyncer));
			harmony.PatchAll(typeof(PreventNaturalMeteorShowerEvent));
			harmony.PatchAll(typeof(SpawnMeteors));
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).AddListener((ParameterEvent<(SelectableLevel, Weather)>)InitializeWeatherMeteors.InitializeMeteors);
		}
	}
	public static class MeteorWeatherRegistry
	{
		public static Weather MeteorShowerWeather { get; private set; }

		public static GameObject SpawnSyncer { get; private set; }

		internal static void Register()
		{
			//IL_0005: 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)
			//IL_0013: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			GameObject val = new GameObject("MeteorWeatherBehavior")
			{
				hideFlags = (HideFlags)61
			};
			val.AddComponent<MeteorWeatherMeteorsWorld>();
			Object.DontDestroyOnLoad((Object)(object)val);
			ImprovedWeatherEffect val2 = ScriptableObject.CreateInstance<ImprovedWeatherEffect>();
			val2.WorldObject = val;
			Weather val3 = new Weather("Meteor Shower", val2);
			val3.ColorGradient = ColorConverter.ToTMPColorGradient(new Color(1f, 0.4f, 0f));
			val3.Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(new string[2] { "None@300", "Eclipsed@20" }, true);
			MeteorShowerWeather = val3;
			WeatherManager.RegisterWeather(MeteorShowerWeather);
			GameObject val4 = new GameObject("MeteorWeatherSpawnSyncer")
			{
				hideFlags = (HideFlags)61
			};
			val4.AddComponent<NetworkObject>();
			val4.AddComponent<MeteorSpawnSyncer>();
			val4.GetComponent<NetworkObject>().DontDestroyWithOwner = true;
			val4.GetComponent<NetworkObject>().SceneMigrationSynchronization = true;
			val4.GetComponent<NetworkObject>().DestroyWithScene = false;
			Object.DontDestroyOnLoad((Object)(object)val4);
			SpawnSyncer = val4;
		}
	}
}
namespace MeteorsWeather.Weather.Patches
{
	internal static class InitializeWeatherMeteors
	{
		internal static void InitializeMeteors((SelectableLevel level, Weather weather) param)
		{
			GameObject worldObject = MeteorWeatherRegistry.MeteorShowerWeather.Effect.WorldObject;
			MeteorWeatherMeteorsWorld component = worldObject.GetComponent<MeteorWeatherMeteorsWorld>();
			if (!((Object)(object)worldObject == (Object)null))
			{
				if (!Object.op_Implicit((Object)(object)MeteorInstance.VanillaMeteorPrefab))
				{
					LogUtils.LogDebug("Currently not storing meteor prefab. Getting it from vanilla.");
					MeteorInstance.VanillaMeteorPrefab = TimeOfDay.Instance.MeteorWeather.meteorPrefab;
				}
				if (!Object.op_Implicit((Object)(object)MeteorInstance.VanillaDistantSpritePrefab))
				{
					LogUtils.LogDebug("Currently not storing distant sprite prefab. Getting it from vanilla.");
					MeteorInstance.VanillaDistantSpritePrefab = TimeOfDay.Instance.MeteorWeather.distantSpritePrefab;
				}
				if (!Object.op_Implicit((Object)(object)MeteorInstance.VanillaMeteorLandingExplosionPrefab))
				{
					LogUtils.LogDebug("Currently not storing landing explosion prefab. Getting it from vanilla.");
					MeteorInstance.VanillaMeteorLandingExplosionPrefab = TimeOfDay.Instance.MeteorWeather.meteorLandingExplosion;
				}
				if (!Object.op_Implicit((Object)(object)MeteorInstance.VanillaInsideFactoryMeteorClip))
				{
					LogUtils.LogDebug("Currently not storing muffled inside factory audio. Getting it from vanilla.");
					MeteorInstance.VanillaInsideFactoryMeteorClip = TimeOfDay.Instance.MeteorWeather.insideFactoryMeteorClip;
				}
				component.SetUpForThisDay();
			}
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "DecideRandomDayEvents")]
	internal static class PreventNaturalMeteorShowerEvent
	{
		[HarmonyPostfix]
		private static void Postfix(TimeOfDay __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			bool flag = false;
			if (Plugin.MeteorWeathersConfig.IsMeteorsEventEnabled.Value == MeteorWeathersConfig.VanillaMeteorEventStatus.Disabled)
			{
				LogUtils.LogInfo("Disabling natural meteor showers for the day.");
				flag = true;
			}
			else if (Plugin.MeteorWeathersConfig.IsMeteorsEventEnabled.Value == MeteorWeathersConfig.VanillaMeteorEventStatus.EnabledOutsideMeteorShowerWeather)
			{
				GameObject worldObject = MeteorWeatherRegistry.MeteorShowerWeather.Effect.WorldObject;
				if ((Object)(object)worldObject != (Object)null && worldObject.activeSelf)
				{
					LogUtils.LogInfo("Detected a Meteor Shower weather. Disabling natural meteor showers for the day.");
					flag = true;
				}
			}
			if (flag)
			{
				__instance.meteorShowerAtTime = -1f;
			}
		}
	}
	[HarmonyPatch]
	[HarmonyPatch(typeof(GameNetworkManager), "Start")]
	internal static class RegisterNetworkPrefabs
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			NetworkManager.Singleton.AddNetworkPrefab(MeteorWeatherRegistry.SpawnSyncer);
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "MoveTimeOfDay")]
	internal static class SpawnMeteors
	{
		[HarmonyPostfix]
		private static void Postfix(TimeOfDay __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				GameObject worldObject = MeteorWeatherRegistry.MeteorShowerWeather.Effect.WorldObject;
				MeteorWeatherMeteorsWorld component = worldObject.GetComponent<MeteorWeatherMeteorsWorld>();
				if (!((Object)(object)worldObject == (Object)null) && ((NetworkBehaviour)TimeOfDay.Instance).IsServer && worldObject.activeSelf)
				{
					component.TrySpawningMeteors(__instance.totalTime, __instance.normalizedTimeOfDay);
				}
			}
		}
	}
}
namespace MeteorsWeather.Utils
{
	internal static class LogUtils
	{
		public static void LogError(string message)
		{
			if (Plugin.MeteorWeathersConfig.LoggingLevel.Value >= MeteorWeathersConfig.LoggingLevels.WarnError)
			{
				Plugin.Logger.LogError((object)message);
			}
		}

		public static void LogWarn(string message)
		{
			if (Plugin.MeteorWeathersConfig.LoggingLevel.Value >= MeteorWeathersConfig.LoggingLevels.WarnError)
			{
				Plugin.Logger.LogWarning((object)message);
			}
		}

		public static void LogInfo(string message)
		{
			if (Plugin.MeteorWeathersConfig.LoggingLevel.Value >= MeteorWeathersConfig.LoggingLevels.Info)
			{
				Plugin.Logger.LogInfo((object)message);
			}
		}

		public static void LogDebug(string message)
		{
			if (Plugin.MeteorWeathersConfig.LoggingLevel.Value >= MeteorWeathersConfig.LoggingLevels.Debug)
			{
				Plugin.Logger.LogDebug((object)message);
			}
		}
	}
	internal static class MathUtils
	{
		[SpecialName]
		public sealed class <G>$867370CB417A981972D955CBF695061F
		{
			[SpecialName]
			public static class <M>$867370CB417A981972D955CBF695061F
			{
			}

			[ExtensionMarker("<M>$867370CB417A981972D955CBF695061F")]
			public static float InverseLerpUnclamped(float a, float b, float value)
			{
				throw new NotSupportedException();
			}
		}

		public static float InverseLerpUnclamped(float a, float b, float value)
		{
			return (value - a) / (b - a);
		}
	}
	internal static class RandomUtils
	{
		[SpecialName]
		public sealed class <G>$5AB4ABAAFA3359CDE65D50F3C2439F05
		{
			[SpecialName]
			public static class <M>$C4DC240E966E550AB8F319C64774CB91
			{
			}

			[ExtensionMarker("<M>$C4DC240E966E550AB8F319C64774CB91")]
			public float NextFloat()
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$C4DC240E966E550AB8F319C64774CB91")]
			public float NextFloat(float maxValue)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$C4DC240E966E550AB8F319C64774CB91")]
			public float NextFloat(float minValue, float maxValue)
			{
				throw new NotSupportedException();
			}
		}

		public static float NextFloat(this Random thisRandom)
		{
			return (float)thisRandom.NextDouble();
		}

		public static float NextFloat(this Random thisRandom, float maxValue)
		{
			return (float)thisRandom.NextDouble() * maxValue;
		}

		public static float NextFloat(this Random thisRandom, float minValue, float maxValue)
		{
			return minValue + (maxValue - minValue) * (float)thisRandom.NextDouble();
		}
	}
	public static class TimeUtils
	{
		public static bool IsValidClock(string timeString)
		{
			string[] array = timeString.Split(':');
			if (array.Length != 2)
			{
				return false;
			}
			if (!int.TryParse(array[0], out var result))
			{
				return false;
			}
			if (!int.TryParse(array[1].Substring(0, 2), out var result2))
			{
				return false;
			}
			if (array[0].Length != 2 && array[0].Length != 1)
			{
				return false;
			}
			if (array[1].Substring(0, 2).Length != 2)
			{
				return false;
			}
			if (result <= 0 || result > 12)
			{
				return false;
			}
			if (result2 < 0 || result2 >= 60)
			{
				return false;
			}
			string text = array[1].Substring(2);
			if (text != "AM" && text != "PM")
			{
				return false;
			}
			return true;
		}

		public static float ClockToTime(string timeString)
		{
			int numberOfHours = TimeOfDay.Instance.numberOfHours;
			string[] array = timeString.Split(':');
			int num = int.Parse(array[0]);
			int num2 = int.Parse(array[1].Substring(0, 2));
			string text = array[1].Substring(2);
			if (text == "PM" && num != 12)
			{
				num += 12;
			}
			if (text == "AM" && num == 12)
			{
				num += 12;
			}
			int num3 = num * 60 + num2;
			return (float)(num3 - 360) / (60f * (float)numberOfHours);
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class OverloadResolutionPriorityAttribute : Attribute
	{
		public int Priority { get; }

		public OverloadResolutionPriorityAttribute(int priority)
		{
			Priority = priority;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace net.babybluesheep.MeteorsWeather.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}