Decompiled source of EvenMoreFootPatrols MONO v1.0.2

mods/EvenMoreFootPatrols-Mono.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using EvenMoreFootPatrols;
using EvenMoreFootPatrols.Helpers;
using EvenMoreFootPatrols.PatrolConfiguration;
using EvenMoreFootPatrols.PatrolOfficers;
using EvenMoreFootPatrols.PatrolRoutes;
using FishNet;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Object;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using ScheduleOne;
using ScheduleOne.AvatarFramework;
using ScheduleOne.DevUtilities;
using ScheduleOne.ItemFramework;
using ScheduleOne.NPCs;
using ScheduleOne.NPCs.Behaviour;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Police;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::EvenMoreFootPatrols.EvenMoreFootPatrols), "Even More Foot Patrols", "1.0.2", "UncleTyrone", null)]
[assembly: MelonColor(1, 0, 0, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EvenMoreFootPatrols-Mono")]
[assembly: AssemblyConfiguration("Release Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1ca05b7a49ec6c2eb556bae9c5d3f7901a9b7fb6")]
[assembly: AssemblyProduct("EvenMoreFootPatrols-Mono")]
[assembly: AssemblyTitle("EvenMoreFootPatrols-Mono")]
[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.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 EvenMoreFootPatrols
{
	public static class BuildInfo
	{
		public const string Name = "Even More Foot Patrols";

		public const string Description = "Even More Foot Patrols!";

		public const string Author = "UncleTyrone";

		public const string Version = "1.0.2";
	}
	public class EvenMoreFootPatrols : MelonMod
	{
		[Serializable]
		public class PatrolRouteData
		{
			[JsonProperty("routes")]
			public List<Route> Routes;
		}

		[Serializable]
		public class Route
		{
			[JsonProperty("routeName")]
			public string RouteName;

			[JsonProperty("waypointsWrapper")]
			public WaypointsWrapper WaypointsWrapper;

			[JsonProperty("MinOfficers")]
			public int MinOfficers;

			[JsonProperty("MaxOfficers")]
			public int MaxOfficers;

			[JsonProperty("OfficerMovementSpeedMultiplier")]
			public float OfficerMovementSpeedMultiplier;
		}

		[Serializable]
		public class WaypointsWrapper
		{
			[JsonProperty("waypoints")]
			public List<Waypoint> Waypoints;
		}

		[Serializable]
		public class Waypoint
		{
			[JsonProperty("x")]
			public float X;

			[JsonProperty("y")]
			public float Y;

			[JsonProperty("z")]
			public float Z;
		}

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

			private object <>2__current;

			public EvenMoreFootPatrols <>4__this;

			private NetworkManager <nm>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<nm>5__1 = InstanceFinder.NetworkManager;
					if (<nm>5__1.IsServer && <nm>5__1.IsClient)
					{
						Logger.Debug("Starting patrols from the host!");
						_officers = Object.FindObjectsOfType<PoliceOfficer>(true);
						MelonCoroutines.Start(global::EvenMoreFootPatrols.PatrolConfiguration.PatrolConfiguration.LoadPatrolRoutesFromJson(<nm>5__1));
					}
					else if (!<nm>5__1.IsServer && !<nm>5__1.IsClient)
					{
						Logger.Debug("Starting patrols in singleplayer!");
						_officers = Object.FindObjectsOfType<PoliceOfficer>(true);
						MelonCoroutines.Start(global::EvenMoreFootPatrols.PatrolConfiguration.PatrolConfiguration.LoadPatrolRoutesFromJson(<nm>5__1));
					}
					else if (<nm>5__1.IsClient && !<nm>5__1.IsServer)
					{
						Logger.Debug("Client-only");
					}
					else if (<nm>5__1.IsServer && !<nm>5__1.IsClient)
					{
						Logger.Debug("Starting patrols from the server!");
						_officers = Object.FindObjectsOfType<PoliceOfficer>(true);
						MelonCoroutines.Start(global::EvenMoreFootPatrols.PatrolConfiguration.PatrolConfiguration.LoadPatrolRoutesFromJson(<nm>5__1));
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

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

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

		private static Instance Logger;

		public static PoliceOfficer[] _officers;

		public override void OnInitializeMelon()
		{
			Logger = ((MelonBase)this).LoggerInstance;
			Logger.Msg("Even More Foot Patrols has been initialized!");
			Logger.Debug("This will only show in debug mode");
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			Logger.Debug("Scene loaded: " + sceneName);
			if (sceneName == "Main")
			{
				Logger.Debug("Main scene loaded, waiting for network");
				MelonCoroutines.Start(Utils.WaitForNetwork(DoNetworkStuff()));
			}
		}

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

		public override void OnUpdate()
		{
			if (Input.GetKeyDown((KeyCode)287))
			{
				LogPlayerCoordinates();
			}
		}

		private static void LogPlayerCoordinates()
		{
			//IL_0022: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			GameObject val = GameObject.Find("Player_Local");
			if ((Object)(object)val != (Object)null)
			{
				Transform transform = val.transform;
				Vector3 position = transform.position;
				MelonLogger.Msg($"{{ \"x\": {position.x}, \"y\": {position.y}, \"z\": {position.z} }}");
			}
			else
			{
				MelonLogger.Msg("Player_Local component is missing, cannot fetch coordinates.");
			}
		}
	}
}
namespace EvenMoreFootPatrols.PatrolRoutes
{
	public class PatrolRoutes
	{
		public static PatrolGroup CreatePatrolGroup(string routeName, List<Vector3> waypoints)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00b9: Expected O, but got Unknown
			//IL_00c0: 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_0145: Expected O, but got Unknown
			GameObject val = GameObject.Find("PatrolRoutes");
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Msg("Patrol group object not found");
				return null;
			}
			GameObject patrolRouteObject = new GameObject(routeName);
			FootPatrolRoute val2 = patrolRouteObject.AddComponent<FootPatrolRoute>();
			val2.RouteName = routeName;
			val2.StartWaypointIndex = 0;
			patrolRouteObject.transform.position = waypoints[0];
			patrolRouteObject.transform.SetParent(val.transform);
			List<GameObject> list = new List<GameObject>();
			foreach (Vector3 waypoint in waypoints)
			{
				GameObject val3 = new GameObject("Waypoint");
				val3.transform.position = waypoint;
				val3.transform.SetParent(patrolRouteObject.transform);
				list.Add(val3);
			}
			Transform[] componentsInChildren = patrolRouteObject.GetComponentsInChildren<Transform>();
			val2.Waypoints = componentsInChildren.Where((Transform t) => (Object)(object)t != (Object)(object)patrolRouteObject.transform).ToArray();
			val2.UpdateWaypoints();
			return new PatrolGroup(val2);
		}
	}
}
namespace EvenMoreFootPatrols.PatrolOfficers
{
	public class PatrolOfficers
	{
		[CompilerGenerated]
		private sealed class <ActivateNetworkObjectAfterDelay>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkObject obj;

			public float delay;

			private bool <flag>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<flag>5__1 = (Object)(object)obj != (Object)null;
					if (<flag>5__1)
					{
						((Component)obj).gameObject.SetActive(true);
					}
					else
					{
						MelonLogger.Msg("Object to activate is null.");
					}
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public NetworkManager manager;

			public NetworkObject obj;

			public float delay;

			private bool <flag>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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 = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<flag>5__1 = (Object)(object)obj != (Object)null;
					if (<flag>5__1)
					{
						manager.ServerManager.Spawn(obj, (NetworkConnection)null, default(Scene));
					}
					else
					{
						MelonLogger.Msg("Object to spawn is null.");
					}
					return false;
				}
			}

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

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

		private static AvatarSettings getRandomOfficerAvatarSettings()
		{
			PoliceOfficer val = EvenMoreFootPatrols._officers[Random.Range(0, EvenMoreFootPatrols._officers.Length)];
			return ((NPC)val).Avatar.CurrentSettings;
		}

		public static void spawnOfficer(NetworkManager manager, string name, PatrolGroup group, float movementSpeedMult, bool warpToStart)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			PrefabObjects spawnablePrefabs = manager.SpawnablePrefabs;
			NetworkObject val = new NetworkObject();
			for (int i = 0; i < spawnablePrefabs.GetObjectCount(); i++)
			{
				NetworkObject @object = spawnablePrefabs.GetObject(true, i);
				if (!((Object)(object)((Component)@object).gameObject == (Object)null) && ((Object)((Component)@object).gameObject).name == "PoliceNPC")
				{
					val = @object;
				}
			}
			NetworkObject val2 = Object.Instantiate<NetworkObject>(val);
			AvatarSettings randomOfficerAvatarSettings = getRandomOfficerAvatarSettings();
			((Object)((Component)val2).gameObject).name = name;
			NPCMovement component = ((Component)val2).gameObject.GetComponent<NPCMovement>();
			component.MoveSpeedMultiplier = movementSpeedMult;
			PoliceOfficer component2 = ((Component)val2).gameObject.GetComponent<PoliceOfficer>();
			((NPC)component2).Avatar.SetSkinColor(randomOfficerAvatarSettings.SkinColor);
			((NPC)component2).Avatar.ApplyBodyLayerSettings(randomOfficerAvatarSettings, -1);
			((NPC)component2).Avatar.ApplyBodySettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyEyeBallSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyAccessorySettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyEyeLidColorSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyEyeLidSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyEyebrowSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyFaceLayerSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyHairColorSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyHairSettings(randomOfficerAvatarSettings);
			((NPC)component2).Avatar.ApplyShapeKeys(randomOfficerAvatarSettings.Gender, randomOfficerAvatarSettings.Weight, false);
			component2.StartFootPatrol(group, warpToStart);
			MelonCoroutines.Start(ActivateNetworkObjectAfterDelay(val2, 0.3f));
			MelonCoroutines.Start(SpawnNetworkObjectAfterDelay(manager, val2, 0.6f));
		}

		[IteratorStateMachine(typeof(<ActivateNetworkObjectAfterDelay>d__2))]
		private static IEnumerator ActivateNetworkObjectAfterDelay(NetworkObject obj, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ActivateNetworkObjectAfterDelay>d__2(0)
			{
				obj = obj,
				delay = delay
			};
		}

		[IteratorStateMachine(typeof(<SpawnNetworkObjectAfterDelay>d__3))]
		private static IEnumerator SpawnNetworkObjectAfterDelay(NetworkManager manager, NetworkObject obj, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnNetworkObjectAfterDelay>d__3(0)
			{
				manager = manager,
				obj = obj,
				delay = delay
			};
		}
	}
}
namespace EvenMoreFootPatrols.PatrolConfiguration
{
	public class PatrolConfiguration
	{
		[CompilerGenerated]
		private sealed class <LoadPatrolRoutesFromJson>d__0 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkManager manager;

