Decompiled source of EmployeeLockers v1.0.3

BepInEx/plugins/EmployeeLockers/EmployeeLockers.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using EmployeeLockers.Configurations;
using EmployeeLockers.Configurations.Data;
using EmployeeLockers.Constants;
using EmployeeLockers.Helpers;
using EmployeeLockers.Logging;
using EmployeeLockers.Managers;
using EmployeeLockers.Scripts.ObjectScripts;
using EmployeeLockers.Utils;
using FishNet;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.DevUtilities;
using ScheduleOne.Dialogue;
using ScheduleOne.Employees;
using ScheduleOne.EntityFramework;
using ScheduleOne.Equipping;
using ScheduleOne.ItemFramework;
using ScheduleOne.Management;
using ScheduleOne.NPCs;
using ScheduleOne.ObjectScripts;
using ScheduleOne.Persistence;
using ScheduleOne.Persistence.Datas;
using ScheduleOne.Persistence.Loaders;
using ScheduleOne.Property;
using ScheduleOne.Storage;
using ScheduleOne.UI.Management;
using ScheduleOne.UI.Shop;
using TMPro;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("FishNet.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EmployeeLockers")]
[assembly: AssemblyConfiguration("DebugBepInEx")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmployeeLockers")]
[assembly: AssemblyTitle("EmployeeLockers")]
[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 EmployeeLockers
{
	[BepInPlugin("EmployeeLockers", "EmployeeLockers", "1.0.0")]
	public class Core : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <InitializeData>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => AssetManager.IsLoaded));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					RegistryManager.RetrieveDataFromRegistry(Singleton<Registry>.Instance);
					RegistryManager.RegisterItem<Locker>("locker", "furniture/locker/locker_01a.prefab", "furniture/locker/locker.asset");
					ShopManager.AddItemToShop(ShopCode.GasMartCentral, "locker");
					ShopManager.AddItemToShop(ShopCode.GasMartWest, "locker");
					ShopManager.AddItemToShop(ShopCode.DarkMarketShop, "locker");
					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 void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			Log.Logger = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo("Initializing EmployeeLockers...");
			new Harmony("com.MaxtorCoder.EmployeeLockers").PatchAll();
			((MonoBehaviour)this).StartCoroutine(InitializeData());
		}

		[IteratorStateMachine(typeof(<InitializeData>d__1))]
		private static IEnumerator InitializeData()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeData>d__1(0);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EmployeeLockers";

		public const string PLUGIN_NAME = "EmployeeLockers";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace EmployeeLockers.Utils
{
	public static class Extensions
	{
		public static ushort Get16BitHash(this AssetBundle assetBundle)
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				throw new ArgumentNullException("assetBundle");
			}
			int seed = 0;
			seed = assetBundle.GetAllAssetNames().Aggregate(seed, (int current, string assetName) => current * 31 * assetName.GetHashCode());
			seed *= 31 * ((Object)assetBundle).name.GetHashCode();
			return (ushort)(65535 - (ushort)(seed % 65535));
		}

		public static string ToPascalCase(this string input)
		{
			if (string.IsNullOrWhiteSpace(input))
			{
				return input;
			}
			string input2 = input.ToLower();
			return Regex.Replace(input2, "(^|_)(\\w)", (Match match) => match.Groups[2].Value.ToUpper());
		}
	}
}
namespace EmployeeLockers.Transpilers
{
	[HarmonyPatch]
	public static class EmployeeTranspiler
	{
		[CompilerGenerated]
		private sealed class <TargetMethods>d__0 : IEnumerable<MethodBase>, IEnumerable, IEnumerator<MethodBase>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private MethodBase <>2__current;

			private int <>l__initialThreadId;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = AccessTools.Method(typeof(Employee), "CanWork", (Type[])null, (Type[])null);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = AccessTools.Method(typeof(Employee), "GetWorkIssue", (Type[])null, (Type[])null);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = AccessTools.Method(typeof(Employee), "UpdateBehaviour", (Type[])null, (Type[])null);
					<>1__state = 3;
					return true;
				case 3:
					<>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();
			}

			[DebuggerHidden]
			IEnumerator<MethodBase> IEnumerable<MethodBase>.GetEnumerator()
			{
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					return this;
				}
				return new <TargetMethods>d__0(0);
			}

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

		[IteratorStateMachine(typeof(<TargetMethods>d__0))]
		[HarmonyTargetMethods]
		public static IEnumerable<MethodBase> TargetMethods()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TargetMethods>d__0(-2);
		}

		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo methodInfo = AccessTools.Method(typeof(Employee), "GetBed", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(EmployeeHelpers), "GetLockerFromEmployee", (Type[])null, (Type[])null);
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.Calls(list[i], methodInfo))
				{
					list[i] = new CodeInstruction(OpCodes.Call, (object)methodInfo2);
				}
			}
			return list;
		}
	}
}
namespace EmployeeLockers.Patches
{
	[HarmonyPatch(typeof(Employee))]
	public class EmployeePatches
	{
		[HarmonyPatch("IsPayAvailable")]
		[HarmonyPrefix]
		public static bool IsPayAvailable_Prefix(Employee __instance, ref bool __result)
		{
			Locker lockerFromEmployee = EmployeeHelpers.GetLockerFromEmployee(__instance);
			if (!Object.op_Implicit((Object)(object)lockerFromEmployee))
			{
				__result = false;
			}
			else
			{
				__result = lockerFromEmployee.GetCashSum() >= __instance.DailyWage;
			}
			return false;
		}

