Decompiled source of HazardSpam v1.2.0

plugins/com.github.tehUsual.HazardSpam.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HazardSpam.Config;
using HazardSpam.Level;
using HazardSpam.Level.Biomes;
using HazardSpam.Level.Caldera;
using HazardSpam.Level.Spawner;
using HazardSpam.Networking;
using HazardSpam.Patches;
using HazardSpam.Spawning;
using HazardSpam.StaticData;
using HazardSpam.Types;
using HazardSpam.Util;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.tehUsual.HazardSpam")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+1fd04826e5781ddefa945f0aa11916299adf3066")]
[assembly: AssemblyProduct("com.github.tehUsual.HazardSpam")]
[assembly: AssemblyTitle("HazardSpam")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	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")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace HazardSpam
{
	[BepInPlugin("com.github.tehUsual.HazardSpam", "HazardSpam", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <DelayedInitNetwork>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				Plugin plugin = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					plugin.InitNetwork();
					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 const int SpawnerNetworkViewID = 9989;

		private bool _isGameStarted;

		private readonly TeleportHandler _teleportHandler = new TeleportHandler();

		public const string Id = "com.github.tehUsual.HazardSpam";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "HazardSpam";

		public static string Version => "1.2.0";

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			ConfigHandler.Init(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("com.github.tehUsual.HazardSpam");
			val.PatchAll(typeof(LevelChangePatches));
			val.PatchAll(typeof(EruptionSpawnerPatches));
			SceneManager.sceneLoaded += OnSceneLoaded;
			LevelState.OnBiomeLoading += OnBiomeLoading;
			LevelState.OnBiomeComplete += OnBiomeComplete;
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		private void InitNetwork()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if ((Object)(object)GameObject.Find("HS_SpawnerNetwork") != (Object)null)
			{
				Log.LogDebug((object)"HS_SpawnerNetwork already exists.");
				return;
			}
			GameObject val = new GameObject("HS_SpawnerNetwork");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<PhotonView>();
			PhotonView component = val.GetComponent<PhotonView>();
			component.ViewID = 9989;
			val.AddComponent<SpawnerNetwork>();
		}

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

		private void CleanupNetwork()
		{
			GameObject val = GameObject.Find("HS_SpawnerNetwork");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
		}

		private void Update()
		{
			if (PhotonNetwork.IsMasterClient && _isGameStarted && ConfigHandler.Debug)
			{
				if (Input.GetKeyDown((KeyCode)55))
				{
					Player.localPlayer.character.refs.balloons.TieNewBalloon(0);
				}
				if (Input.GetKeyDown((KeyCode)56) && Player.localPlayer.character.refs.balloons.tiedBalloons.Count > 0)
				{
					TiedBalloon val = Player.localPlayer.character.refs.balloons.tiedBalloons[0];
					Player.localPlayer.character.refs.balloons.RemoveBalloon(val);
				}
				if (Input.GetKeyDown((KeyCode)257))
				{
					_teleportHandler.WarpToShoreCampfire();
				}
				if (Input.GetKeyDown((KeyCode)258))
				{
					_teleportHandler.WarpToTropicsCampfire();
				}
				if (Input.GetKeyDown((KeyCode)259))
				{
					_teleportHandler.WarpToAlpineMesaCampfire();
				}
			}
		}

		private void OnBiomeLoading(BiomeType biomeType)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0042: Expected I4, but got Unknown
			if (PhotonNetwork.IsMasterClient)
			{
				Log.LogInfo((object)$"[Main] Biome loading: {biomeType}");
				switch (biomeType - 1)
				{
				case 0:
					LevelManager.ClearBiome((BiomeType)0);
					break;
				case 1:
				case 5:
					LevelManager.ClearBiome((BiomeType)1);
					break;
				case 2:
					LevelManager.ClearBiome((BiomeType)2);
					LevelManager.ClearBiome((BiomeType)6);
					break;
				case 3:
				case 4:
					break;
				}
			}
		}

		private void OnBiomeComplete(BiomeType biomeType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected I4, but got Unknown
			if ((int)biomeType == 0)
			{
				LevelManager.Init(LevelState.GetBiomeTypes());
			}
			if (PhotonNetwork.IsMasterClient)
			{
				Log.LogInfo((object)$"Biome complete: {biomeType}");
				switch ((int)biomeType)
				{
				case 0:
					_teleportHandler.Init(LevelState.GetBiomeTypes());
					LevelManager.InitBiome((BiomeType)0);
					break;
				case 1:
					LevelManager.InitBiome((BiomeType)1);
					break;
				case 2:
					LevelManager.InitBiome((BiomeType)2);
					break;
				case 6:
					LevelManager.InitBiome((BiomeType)6);
					break;
				case 3:
					LevelManager.InitBiome((BiomeType)3);
					break;
				case 4:
				case 5:
					break;
				}
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
			Match match = new Regex("^Level_(\\d+)$").Match(((Scene)(ref scene)).name);
			if ((int)mode == 0 && match.Success && int.TryParse(match.Groups[1].Value, out var _) && PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
			{
				Log.LogInfo((object)"Game Start detected");
				_isGameStarted = true;
			}
			if (((Scene)(ref scene)).name == "Airport")
			{
				StatusMessageHandler.DeInit();
				CleanupNetwork();
				((MonoBehaviour)this).StartCoroutine(DelayedInitNetwork());
				LevelManager.Reset();
			}
		}
	}
	public class TeleportHandler
	{
		private Transform? _shoreCampfire;

		private Transform? _tropicsCampfire;

		private Transform? _alpineMesaCampfire;

		public void Init(List<BiomeType> currentBiomeTypes)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected I4, but got Unknown
			foreach (BiomeType currentBiomeType in currentBiomeTypes)
			{
				switch ((int)currentBiomeType)
				{
				case 0:
				{
					GameObject val3 = GameObject.Find("Map/Biome_1/Beach/Beach_Campfire/Campfire");
					if ((Object)(object)val3 != (Object)null)
					{
						_shoreCampfire = val3.transform;
						Plugin.Log.LogInfo((object)"Found Shore Campfire");
					}
					else
					{
						Plugin.Log.LogDebug((object)"Could not find Shore Campfire.");
					}
					break;
				}
				case 1:
				{
					GameObject val2 = GameObject.Find("Map/Biome_2/Jungle/Jungle_Campfire/Campfire");
					if ((Object)(object)val2 != (Object)null)
					{
						_tropicsCampfire = val2.transform;
						Plugin.Log.LogInfo((object)"Found Tropics Campfire");
					}
					else
					{
						Plugin.Log.LogDebug((object)"Could not find Tropics Campfire.");
					}
					break;
				}
				case 2:
				{
					GameObject val4 = GameObject.Find("Map/Biome_3/Snow/Snow_Campfire/Campfire");
					if ((Object)(object)val4 != (Object)null)
					{
						_alpineMesaCampfire = val4.transform;
						Plugin.Log.LogInfo((object)"Found Alpine Campfire");
					}
					else
					{
						Plugin.Log.LogDebug((object)"Could not find Alpine Campfire.");
					}
					break;
				}
				case 6:
				{
					GameObject val = GameObject.Find("Map/Biome_3/Mesa/Desert_Campfire/Snow_Campfire/Campfire");
					if ((Object)(object)val != (Object)null)
					{
						_alpineMesaCampfire = val.transform;
						Plugin.Log.LogInfo((object)"Found Mesa Campfire");
					}
					else
					{
						Plugin.Log.LogDebug((object)"Could not find Mesa Campfire.");
					}
					break;
				}
				}
			}
		}

		public void WarpToShoreCampfire()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_shoreCampfire == (Object)null))
			{
				Player.localPlayer.character.WarpPlayer(_shoreCampfire.position, false);
			}
		}

		public void WarpToTropicsCampfire()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_tropicsCampfire == (Object)null))
			{
				Player.localPlayer.character.WarpPlayer(_tropicsCampfire.position, false);
			}
		}

		public void WarpToAlpineMesaCampfire()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_alpineMesaCampfire == (Object)null))
			{
				Player.localPlayer.character.WarpPlayer(_alpineMesaCampfire.position, false);
			}
		}
	}
}
namespace HazardSpam.Util
{
	public static class StatusMessageHandler
	{
		private static PlayerConnectionLog? _playerConnectionLog;