			private string <path>5__1;

			private string <json>5__2;

			private EvenMoreFootPatrols.PatrolRouteData <patrolRouteData>5__3;

			private float <delayBetweenRoutes>5__4;

			private JsonSerializerSettings <settings>5__5;

			private Exception <ex>5__6;

			private List<EvenMoreFootPatrols.Route>.Enumerator <>s__7;

			private EvenMoreFootPatrols.Route <route>5__8;

			private List<Vector3> <waypoints>5__9;

			private PatrolGroup <group>5__10;

			private int <officerCount>5__11;

			private List<EvenMoreFootPatrols.Waypoint>.Enumerator <>s__12;

			private EvenMoreFootPatrols.Waypoint <waypoint>5__13;

			private int <i>5__14;

			private string <officerName>5__15;

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

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

			[DebuggerHidden]
			public <LoadPatrolRoutesFromJson>d__0(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();
					}
				}
				<path>5__1 = null;
				<json>5__2 = null;
				<patrolRouteData>5__3 = null;
				<settings>5__5 = null;
				<ex>5__6 = null;
				<>s__7 = default(List<EvenMoreFootPatrols.Route>.Enumerator);
				<route>5__8 = null;
				<waypoints>5__9 = null;
				<group>5__10 = null;
				<>s__12 = default(List<EvenMoreFootPatrols.Waypoint>.Enumerator);
				<waypoint>5__13 = null;
				<officerName>5__15 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Expected O, but got Unknown
				//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c5: Expected O, but got Unknown
				//IL_0339: Unknown result type (might be due to invalid IL or missing references)
				//IL_0343: Expected O, but got Unknown
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<path>5__1 = Path.Combine(MelonEnvironment.UserDataDirectory, "routes.json");
						if (!File.Exists(<path>5__1))
						{
							MelonLogger.Msg("JSON file not found at path: " + <path>5__1);
							return false;
						}
						<json>5__2 = File.ReadAllText(<path>5__1);
						<patrolRouteData>5__3 = null;
						try
						{
							<settings>5__5 = new JsonSerializerSettings
							{
								MissingMemberHandling = (MissingMemberHandling)0,
								NullValueHandling = (NullValueHandling)1
							};
							<patrolRouteData>5__3 = JsonConvert.DeserializeObject<EvenMoreFootPatrols.PatrolRouteData>(<json>5__2, <settings>5__5);
							<settings>5__5 = null;
						}
						catch (Exception ex)
						{
							<ex>5__6 = ex;
							MelonLogger.Error($"Failed to deserialize JSON: {<ex>5__6}");
							return false;
						}
						if (<patrolRouteData>5__3?.Routes == null || <patrolRouteData>5__3.Routes.Count == 0)
						{
							MelonLogger.Msg("No routes found in JSON data.");
							return false;
						}
						<delayBetweenRoutes>5__4 = 5f;
						<>s__7 = <patrolRouteData>5__3.Routes.GetEnumerator();
						<>1__state = -3;
						goto IL_036c;
					case 1:
						<>1__state = -3;
						<officerName>5__15 = null;
						<i>5__14++;
						goto IL_02f5;
					case 2:
						{
							<>1__state = -3;
							<waypoints>5__9 = null;
							<group>5__10 = null;
							<route>5__8 = null;
							goto IL_036c;
						}
						IL_036c:
						if (<>s__7.MoveNext())
						{
							<route>5__8 = <>s__7.Current;
							<waypoints>5__9 = new List<Vector3>();
							<>s__12 = <route>5__8.WaypointsWrapper.Waypoints.GetEnumerator();
							try
							{
								while (<>s__12.MoveNext())
								{
									<waypoint>5__13 = <>s__12.Current;
									<waypoints>5__9.Add(new Vector3(<waypoint>5__13.X, <waypoint>5__13.Y, <waypoint>5__13.Z));
									<waypoint>5__13 = null;
								}
							}
							finally
							{
								((IDisposable)<>s__12).Dispose();
							}
							<>s__12 = default(List<EvenMoreFootPatrols.Waypoint>.Enumerator);
							<group>5__10 = global::EvenMoreFootPatrols.PatrolRoutes.PatrolRoutes.CreatePatrolGroup(<route>5__8.RouteName, <waypoints>5__9);
							<officerCount>5__11 = Random.Range(<route>5__8.MinOfficers, <route>5__8.MaxOfficers + 1);
							<i>5__14 = 0;
							goto IL_02f5;
						}
						<>m__Finally1();
						<>s__7 = default(List<EvenMoreFootPatrols.Route>.Enumerator);
						return false;
						IL_02f5:
						if (<i>5__14 < <officerCount>5__11)
						{
							<officerName>5__15 = $"{<route>5__8.RouteName}_Officer{<i>5__14 + 1}";
							global::EvenMoreFootPatrols.PatrolOfficers.PatrolOfficers.spawnOfficer(manager, <officerName>5__15, <group>5__10, <route>5__8.OfficerMovementSpeedMultiplier, warpToStart: true);
							<>2__current = (object)new WaitForSeconds(0.5f);
							<>1__state = 1;
							return true;
						}
						MelonLogger.Msg($"{<route>5__8.RouteName} route created successfully with {<officerCount>5__11} officers");
						<>2__current = (object)new WaitForSeconds(<delayBetweenRoutes>5__4);
						<>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)<>s__7).Dispose();
			}

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

		[IteratorStateMachine(typeof(<LoadPatrolRoutesFromJson>d__0))]
		public static IEnumerator LoadPatrolRoutesFromJson(NetworkManager manager)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadPatrolRoutesFromJson>d__0(0)
			{
				manager = manager
			};
		}
	}
}
namespace EvenMoreFootPatrols.Helpers
{
	public static class MelonLoggerExtensions
	{
		public static void Debug(this Instance logger, string message, bool stacktrace = true)
		{
		}

