Decompiled source of SewerEmployees v1.0.0

SewerEmployees-IL2CPP.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppFishNet;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.Delivery;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Property;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using SewerEmployees;
using UnityEngine;

[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::SewerEmployees.SewerEmployees), "SewerEmployees", "1.0.0", "k073l", null)]
[assembly: MelonColor(1, 210, 105, 30)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SewerEmployees-IL2CPP")]
[assembly: AssemblyConfiguration("Release IL2CPP")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SewerEmployees-IL2CPP")]
[assembly: AssemblyTitle("SewerEmployees-IL2CPP")]
[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 SewerEmployees
{
	public static class BuildInfo
	{
		public const string Name = "SewerEmployees";

		public const string Description = "Adds employees to the sewer office";

		public const string Author = "k073l";

		public const string Version = "1.0.0";
	}
	public class SewerEmployees : MelonMod
	{
		[HarmonyPatch]
		private class SewerOfficePatch
		{
			private static Manor _manorInstance;

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Manor), "Awake")]
			private static void Manor_Awake_Postfix(Manor __instance)
			{
				_manorInstance = __instance;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(SewerOffice), "Awake")]
			private static void Awake_Postfix(SewerOffice __instance)
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Expected O, but got Unknown
				//IL_0097: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_manorInstance == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("Manor instance is null");
					return;
				}
				Transform val = ((IEnumerable<Transform>)((Property)_manorInstance).EmployeeIdlePoints).FirstOrDefault();
				if ((Object)(object)val == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No idle point found for bungalow employee");
					return;
				}
				GameObject val2 = new GameObject("EmployeeIdlePoints");
				val2.transform.SetParent(((Component)__instance).transform);
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(37.89f, -8.26f, 69.47f);
				List<Transform> list = new List<Transform>();
				Vector3 val4 = val3;
				List<float> list2 = new List<float>();
				Vector3 val5 = default(Vector3);
				for (int i = 0; i < 5; i++)
				{
					int num = 0;
					bool flag = false;
					Vector3 val6;
					do
					{
						((Vector3)(ref val5))..ctor(0f, 0f, Random.Range(-3f, 8f));
						val6 = val4 + val5;
						flag = true;
						foreach (float item in list2)
						{
							if (Mathf.Abs(val6.z - item) < 0.8f)
							{
								flag = false;
								break;
							}
						}
						num++;
					}
					while (!flag && num < 20);
					list2.Add(val6.z);
					Transform val7 = Object.Instantiate<Transform>(val, val6, Quaternion.identity);
					val7.SetParent(val2.transform);
					list.Add(val7);
				}
				((Property)__instance).EmployeeIdlePoints = Il2CppReferenceArray<Transform>.op_Implicit(list.ToArray());
				((Property)__instance).EmployeeCapacity = 5;
				_getBin((Property)(object)__instance);
				_getBay((Property)(object)__instance, (Property)(object)_manorInstance);
				Melon<SewerEmployees>.Logger.Msg("Sewer office modified");
			}

			private static void _getBin(Property sewerOfficeProperty)
			{
				//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_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = GameObject.Find("@Properties/Manor/Skip bin");
				if ((Object)(object)val == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No Manor object found");
					return;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val, new Vector3(50.7f, -9f, 40.88f), Quaternion.identity);
				val2.transform.SetParent(((Component)sewerOfficeProperty).transform);
				Transform val3 = val2.transform.Find("Stand point");
				if ((Object)(object)val3 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No stand point found in bin");
					return;
				}
				((Component)val3).transform.position = new Vector3(50.7f, -9f, 43.12f);
				Transform val4 = val2.transform.Find("Trash spawn point");
				if ((Object)(object)val4 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No trash spawn point found in bin");
					return;
				}
				((Component)val4).transform.position = new Vector3(50.7f, -7f, 40.12f);
				Transform val5 = val2.transform.Find("Trash spawner");
				if ((Object)(object)val5 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No trash spawner found in bin");
					return;
				}
				((Component)val5).transform.position = new Vector3(50.7f, -8f, 40.12f);
				Transform val6 = val2.transform.Find("Trash remover");
				if ((Object)(object)val6 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No trash remover found in bin");
					return;
				}
				((Component)val6).transform.position = new Vector3(50.7f, -7.8f, 40.12f);
				Transform obj = val2.transform.Find("skip bin/Bin_LOD1");
				GameObject val7 = ((obj != null) ? ((Component)obj).gameObject : null);
				if ((Object)(object)val7 != (Object)null)
				{
					val7.SetActive(true);
				}
				PropertyDisposalArea component = val2.GetComponent<PropertyDisposalArea>();
				if ((Object)(object)component == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No PropertyDisposalArea found in bin");
				}
				else
				{
					sewerOfficeProperty.DisposalArea = component;
				}
			}

			private static void _getBay(Property sewerOfficeProperty, Property templateProperty)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(55.45f, -9f, 38.09f);
				LoadingDock val2 = ((Il2CppArrayBase<LoadingDock>)(object)templateProperty.LoadingDocks)[0];
				LoadingDock val3 = Object.Instantiate<LoadingDock>(val2, val, Quaternion.identity);
				((Component)val3).transform.SetParent(((Component)sewerOfficeProperty).transform);
				LoadingDock component = ((Component)val3).GetComponent<LoadingDock>();
				if ((Object)(object)component == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No LoadingDock component found in bay");
					return;
				}
				sewerOfficeProperty.LoadingDocks = Il2CppReferenceArray<LoadingDock>.op_Implicit(new List<LoadingDock> { component }.ToArray());
			}
		}

		private static Instance Logger;

		private const int EmployeeCapacity = 5;

		public override void OnInitializeMelon()
		{
			Logger = ((MelonBase)this).LoggerInstance;
			Logger.Msg("SewerEmployees initialized");
		}
	}
}
namespace SewerEmployees.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 List<T> ToIl2CppList<T>(this IEnumerable<T> source)
		{
			List<T> val = new List<T>();
			foreach (T item in source)
			{
				val.Add(item);
			}
			return val;
		}

		public static List<T> ConvertToList<T>(List<T> il2CppList)
		{
			List<T> list = new List<T>();
			T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray());
			list.AddRange(collection);
			return list;
		}

		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			IEnumerable<T> result;
			if (list != null)
			{
				result = ((IEnumerable<T>)list._items).Take(list._size);
			}
			else
			{
				IEnumerable<T> enumerable = Array.Empty<T>();
				result = enumerable;
			}
			return result;
		}
	}
	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("SewerEmployees-Utils");

		public static T FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				foreach (T item in Resources.FindObjectsOfTypeAll<T>())
				{
					if (((Object)item).name != objectName)
					{
						continue;
					}
					Logger.Debug($"Found {typeof(T).Name} '{objectName}' directly in loaded objects");
					return item;
				}
				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[] array = Il2CppArrayBase<T>.op_Implicit(obj.GetComponents<T>());
			if (array.Length != 0)
			{
				list.AddRange(array);
			}
			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 : Object
		{
			Object val = (Object)((obj is Object) ? obj : null);
			if (val != null)
			{
				Type val2 = Il2CppType.Of<T>();
				Type il2CppType = val.GetIl2CppType();
				if (val2.IsAssignableFrom(il2CppType))
				{
					result = ((Il2CppObjectBase)val).TryCast<T>();
					return result != null;
				}
			}
			result = default(T);
			return false;
		}

		public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
		{
			List<ItemRegister> list = Il2CppListExtensions.ConvertToList<ItemRegister>(Singleton<Registry>.Instance.ItemRegistry);
			List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
			foreach (ItemRegister item in list)
			{
				if (Utils.Is<StorableItemDefinition>((object)item.Definition, out StorableItemDefinition 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
			};
		}
	}
}