		public static void Init(PlayerConnectionLog playerConnectionLog)
		{
			_playerConnectionLog = playerConnectionLog;
		}

		public static void DeInit()
		{
			_playerConnectionLog = null;
		}

		public static void AddMessage(string message)
		{
			if ((Object)(object)_playerConnectionLog != (Object)null)
			{
				_playerConnectionLog.AddMessage(message);
			}
		}
	}
}
namespace HazardSpam.Types
{
	public enum BiomeArea
	{
		Plateau,
		Wall,
		WallLeft,
		WallRight
	}
	public readonly struct BiomeSpawnDefinition
	{
		public BiomeType BiomeType { get; }

		public BiomeArea Area { get; }

		public string Path { get; }

		public string SearchName { get; }

		public SpawnType SpawnType { get; }

		public BiomeSpawnDefinition(BiomeType biomeType, string path, BiomeArea area, string searchName, SpawnType spawnType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			BiomeType = biomeType;
			Area = area;
			Path = path;
			SearchName = searchName;
			SpawnType = spawnType;
		}
	}
	public enum BiomeShoreVariants
	{
		Default,
		SnakeBeach,
		RedBeach,
		BlueBeach,
		JellyHell,
		BlackSand
	}
	public enum BiomeTropicVariants
	{
		Default,
		Lava,
		Pillars,
		Thorny,
		Bombs,
		Ivy,
		SkyJungle
	}
	public enum BiomeAlpineVariants
	{
		Default,
		Lava,
		Spiky,
		GeyserHell
	}
	public class SpawnInfo
	{
		public Vector3 Position;

		public Quaternion Rotation;

		public float ScaleGain;

		public SpawnInfo(Vector3 position, Quaternion rotation, float scaleGain = 0f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			Position = position;
			Rotation = rotation;
			ScaleGain = scaleGain;
			base..ctor();
		}
	}
}
namespace HazardSpam.StaticData
{
	public static class SpawnerDefinitions
	{
		public static readonly List<BiomeSpawnDefinition> All = new List<BiomeSpawnDefinition>
		{
			new BiomeSpawnDefinition((BiomeType)0, "PlateauProps", BiomeArea.Plateau, "Jellies", SpawnType.Jellies),
			new BiomeSpawnDefinition((BiomeType)0, "WallProps", BiomeArea.Wall, "Jellies", SpawnType.Jellies),
			new BiomeSpawnDefinition((BiomeType)1, "Props_Wall", BiomeArea.Wall, "ExploShrooms", SpawnType.ExploShrooms),
			new BiomeSpawnDefinition((BiomeType)1, "Props_Wall", BiomeArea.Wall, "PoisonShrooms", SpawnType.PoisonShrooms),
			new BiomeSpawnDefinition((BiomeType)2, "Rocks/IceRockSpawn_L", BiomeArea.WallLeft, "Geysers", SpawnType.Geysers),
			new BiomeSpawnDefinition((BiomeType)2, "Rocks/IceRockSpawn_L", BiomeArea.WallLeft, "FlashPlant", SpawnType.FlashPlant),
			new BiomeSpawnDefinition((BiomeType)2, "Rocks/IceRockSpawn_R", BiomeArea.WallRight, "Geysers", SpawnType.Geysers),
			new BiomeSpawnDefinition((BiomeType)2, "Rocks/IceRockSpawn_R", BiomeArea.WallRight, "FlashPlant", SpawnType.FlashPlant),
			new BiomeSpawnDefinition((BiomeType)2, "", BiomeArea.WallLeft, "LavaRiver", SpawnType.LavaRiver),
			new BiomeSpawnDefinition((BiomeType)2, "", BiomeArea.WallRight, "LavaRiver (1)", SpawnType.LavaRiver),
			new BiomeSpawnDefinition((BiomeType)6, "Platteau/Props", BiomeArea.Plateau, "Cactus_Balls (1)", SpawnType.CactusBalls),
			new BiomeSpawnDefinition((BiomeType)6, "Platteau/Props", BiomeArea.Plateau, "Tumblers", SpawnType.Tumblers),
			new BiomeSpawnDefinition((BiomeType)6, "Wall/Props", BiomeArea.Wall, "Cactus_Balls", SpawnType.CactusBalls),
			new BiomeSpawnDefinition((BiomeType)6, "Wall/Props", BiomeArea.Wall, "Dynamite", SpawnType.Dynamite),
			new BiomeSpawnDefinition((BiomeType)6, "Wall/Props", BiomeArea.Wall, "Dynamite_Outside", SpawnType.DynamiteOutside),
			new BiomeSpawnDefinition((BiomeType)6, "Wall/Props", BiomeArea.Wall, "Scorpions", SpawnType.Scorpions)
		};

