Decompiled source of ExtraSurvivalWaveSettings v1.1.2

plugins/Inas07.ExtraSurvivalWaveSettings.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using AK;
using Agents;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using GTFO.API;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Inas07.ExtraSurvivalWaveSettings")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ea82c764047af97c9f3f5378cbc230b3f1720dcb")]
[assembly: AssemblyProduct("Inas07.ExtraSurvivalWaveSettings")]
[assembly: AssemblyTitle("Inas07.ExtraSurvivalWaveSettings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExtraSurvivalWaveSettings
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Inas.ExtraSurvivalWaveSettings", "ExtraSurvivalWaveSettings", "1.1.2")]
	public class EntryPoint : BasePlugin
	{
		public const string AUTHOR = "Inas";

		public const string PLUGIN_NAME = "ExtraSurvivalWaveSettings";

		public const string VERSION = "1.1.2";

		private Harmony m_Harmony;

		public override void Load()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			m_Harmony = new Harmony("ExtraSurvivalWaveSettings");
			m_Harmony.PatchAll();
		}
	}
	public class SurvivalWaveManager
	{
		public static readonly SurvivalWaveManager Current;

		private ConcurrentDictionary<string, List<ushort>> WaveEventsMap = new ConcurrentDictionary<string, List<ushort>>();

		public Dictionary<uint, (SurvivalWaveSpawnType, int)> LateSpawnTypeOverrideMap = new Dictionary<uint, (SurvivalWaveSpawnType, int)>();

		public void SpawnWave(WardenObjectiveEventData e)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: 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_00c0: Invalid comparison between Unknown and I4
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: 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_00d2: Invalid comparison between Unknown and I4
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Invalid comparison between Unknown and I4
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_00eb: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Invalid comparison between Unknown and I4
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Invalid comparison between Unknown and I4
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Invalid comparison between Unknown and I4
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Invalid comparison between Unknown and I4
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Invalid comparison between Unknown and I4
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Invalid comparison between Unknown and I4
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Invalid comparison between Unknown and I4
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Invalid comparison between Unknown and I4
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			if (!SNet.IsMaster)
			{
				return;
			}
			PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
			if ((Object)(object)localPlayerAgent == (Object)null)
			{
				ESWSLogger.Error("SpawnWave: LocalPlayerAgent is null, wtf?");
				return;
			}
			GenericEnemyWaveData enemyWaveData = e.EnemyWaveData;
			if (enemyWaveData.WaveSettings == 0 || enemyWaveData.WavePopulation == 0)
			{
				ESWSLogger.Error("SpawnWave: WaveSettings or WavePopulation is 0");
				return;
			}
			SurvivalWaveSettingsDataBlock block = GameDataBlockBase<SurvivalWaveSettingsDataBlock>.GetBlock(enemyWaveData.WaveSettings);
			SurvivalWavePopulationDataBlock block2 = GameDataBlockBase<SurvivalWavePopulationDataBlock>.GetBlock(enemyWaveData.WavePopulation);
			if (block == null || block2 == null)
			{
				return;
			}
			AIG_CourseNode val = ((Agent)localPlayerAgent).CourseNode;
			SurvivalWaveSpawnType val2 = (SurvivalWaveSpawnType)0;
			Vector3 val3 = Vector3.zero;
			if (block.m_overrideWaveSpawnType)
			{
				LG_Zone val4 = default(LG_Zone);
				if ((int)block.m_survivalWaveSpawnType != 1 && (int)block.m_survivalWaveSpawnType != 2 && (int)block.m_survivalWaveSpawnType != 3 && (int)block.m_survivalWaveSpawnType != 4)
				{
					val2 = block.m_survivalWaveSpawnType;
				}
				else if (Builder.CurrentFloor.TryGetZoneByLocalIndex(e.DimensionIndex, e.Layer, e.LocalIndex, ref val4) && (Object)(object)val4 != (Object)null)
				{
					val = val4.m_courseNodes[0];
					val2 = (SurvivalWaveSpawnType)1;
					if ((int)block.m_survivalWaveSpawnType == 2 || (int)block.m_survivalWaveSpawnType == 3)
					{
						if (e.Count < val4.m_courseNodes.Count)
						{
							val = val4.m_courseNodes[e.Count];
							val2 = (SurvivalWaveSpawnType)2;
							if ((int)block.m_survivalWaveSpawnType == 3)
							{
								val3 = e.Position;
								val2 = (SurvivalWaveSpawnType)3;
							}
							else if ((int)block.m_survivalWaveSpawnType == 4)
							{
								val2 = (SurvivalWaveSpawnType)4;
							}
						}
						else
						{
							ESWSLogger.Error($"SpawnWave: SpawnType {block.m_survivalWaveSpawnType} is specified but cannot find AREA_{(ushort)(65 + e.Count)} in ({e.DimensionIndex}, {e.Layer}, {e.LocalIndex}), falling back to SpawnType: InSuppliedCourseNodeZone");
						}
					}
				}
				else
				{
					ESWSLogger.Error($"SpawnWave: Failed to find zone with GlobalIndex ({e.DimensionIndex}, {e.Layer}, {e.LocalIndex}), falling back to default spawn type");
				}
			}
			Mastermind current = Mastermind.Current;
			AIG_CourseNode obj = val;
			uint waveSettings = enemyWaveData.WaveSettings;
			uint wavePopulation = enemyWaveData.WavePopulation;
			SurvivalWaveSpawnType val5 = val2;
			float spawnDelay = enemyWaveData.SpawnDelay;
			Vector3 val6 = val3;
			ushort num = default(ushort);
			if (!current.TriggerSurvivalWave(obj, waveSettings, wavePopulation, ref num, val5, spawnDelay, (float)enemyWaveData.AreaDistance, val6, true, false, default(Vector3), ""))
			{
				ESWSLogger.Error("SpawnWave: Critical ERROR! Failed spawning enemy wave");
				return;
			}
			WardenObjectiveManager.RegisterSurvivalWaveID(num);
			ESWSLogger.Log($"SpawnWave: Enemy wave spawned ({val2}) with eventID {num}");
			if (enemyWaveData.TriggerAlarm)
			{
				WardenObjectiveManager.Current.m_sound.UpdatePosition(val.Position);
				WardenObjectiveManager.Current.m_sound.Post(EVENTS.APEX_PUZZLE_START_ALARM, true);
				ESWSLogger.Debug("SpawnWave: Trigger Alarm (prolly bugged when there're multiple alarms)");
			}
			if (!string.IsNullOrEmpty(LocalizedText.op_Implicit(enemyWaveData.IntelMessage)))
			{
				GuiManager.PlayerLayer.m_wardenIntel.ShowSubObjectiveMessage("", LocalizedText.op_Implicit(enemyWaveData.IntelMessage), false, 200f, 8f, (Action)null);
			}
			if ((int)val2 == 1)
			{
				ESWSLogger.Log($"Spawning in: ({e.DimensionIndex}, {e.Layer}, {e.LocalIndex})");
			}
			else if ((int)val2 == 2)
			{
				ESWSLogger.Log($"Spawning in: ({e.DimensionIndex}, {e.Layer}, {e.LocalIndex}, AREA_{(ushort)(65 + e.Count)})");
			}
			else if ((int)val2 == 3)
			{
				ESWSLogger.Log($"Spawning in: ({e.DimensionIndex}, {e.Layer}, {e.LocalIndex}, AREA_{(ushort)(65 + e.Count)}), position: {e.Position}");
			}
			else if ((int)val2 == 4)
			{
				ESWSLogger.Log($"Spawning closest to: ({e.DimensionIndex}, {e.Layer}, {e.LocalIndex}, AREA_{(ushort)(65 + e.Count)})");
				LateSpawnTypeOverrideMap.Add(num, ((SurvivalWaveSpawnType)4, val.NodeID));
			}
			string worldEventObjectFilter = e.WorldEventObjectFilter;
			if (!string.IsNullOrEmpty(worldEventObjectFilter))
			{
				if (!WaveEventsMap.ContainsKey(worldEventObjectFilter))
				{
					WaveEventsMap[worldEventObjectFilter] = new List<ushort>();
				}
				WaveEventsMap[worldEventObjectFilter].Add(num);
				ESWSLogger.Debug($"SpawnWave: Registered wave with filter {worldEventObjectFilter}, number of waves assigned: {WaveEventsMap[worldEventObjectFilter].Count}");
			}
		}

		public void StopNamedWaves(string waveName)
		{
			if (string.IsNullOrEmpty(waveName))
			{
				return;
			}
			if (!WaveEventsMap.Remove(waveName, out var value))
			{
				ESWSLogger.Error("Wave Filter " + waveName + " is unregistered, cannot stop wave.");
				return;
			}
			ESWSLogger.Debug($"StopNamedWaves: Stopping waves with name {waveName}, wave count: {value.Count}");
			value.ForEach(delegate(ushort eventID)
			{
				LateSpawnTypeOverrideMap.Remove(eventID);
				MastermindEvent val = default(MastermindEvent);
				if (Mastermind.Current.TryGetEvent(eventID, ref val))
				{
					val.StopEvent();
				}
				else
				{
					ESWSLogger.Error($"Wave with ID {eventID}: cannot find event. Are you debugging a level?");
				}
			});
		}

		public static AIG_CourseNode GetNodeAtDistanceFromPlayerToSupplied(AIG_CourseNode dest_node, int area_distance)
		{
			AIG_CourseNode result = dest_node;
			int num = int.MaxValue;
			AIG_CourseNode[] array = null;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (IsNodeReachable(current.m_courseNode, dest_node, out var pathToNode) && pathToNode.Length < num)
				{
					array = pathToNode;
					num = pathToNode.Length;
				}
			}
			if (array != null)
			{
				if (array.Length > area_distance)
				{
					result = array[area_distance];
				}
			}
			else
			{
				ESWSLogger.Error("GetNodeAtDistanceFromPlayerToSupplied: No path from any player to supplied node!");
			}
			return result;
		}

		internal static bool IsNodeReachable(AIG_CourseNode source, AIG_CourseNode target, out AIG_CourseNode[] pathToNode)
		{
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Invalid comparison between Unknown and I4
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Invalid comparison between Unknown and I4
			pathToNode = null;
			if (source == null || target == null)
			{
				return false;
			}
			if (source.NodeID == target.NodeID)
			{
				pathToNode = Array.Empty<AIG_CourseNode>();
				return true;
			}
			AIG_SearchID.IncrementSearchID();
			ushort searchID = AIG_SearchID.SearchID;
			Queue<(AIG_CourseNode, AIG_CourseNode[])> queue = new Queue<(AIG_CourseNode, AIG_CourseNode[])>();
			queue.Enqueue((source, Array.Empty<AIG_CourseNode>()));
			while (queue.Count > 0)
			{
				var (val, array) = queue.Dequeue();
				((AIG_CourseGraphMember)val).m_searchID = searchID;
				AIG_CourseNode[] array2 = array;
				int num = 0;
				AIG_CourseNode[] array3 = (AIG_CourseNode[])(object)new AIG_CourseNode[1 + array2.Length];
				ReadOnlySpan<AIG_CourseNode> readOnlySpan = new ReadOnlySpan<AIG_CourseNode>(array2);
				readOnlySpan.CopyTo(new Span<AIG_CourseNode>(array3).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				array3[num] = val;
				AIG_CourseNode[] array4 = array3;
				Enumerator<AIG_CoursePortal> enumerator = val.m_portals.GetEnumerator();
				while (enumerator.MoveNext())
				{
					AIG_CoursePortal current = enumerator.Current;
					LG_Gate gate = current.Gate;
					object obj;
					if (gate == null)
					{
						obj = null;
					}
					else
					{
						iLG_Door_Core spawnedDoor = gate.SpawnedDoor;
						obj = ((spawnedDoor != null) ? ((Il2CppObjectBase)spawnedDoor).TryCast<LG_SecurityDoor>() : null);
					}
					LG_SecurityDoor val2 = (LG_SecurityDoor)obj;
					if ((Object)(object)val2 != (Object)null && (int)val2.LastStatus != 10 && (int)val2.LastStatus != 16)
					{
						continue;
					}
					AIG_CourseNode oppositeNode = current.GetOppositeNode(val);
					if (((AIG_CourseGraphMember)oppositeNode).m_searchID != searchID)
					{
						if (oppositeNode.NodeID == target.NodeID)
						{
							pathToNode = array4;
							return true;
						}
						queue.Enqueue((oppositeNode, array4));
					}
				}
			}
			return false;
		}

		internal void OnStopAllWave()
		{
			Clear();
		}

		public void Clear()
		{
			WaveEventsMap.Clear();
			LateSpawnTypeOverrideMap.Clear();
		}

		private SurvivalWaveManager()
		{
		}

		static SurvivalWaveManager()
		{
			Current = new SurvivalWaveManager();
			LevelAPI.OnLevelCleanup += Current.Clear;
		}
	}
	internal static class ESWSLogger
	{
		private static ManualLogSource logger = Logger.CreateLogSource("ExtraSurvivalWaveSettings");

		public static void Log(string format, params object[] args)
		{
			Log(string.Format(format, args));
		}

		public static void Log(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)8, (object)str);
			}
		}

		public static void Warning(string format, params object[] args)
		{
			Warning(string.Format(format, args));
		}

		public static void Warning(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)4, (object)str);
			}
		}

		public static void Error(string format, params object[] args)
		{
			Error(string.Format(format, args));
		}

		public static void Error(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)2, (object)str);
			}
		}

		public static void Debug(string format, params object[] args)
		{
			Debug(string.Format(format, args));
		}

		public static void Debug(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)32, (object)str);
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_CheckAndExecuteEventsOnTrigger
	{
		[CompilerGenerated]
		private sealed class <Handle>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public WardenObjectiveEventData e;

			public float currentDuration;

			private float <delay>5__1;

			private string <line>5__2;

			private eWardenObjectiveEventType <>s__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Expected O, but got Unknown
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_017e: 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_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Invalid comparison between Unknown and I4
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Invalid comparison between Unknown and I4
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<delay>5__1 = Mathf.Max(e.Delay - currentDuration, 0f);
					if (<delay>5__1 > 0f)
					{
						<>2__current = (object)new WaitForSeconds(<delay>5__1);
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (e.Condition.ConditionIndex >= 0 && WorldEventManager.GetCondition(e.Condition.ConditionIndex) != e.Condition.IsTrue)
				{
					return false;
				}
				WardenObjectiveManager.DisplayWardenIntel(e.Layer, e.WardenIntel);
				if (e.DialogueID != 0)
				{
					PlayerDialogManager.WantToStartDialog(e.DialogueID, -1, false, false);
				}
				if (e.SoundID != 0)
				{
					WardenObjectiveManager.Current.m_sound.Post(e.SoundID, true);
					<line>5__2 = ((Object)e.SoundSubtitle).ToString();
					if (!string.IsNullOrWhiteSpace(<line>5__2))
					{
						GuiManager.PlayerLayer.ShowMultiLineSubtitle(<line>5__2);
					}
					<line>5__2 = null;
				}
				eWardenObjectiveEventType type = e.Type;
				<>s__3 = type;
				eWardenObjectiveEventType val = <>s__3;
				if ((int)val != 9)
				{
					if ((int)val == 10)
					{
						if (string.IsNullOrEmpty(e.WorldEventObjectFilter))
						{
							WardenObjectiveManager.StopAlarms();
							WardenObjectiveManager.StopAllWardenObjectiveEnemyWaves();
							WardenObjectiveManager.Current.m_sound.Post(EVENTS.ALARM_AMBIENT_STOP, true);
							SurvivalWaveManager.Current.OnStopAllWave();
						}
						else
						{
							SurvivalWaveManager.Current.StopNamedWaves(e.WorldEventObjectFilter);
						}
					}
				}
				else
				{
					SurvivalWaveManager.Current.SpawnWave(e);
				}
				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();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(WardenObjectiveManager), "CheckAndExecuteEventsOnTrigger", new Type[]
		{
			typeof(WardenObjectiveEventData),
			typeof(eWardenObjectiveEventTrigger),
			typeof(bool),
			typeof(float)
		})]
		private static bool Pre_CheckAndExecuteEventsOnTrigger(WardenObjectiveEventData eventToTrigger, eWardenObjectiveEventTrigger trigger, bool ignoreTrigger, float currentDuration)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_004e: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			if (eventToTrigger == null || (!ignoreTrigger && eventToTrigger.Trigger != trigger) || ((double)currentDuration != 0.0 && eventToTrigger.Delay <= currentDuration))
			{
				return true;
			}
			bool flag = false;
			eWardenObjectiveEventType type = eventToTrigger.Type;
			eWardenObjectiveEventType val = type;
			if ((int)val != 9)
			{
				if ((int)val == 10)
				{
					flag = true;
					WorldEventManager.m_worldEventEventCoroutines.Add(CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Handle(eventToTrigger, 0f)), (Action)null));
				}
			}
			else if (eventToTrigger.EnemyWaveData.WorldEventObjectFilterSpawnPoint != null && eventToTrigger.EnemyWaveData.WorldEventObjectFilterSpawnPoint.Length > 0)
			{
				flag = false;
			}
			else
			{
				flag = true;
				WorldEventManager.m_worldEventEventCoroutines.Add(CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Handle(eventToTrigger, 0f)), (Action)null));
			}
			return !flag;
		}

		[IteratorStateMachine(typeof(<Handle>d__1))]
		internal static IEnumerator Handle(WardenObjectiveEventData e, float currentDuration)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Handle>d__1(0)
			{
				e = e,
				currentDuration = currentDuration
			};
		}
	}
}