SewerEmployees-Mono.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FishNet;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.Delivery;
using ScheduleOne.DevUtilities;
using ScheduleOne.ItemFramework;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Property;
using SewerEmployees;
using UnityEngine;

[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::SewerEmployees.SewerEmployees), "SewerEmployees", "1.0.0", "k073l", null)]
[assembly: MelonColor(1, 210, 105, 30)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SewerEmployees-Mono")]
[assembly: AssemblyConfiguration("Release Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SewerEmployees-Mono")]
[assembly: AssemblyTitle("SewerEmployees-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 SewerEmployees
{
	public static class BuildInfo
	{
		public const string Name = "SewerEmployees";

		public const string Description = "Adds employees to the sewer office";

		public const string Author = "k073l";

		public const string Version = "1.0.0";
	}
	public class SewerEmployees : MelonMod
	{
		[HarmonyPatch]
		private class SewerOfficePatch
		{
			private static Manor _manorInstance;

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Manor), "Awake")]
			private static void Manor_Awake_Postfix(Manor __instance)
			{
				_manorInstance = __instance;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(SewerOffice), "Awake")]
			private static void Awake_Postfix(SewerOffice __instance)
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Expected O, but got Unknown
				//IL_0097: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_manorInstance == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("Manor instance is null");
					return;
				}
				Transform val = ((Property)_manorInstance).EmployeeIdlePoints.FirstOrDefault();
				if ((Object)(object)val == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No idle point found for bungalow employee");
					return;
				}
				GameObject val2 = new GameObject("EmployeeIdlePoints");
				val2.transform.SetParent(((Component)__instance).transform);
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(37.89f, -8.26f, 69.47f);
				List<Transform> list = new List<Transform>();
				Vector3 val4 = val3;
				List<float> list2 = new List<float>();
				Vector3 val5 = default(Vector3);
				for (int i = 0; i < 5; i++)
				{
					int num = 0;
					bool flag = false;
					Vector3 val6;
					do
					{
						((Vector3)(ref val5))..ctor(0f, 0f, Random.Range(-3f, 8f));
						val6 = val4 + val5;
						flag = true;
						foreach (float item in list2)
						{
							if (Mathf.Abs(val6.z - item) < 0.8f)
							{
								flag = false;
								break;
							}
						}
						num++;
					}
					while (!flag && num < 20);
					list2.Add(val6.z);
					Transform val7 = Object.Instantiate<Transform>(val, val6, Quaternion.identity);
					val7.SetParent(val2.transform);
					list.Add(val7);
				}
				((Property)__instance).EmployeeIdlePoints = list.ToArray();
				((Property)__instance).EmployeeCapacity = 5;
				_getBin((Property)(object)__instance);
				_getBay((Property)(object)__instance, (Property)(object)_manorInstance);
				Melon<SewerEmployees>.Logger.Msg("Sewer office modified");
			}

			private static void _getBin(Property sewerOfficeProperty)
			{
				//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_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = GameObject.Find("@Properties/Manor/Skip bin");
				if ((Object)(object)val == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No Manor object found");
					return;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val, new Vector3(50.7f, -9f, 40.88f), Quaternion.identity);
				val2.transform.SetParent(((Component)sewerOfficeProperty).transform);
				Transform val3 = val2.transform.Find("Stand point");
				if ((Object)(object)val3 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No stand point found in bin");
					return;
				}
				((Component)val3).transform.position = new Vector3(50.7f, -9f, 43.12f);
				Transform val4 = val2.transform.Find("Trash spawn point");
				if ((Object)(object)val4 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No trash spawn point found in bin");
					return;
				}
				((Component)val4).transform.position = new Vector3(50.7f, -7f, 40.12f);
				Transform val5 = val2.transform.Find("Trash spawner");
				if ((Object)(object)val5 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No trash spawner found in bin");
					return;
				}
				((Component)val5).transform.position = new Vector3(50.7f, -8f, 40.12f);
				Transform val6 = val2.transform.Find("Trash remover");
				if ((Object)(object)val6 == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No trash remover found in bin");
					return;
				}
				((Component)val6).transform.position = new Vector3(50.7f, -7.8f, 40.12f);
				Transform obj = val2.transform.Find("skip bin/Bin_LOD1");
				GameObject val7 = ((obj != null) ? ((Component)obj).gameObject : null);
				if ((Object)(object)val7 != (Object)null)
				{
					val7.SetActive(true);
				}
				PropertyDisposalArea component = val2.GetComponent<PropertyDisposalArea>();
				if ((Object)(object)component == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No PropertyDisposalArea found in bin");
				}
				else
				{
					sewerOfficeProperty.DisposalArea = component;
				}
			}

			private static void _getBay(Property sewerOfficeProperty, Property templateProperty)
			{
				//IL_0021: 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)
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(55.45f, -9f, 38.09f);
				LoadingDock val2 = templateProperty.LoadingDocks[0];
				LoadingDock val3 = Object.Instantiate<LoadingDock>(val2, val, Quaternion.identity);
				((Component)val3).transform.SetParent(((Component)sewerOfficeProperty).transform);
				LoadingDock component = ((Component)val3).GetComponent<LoadingDock>();
				if ((Object)(object)component == (Object)null)
				{
					Melon<SewerEmployees>.Logger.Error("No LoadingDock component found in bay");
					return;
				}
				sewerOfficeProperty.LoadingDocks = new List<LoadingDock> { component }.ToArray();
			}
		}

		private static Instance Logger;

		private const int EmployeeCapacity = 5;

		public override void OnInitializeMelon()
		{
			Logger = ((MelonBase)this).LoggerInstance;
			Logger.Msg("SewerEmployees initialized");
		}
	}
}
namespace SewerEmployees.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("SewerEmployees-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)
		{
		}
	}
}