		public static readonly BiomeSpawnDefinition AlpineGeyserPlateau = new BiomeSpawnDefinition((BiomeType)2, "PlateauProps", BiomeArea.Plateau, "Geysers", SpawnType.Geysers);
	}
}
namespace HazardSpam.Spawning
{
	public class SpawnedPropHS : MonoBehaviour
	{
	}
	public enum SpawnType
	{
		Jellies,
		ExploShrooms,
		PoisonShrooms,
		LavaRiver,
		Geysers,
		FlashPlant,
		CactusBalls,
		Tumblers,
		Dynamite,
		DynamiteOutside,
		Scorpions
	}
}
namespace HazardSpam.Patches
{
	[HarmonyPatch]
	public static class EruptionSpawnerPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(EruptionSpawner), "Update")]
		public static bool ReplaceUpdate(EruptionSpawner __instance)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsMasterClient)
			{
				return false;
			}
			float z = __instance.min.position.z;
			float z2 = __instance.max.position.z;
			if (!HelperFunctions.AnyPlayerInZRange(z, z2))
			{
				return false;
			}
			__instance.counter -= Time.deltaTime;
			if (__instance.counter < 0f)
			{
				__instance.counter = Random.Range(-3f, 7f);
				Vector3 position = ((Component)__instance).transform.position;
				position.x += Random.Range(-155f, 155f);
				position.z += Random.Range(-140f, 140f);
				__instance.photonView.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { position });
			}
			return false;
		}
	}
	[HarmonyPatch]
	public static class LevelChangePatches
	{
		public static bool PatchSuccessfull { get; private set; }

		public static AirportCheckInKiosk AirportCheckInKioskInstance { get; private set; }

		[HarmonyPatch(typeof(MapHandler), "Awake")]
		[HarmonyPostfix]
		public static void PostfixAwake(MapHandler __instance)
		{
			LevelState.Initialize(__instance);
			PatchSuccessfull = true;
			Plugin.Log.LogInfo((object)"[MapHandler.Awake] MapHandler fetched!");
		}

		[HarmonyPatch(typeof(AirportCheckInKiosk), "BeginIslandLoadRPC")]
		[HarmonyPrefix]
		public static void PrefixBeginIslandLoadRPC(AirportCheckInKiosk __instance)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Plugin.Log.LogInfo((object)"[AirportCheckInKiosk.BeginIslandLoadRPC] LOADING SHORE");
				AirportCheckInKioskInstance = __instance;
				LevelState.SetBiomeComplete((BiomeType)0);
			}
		}

		[HarmonyPatch(typeof(RunManager), "StartRun")]
		[HarmonyPostfix]
		public static void PostfixStart(RunManager __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name == "Airport"))
			{
				activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name.StartsWith("Level_"))
				{
					Plugin.Log.LogInfo((object)"[RunManager.Start] LOADED SHORE");
					LevelState.SetBiomeComplete((BiomeType)0);
				}
				else
				{
					SceneManager.sceneLoaded += OnLevelSceneLoaded;
				}
			}
		}

		private static void OnLevelSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name.StartsWith("Level_"))
			{
				Plugin.Log.LogInfo((object)"[RunManager.Start] LOADED SHORE");
				LevelState.SetBiomeComplete((BiomeType)0);
				SceneManager.sceneLoaded -= OnLevelSceneLoaded;
			}
		}

		[HarmonyPatch(typeof(MapHandler), "GoToSegment")]
		[HarmonyPostfix]
		public static void PostfixGoToSegment(Segment s)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient)
			{
				Plugin.Log.LogInfo((object)$"[MapHandler.GoToSegment] LOADING BIOME: {s}");
				LevelState.SetBiomeLoading();
			}
		}

		[HarmonyPatch(typeof(MountainProgressHandler), "SetSegmentComplete")]
		[HarmonyPostfix]
		public static void PostfixSetSegmentComplete(int segment)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Plugin.Log.LogInfo((object)$"[MountainProgressHandler.SetSegmentComplete] LOADED BIOME: {segment}");
				LevelState.SetBiomeComplete();
			}
		}
	}
	[HarmonyPatch]
	public static class PlayerConnectionLogPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerConnectionLog), "Awake")]
		public static void PostfixAwake(PlayerConnectionLog __instance)
		{
			StatusMessageHandler.Init(__instance);
		}
	}
}
namespace HazardSpam.Networking
{
	public class SpawnerNetwork : MonoBehaviourPun
	{
		[CompilerGenerated]
		private sealed class <ClearPropsInWorld>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SpawnerData spawnerData;

			private int <removed>5__2;

			private int <i>5__3;

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

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

			[DebuggerHidden]
			public <ClearPropsInWorld>d__10(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;
					goto IL_00af;
				}
				<>1__state = -1;
				<removed>5__2 = 0;
				<i>5__3 = ((Component)spawnerData.PropSpawner).transform.childCount - 1;
				goto IL_00bf;
				IL_00af:
				<i>5__3--;
				goto IL_00bf;
				IL_00bf:
				if (<i>5__3 >= 0)
				{
					GameObject gameObject = ((Component)((Component)spawnerData.PropSpawner).transform.GetChild(<i>5__3)).gameObject;
					if ((Object)(object)gameObject.GetComponent<SpawnedPropHS>() != (Object)null)
					{
						Object.Destroy((Object)(object)gameObject);
						<removed>5__2++;
					}
					if (<i>5__3 % 50 == 0 && <i>5__3 != 0)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_00af;
				}
				spawnerData.Clear();
				Plugin.Log.LogInfo((object)$"Cleared {<removed>5__2} '{spawnerData.SpawnType}' from {spawnerData.Area}");
				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 <SpawnPropsInWorld>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SpawnerData spawnerData;

			public Vector3[] positions;

			public Quaternion[] rotations;

			public string area;

			private int <spawns>5__2;

			private int <i>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0044: 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_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_00f0;
				}
				<>1__state = -1;
				<spawns>5__2 = 0;
				<i>5__3 = 0;
				goto IL_0100;
				IL_00f0:
				<i>5__3++;
				goto IL_0100;
				IL_0100:
				if (<i>5__3 < positions.Length)
				{
					GameObject val = Object.Instantiate<GameObject>(spawnerData.Prefab, positions[<i>5__3], rotations[<i>5__3], ((Component)spawnerData.PropSpawner).transform);
					if ((Object)(object)val != (Object)null)
					{
						val.AddComponent<SpawnedPropHS>();
						spawnerData.AddSpawnInfo(positions[<i>5__3], rotations[<i>5__3]);
						<spawns>5__2++;
					}
					if (<i>5__3 % 50 == 0 && <i>5__3 != 0)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_00f0;
				}
				Plugin.Log.LogInfo((object)$"Spawned {<spawns>5__2}/{positions.Length} '{((Object)spawnerData.Prefab).name}' in {area}");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static SpawnerNetwork Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		public void SpawnPropsNetwork(SpawnerData spawnData, Vector3[] positions, Quaternion[] rotations, float[] scaleGains)
		{
			//IL_0023: 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)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (positions.Length != 0)
			{
				ManualLogSource log = Plugin.Log;
				object[] obj = new object[4] { positions.Length, null, null, null };
				BiomeType biomeType = spawnData.BiomeType;
				obj[1] = ((object)(BiomeType)(ref biomeType)).ToString();
				obj[2] = spawnData.Area.ToString();
				obj[3] = spawnData.SpawnType.ToString();
				log.LogInfo((object)string.Format("[Network] Sending 'RPC_SpawnProps' for {0} at {1}/{2}/{3}", obj));
				((MonoBehaviourPun)this).photonView.RPC("RPC_SpawnProps", (RpcTarget)0, new object[5] { spawnData.BiomeType, spawnData.Area, spawnData.SpawnType, positions, rotations });
			}
		}

		[PunRPC]
		public void RPC_SpawnProps(BiomeType biomeType, BiomeArea area, SpawnType spawnType, Vector3[] positions, Quaternion[] rotations)
		{
			//IL_0056: 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)
			Plugin.Log.LogInfo((object)$"[Network] Received 'RPC_SpawnProps' for {positions.Length} at {((object)(BiomeType)(ref biomeType)).ToString()}/{area.ToString()}/{spawnType.ToString()}");
			BiomeInfo biomeInfo = LevelManager.GetBiomeInfo(biomeType);
			if (biomeInfo == null)
			{
				return;
			}
			foreach (SpawnerData spawner in biomeInfo.Spawners)
			{
				if (spawner.Area == area && spawner.SpawnType == spawnType)
				{
					BiomeType biomeType2 = spawner.BiomeType;
					string area2 = ((object)(BiomeType)(ref biomeType2)).ToString() + "/" + spawner.Area;
					((MonoBehaviour)this).StartCoroutine(SpawnPropsInWorld(spawner, positions, rotations, area2));
					break;
				}
			}
		}