		[HarmonyPatch("RemoveDailyWage")]
		[HarmonyPrefix]
		public static bool RemoveDailyWage_Prefix(Employee __instance)
		{
			Locker lockerFromEmployee = EmployeeHelpers.GetLockerFromEmployee(__instance);
			if (Object.op_Implicit((Object)(object)lockerFromEmployee) && lockerFromEmployee.GetCashSum() >= __instance.DailyWage)
			{
				lockerFromEmployee.RemoveCash(__instance.DailyWage);
			}
			return false;
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void Start_Prefix(Employee __instance)
		{
			DialogueNodeData val = ((IEnumerable<DialogueNodeData>)__instance.BedNotAssignedDialogue.DialogueNodeData).FirstOrDefault((Func<DialogueNodeData, bool>)((DialogueNodeData x) => x.DialogueNodeLabel == "ENTRY"));
			val.DialogueText = "Sorry boss, I need to be assigned a locker before I can get to work.";
			val.choices[1].ChoiceText = "How do I assign your locker?";
			DialogueNodeData val2 = ((IEnumerable<DialogueNodeData>)__instance.NotPaidDialogue.DialogueNodeData).FirstOrDefault((Func<DialogueNodeData, bool>)((DialogueNodeData x) => x.Guid == "962c0749-7042-4b4c-83df-7eedb37ea43d"));
			val2.DialogueText = "You can place cash in the assigned locker.";
		}
	}
	[HarmonyPatch(typeof(Registry))]
	public class RegistryPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		public static void Awake_Prefix(Registry __instance)
		{
			AssetManager.LoadAssetBundle("employeelocker", InstanceFinder.NetworkManager);
		}
	}
	[HarmonyPatch(typeof(ShopInterface))]
	public class ShopInterfacePatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		public static void Awake_Prefix(ShopInterface __instance)
		{
			if (__instance.ShopCode == "shop" || __instance.Listings == null)
			{
				return;
			}
			ShopCode shopCode = (ShopCode)Enum.Parse(typeof(ShopCode), __instance.ShopCode.ToPascalCase());
			List<ShopListing> shopListings = ShopManager.GetShopListings(shopCode);
			if (shopListings == null)
			{
				return;
			}
			foreach (ShopListing item in shopListings.Where((ShopListing customShopListing) => __instance.Listings.All((ShopListing x) => x.name != customShopListing.name)))
			{
				__instance.Listings.Add(item);
			}
		}
	}
}
namespace EmployeeLockers.Patches.Employees
{
	[HarmonyPatch(typeof(Botanist))]
	public class BotanistPatches
	{
		[HarmonyPatch("AssignProperty")]
		[HarmonyPrefix]
		public static bool AssignProperty_Prefix(Botanist __instance, Property prop)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((Employee)__instance).AssignedProperty = prop;
			((Employee)__instance).EmployeeIndex = ((Employee)__instance).AssignedProperty.RegisterEmployee((Employee)(object)__instance);
			((NPC)__instance).movement.Warp(prop.NPCSpawnPoint.position);
			((Employee)__instance).WaitOutside.IdlePoint = prop.EmployeeIdlePoints[((Employee)__instance).EmployeeIndex];
			prop.AddConfigurable((IConfigurable)(object)__instance);
			__instance.configuration = (BotanistConfiguration)(object)new CustomBotanistConfiguration(__instance.configReplicator, (IConfigurable)(object)__instance, __instance);
			__instance.CreateWorldspaceUI();
			return false;
		}
	}
	[HarmonyPatch(typeof(BotanistLoader))]
	public static class BotanistLoaderPatches
	{
		[HarmonyPatch("Load")]
		[HarmonyPrefix]
		public static bool Load_Prefix(BotanistLoader __instance, string mainPath)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			Employee val = ((EmployeeLoader)__instance).LoadAndCreateEmployee(mainPath);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			Botanist botanist = (Botanist)(object)((val is Botanist) ? val : null);
			if (!Object.op_Implicit((Object)(object)botanist))
			{
				Console.LogWarning((object)"Failed to cast employee to botanist", (Object)null);
				return false;
			}
			string text = default(string);
			CustomBotanistConfigurationData configData;
			if (((Loader)__instance).TryLoadFile(mainPath, "Configuration", ref text))
			{
				configData = JsonUtility.FromJson<CustomBotanistConfigurationData>(text);
				if (configData != null)
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadConfiguration));
				}
			}
			string text2 = default(string);
			BotanistData data;
			if (((Loader)__instance).TryLoadFile(mainPath, "NPC", ref text2))
			{
				data = null;
				try
				{
					data = JsonUtility.FromJson<BotanistData>(text2);
				}
				catch (Exception ex)
				{
					Console.LogError((object)(((object)__instance).GetType()?.ToString() + " error reading data: " + ex), (Object)null);
				}
				if (data == null)
				{
					Console.LogWarning((object)"Failed to load botanist data", (Object)null);
				}
				else
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadNpcConfiguration));
				}
			}
			return false;
			void LoadConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadConfiguration));
				CustomBotanistConfiguration customBotanistConfiguration = botanist.Configuration as CustomBotanistConfiguration;
				customBotanistConfiguration.LockerObjectField.Load(configData.Locker);
				((BotanistConfiguration)customBotanistConfiguration).Supplies.Load(configData.Supplies);
				((BotanistConfiguration)customBotanistConfiguration).AssignedStations.Load(configData.Pots);
			}
			void LoadNpcConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadNpcConfiguration));
				((Employee)botanist).MoveItemBehaviour.Load(data.MoveItemData);
			}
		}
	}
	[HarmonyPatch(typeof(Chemist))]
	public class ChemistPatches
	{
		[HarmonyPatch("AssignProperty")]
		[HarmonyPrefix]
		public static bool AssignProperty_Prefix(Chemist __instance, Property prop)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((Employee)__instance).AssignedProperty = prop;
			((Employee)__instance).EmployeeIndex = ((Employee)__instance).AssignedProperty.RegisterEmployee((Employee)(object)__instance);
			((NPC)__instance).movement.Warp(prop.NPCSpawnPoint.position);
			((Employee)__instance).WaitOutside.IdlePoint = prop.EmployeeIdlePoints[((Employee)__instance).EmployeeIndex];
			prop.AddConfigurable((IConfigurable)(object)__instance);
			__instance.configuration = (ChemistConfiguration)(object)new CustomChemistConfiguration(__instance.configReplicator, (IConfigurable)(object)__instance, __instance);
			__instance.CreateWorldspaceUI();
			return false;
		}
	}
	[HarmonyPatch(typeof(ChemistLoader))]
	public static class ChemistLoaderPatches
	{
		[HarmonyPatch("Load")]
		[HarmonyPrefix]
		public static bool Load_Prefix(ChemistLoader __instance, string mainPath)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			Employee val = ((EmployeeLoader)__instance).LoadAndCreateEmployee(mainPath);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			Chemist chemist = (Chemist)(object)((val is Chemist) ? val : null);
			if (!Object.op_Implicit((Object)(object)chemist))
			{
				Console.LogWarning((object)"Failed to cast employee to chemist", (Object)null);
				return false;
			}
			string text = default(string);
			CustomChemistConfigurationData configData;
			if (((Loader)__instance).TryLoadFile(mainPath, "Configuration", ref text))
			{
				configData = JsonUtility.FromJson<CustomChemistConfigurationData>(text);
				if (configData != null)
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadConfiguration));
				}
			}
			string text2 = default(string);
			ChemistData data;
			if (((Loader)__instance).TryLoadFile(mainPath, "NPC", ref text2))
			{
				data = null;
				try
				{
					data = JsonUtility.FromJson<ChemistData>(text2);
				}
				catch (Exception ex)
				{
					Console.LogError((object)(((object)__instance).GetType()?.ToString() + " error reading data: " + ex), (Object)null);
				}
				if (data == null)
				{
					Console.LogWarning((object)"Failed to load chemist data", (Object)null);
				}
				else
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadNpcConfiguration));
				}
			}
			return false;
			void LoadConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadConfiguration));
				CustomChemistConfiguration customChemistConfiguration = chemist.Configuration as CustomChemistConfiguration;
				customChemistConfiguration.LockerObjectField.Load(configData.Locker);
				((ChemistConfiguration)customChemistConfiguration).Stations.Load(configData.Stations);
			}
			void LoadNpcConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadNpcConfiguration));
				((Employee)chemist).MoveItemBehaviour.Load(data.MoveItemData);
			}
		}
	}
	[HarmonyPatch(typeof(Cleaner))]
	public class CleanerPatches
	{
		[HarmonyPatch("AssignProperty")]
		[HarmonyPrefix]
		public static bool AssignProperty_Prefix(Cleaner __instance, Property prop)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((Employee)__instance).AssignedProperty = prop;
			((Employee)__instance).EmployeeIndex = ((Employee)__instance).AssignedProperty.RegisterEmployee((Employee)(object)__instance);
			((NPC)__instance).movement.Warp(prop.NPCSpawnPoint.position);
			((Employee)__instance).WaitOutside.IdlePoint = prop.EmployeeIdlePoints[((Employee)__instance).EmployeeIndex];
			prop.AddConfigurable((IConfigurable)(object)__instance);
			__instance.configuration = (CleanerConfiguration)(object)new CustomCleanerConfiguration(__instance.configReplicator, (IConfigurable)(object)__instance, __instance);
			__instance.CreateWorldspaceUI();
			return false;
		}
	}
	[HarmonyPatch(typeof(CleanerLoader))]
	public static class CleanerLoaderPatches
	{
		[HarmonyPatch("Load")]
		[HarmonyPrefix]
		public static bool Load_Prefix(CleanerLoader __instance, string mainPath)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			Employee val = ((EmployeeLoader)__instance).LoadAndCreateEmployee(mainPath);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			Cleaner cleaner = (Cleaner)(object)((val is Cleaner) ? val : null);
			if (!Object.op_Implicit((Object)(object)cleaner))
			{
				Console.LogWarning((object)"Failed to cast employee to cleaner", (Object)null);
				return false;
			}
			string text = default(string);
			CustomCleanerConfigurationData configData;
			if (((Loader)__instance).TryLoadFile(mainPath, "Configuration", ref text))
			{
				configData = JsonUtility.FromJson<CustomCleanerConfigurationData>(text);
				if (configData != null)
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadConfiguration));
				}
			}
			string text2 = default(string);
			CleanerData data;
			if (((Loader)__instance).TryLoadFile(mainPath, "NPC", ref text2))
			{
				data = null;
				try
				{
					data = JsonUtility.FromJson<CleanerData>(text2);
				}
				catch (Exception ex)
				{
					Console.LogError((object)(((object)__instance).GetType()?.ToString() + " error reading data: " + ex), (Object)null);
				}
				if (data == null)
				{
					Console.LogWarning((object)"Failed to load cleaner data", (Object)null);
				}
				else
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadNpcConfiguration));
				}
			}
			return false;
			void LoadConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadConfiguration));
				CustomCleanerConfiguration customCleanerConfiguration = cleaner.Configuration as CustomCleanerConfiguration;
				customCleanerConfiguration.LockerObjectField.Load(configData.Locker);
				((CleanerConfiguration)customCleanerConfiguration).Bins.Load(configData.Bins);
			}
			void LoadNpcConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadNpcConfiguration));
				((Employee)cleaner).MoveItemBehaviour.Load(data.MoveItemData);
			}
		}
	}
	[HarmonyPatch(typeof(Packager))]
	public class PackagerPatches
	{
		[HarmonyPatch("AssignProperty")]
		[HarmonyPrefix]
		public static bool AssignProperty_Prefix(Packager __instance, Property prop)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((Employee)__instance).AssignedProperty = prop;
			((Employee)__instance).EmployeeIndex = ((Employee)__instance).AssignedProperty.RegisterEmployee((Employee)(object)__instance);
			((NPC)__instance).movement.Warp(prop.NPCSpawnPoint.position);
			((Employee)__instance).WaitOutside.IdlePoint = prop.EmployeeIdlePoints[((Employee)__instance).EmployeeIndex];
			prop.AddConfigurable((IConfigurable)(object)__instance);
			__instance.configuration = (PackagerConfiguration)(object)new CustomPackagerConfiguration(__instance.configReplicator, (IConfigurable)(object)__instance, __instance);
			__instance.CreateWorldspaceUI();
			return false;
		}
	}
	[HarmonyPatch(typeof(PackagerLoader))]
	public static class PackagerLoaderPatches
	{
		[HarmonyPatch("Load")]
		[HarmonyPrefix]
		public static bool Load_Prefix(PackagerLoader __instance, string mainPath)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			Employee val = ((EmployeeLoader)__instance).LoadAndCreateEmployee(mainPath);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			Packager packager = (Packager)(object)((val is Packager) ? val : null);
			if (!Object.op_Implicit((Object)(object)packager))
			{
				Console.LogWarning((object)"Failed to cast employee to packager", (Object)null);
				return false;
			}
			string text = default(string);
			CustomPackagerConfigurationData configData;
			if (((Loader)__instance).TryLoadFile(mainPath, "Configuration", ref text))
			{
				configData = JsonUtility.FromJson<CustomPackagerConfigurationData>(text);
				if (configData != null)
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadConfiguration));
				}
			}
			string text2 = default(string);
			PackagerData data;
			if (((Loader)__instance).TryLoadFile(mainPath, "NPC", ref text2))
			{
				data = null;
				try
				{
					data = JsonUtility.FromJson<PackagerData>(text2);
				}
				catch (Exception ex)
				{
					Console.LogError((object)(((object)__instance).GetType()?.ToString() + " error reading data: " + ex), (Object)null);
				}
				if (data == null)
				{
					Console.LogWarning((object)"Failed to load packager data", (Object)null);
				}
				else
				{
					Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(LoadNpcConfiguration));
				}
			}
			return false;
			void LoadConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadConfiguration));
				CustomPackagerConfiguration customPackagerConfiguration = packager.Configuration as CustomPackagerConfiguration;
				customPackagerConfiguration.LockerObjectField.Load(configData.Locker);
				((PackagerConfiguration)customPackagerConfiguration).Stations.Load(configData.Stations);
				((PackagerConfiguration)customPackagerConfiguration).Routes.Load(configData.Routes);
			}
			void LoadNpcConfiguration()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(LoadNpcConfiguration));
				((Employee)packager).MoveItemBehaviour.Load(data.MoveItemData);
			}
		}
	}
}
namespace EmployeeLockers.Patches.ConfigPanels
{
	[HarmonyPatch(typeof(BotanistConfigPanel))]
	public class BotanistConfigPanelPatches
	{
		[HarmonyPatch("Bind")]
		[HarmonyPrefix]
		public static bool Bind_Prefix(BotanistConfigPanel __instance, List<EntityConfiguration> configs)
		{
			List<ObjectField> list = new List<ObjectField>();
			List<ObjectField> list2 = new List<ObjectField>();
			List<ObjectListField> list3 = new List<ObjectListField>();
			foreach (CustomBotanistConfiguration item in configs.Cast<CustomBotanistConfiguration>())
			{
				if (item == null)
				{
					Console.LogError((object)"Failed to cast EntityConfiguration to CustomBotanistConfiguration", (Object)null);
					return false;
				}
				list.Add(item.LockerObjectField);
				list2.Add(((BotanistConfiguration)item).Supplies);
				list3.Add(((BotanistConfiguration)item).AssignedStations);
			}
			__instance.BedUI.Bind(list);
			((TMP_Text)__instance.BedUI.FieldLabel).text = "Locker";
			__instance.SuppliesUI.Bind(list2);
			__instance.PotsUI.Bind(list3);
			return false;
		}
	}
	[HarmonyPatch(typeof(ChemistConfigPanel))]
	public class ChemistConfigPanelPatches
	{
		[HarmonyPatch("Bind")]
		[HarmonyPrefix]
		public static bool Bind_Prefix(ChemistConfigPanel __instance, List<EntityConfiguration> configs)
		{
			List<ObjectField> list = new List<ObjectField>();
			List<ObjectListField> list2 = new List<ObjectListField>();
			foreach (CustomChemistConfiguration item in configs.Cast<CustomChemistConfiguration>())
			{
				if (item == null)
				{
					Console.LogError((object)"Failed to cast EntityConfiguration to CustomChemistConfiguration", (Object)null);
					return false;
				}
				list.Add(item.LockerObjectField);
				list2.Add(((ChemistConfiguration)item).Stations);
			}
			__instance.BedUI.Bind(list);
			((TMP_Text)__instance.BedUI.FieldLabel).text = "Locker";
			__instance.StationsUI.Bind(list2);
			return false;
		}
	}
	[HarmonyPatch(typeof(CleanerConfigPanel))]
	public class CleanerConfigPanelPatches
	{
		[HarmonyPatch("Bind")]
		[HarmonyPrefix]
		public static bool Bind_Prefix(CleanerConfigPanel __instance, List<EntityConfiguration> configs)
		{
			List<ObjectField> list = new List<ObjectField>();
			List<ObjectListField> list2 = new List<ObjectListField>();
			foreach (CustomCleanerConfiguration item in configs.Cast<CustomCleanerConfiguration>())
			{
				if (item == null)
				{
					Console.LogError((object)"Failed to cast EntityConfiguration to CustomCleanerConfiguration", (Object)null);
					return false;
				}
				list.Add(item.LockerObjectField);
				list2.Add(((CleanerConfiguration)item).Bins);
			}
			__instance.BedUI.Bind(list);
			((TMP_Text)__instance.BedUI.FieldLabel).text = "Locker";
			__instance.BinsUI.Bind(list2);
			return false;
		}
	}
	[HarmonyPatch(typeof(PackagerConfigPanel))]
	public class PackagerConfigPanelPatches
	{
		[HarmonyPatch("Bind")]
		[HarmonyPrefix]
		public static bool Bind_Prefix(PackagerConfigPanel __instance, List<EntityConfiguration> configs)
		{
			List<ObjectField> list = new List<ObjectField>();
			List<ObjectListField> list2 = new List<ObjectListField>();
			List<RouteListField> list3 = new List<RouteListField>();
			foreach (CustomPackagerConfiguration item in configs.Cast<CustomPackagerConfiguration>())
			{
				if (item == null)
				{
					Console.LogError((object)"Failed to cast EntityConfiguration to CustomPackagerConfiguration", (Object)null);
					return false;
				}
				list.Add(item.LockerObjectField);
				list2.Add(((PackagerConfiguration)item).Stations);
				list3.Add(((PackagerConfiguration)item).Routes);
			}
			__instance.BedUI.Bind(list);
			((TMP_Text)__instance.BedUI.FieldLabel).text = "Locker";
			__instance.StationsUI.Bind(list2);
			__instance.RoutesUI.Bind(list3);
			return false;
		}
	}
}
namespace EmployeeLockers.Managers
{
	public static class AssetManager
	{
		public static bool IsLoaded;