		private static string GetLoggerName(Instance logger)
		{
			return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string;
		}

		private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message)
		{
			typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5]
			{
				namesectionColor,
				textColor,
				nameSection,
				message ?? "null",
				false
			});
		}

		private static string GetCallerInfo()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 2; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				if (!(method?.DeclaringType == null))
				{
					return method.DeclaringType.FullName + "." + method.Name;
				}
			}
			return "unknown";
		}
	}
	public static class Il2CppListExtensions
	{
		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			return list ?? new List<T>();
		}
	}
	public static class Utils
	{
		[CompilerGenerated]
		private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator routine;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MelonCoroutines.Start(routine);
				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 <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator coroutine;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_0044;
				case 1:
					<>1__state = -1;
					goto IL_0044;
				case 2:
					{
						<>1__state = -1;
						return false;
					}
					IL_0044:
					if (!NetworkSingleton<T>.InstanceExists)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<>2__current = coroutine;
					<>1__state = 2;
					return true;
				}
			}

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

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

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

			private object <>2__current;

			public object obj;

			public float timeout;

			public Action onTimeout;

			public Action onFinish;

			private float <startTime>5__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<startTime>5__1 = Time.time;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (obj == null)
				{
					if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
					{
						onTimeout?.Invoke();
						return false;
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				onFinish?.Invoke();
				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 <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IEnumerator routine;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MelonCoroutines.Start(routine);
				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 readonly Instance Logger = new Instance("Even More Foot Patrols-Utils");

		public static T FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				T[] array = Resources.FindObjectsOfTypeAll<T>();
				foreach (T val in array)
				{
					if (!(((Object)val).name != objectName))
					{
						Logger.Debug("Found " + typeof(T).Name + " '" + objectName + "' directly in loaded objects");
						return val;
					}
				}
				return default(T);
			}
			catch (Exception ex)
			{
				Logger.Error("Error finding " + typeof(T).Name + " '" + objectName + "': " + ex.Message);
				return default(T);
			}
		}

		public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
		{
			List<T> list = new List<T>();
			if ((Object)(object)obj == (Object)null)
			{
				return list;
			}
			T[] components = obj.GetComponents<T>();
			if (components.Length != 0)
			{
				list.AddRange(components);
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform child = obj.transform.GetChild(i);
				list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
			}
			return list;
		}

		public static bool Is<T>(object obj, out T result) where T : class
		{
			if (obj is T val)
			{
				result = val;
				return true;
			}
			result = null;
			return false;
		}

		public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
		{
			List<ItemRegister> list = Singleton<Registry>.Instance.ItemRegistry.ToList();
			List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
			foreach (ItemRegister item in list)
			{
				if (Is<StorableItemDefinition>(item.Definition, out var result))
				{
					list2.Add(result);
				}
				else
				{
					Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
				}
			}
			return list2.ToList();
		}

		[IteratorStateMachine(typeof(<WaitForPlayer>d__5))]
		public static IEnumerator WaitForPlayer(IEnumerator routine)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPlayer>d__5(0)
			{
				routine = routine
			};
		}

		[IteratorStateMachine(typeof(<WaitForNetwork>d__6))]
		public static IEnumerator WaitForNetwork(IEnumerator routine)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForNetwork>d__6(0)
			{
				routine = routine
			};
		}

		[IteratorStateMachine(typeof(<WaitForNotNull>d__7))]
		public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForNotNull>d__7(0)
			{
				obj = obj,
				timeout = timeout,
				onTimeout = onTimeout,
				onFinish = onFinish
			};
		}

		[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))]
		public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForNetworkSingleton>d__8<T>(0)
			{
				coroutine = coroutine
			};
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}