		[IteratorStateMachine(typeof(<SpawnPropsInWorld>d__7))]
		private IEnumerator SpawnPropsInWorld(SpawnerData spawnerData, Vector3[] positions, Quaternion[] rotations, string area)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnPropsInWorld>d__7(0)
			{
				spawnerData = spawnerData,
				positions = positions,
				rotations = rotations,
				area = area
			};
		}

		public void ClearPropsNetwork(SpawnerData spawnData)
		{
			//IL_0016: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource log = Plugin.Log;
			string[] obj = new string[6] { "[Network] Sending 'RPC_ClearProps' ", null, null, null, null, null };
			BiomeType biomeType = spawnData.BiomeType;
			obj[1] = ((object)(BiomeType)(ref biomeType)).ToString();
			obj[2] = "/";
			obj[3] = spawnData.Area.ToString();
			obj[4] = "/";
			obj[5] = spawnData.SpawnType.ToString();
			log.LogInfo((object)string.Concat(obj));
			((MonoBehaviourPun)this).photonView.RPC("RPC_ClearProps", (RpcTarget)0, new object[3] { spawnData.BiomeType, spawnData.Area, spawnData.SpawnType });
		}

		[PunRPC]
		public void RPC_ClearProps(BiomeType biomeType, BiomeArea area, SpawnType spawnType)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)("[Network] Received 'RPC_ClearProps' at " + ((object)(BiomeType)(ref biomeType)).ToString() + "/" + area.ToString() + "/" + spawnType));
			BiomeInfo biomeInfo = LevelManager.GetBiomeInfo(biomeType);
			if (biomeInfo == null)
			{
				return;
			}
			foreach (SpawnerData spawner in biomeInfo.Spawners)
			{
				if (spawner.Area == area && spawner.SpawnType == spawnType)
				{
					BiomeType biomeType2 = spawner.BiomeType;
					string area2 = ((object)(BiomeType)(ref biomeType2)).ToString() + "/" + spawner.Area;
					((MonoBehaviour)this).StartCoroutine(ClearPropsInWorld(spawner, area2));
					break;
				}
			}
		}

		[IteratorStateMachine(typeof(<ClearPropsInWorld>d__10))]
		private IEnumerator ClearPropsInWorld(SpawnerData spawnerData, string area)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ClearPropsInWorld>d__10(0)
			{
				spawnerData = spawnerData
			};
		}
	}
}
namespace HazardSpam.Level
{
	public static class LevelManager
	{
		[CompilerGenerated]
		private sealed class <InvokeClearBiome>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BiomeType biomeType;

			public float intervalDelay;

			private List<SpawnerData>.Enumerator <>7__wrap1;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = default(List<SpawnerData>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0020: 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_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						BiomeInfo biomeInfo = GetBiomeInfo(biomeType);
						if (biomeInfo == null)
						{
							Plugin.Log.LogError((object)$"Failed to clear {biomeType}");
							return false;
						}
						<>7__wrap1 = biomeInfo.Spawners.GetEnumerator();
						<>1__state = -3;
						break;
					}
					case 1:
						<>1__state = -3;
						break;
					}
					if (<>7__wrap1.MoveNext())
					{
						SpawnerData current = <>7__wrap1.Current;
						SpawnerNetwork.Instance.ClearPropsNetwork(current);
						<>2__current = (object)new WaitForSeconds(intervalDelay);
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>7__wrap1 = default(List<SpawnerData>.Enumerator);
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap1).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

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

			private object <>2__current;

			public BiomeType biomeType;

			public float intervalDelay;

			private BiomeInfo <biomeInfo>5__2;

			private List<SpawnerData>.Enumerator <>7__wrap2;

			private SpawnerData <spawner>5__4;

			private Vector3[] <pos>5__5;

			private Quaternion[] <rot>5__6;