		private static readonly Dictionary<string, GameObject> _loadedGameObjects = new Dictionary<string, GameObject>();

		private static readonly Dictionary<string, ScriptableObject> _loadedScriptableObjects = new Dictionary<string, ScriptableObject>();

		public static void LoadAssetBundle(string assetBundleName, NetworkManager networkManager)
		{
			if (IsLoaded)
			{
				return;
			}
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EmployeeLockers.Assets." + assetBundleName);
			if (stream == null)
			{
				Log.LogError("[AssetManager]: Failed to load stream: " + assetBundleName);
				return;
			}
			AssetBundle val = AssetBundle.LoadFromStream(stream);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.LogError("[AssetManager]: Failed to load AssetBundle: " + assetBundleName);
				return;
			}
			ushort num = val.Get16BitHash();
			PrefabObjects prefabObjects = networkManager.GetPrefabObjects<SinglePrefabObjects>(num, true);
			string[] allAssetNames = val.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				Log.LogInfo("[AssetManager]: Loading asset: " + text);
				GameObject val2 = val.LoadAsset<GameObject>(text);
				if (Object.op_Implicit((Object)(object)val2) && !_loadedGameObjects.ContainsKey(text))
				{
					NetworkObject component = val2.GetComponent<NetworkObject>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Log.LogInfo("[AssetManager]:     -> Loaded GameObject " + text + " with NetworkedObject");
						prefabObjects.AddObject(component, true);
					}
					else
					{
						Log.LogInfo("[AssetManager]:     -> Loaded GameObject " + text);
					}
					_loadedGameObjects.Add(text, val2);
				}
				ScriptableObject val3 = val.LoadAsset<ScriptableObject>(text);
				if (Object.op_Implicit((Object)(object)val3) && !_loadedScriptableObjects.ContainsKey(text))
				{
					Log.LogInfo("[AssetManager]:     -> Loaded ScriptableObject " + text);
					_loadedScriptableObjects.TryAdd(text, val3);
				}
			}
			IsLoaded = true;
		}

		public static GameObject GetRegisteredGameObject(string objectName)
		{
			if (_loadedGameObjects.TryGetValue(objectName.ToLower(), out var value))
			{
				return value;
			}
			Log.LogError("[AssetManager]: Could not find loaded GameObject with name " + objectName.ToLower());
			return null;
		}

		public static ScriptableObject GetRegisteredScriptableObject(string objectName)
		{
			if (_loadedScriptableObjects.TryGetValue(objectName.ToLower(), out var value))
			{
				return value;
			}
			Log.LogError("[AssetManager]: Could not find loaded ScriptableObject with name " + objectName.ToLower());
			return null;
		}
	}
	public static class RegistryManager
	{
		private static readonly Dictionary<string, GameObject> _buildHandlerObjects = new Dictionary<string, GameObject>();

		private static readonly Dictionary<string, Equippable> _equippableObjects = new Dictionary<string, Equippable>();

		private static readonly Dictionary<string, StoredItem> _storedItemObjects = new Dictionary<string, StoredItem>();

		private static TMP_FontAsset _fontAsset;

		public static void RegisterItem<T>(string key, string prefabPath, string itemDefinitionPath = "") where T : Object
		{
			//IL_009d: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			prefabPath = "assets/resources/" + prefabPath;
			if (!string.IsNullOrEmpty(itemDefinitionPath))
			{
				itemDefinitionPath = "assets/resources/" + itemDefinitionPath;
			}
			ItemRegister val = ((IEnumerable<ItemRegister>)Singleton<Registry>.Instance.ItemRegistry).FirstOrDefault((Func<ItemRegister, bool>)((ItemRegister x) => x.ID == key));
			ItemRegister val2 = val;
			ItemRegister val3 = val2;
			if (val3 == null)
			{
				if (!string.IsNullOrEmpty(itemDefinitionPath))
				{
					ScriptableObject registeredScriptableObject = AssetManager.GetRegisteredScriptableObject(itemDefinitionPath);
					if (!Object.op_Implicit((Object)(object)registeredScriptableObject))
					{
						Log.LogError("[RegistryManager]: Failed to find definition for " + itemDefinitionPath);
						return;
					}
					val = new ItemRegister
					{
						Definition = (ItemDefinition)registeredScriptableObject,
						ID = key,
						AssetPath = prefabPath
					};
					Singleton<Registry>.Instance.ItemRegistry.Add(val);
					Singleton<Registry>.Instance.AddToItemDictionary(val);
				}
				else if (string.IsNullOrEmpty(itemDefinitionPath))
				{
					Log.LogError("[RegistryManager]: Failed to create new ItemDefinition with key: " + key + ", itemDefinition argument is null");
					return;
				}
			}
			if (val == null)
			{
				Log.LogError("[RegistryManager]: Failed to retrieve itemRegistry for key: " + key);
				return;
			}
			GameObject registeredGameObject = AssetManager.GetRegisteredGameObject(prefabPath);
			if (!Object.op_Implicit((Object)(object)registeredGameObject))
			{
				Log.LogError("[RegistryManager]: Failed to find " + prefabPath + " in asset bundle");
				return;
			}
			if (_equippableObjects.TryGetValue(((Object)val.Definition.Equippable).name, out var value))
			{
				val.Definition.Equippable = value;
			}
			ItemDefinition definition = val.Definition;
			StorableItemDefinition val4 = (StorableItemDefinition)(object)((definition is StorableItemDefinition) ? definition : null);
			if (val4 != null && _storedItemObjects.TryGetValue(((Object)val4.StoredItem).name, out var value2))
			{
				val4.StoredItem = value2;
			}
			ItemDefinition definition2 = val.Definition;
			BuildableItemDefinition val5 = (BuildableItemDefinition)(object)((definition2 is BuildableItemDefinition) ? definition2 : null);
			if (val5 == null)
			{
				return;
			}
			BuildableItem component = registeredGameObject.GetComponent<BuildableItem>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				Log.LogError($"[RegistryManager]: Failed to find \"BuildableItem\" component in {registeredGameObject}");
				return;
			}
			if (_buildHandlerObjects.TryGetValue(((Object)val5.BuiltItem.BuildHandler).name, out var value3))
			{
				component.buildHandler = value3;
			}
			val5.BuiltItem = component;
			Locker component2 = ((Component)val5.BuiltItem).GetComponent<Locker>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				TMP_Text componentInChildren = component2.clipboard.GetComponentInChildren<TMP_Text>();
				componentInChildren.font = _fontAsset;
				Log.LogInfo($"[RegistryManager]: Override the font for {componentInChildren}");
			}
		}

		public static void RetrieveDataFromRegistry(Registry registryInstance)
		{
			foreach (ItemRegister item in registryInstance.ItemRegistry)
			{
				ItemDefinition definition = item.Definition;
				BuildableItemDefinition val = (BuildableItemDefinition)(object)((definition is BuildableItemDefinition) ? definition : null);
				if (val != null)
				{
					if (!Object.op_Implicit((Object)(object)val.BuiltItem))
					{
						continue;
					}
					GameObject buildHandler = val.BuiltItem.BuildHandler;
					_buildHandlerObjects.TryAdd(((Object)buildHandler).name, buildHandler);
					if (item.ID == "bed")
					{
						Bed component = ((Component)val.BuiltItem).GetComponent<Bed>();
						TMP_Text componentInChildren = component.Clipboard.GetComponentInChildren<TMP_Text>();
						_fontAsset = componentInChildren.font;
					}
				}
				ItemDefinition definition2 = item.Definition;
				StorableItemDefinition val2 = (StorableItemDefinition)(object)((definition2 is StorableItemDefinition) ? definition2 : null);
				if (val2 != null)
				{
					if (!Object.op_Implicit((Object)(object)val2.StoredItem))
					{
						continue;
					}
					StoredItem storedItem = val2.StoredItem;
					_storedItemObjects.TryAdd(((Object)storedItem).name, storedItem);
				}
				if (Object.op_Implicit((Object)(object)item.Definition.Equippable))
				{
					_equippableObjects.TryAdd(((Object)item.Definition.Equippable).name, item.Definition.Equippable);
				}
			}
			Log.LogInfo($"[RegistryManager]: Loaded {_buildHandlerObjects.Count} build handler(s)");
			Log.LogInfo($"[RegistryManager]: Loaded {_storedItemObjects.Count} stored item(s)");
			Log.LogInfo($"[RegistryManager]: Loaded {_equippableObjects.Count} equippable(s)");
		}
	}
	public static class ShopManager
	{
		private static readonly Dictionary<ShopCode, List<ShopListing>> _customShopListings = new Dictionary<ShopCode, List<ShopListing>>();

		public static void AddItemToShop(ShopCode shopCode, string itemCode, float? price = null)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			ItemRegister val = ((IEnumerable<ItemRegister>)Singleton<Registry>.Instance.ItemRegistry).FirstOrDefault((Func<ItemRegister, bool>)((ItemRegister x) => x.ID == itemCode));
			if (val == null)
			{
				return;
			}
			ItemDefinition definition = val.Definition;
			StorableItemDefinition val2 = (StorableItemDefinition)(object)((definition is StorableItemDefinition) ? definition : null);
			if (val2 != null)
			{
				ShopListing val3 = new ShopListing();
				float num = val2.BasePurchasePrice;
				if (price.HasValue)
				{
					val3.OverridePrice = true;
					val3.OverriddenPrice = price.Value;
					num = price.Value;
				}
				string arg = val2.ShopCategories.Aggregate("", (string current, CategoryInstance categoryInstance) => current + $"{categoryInstance.Category}, ");
				val3.name = $"{((ItemDefinition)val2).Name} ({num}) ({arg})";
				val3.Item = val2;
				if (!_customShopListings.ContainsKey(shopCode))
				{
					_customShopListings.Add(shopCode, new List<ShopListing>());
				}
				_customShopListings[shopCode].Add(val3);
				Log.LogInfo($"[ShopManager]: Added {val3.name} to {shopCode}");
			}
		}

		public static List<ShopListing> GetShopListings(ShopCode shopCode)
		{
			return _customShopListings.GetValueOrDefault(shopCode);
		}
	}
}
namespace EmployeeLockers.Logging
{
	public static class Log
	{
		public static ManualLogSource Logger;