			private float[] <scaleGain>5__7;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 1u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<biomeInfo>5__2 = null;
				<>7__wrap2 = default(List<SpawnerData>.Enumerator);
				<spawner>5__4 = null;
				<pos>5__5 = null;
				<rot>5__6 = null;
				<scaleGain>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0029: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fd: Expected O, but got Unknown
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Expected O, but got Unknown
				try
				{
					int spawnRate;
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<biomeInfo>5__2 = GetBiomeInfo(biomeType);
						if (<biomeInfo>5__2 == null)
						{
							Plugin.Log.LogError((object)$"Failed to init {biomeType}");
							return false;
						}
						<>7__wrap2 = <biomeInfo>5__2.Spawners.GetEnumerator();
						<>1__state = -3;
						goto IL_022c;
					case 1:
						<>1__state = -3;
						goto IL_01ca;
					case 2:
						{
							<>1__state = -3;
							<pos>5__5 = null;
							<rot>5__6 = null;
							<scaleGain>5__7 = null;
							<spawner>5__4 = null;
							goto IL_022c;
						}
						IL_01ca:
						SpawnerNetwork.Instance.SpawnPropsNetwork(<spawner>5__4, <pos>5__5, <rot>5__6, <scaleGain>5__7);
						break;
						IL_022c:
						while (true)
						{
							if (<>7__wrap2.MoveNext())
							{
								<spawner>5__4 = <>7__wrap2.Current;
								spawnRate = ConfigHandler.GetSpawnRate(biomeType, <spawner>5__4.Area, <spawner>5__4.SpawnType);
								if (spawnRate != 0)
								{
									break;
								}
								ManualLogSource log = Plugin.Log;
								string[] obj = new string[6] { "Unknown spawn rate for ", null, null, null, null, null };
								BiomeType val = <spawner>5__4.BiomeType;
								obj[1] = ((object)(BiomeType)(ref val)).ToString();
								obj[2] = "/";
								obj[3] = <spawner>5__4.Area.ToString();
								obj[4] = "/";
								obj[5] = <spawner>5__4.SpawnType.ToString();
								log.LogWarning((object)string.Concat(obj));
								continue;
							}
							<>m__Finally1();
							<>7__wrap2 = default(List<SpawnerData>.Enumerator);
							return false;
						}
						(<pos>5__5, <rot>5__6, <scaleGain>5__7) = <spawner>5__4.GenerateSpawnPoints(spawnRate);
						if (<pos>5__5.Length == 0)
						{
							break;
						}
						if ((int)<biomeInfo>5__2.BiomeType == 0)
						{
							Plugin.Log.LogInfo((object)"CRUDE FIX: Delaying shore spawn for 12 seconds");
							<>2__current = (object)new WaitForSeconds(12f);
							<>1__state = 1;
							return true;
						}
						goto IL_01ca;
					}
					<>2__current = (object)new WaitForSeconds(intervalDelay);
					<>1__state = 2;
					return true;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap2).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static List<BiomeInfo> BiomeInfo { get; } = new List<BiomeInfo>();


		public static BiomeInfo? GetShoreBiome()
		{
			return BiomeInfo.FirstOrDefault((BiomeInfo b) => (int)b.BiomeType == 0);
		}

		public static BiomeInfo? GetTropicBiome()
		{
			return BiomeInfo.FirstOrDefault((BiomeInfo b) => (int)b.BiomeType == 1);
		}

		public static BiomeInfo? GetAlpineBiome()
		{
			return BiomeInfo.FirstOrDefault((BiomeInfo b) => (int)b.BiomeType == 2);
		}

		public static BiomeInfo? GetMesaBiome()
		{
			return BiomeInfo.FirstOrDefault((BiomeInfo b) => (int)b.BiomeType == 6);
		}

		public static BiomeInfo? GetBiomeInfo(BiomeType biomeType)
		{
			//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)
			return BiomeInfo.FirstOrDefault((BiomeInfo b) => b.BiomeType == biomeType);
		}

		public static void Init(List<BiomeType> currentBiomeTypes)
		{
			Reset();
			GatherBiomesInfo(currentBiomeTypes);
		}

		public static void Reset()
		{
			foreach (BiomeInfo item in BiomeInfo)
			{
				item.Clear();
			}
			BiomeInfo.Clear();
		}

		private static void GatherBiomesInfo(List<BiomeType> biomeTypes)
		{
			//IL_002e: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)("Gathering info for BiomeTypes: " + string.Join(", ", LevelState.GetBiomeTypes())));
			foreach (BiomeType biomeType2 in biomeTypes)
			{
				if ((int)biomeType2 != 3)
				{
					BiomeInfo biomeInfo = BiomeFinder.FindActiveBiome(biomeType2);
					if (biomeInfo == null)
					{
						Plugin.Log.LogError((object)$"Failed to gather biome {biomeType2}");
					}
					else
					{
						BiomeInfo.Add(biomeInfo);
					}
				}
			}
			foreach (BiomeInfo item in BiomeInfo)
			{
				ManualLogSource log = Plugin.Log;
				BiomeType biomeType = item.BiomeType;
				log.LogInfo((object)("Successfully gathered spawners for " + ((object)(BiomeType)(ref biomeType)).ToString() + "/" + item.BiomeVariant));
			}
		}

		public static void InitBiome(BiomeType biomeType, float intervalDelay = 0.15f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)biomeType == 3)
			{
				CalderaHandler.InitCaldera();
			}
			else
			{
				((MonoBehaviour)SpawnerNetwork.Instance).StartCoroutine(InvokeInitBiome(biomeType, intervalDelay));
			}
		}

		[IteratorStateMachine(typeof(<InvokeInitBiome>d__12))]
		private static IEnumerator InvokeInitBiome(BiomeType biomeType, float intervalDelay)
		{
			//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 <InvokeInitBiome>d__12(0)
			{
				biomeType = biomeType,
				intervalDelay = intervalDelay
			};
		}

		public static void ClearBiome(BiomeType biomeType, float intervalDelay = 0.15f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)SpawnerNetwork.Instance).StartCoroutine(InvokeClearBiome(biomeType, intervalDelay));
		}

		[IteratorStateMachine(typeof(<InvokeClearBiome>d__14))]
		private static IEnumerator InvokeClearBiome(BiomeType biomeType, float intervalDelay)
		{
			//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 <InvokeClearBiome>d__14(0)
			{
				biomeType = biomeType,
				intervalDelay = intervalDelay
			};
		}

		public static string GenSpawnID(BiomeType biomeType, BiomeArea area, SpawnType spawnType, int index)
		{
			return $"{((object)(BiomeType)(ref biomeType)).ToString()}-{area.ToString()}-{spawnType.ToString()}-{index}";
		}
	}
	public static class LevelState
	{
		[CompilerGenerated]
		private sealed class <InvokeOnBiomeComplete>d__19 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BiomeType biomeType;

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

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

			[DebuggerHidden]
			public <InvokeOnBiomeComplete>d__19(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)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					LevelState.OnBiomeComplete?.Invoke(biomeType);
					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 <InvokeOnBiomeLoading>d__16 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BiomeType biomeType;

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

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

			[DebuggerHidden]
			public <InvokeOnBiomeLoading>d__16(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)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					LevelState.OnBiomeLoading?.Invoke(biomeType);
					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 static MapHandler? _mapHandlerInstance;

		private static bool _triedToFetchMapHandler;

		private static BiomeType _currentBiome;

		public static MapHandler MapHandlerInstance => _mapHandlerInstance ?? throw new InvalidOperationException("MapHandler not set yet.");

		public static event Action<BiomeType>? OnBiomeLoading;

		public static event Action<BiomeType>? OnBiomeComplete;

		public static void Initialize(MapHandler instance)
		{
			if (!((Object)(object)_mapHandlerInstance != (Object)null))
			{
				_mapHandlerInstance = instance;
			}
		}

		public static List<BiomeType> GetBiomeTypes()
		{
			if ((Object)(object)_mapHandlerInstance == (Object)null)
			{
				Plugin.Log.LogError((object)"[LevelState] MapHandler is null, could not trigger GetBiomeTypes()");
				return new List<BiomeType>();
			}
			Plugin.Log.LogInfo((object)("[LevelState] Got biome types: " + string.Join(", ", _mapHandlerInstance.biomes)));
			return _mapHandlerInstance.biomes;
		}

		public static void SetBiomeLoading(BiomeType biomeType)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_004d: 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)
			Plugin.Log.LogInfo((object)$"[LevelState] Biome loading: {biomeType}");
			_currentBiome = biomeType;
			if ((Object)(object)_mapHandlerInstance != (Object)null)
			{
				((MonoBehaviour)_mapHandlerInstance).StartCoroutine(InvokeOnBiomeLoading(_currentBiome));
			}
			else
			{
				Plugin.Log.LogError((object)$"[LevelState] MapHandler is null, did not trigger SetBiomeLoading() for {biomeType}");
			}
		}

		public static void SetBiomeLoading()
		{
			//IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_mapHandlerInstance == (Object)null && !_triedToFetchMapHandler)
			{
				TryFetchMapHandler();
				_triedToFetchMapHandler = true;
			}
			if ((Object)(object)_mapHandlerInstance != (Object)null)
			{
				BiomeType currentBiome = _mapHandlerInstance.GetCurrentBiome();
				SetBiomeLoading(currentBiome);
			}
			else
			{
				Plugin.Log.LogError((object)"[LevelState] MapHandler is null, did not trigger SetBiomeLoading()");
			}
		}

		public static bool TryFetchMapHandler()
		{
			GameObject val = GameObject.Find("Map");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			MapHandler component = val.GetComponent<MapHandler>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			Initialize(component);
			return true;
		}

		[IteratorStateMachine(typeof(<InvokeOnBiomeLoading>d__16))]
		private static IEnumerator InvokeOnBiomeLoading(BiomeType biomeType)
		{
			//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 <InvokeOnBiomeLoading>d__16(0)
			{
				biomeType = biomeType
			};
		}

		public static void SetBiomeComplete(BiomeType biomeType)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			Plugin.Log.LogInfo((object)$"[LevelState] Segment complete: {biomeType}");
			if ((Object)(object)_mapHandlerInstance != (Object)null)
			{
				((MonoBehaviour)_mapHandlerInstance).StartCoroutine(InvokeOnBiomeComplete(biomeType));
			}
			else
			{
				Plugin.Log.LogError((object)$"[LevelState] MapHandler is null, did not trigger SetBiomeLoading() for {biomeType}");
			}
		}

		public static void SetBiomeComplete()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			if ((Object)(object)_mapHandlerInstance != (Object)null)
			{
				BiomeType currentBiome = _mapHandlerInstance.GetCurrentBiome();
				SetBiomeComplete(currentBiome);
			}
			else
			{
				Plugin.Log.LogError((object)"[LevelState] MapHandler is null, did not trigger SetBiomeComplete()");
			}
		}

		[IteratorStateMachine(typeof(<InvokeOnBiomeComplete>d__19))]
		private static IEnumerator InvokeOnBiomeComplete(BiomeType biomeType)
		{
			//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 <InvokeOnBiomeComplete>d__19(0)
			{
				biomeType = biomeType
			};
		}
	}
}
namespace HazardSpam.Level.Spawner
{
	public class SpawnerData
	{
		private int _defaultNrOfSpawns;

		private readonly List<SpawnInfo> _spawnInfo = new List<SpawnInfo>();

		public PropSpawner PropSpawner { get; }

		public GameObject Prefab { get; }

		public BiomeType BiomeType { get; private set; }

		public BiomeArea Area { get; private set; }

		public SpawnType SpawnType { get; private set; }

		public SpawnerData(PropSpawner propSpawner, GameObject prefab, BiomeType biomeType, BiomeArea area, SpawnType spawnType)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			PropSpawner = propSpawner;
			Prefab = prefab;
			_defaultNrOfSpawns = PropSpawner.nrOfSpawns;
			BiomeType = biomeType;
			Area = area;
			SpawnType = spawnType;
		}

		public void Clear()
		{
			_spawnInfo.Clear();
		}

		public void AddSpawnInfos(Vector3[] positions, Quaternion[] rotations, float[]? scaleGains)
		{
			//IL_0043: 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)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (positions.Length == _spawnInfo.Count)
			{
				return;
			}
			for (int i = 0; i < positions.Length; i++)
			{
				if (scaleGains != null)
				{
					_spawnInfo.Add(new SpawnInfo(positions[i], rotations[i], scaleGains[i]));
				}
				else
				{
					_spawnInfo.Add(new SpawnInfo(positions[i], rotations[i]));
				}
			}
		}

		public void AddSpawnInfo(Vector3 position, Quaternion rotation, float? scaleGain = null)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			if (scaleGain.HasValue)
			{
				_spawnInfo.Add(new SpawnInfo(position, rotation, scaleGain.Value));
			}
			else
			{
				_spawnInfo.Add(new SpawnInfo(position, rotation));
			}
		}

		public (Vector3[] positions, Quaternion[] rotations, float[] scaleGains) GetSpawnInfoArrays()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			int count = _spawnInfo.Count;
			Vector3[] array = (Vector3[])(object)new Vector3[count];
			Quaternion[] array2 = (Quaternion[])(object)new Quaternion[count];
			float[] array3 = new float[count];
			for (int i = 0; i < count; i++)
			{
				array[i] = _spawnInfo[i].Position;
				array2[i] = _spawnInfo[i].Rotation;
				array3[i] = _spawnInfo[i].ScaleGain;
			}
			return (array, array2, array3);
		}

		public (Vector3[] positions, Quaternion[] rotations, float[] scaleGains) GenerateSpawnPoints(int attempts, float chance, float scaleGainMin, float scaleGainMax)
		{
			(Vector3[] positions, Quaternion[] rotations, float[] scaleGains) tuple = GenerateSpawnPoints(attempts);
			Vector3[] item = tuple.positions;
			Quaternion[] item2 = tuple.rotations;
			float[] item3 = tuple.scaleGains;
			for (int i = 0; i < item3.Length; i++)
			{
				if (Random.Range(0f, 1f) < chance)
				{
					item3[i] = Random.Range(scaleGainMin, scaleGainMax);
				}
			}
			return (item, item2, item3);
		}

		public (Vector3[] positions, Quaternion[] rotations, float[] scaleGains) GenerateSpawnPoints(int attempts)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsMasterClient)
			{
				return (Array.Empty<Vector3>(), Array.Empty<Quaternion>(), Array.Empty<float>());
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			List<Vector3> list = new List<Vector3>();
			List<Quaternion> list2 = new List<Quaternion>();
			List<float> list3 = new List<float>();
			while (num < attempts && num2 < attempts)
			{
				MethodInfo method = ((object)PropSpawner).GetType().GetMethod("GetRandomPoint", BindingFlags.Instance | BindingFlags.NonPublic);
				if (method == null)
				{
					break;
				}
				num2++;
				try
				{
					object obj = method.Invoke(PropSpawner, null);
					if (obj != null)
					{
						Vector3 item = (Vector3)obj.GetType().GetField("pos").GetValue(obj);
						Vector3 val = (Vector3)obj.GetType().GetField("normal").GetValue(obj);
						Quaternion randomRotationWithUp = HelperFunctions.GetRandomRotationWithUp(val);
						list.Add(item);
						list2.Add(randomRotationWithUp);
						list3.Add(0f);
						num++;
					}
				}
				catch (Exception)
				{
					num3++;
				}
			}
			Plugin.Log.LogInfo((object)$"Generated {num} spawn points, {num3} failed (which is fine)");
			return (list.ToArray(), list2.ToArray(), list3.ToArray());
		}
	}
	public static class SpawnerFinderAndInit
	{
		[CompilerGenerated]
		private sealed class <GetSpawnersFromPath>d__3 : IEnumerable<SpawnerData>, IEnumerable, IEnumerator<SpawnerData>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private SpawnerData <>2__current;

			private int <>l__initialThreadId;

			private Transform activeBiome;

			public Transform <>3__activeBiome;

			private string path;

			public string <>3__path;

			private List<(string searcName, SpawnType spawnType)> spawnersToSearch;

			public List<(string searcName, SpawnType spawnType)> <>3__spawnersToSearch;

			private BiomeType biomeType;

			public BiomeType <>3__biomeType;

			private BiomeArea area;

			public BiomeArea <>3__area;

			private IEnumerator <>7__wrap1;

			private Transform <child>5__3;

			private List<(string searcName, SpawnType spawnType)>.Enumerator <>7__wrap3;

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

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

			[DebuggerHidden]
			public <GetSpawnersFromPath>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if ((uint)(num - -4) <= 1u || num == 1)
				{
					try
					{
						if (num == -4 || num == 1)
						{
							try
							{
							}
							finally
							{
								<>m__Finally2();
							}
						}
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = null;
				<child>5__3 = null;
				<>7__wrap3 = default(List<(string, SpawnType)>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Expected O, but got Unknown
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -4;
						goto IL_0192;
					}
					<>1__state = -1;
					Transform val = activeBiome.Find(path);
					if ((Object)(object)val == (Object)null)
					{
						Plugin.Log.LogWarning((object)("Could not find path '" + path + "' in " + ((Object)activeBiome).name));
						return false;
					}
					<>7__wrap1 = val.GetEnumerator();
					<>1__state = -3;
					goto IL_01bb;
					IL_0192:
					while (<>7__wrap3.MoveNext())
					{
						var (text, spawnType) = <>7__wrap3.Current;
						if (((Object)<child>5__3).name == text)
						{
							SpawnerData spawnerFromObject = GetSpawnerFromObject(((Component)<child>5__3).gameObject, biomeType, area, spawnType);
							if (spawnerFromObject != null)
							{
								<>2__current = spawnerFromObject;
								<>1__state = 1;
								return true;
							}
							Plugin.Log.LogWarning((object)("Could not find spawner '" + spawnType.ToString() + "' in " + ((Object)<child>5__3).name + " from " + path + ", biome " + ((Object)activeBiome).name));
						}
					}
					<>m__Finally2();
					<>7__wrap3 = default(List<(string, SpawnType)>.Enumerator);
					<child>5__3 = null;
					goto IL_01bb;
					IL_01bb:
					if (<>7__wrap1.MoveNext())
					{
						<child>5__3 = (Transform)<>7__wrap1.Current;
						<>7__wrap3 = spawnersToSearch.GetEnumerator();
						<>1__state = -4;
						goto IL_0192;
					}
					<>m__Finally1();
					<>7__wrap1 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap1 is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}

			private void <>m__Finally2()
			{
				<>1__state = -3;
				((IDisposable)<>7__wrap3).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<SpawnerData> IEnumerable<SpawnerData>.GetEnumerator()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				<GetSpawnersFromPath>d__3 <GetSpawnersFromPath>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<GetSpawnersFromPath>d__ = this;
				}
				else
				{
					<GetSpawnersFromPath>d__ = new <GetSpawnersFromPath>d__3(0);
				}
				<GetSpawnersFromPath>d__.activeBiome = <>3__activeBiome;
				<GetSpawnersFromPath>d__.biomeType = <>3__biomeType;
				<GetSpawnersFromPath>d__.path = <>3__path;
				<GetSpawnersFromPath>d__.area = <>3__area;
				<GetSpawnersFromPath>d__.spawnersToSearch = <>3__spawnersToSearch;
				return <GetSpawnersFromPath>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<SpawnerData>)this).GetEnumerator();
			}
		}

		[CompilerGenerated]
		private sealed class <HandleAlpinePlateauGeyser>d__1 : IEnumerable<SpawnerData>, IEnumerable, IEnumerator<SpawnerData>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private SpawnerData <>2__current;

			private int <>l__initialThreadId;

			private Transform activeBiome;

			public Transform <>3__activeBiome;

			private BiomeSpawnDefinition bsd;

			public BiomeSpawnDefinition <>3__bsd;

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

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

			[DebuggerHidden]
			public <HandleAlpinePlateauGeyser>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

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

			private bool MoveNext()
			{
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					Transform val = activeBiome.parent.Find("GeyserHell/PlateauProps/Geysers");
					if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent<PropSpawner>() == (Object)null)
					{
						return false;
					}
					Transform val2 = activeBiome.Find("PlateauProps");
					if ((Object)(object)val2 == (Object)null)
					{
						return false;
					}
					GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val2, true);
					val3.SetActive(true);
					SpawnerData spawnerFromObject = GetSpawnerFromObject(val3, bsd.BiomeType, bsd.Area, bsd.SpawnType);
					if (spawnerFromObject != null)
					{
						<>2__current = spawnerFromObject;
						<>1__state = 1;
						return true;
					}
					break;
				}
				case 1:
					<>1__state = -1;
					break;
				}
				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();
			}

			[DebuggerHidden]
			IEnumerator<SpawnerData> IEnumerable<SpawnerData>.GetEnumerator()
			{
				<HandleAlpinePlateauGeyser>d__1 <HandleAlpinePlateauGeyser>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<HandleAlpinePlateauGeyser>d__ = this;
				}
				else
				{
					<HandleAlpinePlateauGeyser>d__ = new <HandleAlpinePlateauGeyser>d__1(0);
				}
				<HandleAlpinePlateauGeyser>d__.activeBiome = <>3__activeBiome;
				<HandleAlpinePlateauGeyser>d__.bsd = <>3__bsd;
				return <HandleAlpinePlateauGeyser>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<SpawnerData>)this).GetEnumerator();
			}
		}

		public static List<SpawnerData> GetSpawnersFromBiomeType(Transform activeBiome, BiomeType biomeType, string biomeVariant)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_004d: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			List<SpawnerData> list = new List<SpawnerData>();
			foreach (BiomeSpawnDefinition item in SpawnerDefinitions.All)
			{
				if (item.BiomeType == biomeType)
				{
					list.AddRange(GetSpawnersFromDefinition(activeBiome, item));
				}
			}
			if ((int)biomeType == 2 && biomeVariant != "Geysers")
			{
				list.AddRange(HandleAlpinePlateauGeyser(activeBiome, SpawnerDefinitions.AlpineGeyserPlateau));
			}
			foreach (SpawnerData item2 in list)
			{
				Plugin.Log.LogInfo((object)$"Added spawner '{item2.SpawnType}' from {biomeType}/{biomeVariant}/{item2.Area}");
			}
			return list;
		}

		[IteratorStateMachine(typeof(<HandleAlpinePlateauGeyser>d__1))]
		private static IEnumerable<SpawnerData> HandleAlpinePlateauGeyser(Transform activeBiome, BiomeSpawnDefinition bsd)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <HandleAlpinePlateauGeyser>d__1(-2)
			{
				<>3__activeBiome = activeBiome,
				<>3__bsd = bsd
			};
		}

		private static IEnumerable<SpawnerData> GetSpawnersFromDefinition(Transform activeBiome, BiomeSpawnDefinition bsd)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GetSpawnersFromPath(activeBiome, bsd.BiomeType, bsd.Path, bsd.Area, new List<(string, SpawnType)>(1) { (bsd.SearchName, bsd.SpawnType) });
		}

		[IteratorStateMachine(typeof(<GetSpawnersFromPath>d__3))]
		private static IEnumerable<SpawnerData> GetSpawnersFromPath(Transform activeBiome, BiomeType biomeType, string path, BiomeArea area, List<(string searcName, SpawnType spawnType)> spawnersToSearch)
		{
			//IL_000f: 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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetSpawnersFromPath>d__3(-2)
			{
				<>3__activeBiome = activeBiome,
				<>3__biomeType = biomeType,
				<>3__path = path,
				<>3__area = area,
				<>3__spawnersToSearch = spawnersToSearch
			};
		}

		public static SpawnerData? GetSpawnerFromObject(GameObject go, BiomeType biomeType, BiomeArea area, SpawnType spawnType)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			PropSpawner component = go.GetComponent<PropSpawner>();
			if ((Object)(object)component == (Object)null || component.props.Length == 0)
			{
				return null;
			}
			return new SpawnerData(component, component.props[0], biomeType, area, spawnType);
		}
	}
}
namespace HazardSpam.Level.Caldera
{
	public static class CalderaHandler
	{
		public static void InitCaldera()
		{
			GameObject val = GameObject.Find("Map/Biome_4/Volcano/Caldera_Segment/River");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogError((object)"Could not find LavaRiver in Caldera");
				return;
			}
			LavaRiverSpeedRandomizer lavaRiverSpeedRandomizer = val.AddComponent<LavaRiverSpeedRandomizer>();
			if ((Object)(object)lavaRiverSpeedRandomizer == (Object)null)
			{
				Plugin.Log.LogError((object)"Could not add LavaRiverSpeedRandomizer to LavaRiver");
			}
		}
	}
	public class LavaRiverSpeedRandomizer : MonoBehaviour
	{
		private readonly float _minSpeed = 1f;

		private readonly float _maxSpeed = 5f;

		private readonly float _randomChangeIntervalMin = 10f;

		private readonly float _randomChangeIntervalMax = 15f;

		private readonly float _spikeIntervalMin = 120f;

		private readonly float _spikeIntervalMax = 150f;

		private readonly float _spikeDuration = 6f;

		private float _timer;

		private float _nextRandomChange;

		private float _nextSpikeTime;

		private float _currentSpeed = 1f;

		private bool _isSpike;

		private float _spikeEndTime;

		private Animator? _animator;

		private void Awake()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			_animator = ((Component)this).GetComponent<Animator>();
			if ((Object)(object)_animator == (Object)null)
			{
				Debug.LogError((object)"LavaRiverSpeedRandomizer: No animator found!");
				((Behaviour)this).enabled = false;
			}
		}

		private void Update()
		{
			var (flag, speed) = GetNextSpeed();
			if (flag && (Object)(object)_animator != (Object)null)
			{
				_animator.speed = speed;
			}
		}

		private (bool, float) GetNextSpeed()
		{
			_timer += Time.deltaTime;
			if (_nextRandomChange == 0f)
			{
				_nextRandomChange = _timer + Random.Range(_randomChangeIntervalMin, _randomChangeIntervalMax);
			}
			if (_nextSpikeTime == 0f)
			{
				_nextSpikeTime = _timer + Random.Range(_spikeIntervalMin, _spikeIntervalMax);
			}
			if (_isSpike)
			{
				if (_timer >= _spikeEndTime)
				{
					_isSpike = false;
					_nextRandomChange = _timer + Random.Range(_randomChangeIntervalMin, _randomChangeIntervalMax);
					_currentSpeed = Random.Range(_minSpeed, _maxSpeed);
					return (true, _currentSpeed);
				}
				return (false, 25f);
			}
			if (_timer >= _nextSpikeTime)
			{
				_isSpike = true;
				_spikeEndTime = _timer + _spikeDuration;
				_nextSpikeTime = _timer + Random.Range(_spikeIntervalMin, _spikeIntervalMax);
				return (true, 25f);
			}
			if (_timer >= _nextRandomChange)
			{
				_currentSpeed = Random.Range(_minSpeed, _maxSpeed);
				_nextRandomChange = _timer + Random.Range(_randomChangeIntervalMin, _randomChangeIntervalMax);
				return (true, _currentSpeed);
			}
			return (false, _currentSpeed);
		}
	}
}
namespace HazardSpam.Level.Biomes
{
	public static class BiomeFinder
	{
		public static BiomeInfo? FindActiveBiome(BiomeType biomeType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			switch ((int)biomeType)
			{
			case 0:
			{
				GameObject val4 = GameObject.Find("Map/Biome_1/Beach/Beach_Segment");
				if ((Object)(object)val4 == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find Beach_Segment for Shore");
					return null;
				}
				Transform val5 = DetermineBiomeVariant(Enum.GetNames(typeof(BiomeShoreVariants)), val4.transform);
				if ((Object)(object)val5 == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find biome variant for Shore");
					return null;
				}
				return new BiomeInfo(biomeType, ((Object)val5).name, val4.transform, val5);
			}
			case 1:
			{
				GameObject val2 = GameObject.Find("Map/Biome_2/Jungle/Jungle_Segment");
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find Jungle_Segment for Tropics");
					return null;
				}
				Transform val3 = DetermineBiomeVariant(Enum.GetNames(typeof(BiomeTropicVariants)), val2.transform);
				if ((Object)(object)val3 == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find biome variant for Tropics");
					return null;
				}
				return new BiomeInfo(biomeType, ((Object)val3).name, val2.transform, val3);
			}
			case 2:
			{
				GameObject val6 = GameObject.Find("Map/Biome_3/Snow/Snow_Segment");
				if ((Object)(object)val6 == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find Snow_Segment for Alpine");
					return null;
				}
				Transform val7 = DetermineBiomeVariant(Enum.GetNames(typeof(BiomeAlpineVariants)), val6.transform);
				if ((Object)(object)val7 == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find biome variant for Alpine");
					return null;
				}
				return new BiomeInfo(biomeType, ((Object)val7).name, val6.transform, val7);
			}
			case 6:
			{
				GameObject val = GameObject.Find("Map/Biome_3/Desert/Desert_Segment");
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogError((object)"Could not find Desert_Segment for Mesa");
					return null;
				}
				return new BiomeInfo(biomeType, "", val.transform, val.transform);
			}
			default:
				return null;
			}
		}

		private static Transform? DetermineBiomeVariant(string[] variants, Transform segment)
		{
			foreach (string text in variants)
			{
				Transform val = segment.Find(text);
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogWarning((object)("Biome variant '" + text + "' is null"));
				}
				else if (((Component)val).gameObject.activeSelf)
				{
					Plugin.Log.LogInfo((object)("Found biome variant '" + text + "'"));
					return val;
				}
			}
			return null;
		}
	}
	public class BiomeInfo
	{
		public BiomeType BiomeType { get; }

		public string BiomeVariant { get; }

		public Transform Segment { get; }

		public Transform ActiveBiome { get; }

		public List<SpawnerData> Spawners { get; } = new List<SpawnerData>();


		public BiomeInfo(BiomeType biomeType, string biomeVariant, Transform segment, Transform activeBiome)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			BiomeType = biomeType;
			BiomeVariant = biomeVariant;
			Segment = segment;
			ActiveBiome = activeBiome;
			InitSpawners();
		}

		public void Clear()
		{
			foreach (SpawnerData spawner in Spawners)
			{
				spawner.Clear();
			}
			Spawners.Clear();
		}

		private void InitSpawners()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Spawners.AddRange(SpawnerFinderAndInit.GetSpawnersFromBiomeType(ActiveBiome, BiomeType, BiomeVariant));
		}
	}
}
namespace HazardSpam.Config
{
	public static class ConfigHandler
	{
		private static ConfigEntry<bool> _configDebug = null;