		public static void LogInfo(string message)
		{
			Logger.LogInfo((object)message);
		}

		public static void LogWarning(string message)
		{
			Logger.LogWarning((object)message);
		}

		public static void LogError(string message)
		{
			Logger.LogError((object)message);
		}

		public static void LogFatal(string message)
		{
			Logger.LogFatal((object)message);
		}
	}
}
namespace EmployeeLockers.Helpers
{
	public static class EmployeeHelpers
	{
		public static Locker GetLockerFromEmployee(Employee employee)
		{
			if (1 == 0)
			{
			}
			Botanist val = (Botanist)(object)((employee is Botanist) ? employee : null);
			Locker result;
			if (val != null)
			{
				EntityConfiguration configuration = val.Configuration;
				if (configuration is CustomBotanistConfiguration customBotanistConfiguration)
				{
					result = customBotanistConfiguration.LockerItem;
					goto IL_00c5;
				}
			}
			else
			{
				Chemist val2 = (Chemist)(object)((employee is Chemist) ? employee : null);
				if (val2 != null)
				{
					EntityConfiguration configuration2 = val2.Configuration;
					if (configuration2 is CustomChemistConfiguration customChemistConfiguration)
					{
						result = customChemistConfiguration.LockerItem;
						goto IL_00c5;
					}
				}
				else
				{
					Cleaner val3 = (Cleaner)(object)((employee is Cleaner) ? employee : null);
					if (val3 != null)
					{
						EntityConfiguration configuration3 = val3.Configuration;
						if (configuration3 is CustomCleanerConfiguration customCleanerConfiguration)
						{
							result = customCleanerConfiguration.LockerItem;
							goto IL_00c5;
						}
					}
					else
					{
						Packager val4 = (Packager)(object)((employee is Packager) ? employee : null);
						if (val4 != null)
						{
							EntityConfiguration configuration4 = val4.Configuration;
							if (configuration4 is CustomPackagerConfiguration customPackagerConfiguration)
							{
								result = customPackagerConfiguration.LockerItem;
								goto IL_00c5;
							}
						}
					}
				}
			}
			result = null;
			goto IL_00c5;
			IL_00c5:
			if (1 == 0)
			{
			}
			return result;
		}
	}
}
namespace EmployeeLockers.Constants
{
	public enum ShopCode
	{
		GasMartCentral,
		GasMartWest,
		ThriftyThreads,
		CokeShop,
		MethShop,
		WeedShop,
		Boutique,
		DarkMarketShop,
		DansHardware,
		HandyHanks
	}
}
namespace EmployeeLockers.Configurations
{
	public class CustomBotanistConfiguration : BotanistConfiguration
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ObjectFilter <0>__IsLockerValid;
		}

		public readonly ObjectField LockerObjectField;

		public Locker LockerItem { get; private set; }

		public CustomBotanistConfiguration(ConfigurationReplicator replicator, IConfigurable configurable, Botanist botanist)
			: base(replicator, configurable, botanist)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			base.Bed = null;
			((BotanistConfiguration)this).bedItem = null;
			ObjectField val = new ObjectField((EntityConfiguration)(object)this);
			val.TypeRequirements = new List<Type>(1) { typeof(Locker) };
			object obj = <>O.<0>__IsLockerValid;
			if (obj == null)
			{
				ObjectFilter val2 = Locker.IsLockerValid;
				<>O.<0>__IsLockerValid = val2;
				obj = (object)val2;
			}
			val.objectFilter = (ObjectFilter)obj;
			LockerObjectField = val;
			LockerObjectField.onObjectChanged.AddListener((UnityAction<BuildableItem>)LockerChanged);
		}

		private void LockerChanged(BuildableItem newItem)
		{
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)null);
			}
			LockerItem = (Locker)(object)(Object.op_Implicit((Object)(object)newItem) ? ((newItem is Locker) ? newItem : null) : null);
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)(object)((BotanistConfiguration)this).botanist);
			}
			((EntityConfiguration)this).InvokeChanged();
		}

		public override void Destroy()
		{
			((BotanistConfiguration)this).Destroy();
			LockerObjectField.SetObject((BuildableItem)null, false);
			foreach (Pot assignedPot in base.AssignedPots)
			{
				EntityConfiguration configuration = assignedPot.Configuration;
				EntityConfiguration obj = ((configuration is PotConfiguration) ? configuration : null);
				if (obj != null)
				{
					((PotConfiguration)obj).AssignedBotanist.SetNPC((NPC)null, false);
				}
			}
			foreach (DryingRack assignedRack in base.AssignedRacks)
			{
				EntityConfiguration configuration2 = assignedRack.Configuration;
				EntityConfiguration obj2 = ((configuration2 is DryingRackConfiguration) ? configuration2 : null);
				if (obj2 != null)
				{
					((DryingRackConfiguration)obj2).AssignedBotanist.SetNPC((NPC)null, false);
				}
			}
		}

		public override bool ShouldSave()
		{
			if (base.AssignedPots.Count > 0)
			{
				return true;
			}
			if (base.AssignedRacks.Count > 0)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)base.Supplies.SelectedObject))
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)LockerObjectField.SelectedObject))
			{
				return true;
			}
			return ((BotanistConfiguration)this).ShouldSave();
		}

		public override string GetSaveString()
		{
			return ((SaveData)new CustomBotanistConfigurationData(LockerObjectField.GetData(), base.Supplies.GetData(), base.AssignedStations.GetData())).GetJson(true);
		}
	}
	public class CustomChemistConfiguration : ChemistConfiguration
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ObjectFilter <0>__IsLockerValid;
		}

		public readonly ObjectField LockerObjectField;

		public Locker LockerItem { get; private set; }

		public CustomChemistConfiguration(ConfigurationReplicator replicator, IConfigurable configurable, Chemist chemist)
			: base(replicator, configurable, chemist)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			base.Bed = null;
			((ChemistConfiguration)this).bedItem = null;
			ObjectField val = new ObjectField((EntityConfiguration)(object)this);
			val.TypeRequirements = new List<Type>(1) { typeof(Locker) };
			object obj = <>O.<0>__IsLockerValid;
			if (obj == null)
			{
				ObjectFilter val2 = Locker.IsLockerValid;
				<>O.<0>__IsLockerValid = val2;
				obj = (object)val2;
			}
			val.objectFilter = (ObjectFilter)obj;
			LockerObjectField = val;
			LockerObjectField.onObjectChanged.AddListener((UnityAction<BuildableItem>)LockerChanged);
		}

		private void LockerChanged(BuildableItem newItem)
		{
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)null);
			}
			LockerItem = (Locker)(object)(Object.op_Implicit((Object)(object)newItem) ? ((newItem is Locker) ? newItem : null) : null);
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)(object)((ChemistConfiguration)this).chemist);
			}
			((EntityConfiguration)this).InvokeChanged();
		}

		public override void Destroy()
		{
			((ChemistConfiguration)this).Destroy();
			LockerObjectField.SetObject((BuildableItem)null, false);
			foreach (ChemistryStation chemStation in base.ChemStations)
			{
				EntityConfiguration configuration = chemStation.Configuration;
				((ChemistryStationConfiguration)((configuration is ChemistryStationConfiguration) ? configuration : null)).AssignedChemist.SetNPC((NPC)null, false);
			}
			foreach (LabOven labOven in base.LabOvens)
			{
				EntityConfiguration configuration2 = labOven.Configuration;
				((LabOvenConfiguration)((configuration2 is LabOvenConfiguration) ? configuration2 : null)).AssignedChemist.SetNPC((NPC)null, false);
			}
			foreach (Cauldron cauldron in base.Cauldrons)
			{
				EntityConfiguration configuration3 = cauldron.Configuration;
				((CauldronConfiguration)((configuration3 is CauldronConfiguration) ? configuration3 : null)).AssignedChemist.SetNPC((NPC)null, false);
			}
			foreach (MixingStation mixStation in base.MixStations)
			{
				EntityConfiguration configuration4 = mixStation.Configuration;
				((MixingStationConfiguration)((configuration4 is MixingStationConfiguration) ? configuration4 : null)).AssignedChemist.SetNPC((NPC)null, false);
			}
		}

		public override bool ShouldSave()
		{
			if (base.ChemStations.Count > 0)
			{
				return true;
			}
			if (base.LabOvens.Count > 0)
			{
				return true;
			}
			if (base.Cauldrons.Count > 0)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)LockerObjectField.SelectedObject))
			{
				return true;
			}
			return ((ChemistConfiguration)this).ShouldSave();
		}

		public override string GetSaveString()
		{
			return ((SaveData)new CustomChemistConfigurationData(LockerObjectField.GetData(), base.Stations.GetData())).GetJson(true);
		}
	}
	public class CustomCleanerConfiguration : CleanerConfiguration
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ObjectFilter <0>__IsLockerValid;
		}

		public readonly ObjectField LockerObjectField;

		public Locker LockerItem { get; private set; }

		public CustomCleanerConfiguration(ConfigurationReplicator replicator, IConfigurable configurable, Cleaner cleaner)
			: base(replicator, configurable, cleaner)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			base.Bed = null;
			((CleanerConfiguration)this).bedItem = null;
			ObjectField val = new ObjectField((EntityConfiguration)(object)this);
			val.TypeRequirements = new List<Type>(1) { typeof(Locker) };
			object obj = <>O.<0>__IsLockerValid;
			if (obj == null)
			{
				ObjectFilter val2 = Locker.IsLockerValid;
				<>O.<0>__IsLockerValid = val2;
				obj = (object)val2;
			}
			val.objectFilter = (ObjectFilter)obj;
			LockerObjectField = val;
			LockerObjectField.onObjectChanged.AddListener((UnityAction<BuildableItem>)LockerChanged);
		}

		private void LockerChanged(BuildableItem newItem)
		{
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)null);
			}
			LockerItem = (Locker)(object)(Object.op_Implicit((Object)(object)newItem) ? ((newItem is Locker) ? newItem : null) : null);
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)(object)((CleanerConfiguration)this).cleaner);
			}
			((EntityConfiguration)this).InvokeChanged();
		}

		public override void Destroy()
		{
			((CleanerConfiguration)this).Destroy();
			LockerObjectField.SetObject((BuildableItem)null, false);
		}

		public override bool ShouldSave()
		{
			if (base.Bins.SelectedObjects.Count > 0)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)LockerObjectField.SelectedObject))
			{
				return true;
			}
			return ((CleanerConfiguration)this).ShouldSave();
		}

		public override string GetSaveString()
		{
			return ((SaveData)new CustomCleanerConfigurationData(LockerObjectField.GetData(), base.Bins.GetData())).GetJson(true);
		}
	}
	public class CustomPackagerConfiguration : PackagerConfiguration
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ObjectFilter <0>__IsLockerValid;
		}

		public readonly ObjectField LockerObjectField;

		public Locker LockerItem { get; private set; }

		public CustomPackagerConfiguration(ConfigurationReplicator replicator, IConfigurable configurable, Packager packager)
			: base(replicator, configurable, packager)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			base.Bed = null;
			((PackagerConfiguration)this).bedItem = null;
			ObjectField val = new ObjectField((EntityConfiguration)(object)this);
			val.TypeRequirements = new List<Type>(1) { typeof(Locker) };
			object obj = <>O.<0>__IsLockerValid;
			if (obj == null)
			{
				ObjectFilter val2 = Locker.IsLockerValid;
				<>O.<0>__IsLockerValid = val2;
				obj = (object)val2;
			}
			val.objectFilter = (ObjectFilter)obj;
			LockerObjectField = val;
			LockerObjectField.onObjectChanged.AddListener((UnityAction<BuildableItem>)LockerChanged);
		}

		private void LockerChanged(BuildableItem newItem)
		{
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)null);
			}
			LockerItem = (Locker)(object)(Object.op_Implicit((Object)(object)newItem) ? ((newItem is Locker) ? newItem : null) : null);
			if (Object.op_Implicit((Object)(object)LockerItem))
			{
				LockerItem.SetAssignedEmployee((Employee)(object)((PackagerConfiguration)this).packager);
			}
			((EntityConfiguration)this).InvokeChanged();
		}

		public override void Destroy()
		{
			((PackagerConfiguration)this).Destroy();
			LockerObjectField.SetObject((BuildableItem)null, false);
			foreach (PackagingStation assignedStation in base.AssignedStations)
			{
				EntityConfiguration configuration = assignedStation.Configuration;
				((PackagingStationConfiguration)((configuration is PackagingStationConfiguration) ? configuration : null)).AssignedPackager.SetNPC((NPC)null, false);
			}
			foreach (BrickPress assignedBrickPress in base.AssignedBrickPresses)
			{
				EntityConfiguration configuration2 = assignedBrickPress.Configuration;
				((BrickPressConfiguration)((configuration2 is BrickPressConfiguration) ? configuration2 : null)).AssignedPackager.SetNPC((NPC)null, false);
			}
		}

		public override bool ShouldSave()
		{
			if (base.AssignedStations.Count > 0)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)LockerObjectField.SelectedObject))
			{
				return true;
			}
			return ((PackagerConfiguration)this).ShouldSave();
		}

		public override string GetSaveString()
		{
			return ((SaveData)new CustomPackagerConfigurationData(LockerObjectField.GetData(), base.Stations.GetData(), base.Routes.GetData())).GetJson(true);
		}
	}
}
namespace EmployeeLockers.Configurations.Data
{
	[Serializable]
	public class CustomBotanistConfigurationData : SaveData
	{
		public ObjectFieldData Locker;