		private static readonly Dictionary<(BiomeType, BiomeArea, SpawnType), ConfigEntry<int>> SpawnRatesDict = new Dictionary<(BiomeType, BiomeArea, SpawnType), ConfigEntry<int>>();

		public static bool Debug => _configDebug.Value;

		public static void Init(ConfigFile config)
		{
			_configDebug = config.Bind<bool>("Debug", "Debug", false, "Enabled debug logging and utils");
			InitSpawnRates(config);
		}

		private static void InitSpawnRates(ConfigFile config)
		{
			BindSpawnRates(config, (BiomeType)0, BiomeArea.Plateau, SpawnType.Jellies, 1000);
			BindSpawnRates(config, (BiomeType)0, BiomeArea.Wall, SpawnType.Jellies, 2000);
			BindSpawnRates(config, (BiomeType)1, BiomeArea.Wall, SpawnType.ExploShrooms, 2000);
			BindSpawnRates(config, (BiomeType)1, BiomeArea.Wall, SpawnType.PoisonShrooms, 2000);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.WallLeft, SpawnType.LavaRiver, 7);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.WallRight, SpawnType.LavaRiver, 7);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.WallLeft, SpawnType.Geysers, 150);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.WallLeft, SpawnType.FlashPlant, 150);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.WallRight, SpawnType.Geysers, 150);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.WallRight, SpawnType.FlashPlant, 150);
			BindSpawnRates(config, (BiomeType)2, BiomeArea.Plateau, SpawnType.Geysers, 250);
			BindSpawnRates(config, (BiomeType)6, BiomeArea.Plateau, SpawnType.CactusBalls, 500);
			BindSpawnRates(config, (BiomeType)6, BiomeArea.Plateau, SpawnType.Tumblers, 5);
			BindSpawnRates(config, (BiomeType)6, BiomeArea.Wall, SpawnType.CactusBalls, 750);
			BindSpawnRates(config, (BiomeType)6, BiomeArea.Wall, SpawnType.Dynamite, 200);
			BindSpawnRates(config, (BiomeType)6, BiomeArea.Wall, SpawnType.DynamiteOutside, 200);
			BindSpawnRates(config, (BiomeType)6, BiomeArea.Wall, SpawnType.Scorpions, 10);
		}

		private static void BindSpawnRates(ConfigFile config, BiomeType biomeType, BiomeArea area, SpawnType spawnType, int defaultValue)
		{
			//IL_0005: 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)
			string text = $"{biomeType}.{area}-{spawnType}";
			ConfigEntry<int> value = config.Bind<int>("SpawnRates", text, defaultValue, "Attempted spawn rate, will not guarantee this amount");
			SpawnRatesDict[(biomeType, area, spawnType)] = value;
		}

		public static int GetSpawnRate(BiomeType biomeType, BiomeArea area, SpawnType spawnType)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!SpawnRatesDict.TryGetValue((biomeType, area, spawnType), out ConfigEntry<int> value))
			{
				return 0;
			}
			return value.Value;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}