		public ObjectFieldData Supplies;

		public ObjectListFieldData Pots;

		public CustomBotanistConfigurationData(ObjectFieldData locker, ObjectFieldData supplies, ObjectListFieldData pots)
		{
			Locker = locker;
			Supplies = supplies;
			Pots = pots;
			((SaveData)this)..ctor();
		}
	}
	[Serializable]
	public class CustomChemistConfigurationData : SaveData
	{
		public ObjectFieldData Locker;

		public ObjectListFieldData Stations;

		public CustomChemistConfigurationData(ObjectFieldData locker, ObjectListFieldData stations)
		{
			Locker = locker;
			Stations = stations;
			((SaveData)this)..ctor();
		}
	}
	[Serializable]
	public class CustomCleanerConfigurationData : SaveData
	{
		public ObjectFieldData Locker;

		public ObjectListFieldData Bins;

		public CustomCleanerConfigurationData(ObjectFieldData locker, ObjectListFieldData bins)
		{
			Locker = locker;
			Bins = bins;
			((SaveData)this)..ctor();
		}
	}
	[Serializable]
	public class CustomPackagerConfigurationData : SaveData
	{
		public ObjectFieldData Locker;

		public ObjectListFieldData Stations;

		public RouteListData Routes;

		public CustomPackagerConfigurationData(ObjectFieldData locker, ObjectListFieldData stations, RouteListData routes)
		{
			Locker = locker;
			Stations = stations;
			Routes = routes;
			((SaveData)this)..ctor();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BepInEx/plugins/EmployeeLockers/EmployeeLockers.Scripts.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using ScheduleOne.DevUtilities;
using ScheduleOne.Employees;
using ScheduleOne.EntityFramework;
using ScheduleOne.Interaction;
using ScheduleOne.ItemFramework;
using ScheduleOne.Money;
using ScheduleOne.NPCs;
using ScheduleOne.Storage;
using ScheduleOne.Tools;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("FishNet.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EmployeeLockers.Scripts")]
[assembly: AssemblyConfiguration("DebugBepInEx")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmployeeLockers.Scripts")]
[assembly: AssemblyTitle("EmployeeLockers.Scripts")]
[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 EmployeeLockers.Scripts.ObjectScripts
{
	public class Locker : GridItem
	{
		[Header("Employee Settings")]
		public GameObject clipboard;

		public SpriteRenderer mugshotSprite;

		public TextMeshPro employeeName;

		[Header("Miscellaneous Settings")]
		public InteractableObject interactableObject;

		public StorageEntity storageEntity;

		public Employee AssignedEmployee { get; protected set; }

		public void Hovered()
		{
			if (Singleton<ManagementClipboard>.Instance.IsEquipped)
			{
				interactableObject.SetInteractableState((EInteractableState)2);
			}
			else if (Object.op_Implicit((Object)(object)AssignedEmployee))
			{
				interactableObject.SetInteractableState((EInteractableState)1);
				interactableObject.SetMessage("Assigned to " + ((NPC)AssignedEmployee).fullName);
			}
		}

		public void SetAssignedEmployee(Employee employee)
		{
			AssignedEmployee = employee;
			if (Object.op_Implicit((Object)(object)AssignedEmployee))
			{
				mugshotSprite.sprite = ((NPC)AssignedEmployee).MugshotSprite;
				((TMP_Text)employeeName).text = ((NPC)AssignedEmployee).FirstName + "\n" + ((NPC)AssignedEmployee).LastName;
				clipboard.SetActive(true);
			}
			else
			{
				clipboard.SetActive(false);
			}
			UpdateLocker();
		}

		private void UpdateLocker()
		{
			if (Object.op_Implicit((Object)(object)AssignedEmployee))
			{
				storageEntity.StorageEntityName = ((NPC)AssignedEmployee).FirstName + "'s Locker";
				string text = "<color=#54E717>" + MoneyManager.FormatAmount(AssignedEmployee.DailyWage, false, false) + "</color>";
				storageEntity.StorageEntitySubtitle = ((NPC)AssignedEmployee).FirstName + " will draw " + (AssignedEmployee.IsMale ? "his" : "her") + " daily wage of " + text + " from this locker.";
			}
			else
			{
				storageEntity.StorageEntityName = "Locker";
				storageEntity.StorageEntitySubtitle = string.Empty;
			}
		}

		public static bool IsLockerValid(BuildableItem obj, out string reason)
		{
			reason = string.Empty;
			if (!(obj is Locker locker))
			{
				return false;
			}
			if (!Object.op_Implicit((Object)(object)locker.AssignedEmployee))
			{
				return true;
			}
			reason = "Already assigned to " + ((NPC)locker.AssignedEmployee).fullName;
			return false;
		}

		public float GetCashSum()
		{
			float num = 0f;
			foreach (ItemSlot itemSlot in storageEntity.ItemSlots)
			{
				ItemInstance itemInstance = itemSlot.ItemInstance;
				CashInstance val = (CashInstance)(object)((itemInstance is CashInstance) ? itemInstance : null);
				if (val != null)
				{
					num += val.Balance;
				}
			}
			return num;
		}

		public void RemoveCash(float amount)
		{
			if (amount <= 0f)
			{
				return;
			}
			foreach (ItemSlot itemSlot in storageEntity.ItemSlots)
			{
				ItemInstance itemInstance = itemSlot.ItemInstance;
				CashInstance val = (CashInstance)(object)((itemInstance is CashInstance) ? itemInstance : null);
				if (val != null)
				{
					float num = Mathf.Min(amount, val.Balance);
					val.ChangeBalance(0f - num);
					itemSlot.ReplicateStoredInstance();
					amount -= num;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}