Decompiled source of MurderItemSpawner v1.0.0

MurderItemSpawner.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using SOD.Common;
using SOD.Common.BepInEx;
using UnityEngine;
using UniverseLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MurderItemSpawner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fd18034234b1bc5b3744e48ee190066c38503ea8")]
[assembly: AssemblyProduct("MurderItemSpawner")]
[assembly: AssemblyTitle("MurderItemSpawner")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MurderItemSpawner;

public class ConfigManager
{
	private static ConfigManager _instance;

	private Dictionary<string, bool> triggeredRules = new Dictionary<string, bool>();

	public static ConfigManager Instance
	{
		get
		{
			if (_instance == null)
			{
				_instance = new ConfigManager();
			}
			return _instance;
		}
	}

	public List<ModConfig> Configs { get; private set; } = new List<ModConfig>();


	private string ConfigFolderPath => Path.Combine(Paths.PluginPath, "ShaneeexD-MurderItemSpawner");

	private ConfigManager()
	{
		LoadConfig();
	}

	public void LoadConfig()
	{
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Expected O, but got Unknown
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Expected O, but got Unknown
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Expected O, but got Unknown
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Expected O, but got Unknown
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Expected O, but got Unknown
		Configs.Clear();
		if (!Directory.Exists(ConfigFolderPath))
		{
			Directory.CreateDirectory(ConfigFolderPath);
		}
		string pluginPath = Paths.PluginPath;
		List<string> list = new List<string>();
		string[] files = Directory.GetFiles(ConfigFolderPath, "*MIS.json");
		if (files.Length != 0)
		{
			list.AddRange(files);
		}
		else
		{
			string text = Path.Combine(ConfigFolderPath, "DefaultMIS.json");
			ModConfig modConfig = new ModConfig();
			modConfig.SaveToFile(text);
			list.Add(text);
			PluginController<Plugin, IEmptyBindings>.Log.LogInfo((object)"Created default configuration file: DefaultMIS.json");
		}
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val;
		try
		{
			string[] directories = Directory.GetDirectories(pluginPath, "*", SearchOption.AllDirectories);
			string[] array = directories;
			foreach (string text2 in array)
			{
				if (text2.Equals(ConfigFolderPath, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				string[] files2 = Directory.GetFiles(text2, "*MIS.json");
				if (files2.Length != 0)
				{
					list.AddRange(files2);
					ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
					val = new BepInExInfoLogInterpolatedStringHandler(32, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(files2.Length);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" additional config(s) in: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					}
					log.LogInfo(val);
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error searching for config files: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log2.LogError(val2);
		}
		foreach (string item in list)
		{
			try
			{
				ModConfig modConfig2 = ModConfig.LoadFromFile(item);
				if (modConfig2 != null)
				{
					Configs.Add(modConfig2);
					ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
					val = new BepInExInfoLogInterpolatedStringHandler(39, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded configuration from ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Path.GetFileName(Path.GetDirectoryName(item)));
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Path.GetFileName(item));
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" with ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(modConfig2.SpawnRules.Count);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" rules");
					}
					log3.LogInfo(val);
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(28, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error loading config file ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
				}
				log4.LogError(val2);
			}
		}
		triggeredRules.Clear();
		foreach (ModConfig config in Configs)
		{
			foreach (SpawnRule spawnRule in config.SpawnRules)
			{
				triggeredRules[spawnRule.Name] = false;
			}
		}
		int num = 0;
		foreach (ModConfig config2 in Configs)
		{
			num += config2.SpawnRules.Count;
		}
		ManualLogSource log5 = PluginController<Plugin, IEmptyBindings>.Log;
		val = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Configs.Count);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" configuration files with ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" total rules");
		}
		log5.LogInfo(val);
	}

	public void SaveConfig(ModConfig config, string fileName)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		string filePath = Path.Combine(ConfigFolderPath, fileName);
		config.SaveToFile(filePath);
		ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Configuration saved to ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(fileName);
		}
		log.LogInfo(val);
	}

	public void SaveDefaultConfig()
	{
		if (Configs.Count > 0)
		{
			SaveConfig(Configs[0], "DefaultMIS.json");
			return;
		}
		ModConfig config = new ModConfig();
		SaveConfig(config, "DefaultMIS.json");
	}

	public void CheckRulesForEvent(string eventName, string murderType)
	{
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Expected O, but got Unknown
		bool flag = default(bool);
		foreach (ModConfig config in Configs)
		{
			if (!config.Enabled)
			{
				continue;
			}
			foreach (SpawnRule spawnRule in config.SpawnRules)
			{
				if (!spawnRule.Enabled || (triggeredRules.ContainsKey(spawnRule.Name) && triggeredRules[spawnRule.Name]) || !spawnRule.TriggerEvents.Contains(eventName) || (!string.IsNullOrEmpty(spawnRule.MurderMO) && !(spawnRule.MurderMO == murderType)))
				{
					continue;
				}
				if (config.ShowDebugMessages)
				{
					ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Rule '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(spawnRule.Name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' triggered by event '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(eventName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' with murder type '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(murderType);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					}
					log.LogInfo(val);
				}
				SpawnItem(spawnRule);
				triggeredRules[spawnRule.Name] = true;
			}
		}
	}

	private void SpawnItem(SpawnRule rule)
	{
		//IL_0531: Unknown result type (might be due to invalid IL or missing references)
		//IL_0538: Expected O, but got Unknown
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Expected O, but got Unknown
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cd: Expected O, but got Unknown
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Expected O, but got Unknown
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Expected O, but got Unknown
		bool flag = default(bool);
		try
		{
			Human owner = GetOwner(rule.BelongsTo);
			if ((Object)(object)owner == (Object)null)
			{
				ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(51, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot spawn item for rule '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(rule.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': No valid owner found");
				}
				log.LogInfo(val);
				return;
			}
			Human recipient = GetRecipient(rule.Recipient);
			if ((Object)(object)recipient == (Object)null)
			{
				ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(55, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot spawn item for rule '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(rule.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': No valid recipient found");
				}
				log2.LogInfo(val);
				return;
			}
			Interactable spawnLocation = GetSpawnLocation(rule, owner, recipient);
			if (spawnLocation == null && rule.SpawnLocation == SpawnLocationType.Mailbox)
			{
				ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot spawn item for rule '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(rule.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': No valid spawn location found");
				}
				log3.LogInfo(val);
				return;
			}
			if (rule.SpawnLocation == SpawnLocationType.HomeBuildingEntrance)
			{
			}
			switch (rule.SpawnLocation)
			{
			case SpawnLocationType.Mailbox:
				SpawnItemMailbox.SpawnItemAtLocation(owner, recipient, spawnLocation, rule.ItemToSpawn, rule.UnlockMailbox, rule.SpawnChance);
				break;
			case SpawnLocationType.Doormat:
				SpawnItemDoormat.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance);
				break;
			case SpawnLocationType.HomeLobby:
				SpawnItemLobbyHome.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance);
				break;
			case SpawnLocationType.WorkplaceLobby:
				SpawnItemLobbyWork.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance);
				break;
			case SpawnLocationType.HomeBuildingEntrance:
				SpawnItemBuildingEntranceHome.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance, rule.SubLocationTypeBuildingEntrances);
				break;
			case SpawnLocationType.WorkplaceBuildingEntrance:
				SpawnItemBuildingEntranceWorkplace.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance, rule.SubLocationTypeBuildingEntrances);
				break;
			case SpawnLocationType.HotelRooftopBar:
				SpawnItemHotelRooftopBar.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance, rule.HotelRooftopBarSubLocations);
				break;
			case SpawnLocationType.Random:
			{
				if (rule.RandomSpawnLocations == null || rule.RandomSpawnLocations.Count == 0)
				{
					ManualLogSource log5 = PluginController<Plugin, IEmptyBindings>.Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(93, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ConfigManager] Random spawn location selected but no RandomSpawnLocations defined in rule '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(rule.Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					log5.LogWarning(val2);
					break;
				}
				int index = Random.Range(0, rule.RandomSpawnLocations.Count);
				string text = rule.RandomSpawnLocations[index];
				if (!Enum.TryParse<SpawnLocationType>(text, out var result))
				{
					ManualLogSource log6 = PluginController<Plugin, IEmptyBindings>.Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(58, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ConfigManager] Invalid random location name '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' in rule '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(rule.Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					log6.LogWarning(val2);
				}
				else
				{
					SpawnRule rule2 = new SpawnRule
					{
						Name = rule.Name + "_Random",
						ItemToSpawn = rule.ItemToSpawn,
						BelongsTo = rule.BelongsTo,
						Recipient = rule.Recipient,
						SpawnLocation = result,
						SpawnChance = rule.SpawnChance,
						UnlockMailbox = rule.UnlockMailbox,
						SubLocationTypeBuildingEntrances = rule.SubLocationTypeBuildingEntrances
					};
					SpawnItem(rule2);
				}
				break;
			}
			case SpawnLocationType.CityHallBathroom:
				SpawnItemCityHallBathroom.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance);
				break;
			case SpawnLocationType.Custom:
				SpawnItemCustomBuilding.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance, rule.CustomRoomName, rule.CustomBuildingPreset, rule.CustomFloorNames, rule.CustomSubRoomName, rule.CustomRoomPreset, rule.CustomSubRoomPreset, rule.CustomRoomNames, rule.CustomRoomPresets, rule.CustomSubRoomNames, rule.CustomSubRoomPresets, rule.UseFurniture, rule.FurniturePresets);
				break;
			case SpawnLocationType.Home:
				SpawnItemHome.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance, rule.CustomRoomName, rule.UseFurniture, rule.FurniturePresets);
				break;
			case SpawnLocationType.Workplace:
				SpawnItemWork.SpawnItemAtLocation(owner, recipient, rule.ItemToSpawn, rule.SpawnChance, rule.CustomRoomName, rule.UseFurniture, rule.FurniturePresets);
				break;
			default:
			{
				ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Using mailbox spawner for location type by default: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<SpawnLocationType>(rule.SpawnLocation);
				}
				log4.LogInfo(val);
				if (spawnLocation != null)
				{
					SpawnItemMailbox.SpawnItemAtLocation(owner, recipient, spawnLocation, rule.ItemToSpawn, rule.UnlockMailbox, rule.SpawnChance);
				}
				break;
			}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log7 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(33, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error spawning item for rule '");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(rule.Name);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("': ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
			}
			log7.LogError(val3);
		}
	}

	private Human GetOwner(BelongsTo belongsTo)
	{
		switch (belongsTo)
		{
		case BelongsTo.Murderer:
			return MurderController.Instance.currentMurderer;
		case BelongsTo.Victim:
			return MurderController.Instance.currentVictim;
		case BelongsTo.Player:
			return (Human)(object)Player.Instance;
		case BelongsTo.MurdererDoctor:
			return MurderController.Instance.currentMurderer.GetDoctor();
		case BelongsTo.VictimDoctor:
			return MurderController.Instance.currentVictim.GetDoctor();
		case BelongsTo.MurdererLandlord:
			return MurderController.Instance.currentMurderer.GetLandlord();
		case BelongsTo.VictimLandlord:
			return MurderController.Instance.currentVictim.GetLandlord();
		case BelongsTo.Random:
			if (Random.Range(0f, 1f) > 0.5f)
			{
				return MurderController.Instance.currentMurderer;
			}
			return MurderController.Instance.currentVictim;
		default:
			return MurderController.Instance.currentMurderer;
		}
	}

	private Human GetRecipient(Recipient recipient)
	{
		switch (recipient)
		{
		case Recipient.Murderer:
			return MurderController.Instance.currentMurderer;
		case Recipient.Victim:
			return MurderController.Instance.currentVictim;
		case Recipient.Player:
			return (Human)(object)Player.Instance;
		case Recipient.MurdererDoctor:
			return MurderController.Instance.currentMurderer.GetDoctor();
		case Recipient.VictimDoctor:
			return MurderController.Instance.currentVictim.GetDoctor();
		case Recipient.MurdererLandlord:
			return MurderController.Instance.currentMurderer.GetLandlord();
		case Recipient.VictimLandlord:
			return MurderController.Instance.currentVictim.GetLandlord();
		case Recipient.Random:
			if (Random.Range(0f, 1f) > 0.5f)
			{
				return MurderController.Instance.currentMurderer;
			}
			return MurderController.Instance.currentVictim;
		default:
			return MurderController.Instance.currentMurderer;
		}
	}

	private Interactable GetSpawnLocation(SpawnRule rule, Human belongsTo, Human recipient)
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		switch (rule.SpawnLocation)
		{
		case SpawnLocationType.Mailbox:
			return Toolbox.Instance.GetMailbox(recipient);
		case SpawnLocationType.Doormat:
		{
			if ((Object)(object)recipient != (Object)null && (Object)(object)recipient.home != (Object)null)
			{
				return null;
			}
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(84, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ConfigManager] Cannot spawn item in doormat: Recipient or home address is null for ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((recipient != null) ? ((Object)recipient).name : null);
			}
			log.LogWarning(val);
			return null;
		}
		case SpawnLocationType.HomeLobby:
			if ((Object)(object)recipient != (Object)null && (Object)(object)recipient.home != (Object)null)
			{
				return null;
			}
			return null;
		case SpawnLocationType.HomeBuildingEntrance:
			if ((Object)(object)recipient != (Object)null && (Object)(object)recipient.home != (Object)null)
			{
				return null;
			}
			return null;
		case SpawnLocationType.WorkplaceBuildingEntrance:
			if ((Object)(object)belongsTo != (Object)null && belongsTo.job != null && belongsTo.job.employer != null && (Object)(object)belongsTo.job.employer.address != (Object)null)
			{
				return null;
			}
			return null;
		case SpawnLocationType.CityHallBathroom:
			if ((Object)(object)belongsTo != (Object)null)
			{
				return null;
			}
			return null;
		case SpawnLocationType.HotelRooftopBar:
			if ((Object)(object)belongsTo != (Object)null)
			{
				return null;
			}
			return null;
		case SpawnLocationType.Random:
			return null;
		default:
			return null;
		}
	}

	public void ResetTriggeredRules()
	{
		triggeredRules.Clear();
		foreach (ModConfig config in Configs)
		{
			foreach (SpawnRule spawnRule in config.SpawnRules)
			{
				triggeredRules[spawnRule.Name] = false;
			}
		}
	}
}
public static class CoroutineHelper
{
	public static void StartCoroutine(IEnumerator routine)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		try
		{
			RuntimeHelper.StartCoroutine(routine);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error starting coroutine: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}

	public static IEnumerator WaitForSeconds(float seconds)
	{
		float startTime = Time.time;
		while (Time.time - startTime < seconds)
		{
			yield return null;
		}
	}

	public static IEnumerator DelayedAction(float seconds, Action action)
	{
		yield return WaitForSeconds(seconds);
		action?.Invoke();
	}
}
public class ModConfig
{
	public static ModConfig Instance { get; set; }

	public bool Enabled { get; set; } = true;


	public bool ShowDebugMessages { get; set; } = true;


	public List<SpawnRule> SpawnRules { get; set; } = new List<SpawnRule>();


	public ModConfig()
	{
		SpawnRules.Add(new SpawnRule
		{
			Name = "Default Pencil in Mailbox",
			Enabled = true,
			MurderMO = "ExampleMO",
			TriggerEvents = new List<string> { "OnVictimKilled" },
			ItemToSpawn = "Pencil",
			SpawnLocation = SpawnLocationType.Mailbox,
			BelongsTo = BelongsTo.Murderer,
			Recipient = Recipient.Victim,
			SpawnChance = 1f,
			UnlockMailbox = true,
			SubLocationTypeBuildingEntrances = SubLocationTypeBuildingEntrances.Inside,
			RandomSpawnLocations = new List<string> { "Doormat", "Lobby", "BuildingEntrance", "WorkplaceBuildingEntrance" },
			HotelRooftopBarSubLocations = new List<string> { "RooftopBar", "BarDiningRoom" }
		});
	}

	public void SaveToFile(string filePath)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			JsonSerializerOptions options = new JsonSerializerOptions
			{
				WriteIndented = true
			};
			string contents = JsonSerializer.Serialize(this, options);
			File.WriteAllText(filePath, contents);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save configuration: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}

	public static ModConfig LoadFromFile(string filePath)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		try
		{
			if (File.Exists(filePath))
			{
				string json = File.ReadAllText(filePath);
				return JsonSerializer.Deserialize<ModConfig>(json);
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to load configuration: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
		return new ModConfig();
	}
}
[Serializable]
public class Vector3Serializable
{
	public float X { get; set; }

	public float Y { get; set; }

	public float Z { get; set; }

	public Vector3Serializable()
	{
	}

	public Vector3Serializable(float x, float y, float z)
	{
		X = x;
		Y = y;
		Z = z;
	}

	public Vector3 ToVector3()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(X, Y, Z);
	}

	public static Vector3Serializable FromVector3(Vector3 vector)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3Serializable(vector.x, vector.y, vector.z);
	}
}
public enum SpawnLocationType
{
	Mailbox,
	Doormat,
	HomeLobby,
	WorkplaceLobby,
	HomeBuildingEntrance,
	WorkplaceBuildingEntrance,
	CityHallBathroom,
	HotelRooftopBar,
	Home,
	Workplace,
	Random,
	Custom
}
public enum SubLocationTypeBuildingEntrances
{
	Inside,
	Outside
}
public enum BelongsTo
{
	Murderer,
	Victim,
	Player,
	MurdererDoctor,
	VictimDoctor,
	MurdererLandlord,
	VictimLandlord,
	Random
}
public enum Recipient
{
	Murderer,
	Victim,
	Player,
	MurdererDoctor,
	VictimDoctor,
	MurdererLandlord,
	VictimLandlord,
	Random
}
[Serializable]
public class SpawnRule
{
	public string Name { get; set; } = "Unnamed Rule";


	public bool Enabled { get; set; } = true;


	public List<string> TriggerEvents { get; set; } = new List<string>();


	public string MurderMO { get; set; } = "ExampleMO";


	public string ItemToSpawn { get; set; } = "Pencil";


	public SpawnLocationType SpawnLocation { get; set; } = SpawnLocationType.Mailbox;


	public BelongsTo BelongsTo { get; set; } = BelongsTo.Murderer;


	public Recipient Recipient { get; set; } = Recipient.Murderer;


	public int SpawnCount { get; set; } = 1;


	public float SpawnChance { get; set; } = 1f;


	public bool UnlockMailbox { get; set; } = true;


	public SubLocationTypeBuildingEntrances SubLocationTypeBuildingEntrances { get; set; } = SubLocationTypeBuildingEntrances.Inside;


	public List<string> RandomSpawnLocations { get; set; } = new List<string>();


	public List<string> HotelRooftopBarSubLocations { get; set; } = new List<string>();


	public string CustomBuildingPreset { get; set; } = "";


	public string CustomRoomName { get; set; } = "";


	public string CustomRoomPreset { get; set; } = "";


	public string CustomSubRoomName { get; set; } = "";


	public string CustomSubRoomPreset { get; set; } = "";


	public List<string> CustomRoomNames { get; set; } = new List<string>();


	public List<string> CustomRoomPresets { get; set; } = new List<string>();


	public List<string> CustomSubRoomNames { get; set; } = new List<string>();


	public List<string> CustomSubRoomPresets { get; set; } = new List<string>();


	public List<string> CustomFloorNames { get; set; } = new List<string>();


	public bool UseFurniture { get; set; } = false;


	public List<string> FurniturePresets { get; set; } = new List<string>();

}
[HarmonyPatch(typeof(MurderController), "OnVictimKilled")]
public class OnVictimKilledPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("OnVictimKilled", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in OnVictimKilledPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "PickNewVictim")]
public class PickNewVictimPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("PickNewVictim", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in PickNewVictimPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "OnVictimDiscovery")]
public class OnVictimDiscoveryPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("OnVictimDiscovery", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in OnVictimDiscoveryPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "TriggerCoverUpTelephoneCall")]
public class TriggerCoverUpTelephoneCallPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("TriggerCoverUpTelephoneCall", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in TriggerCoverUpTelephoneCallPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "OnCoverUpAccept")]
public class OnCoverUpAcceptPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("OnCoverUpAccept", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in OnCoverUpAcceptPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "OnCoverUpReject")]
public class OnCoverUpRejectPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("OnCoverUpReject", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in OnCoverUpRejectPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "TriggerKidnappingCase")]
public class TriggerKidnappingCasePatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("TriggerKidnappingCase", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in TriggerKidnappingCasePatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "TriggerRansomDelivery")]
public class TriggerRansomDeliveryPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("TriggerRansomDelivery", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in TriggerRansomDeliveryPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "KidnapperCollectsRansom")]
public class KidnapperCollectsRansomPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("KidnapperCollectsRansom", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in KidnapperCollectsRansomPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "KidnapperCollectedRansom")]
public class KidnapperCollectedRansomPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("KidnapperCollectedRansom", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in KidnapperCollectedRansomPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "TriggerRansomFail")]
public class TriggerRansomFailPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("TriggerRansomFail", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in TriggerRansomFailPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "VictimFreed")]
public class VictimFreedPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("VictimFreed", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in VictimFreedPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "OnCaseSolved")]
public class OnCaseSolvedPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("OnCaseSolved", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in OnCaseSolvedPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "CitizenHasSeenBody", new Type[]
{
	typeof(Human),
	typeof(Human)
})]
public class CitizenHasSeenBodyPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("CitizenHasSeenBody", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in CitizenHasSeenBodyPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "CoverUpFailCheck", new Type[] { typeof(Human) })]
public class CoverUpFailCheckPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("CoverUpFailCheck", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in CoverUpFailCheckPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(MurderController), "TriggerSuccessfulCoverUp", new Type[] { typeof(Evidence) })]
public class TriggerSuccessfulCoverUpPatch
{
	public static void Postfix()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		try
		{
			string murderType = "";
			if ((Object)(object)MurderController.Instance != (Object)null && (SoCustomComparison)(object)MurderController.Instance.chosenMO != (SoCustomComparison)null)
			{
				murderType = ((Object)MurderController.Instance.chosenMO).name;
			}
			ConfigManager.Instance.CheckRulesForEvent("TriggerSuccessfulCoverUp", murderType);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in TriggerSuccessfulCoverUpPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[BepInPlugin("ShaneeexD.MurderItemSpawner", "MurderItemSpawner", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : PluginController<Plugin>
{
	public const string PLUGIN_GUID = "ShaneeexD.MurderItemSpawner";

	public const string PLUGIN_NAME = "MurderItemSpawner";

	public const string PLUGIN_VERSION = "1.0.0";

	public static ConfigEntry<bool> showDebugLogs;

	public override void Load()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		((PluginController<Plugin, IEmptyBindings>)(object)this).Harmony.PatchAll(Assembly.GetExecutingAssembly());
		SaveGamerHandlers saveGamerHandlers = new SaveGamerHandlers();
		PluginController<Plugin, IEmptyBindings>.Log.LogInfo((object)"MurderItemSpawner plugin is patched.");
		showDebugLogs = base.Config.Bind<bool>("General", "ShowDebugLogs", false, new ConfigDescription("Show debug logs.", (AcceptableValueBase)null, Array.Empty<object>()));
	}

	public static void LogDebug(string message)
	{
		if (showDebugLogs != null && showDebugLogs.Value)
		{
			PluginController<Plugin, IEmptyBindings>.Log.LogInfo((object)message);
		}
	}
}
[HarmonyPatch(typeof(SessionData))]
[HarmonyPatch("PauseGame")]
public class PauseManager
{
	public static void Prefix(ref bool showPauseText, ref bool delayOverride, ref bool openDesktopMode)
	{
	}
}
[HarmonyPatch(typeof(SessionData))]
[HarmonyPatch("ResumeGame")]
public class ResumeGameManager
{
	public static void Prefix()
	{
	}
}
public class SaveGamerHandlers : MonoBehaviour
{
	public SaveGamerHandlers()
	{
		Lib.SaveGame.OnAfterLoad += HandleGameLoaded;
		Lib.SaveGame.OnAfterNewGame += HandleNewGameStarted;
		Lib.SaveGame.OnBeforeNewGame += HandleGameBeforeNewGame;
		Lib.SaveGame.OnBeforeLoad += HandleGameBeforeLoad;
		Lib.SaveGame.OnBeforeDelete += HandleGameBeforeDelete;
		Lib.SaveGame.OnAfterDelete += HandleGameAfterDelete;
	}

	private void HandleNewGameStarted(object sender, EventArgs e)
	{
		HandleConfig(sender, e);
	}

	private void HandleGameLoaded(object sender, EventArgs e)
	{
		HandleConfig(sender, e);
	}

	private void HandleGameBeforeNewGame(object sender, EventArgs e)
	{
	}

	private void HandleGameBeforeLoad(object sender, EventArgs e)
	{
	}

	private void HandleGameBeforeDelete(object sender, EventArgs e)
	{
	}

	private void HandleGameAfterDelete(object sender, EventArgs e)
	{
	}

	private void HandleConfig(object sender, EventArgs e)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		try
		{
			PluginController<Plugin, IEmptyBindings>.Log.LogInfo((object)"New game started, resetting configuration");
			ConfigManager.Instance.ResetTriggeredRules();
			ConfigManager.Instance.LoadConfig();
		}
		catch (Exception ex)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in GameStartPatch: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
public class SpawnItemBuildingEntranceHome : MonoBehaviour
{
	private static SpawnItemBuildingEntranceHome _instance;

	private static Vector3 spawnPosition;

	private static SpawnItemBuildingEntranceHome Instance
	{
		get
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("SpawnItemBuildingEntranceHome_Instance");
				Object.DontDestroyOnLoad((Object)(object)val);
				_instance = val.AddComponent<SpawnItemBuildingEntranceHome>();
			}
			return _instance;
		}
	}

	public static void SpawnItemAtLocation(Human owner, Human recipient, string presetName, float spawnChance, SubLocationTypeBuildingEntrances subLocationTypeBuildingEntrances)
	{
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Expected O, but got Unknown
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Expected O, but got Unknown
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Expected O, but got Unknown
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		try
		{
			float num = Random.Range(0f, 1f);
			if (num > spawnChance)
			{
				Plugin.LogDebug($"[SpawnItemBuildingEntrance] Skipping spawn of {presetName} due to chance (roll: {num}, needed: <= {spawnChance})");
				return;
			}
			InteractablePreset interactablePreset = Toolbox.Instance.GetInteractablePreset(presetName);
			BepInExErrorLogInterpolatedStringHandler val;
			if ((SoCustomComparison)(object)interactablePreset == (SoCustomComparison)null)
			{
				ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
				val = new BepInExErrorLogInterpolatedStringHandler(73, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Could not find interactable preset with name ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				}
				log.LogError(val);
				return;
			}
			if ((Object)(object)recipient == (Object)null || (Object)(object)recipient.home == (Object)null)
			{
				ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(73, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SpawnItemBuildingEntrance] Recipient has no valid address. Cannot spawn ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(presetName);
				}
				log2.LogWarning(val2);
				return;
			}
			NewAddress home = recipient.home;
			Plugin.LogDebug($"[SpawnItemBuildingEntrance] Owner: {((Object)owner).name}, Recipient: {((Object)recipient).name}, Address: {((Object)home).name}");
			Interactable val3 = SpawnItemAtBuildingEntrance(home, interactablePreset, owner, recipient, presetName, spawnChance, subLocationTypeBuildingEntrances);
			if (val3 != null)
			{
				val3.SetOwner(owner, true);
				Plugin.LogDebug("[SpawnItemBuildingEntrance] Successfully spawned '" + presetName + "' at building entrance. Item node: " + ((val3.node != null) ? ((Object)val3.node).ToString() : "null"));
				Plugin.LogDebug($"[SpawnItemBuildingEntrance] Item '{presetName}' final world position: {val3.wPos}");
				return;
			}
			ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
			val = new BepInExErrorLogInterpolatedStringHandler(74, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Failed to create item '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' at building entrance.");
			}
			log3.LogError(val);
		}
		catch (Exception ex)
		{
			ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(50, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Error spawning item ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log4.LogError(val);
			ManualLogSource log5 = PluginController<Plugin, IEmptyBindings>.Log;
			val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Stack trace: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.StackTrace);
			}
			log5.LogError(val);
		}
	}

	private static Interactable SpawnItemAtBuildingEntrance(NewAddress address, InteractablePreset itemPreset, Human owner, Human recipient, string itemNameForLog, float spawnChance, SubLocationTypeBuildingEntrances subLocationTypeBuildingEntrances)
	{
		//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a25: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0a5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a62: Expected O, but got Unknown
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0502: Expected O, but got Unknown
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Expected O, but got Unknown
		//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c1: Expected O, but got Unknown
		//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0703: Unknown result type (might be due to invalid IL or missing references)
		//IL_0708: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Unknown result type (might be due to invalid IL or missing references)
		//IL_0716: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0720: Unknown result type (might be due to invalid IL or missing references)
		//IL_0724: Unknown result type (might be due to invalid IL or missing references)
		//IL_0729: Unknown result type (might be due to invalid IL or missing references)
		//IL_072b: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: Unknown result type (might be due to invalid IL or missing references)
		//IL_067d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0684: Expected O, but got Unknown
		//IL_073e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0743: Unknown result type (might be due to invalid IL or missing references)
		//IL_0759: Unknown result type (might be due to invalid IL or missing references)
		//IL_075b: Unknown result type (might be due to invalid IL or missing references)
		//IL_075f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0764: Unknown result type (might be due to invalid IL or missing references)
		//IL_0769: Unknown result type (might be due to invalid IL or missing references)
		//IL_084d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0864: Unknown result type (might be due to invalid IL or missing references)
		//IL_0892: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cb: Expected O, but got Unknown
		//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_090a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0928: Unknown result type (might be due to invalid IL or missing references)
		//IL_092d: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ec: Expected O, but got Unknown
		//IL_095a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0986: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		if ((Object)(object)address == (Object)null)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(49, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Address is null for ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(itemNameForLog);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			log.LogWarning(val);
			return null;
		}
		NewBuilding building = ((NewGameLocation)address).building;
		if ((Object)(object)building != (Object)null)
		{
			Plugin.LogDebug("[SpawnItemBuildingEntrance] Found building directly from address: " + ((Object)building).name);
		}
		else
		{
			Plugin.LogDebug("[SpawnItemBuildingEntrance] No building found directly from address, trying floor");
			if (!((Object)(object)((NewGameLocation)address).floor != (Object)null))
			{
				ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Could not find floor for address ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
				}
				log2.LogWarning(val);
				return null;
			}
			Plugin.LogDebug("[SpawnItemBuildingEntrance] Found floor for address " + ((Object)address).name);
		}
		NewWall val2 = null;
		NewWall val3 = null;
		if ((Object)(object)building != (Object)null && building.mainEntrance != null)
		{
			val3 = building.mainEntrance;
			Plugin.LogDebug("[SpawnItemBuildingEntrance] Found main entrance directly from building");
		}
		else if ((Object)(object)building != (Object)null && building.additionalEntrances != null && building.additionalEntrances.Count > 0)
		{
			Plugin.LogDebug($"[SpawnItemBuildingEntrance] Checking {building.additionalEntrances.Count} additional entrances from building");
			Enumerator<NewWall> enumerator = building.additionalEntrances.GetEnumerator();
			while (enumerator.MoveNext())
			{
				NewWall current = enumerator.Current;
				if (current != null)
				{
					NewNode node = current.otherWall.node;
					if (node != null && (Object)(object)node.gameLocation != (Object)null && (Object)(object)node.gameLocation.thisAsStreet != (Object)null)
					{
						val3 = current;
						Plugin.LogDebug("[SpawnItemBuildingEntrance] Found street entrance in building's additional entrances");
						break;
					}
				}
			}
		}
		if (val3 == null && (Object)(object)((NewGameLocation)address).floor != (Object)null && ((NewGameLocation)address).floor.buildingEntrances != null && ((NewGameLocation)address).floor.buildingEntrances.Count > 0)
		{
			Plugin.LogDebug($"[SpawnItemBuildingEntrance] Checking {((NewGameLocation)address).floor.buildingEntrances.Count} entrances from floor");
			Enumerator<NewWall> enumerator2 = ((NewGameLocation)address).floor.buildingEntrances.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				NewWall current2 = enumerator2.Current;
				if (current2 != null)
				{
					NewNode node2 = current2.otherWall.node;
					if (node2 != null && (Object)(object)node2.gameLocation != (Object)null && (Object)(object)node2.gameLocation.thisAsStreet != (Object)null)
					{
						val3 = current2;
						Plugin.LogDebug("[SpawnItemBuildingEntrance] Found street entrance in building entrances");
						break;
					}
				}
			}
		}
		if (val3 == null)
		{
			List<NodeAccess> entrances = ((NewGameLocation)address).entrances;
			if (entrances == null || entrances.Count == 0)
			{
				ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] No entrances found for ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
				}
				log3.LogWarning(val);
				return null;
			}
			Enumerator<NodeAccess> enumerator3 = entrances.GetEnumerator();
			while (enumerator3.MoveNext())
			{
				NodeAccess current3 = enumerator3.Current;
				if (current3.wall != null)
				{
					NewNode node3 = current3.wall.otherWall.node;
					if (node3 != null && (Object)(object)node3.gameLocation != (Object)null && (Object)(object)node3.gameLocation.thisAsStreet != (Object)null)
					{
						val3 = current3.wall;
						Plugin.LogDebug("[SpawnItemBuildingEntrance] Found street entrance from address entrances for " + ((Object)address).name);
						break;
					}
				}
			}
		}
		if (val3 != null)
		{
			val2 = val3;
			Plugin.LogDebug("[SpawnItemBuildingEntrance] Using main entrance to street for building");
		}
		else
		{
			if (((NewGameLocation)address).entrances == null || ((NewGameLocation)address).entrances.Count <= 0)
			{
				ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(70, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] No entrances found for building or address");
				}
				log4.LogWarning(val);
				return null;
			}
			val2 = ((NewGameLocation)address).entrances[0].wall;
			Plugin.LogDebug("[SpawnItemBuildingEntrance] No street entrance found, using first address entrance for " + ((Object)address).name);
		}
		if (val2 == null)
		{
			ManualLogSource log5 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Entrance wall is null for ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
			}
			log5.LogWarning(val);
			return null;
		}
		Plugin.LogDebug("[SpawnItemBuildingEntrance] Using entrance for " + ((Object)address).name);
		NewNode node4 = val2.otherWall.node;
		bool flag2 = false;
		if (node4 != null && (Object)(object)node4.gameLocation != (Object)null)
		{
			if ((Object)(object)node4.gameLocation.thisAsStreet != (Object)null)
			{
				flag2 = true;
				Plugin.LogDebug("[SpawnItemBuildingEntrance] Found street node on otherWall side for " + ((Object)address).name);
			}
			else if ((Object)(object)node4.gameLocation != (Object)(object)address)
			{
				flag2 = true;
				Plugin.LogDebug("[SpawnItemBuildingEntrance] Found outside node on otherWall side for " + ((Object)address).name);
			}
		}
		if (!flag2)
		{
			node4 = val2.node;
			if (node4 != null && (Object)(object)node4.gameLocation != (Object)null)
			{
				if ((Object)(object)node4.gameLocation.thisAsStreet != (Object)null)
				{
					flag2 = true;
					Plugin.LogDebug("[SpawnItemBuildingEntrance] Found street node on wall side for " + ((Object)address).name);
				}
				else if ((Object)(object)node4.gameLocation != (Object)(object)address)
				{
					flag2 = true;
					Plugin.LogDebug("[SpawnItemBuildingEntrance] Found outside node on wall side for " + ((Object)address).name);
				}
			}
		}
		if (!flag2)
		{
			ManualLogSource log6 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(83, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntrance] Could not find a valid street node for the entrance of ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
			}
			log6.LogWarning(val);
			return null;
		}
		Plugin.LogDebug($"[SpawnItemBuildingEntrance] Found entrance node at {node4.nodeCoord} for {((Object)address).name}");
		Vector3 position = node4.position;
		Vector3 val4 = val2.otherWall.position - val2.position;
		Vector3 val5 = ((Vector3)(ref val4)).normalized;
		if (val5 == Vector3.zero)
		{
			val5 = Vector3.forward;
		}
		switch (subLocationTypeBuildingEntrances)
		{
		case SubLocationTypeBuildingEntrances.Inside:
		{
			float num2 = -2f;
			spawnPosition = position + val5 * num2;
			spawnPosition.y += 0f;
			spawnPosition.z += Random.Range(-0.5f, 0.5f);
			spawnPosition.x += Random.Range(-0.5f, 0.5f);
			break;
		}
		case SubLocationTypeBuildingEntrances.Outside:
		{
			float num = 1f;
			spawnPosition = position + val5 * num;
			spawnPosition.y += 0.05f;
			spawnPosition.z += Random.Range(-0.5f, 0.5f);
			spawnPosition.x += Random.Range(-0.5f, 0.3f);
			break;
		}
		}
		Plugin.LogDebug($"[SpawnItemBuildingEntrance] Entrance position: {position}, Wall direction: {val5}");
		Plugin.LogDebug($"[SpawnItemBuildingEntrance] Calculated spawn position: {spawnPosition}");
		List<Passed> val6 = new List<Passed>();
		val6.Add(new Passed((PassedVarType)3, (float)node4.room.roomID, (string)null));
		try
		{
			float num3 = Random.Range(0f, 360f);
			Vector3 val7 = default(Vector3);
			((Vector3)(ref val7))..ctor(0f, num3, 0f);
			Plugin.LogDebug($"[SpawnItemBuildingEntrance] Using random rotation: {val7}");
			Interactable val8 = InteractableCreator.Instance.CreateWorldInteractable(itemPreset, owner, owner, recipient, spawnPosition, val7, val6, (Object)null, "");
			if (val8 != null)
			{
				val8.node = node4;
				val8.UpdateWorldPositionAndNode(true, true);
				Plugin.LogDebug("[SpawnItemBuildingEntrance] Successfully created item at building entrance");
				Plugin.LogDebug($"[SpawnItemBuildingEntrance] Item position: {val8.wPos}, node: {((val8.node != null) ? ((Object)val8.node).ToString() : "null")}");
				return val8;
			}
			ManualLogSource log7 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val9 = new BepInExErrorLogInterpolatedStringHandler(70, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[SpawnItemBuildingEntrance] Failed to create item at building entrance");
			}
			log7.LogError(val9);
			return null;
		}
		catch (Exception ex)
		{
			ManualLogSource log8 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val9 = new BepInExErrorLogInterpolatedStringHandler(49, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[SpawnItemBuildingEntrance] Error creating item: ");
				((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(ex.Message);
			}
			log8.LogError(val9);
			ManualLogSource log9 = PluginController<Plugin, IEmptyBindings>.Log;
			val9 = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[SpawnItemBuildingEntrance] Stack trace: ");
				((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(ex.StackTrace);
			}
			log9.LogError(val9);
			return null;
		}
	}
}
public class SpawnItemBuildingEntranceWorkplace : MonoBehaviour
{
	private static SpawnItemBuildingEntranceWorkplace _instance;

	private static Vector3 spawnPosition;

	private static SpawnItemBuildingEntranceWorkplace Instance
	{
		get
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("SpawnItemBuildingEntranceWorkplace_Instance");
				Object.DontDestroyOnLoad((Object)(object)val);
				_instance = val.AddComponent<SpawnItemBuildingEntranceWorkplace>();
			}
			return _instance;
		}
	}

	public static void SpawnItemAtLocation(Human owner, Human recipient, string presetName, float spawnChance, SubLocationTypeBuildingEntrances subLocationTypeBuildingEntrances)
	{
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Expected O, but got Unknown
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Expected O, but got Unknown
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Expected O, but got Unknown
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		try
		{
			float num = Random.Range(0f, 1f);
			if (num > spawnChance)
			{
				Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Skipping spawn of {presetName} due to chance (roll: {num}, needed: <= {spawnChance})");
				return;
			}
			InteractablePreset interactablePreset = Toolbox.Instance.GetInteractablePreset(presetName);
			BepInExErrorLogInterpolatedStringHandler val;
			if ((SoCustomComparison)(object)interactablePreset == (SoCustomComparison)null)
			{
				ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
				val = new BepInExErrorLogInterpolatedStringHandler(82, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Could not find interactable preset with name ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				}
				log.LogError(val);
				return;
			}
			if ((Object)(object)recipient == (Object)null)
			{
				ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(69, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Recipient is null. Cannot spawn ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(presetName);
				}
				log2.LogWarning(val2);
				return;
			}
			if (recipient.job == null || recipient.job.employer == null || (Object)(object)recipient.job.employer.address == (Object)null)
			{
				Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Recipient " + ((Object)recipient).name + " has no valid workplace. Falling back to home building entrance.");
				SpawnItemBuildingEntranceHome.SpawnItemAtLocation(owner, recipient, presetName, spawnChance, subLocationTypeBuildingEntrances);
				return;
			}
			NewAddress address = recipient.job.employer.address;
			Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Owner: {((Object)owner).name}, Recipient: {((Object)recipient).name}, Workplace: {((Object)address).name}");
			Interactable val3 = SpawnItemAtBuildingEntrance(address, interactablePreset, owner, recipient, presetName, spawnChance, subLocationTypeBuildingEntrances);
			if (val3 != null)
			{
				val3.SetOwner(owner, true);
				Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Successfully spawned '" + presetName + "' at workplace building entrance. Item node: " + ((val3.node != null) ? ((Object)val3.node).ToString() : "null"));
				Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Item '{presetName}' final world position: {val3.wPos}");
				return;
			}
			ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
			val = new BepInExErrorLogInterpolatedStringHandler(93, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Failed to create item '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' at workplace building entrance.");
			}
			log3.LogError(val);
		}
		catch (Exception ex)
		{
			ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(59, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Error spawning item ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log4.LogError(val);
			ManualLogSource log5 = PluginController<Plugin, IEmptyBindings>.Log;
			val = new BepInExErrorLogInterpolatedStringHandler(50, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Stack trace: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.StackTrace);
			}
			log5.LogError(val);
		}
	}

	private static Interactable SpawnItemAtBuildingEntrance(NewAddress address, InteractablePreset itemPreset, Human owner, Human recipient, string itemNameForLog, float spawnChance, SubLocationTypeBuildingEntrances subLocationTypeBuildingEntrances)
	{
		//IL_0a02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a09: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a46: Expected O, but got Unknown
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Expected O, but got Unknown
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Expected O, but got Unknown
		//IL_049e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Expected O, but got Unknown
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0704: Unknown result type (might be due to invalid IL or missing references)
		//IL_0708: Unknown result type (might be due to invalid IL or missing references)
		//IL_070d: Unknown result type (might be due to invalid IL or missing references)
		//IL_070f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0711: Unknown result type (might be due to invalid IL or missing references)
		//IL_0661: Unknown result type (might be due to invalid IL or missing references)
		//IL_0668: Expected O, but got Unknown
		//IL_0722: Unknown result type (might be due to invalid IL or missing references)
		//IL_0727: Unknown result type (might be due to invalid IL or missing references)
		//IL_073d: Unknown result type (might be due to invalid IL or missing references)
		//IL_073f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0743: Unknown result type (might be due to invalid IL or missing references)
		//IL_0748: Unknown result type (might be due to invalid IL or missing references)
		//IL_074d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0831: Unknown result type (might be due to invalid IL or missing references)
		//IL_0848: Unknown result type (might be due to invalid IL or missing references)
		//IL_0876: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08af: Expected O, but got Unknown
		//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_090c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0911: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d0: Expected O, but got Unknown
		//IL_093e: Unknown result type (might be due to invalid IL or missing references)
		//IL_096a: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		if ((Object)(object)address == (Object)null)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Address is null for ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(itemNameForLog);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			log.LogWarning(val);
			return null;
		}
		NewBuilding building = ((NewGameLocation)address).building;
		if ((Object)(object)building != (Object)null)
		{
			Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found building directly from workplace address: " + ((Object)building).name);
		}
		else
		{
			Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] No building found directly from workplace address, trying floor");
			if (!((Object)(object)((NewGameLocation)address).floor != (Object)null))
			{
				ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(80, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Could not find floor for workplace address ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
				}
				log2.LogWarning(val);
				return null;
			}
			Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found floor for workplace address " + ((Object)address).name);
		}
		NewWall val2 = null;
		NewWall val3 = null;
		if ((Object)(object)building != (Object)null && building.mainEntrance != null)
		{
			val3 = building.mainEntrance;
			Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found main entrance directly from workplace building");
		}
		else if ((Object)(object)building != (Object)null && building.additionalEntrances != null && building.additionalEntrances.Count > 0)
		{
			Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Checking {building.additionalEntrances.Count} additional entrances from workplace building");
			Enumerator<NewWall> enumerator = building.additionalEntrances.GetEnumerator();
			while (enumerator.MoveNext())
			{
				NewWall current = enumerator.Current;
				if (current != null)
				{
					NewNode node = current.otherWall.node;
					if (node != null && (Object)(object)node.gameLocation != (Object)null && (Object)(object)node.gameLocation.thisAsStreet != (Object)null)
					{
						val3 = current;
						Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found street entrance in workplace building's additional entrances");
						break;
					}
				}
			}
		}
		if (val3 == null && (Object)(object)((NewGameLocation)address).floor != (Object)null && ((NewGameLocation)address).floor.buildingEntrances != null && ((NewGameLocation)address).floor.buildingEntrances.Count > 0)
		{
			Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Checking {((NewGameLocation)address).floor.buildingEntrances.Count} entrances from workplace floor");
			Enumerator<NewWall> enumerator2 = ((NewGameLocation)address).floor.buildingEntrances.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				NewWall current2 = enumerator2.Current;
				if (current2 != null)
				{
					NewNode node2 = current2.otherWall.node;
					if (node2 != null && (Object)(object)node2.gameLocation != (Object)null && (Object)(object)node2.gameLocation.thisAsStreet != (Object)null)
					{
						val3 = current2;
						Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found street entrance in workplace building entrances");
						break;
					}
				}
			}
		}
		if (val3 == null)
		{
			List<NodeAccess> entrances = ((NewGameLocation)address).entrances;
			if (entrances == null || entrances.Count == 0)
			{
				ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(70, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] No entrances found for workplace ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
				}
				log3.LogWarning(val);
				return null;
			}
			Enumerator<NodeAccess> enumerator3 = entrances.GetEnumerator();
			while (enumerator3.MoveNext())
			{
				NodeAccess current3 = enumerator3.Current;
				if (current3.wall != null)
				{
					NewNode node3 = current3.wall.otherWall.node;
					if (node3 != null && (Object)(object)node3.gameLocation != (Object)null && (Object)(object)node3.gameLocation.thisAsStreet != (Object)null)
					{
						val3 = current3.wall;
						Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found street entrance from workplace address entrances");
						break;
					}
				}
			}
		}
		if (val3 != null)
		{
			val2 = val3;
			Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Using main entrance to street for workplace building");
		}
		else
		{
			if (((NewGameLocation)address).entrances == null || ((NewGameLocation)address).entrances.Count <= 0)
			{
				ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(89, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] No entrances found for workplace building or address");
				}
				log4.LogWarning(val);
				return null;
			}
			val2 = ((NewGameLocation)address).entrances[0].wall;
			Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] No street entrance found, using first workplace address entrance");
		}
		if (val2 == null)
		{
			ManualLogSource log5 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Entrance wall is null for workplace ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
			}
			log5.LogWarning(val);
			return null;
		}
		Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Using entrance for workplace " + ((Object)address).name);
		NewNode node4 = val2.otherWall.node;
		bool flag2 = false;
		if (node4 != null && (Object)(object)node4.gameLocation != (Object)null)
		{
			if ((Object)(object)node4.gameLocation.thisAsStreet != (Object)null)
			{
				flag2 = true;
				Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found street node on otherWall side for workplace " + ((Object)address).name);
			}
			else if ((Object)(object)node4.gameLocation != (Object)(object)address)
			{
				flag2 = true;
				Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found outside node on otherWall side for workplace " + ((Object)address).name);
			}
		}
		if (!flag2)
		{
			node4 = val2.node;
			if (node4 != null && (Object)(object)node4.gameLocation != (Object)null)
			{
				if ((Object)(object)node4.gameLocation.thisAsStreet != (Object)null)
				{
					flag2 = true;
					Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found street node on wall side for workplace " + ((Object)address).name);
				}
				else if ((Object)(object)node4.gameLocation != (Object)(object)address)
				{
					flag2 = true;
					Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Found outside node on wall side for workplace " + ((Object)address).name);
				}
			}
		}
		if (!flag2)
		{
			ManualLogSource log6 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(102, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Could not find a valid street node for the entrance of workplace ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)address).name);
			}
			log6.LogWarning(val);
			return null;
		}
		Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Found entrance node at {node4.nodeCoord} for workplace {((Object)address).name}");
		Vector3 position = node4.position;
		Vector3 val4 = val2.otherWall.position - val2.position;
		Vector3 val5 = ((Vector3)(ref val4)).normalized;
		if (val5 == Vector3.zero)
		{
			val5 = Vector3.forward;
		}
		switch (subLocationTypeBuildingEntrances)
		{
		case SubLocationTypeBuildingEntrances.Inside:
		{
			float num2 = -3f;
			spawnPosition = position + val5 * num2;
			spawnPosition.y += 0f;
			spawnPosition.z += Random.Range(-0.5f, 0.5f);
			spawnPosition.x += Random.Range(-0.5f, 0.5f);
			break;
		}
		case SubLocationTypeBuildingEntrances.Outside:
		{
			float num = 1f;
			spawnPosition = position + val5 * num;
			spawnPosition.y += 0.05f;
			spawnPosition.z += Random.Range(-0.5f, 0.5f);
			spawnPosition.x += Random.Range(-0.5f, 0.3f);
			break;
		}
		}
		Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Entrance position: {position}, Wall direction: {val5}");
		Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Calculated spawn position: {spawnPosition}");
		List<Passed> val6 = new List<Passed>();
		val6.Add(new Passed((PassedVarType)3, (float)node4.room.roomID, (string)null));
		try
		{
			float num3 = Random.Range(0f, 360f);
			Vector3 val7 = default(Vector3);
			((Vector3)(ref val7))..ctor(0f, num3, 0f);
			Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Using random rotation: {val7}");
			Interactable val8 = InteractableCreator.Instance.CreateWorldInteractable(itemPreset, owner, owner, recipient, spawnPosition, val7, val6, (Object)null, "");
			if (val8 != null)
			{
				val8.node = node4;
				val8.UpdateWorldPositionAndNode(true, true);
				Plugin.LogDebug("[SpawnItemBuildingEntranceWorkplace] Successfully created item at workplace building entrance");
				Plugin.LogDebug($"[SpawnItemBuildingEntranceWorkplace] Item position: {val8.wPos}, node: {((val8.node != null) ? ((Object)val8.node).ToString() : "null")}");
				return val8;
			}
			ManualLogSource log7 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val9 = new BepInExErrorLogInterpolatedStringHandler(89, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Failed to create item at workplace building entrance");
			}
			log7.LogError(val9);
			return null;
		}
		catch (Exception ex)
		{
			ManualLogSource log8 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val9 = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Error creating item: ");
				((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(ex.Message);
			}
			log8.LogError(val9);
			ManualLogSource log9 = PluginController<Plugin, IEmptyBindings>.Log;
			val9 = new BepInExErrorLogInterpolatedStringHandler(50, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("[SpawnItemBuildingEntranceWorkplace] Stack trace: ");
				((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<string>(ex.StackTrace);
			}
			log9.LogError(val9);
			return null;
		}
	}
}
public class SpawnItemCityHallBathroom : MonoBehaviour
{
	private static SpawnItemCityHallBathroom _instance;

	private static SpawnItemCityHallBathroom Instance
	{
		get
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("SpawnItemCityHallBathroom_Instance");
				Object.DontDestroyOnLoad((Object)(object)val);
				_instance = val.AddComponent<SpawnItemCityHallBathroom>();
			}
			return _instance;
		}
	}

	public static void SpawnItemAtLocation(Human owner, Human recipient, string presetName, float SpawnChance)
	{
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Expected O, but got Unknown
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Expected O, but got Unknown
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		try
		{
			float num = Random.Range(0f, 1f);
			if (num > SpawnChance)
			{
				Plugin.LogDebug($"[SpawnItemCityHallBathroom] Skipping spawn of {presetName} due to chance (roll: {num}, needed: <= {SpawnChance})");
				return;
			}
			InteractablePreset interactablePreset = Toolbox.Instance.GetInteractablePreset(presetName);
			BepInExErrorLogInterpolatedStringHandler val;
			if ((SoCustomComparison)(object)interactablePreset == (SoCustomComparison)null)
			{
				ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
				val = new BepInExErrorLogInterpolatedStringHandler(73, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemCityHallBathroom] Could not find interactable preset with name ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				}
				log.LogError(val);
				return;
			}
			Plugin.LogDebug("[SpawnItemCityHallBathroom] Owner: " + ((Object)owner).name + ", Recipient: " + ((Object)recipient).name);
			Interactable val2 = SpawnItemInCityHallBathroom(interactablePreset, owner, recipient, presetName);
			if (val2 != null)
			{
				val2.SetOwner(owner, true);
				Plugin.LogDebug("[SpawnItemCityHallBathroom] Successfully spawned '" + presetName + "' in City Hall bathroom. Item node: " + ((val2.node != null) ? ((Object)val2.node).ToString() : "null"));
				Plugin.LogDebug($"[SpawnItemCityHallBathroom] Item '{presetName}' final world position: {val2.wPos}");
				return;
			}
			ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
			val = new BepInExErrorLogInterpolatedStringHandler(75, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemCityHallBathroom] Failed to create item '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' in City Hall bathroom.");
			}
			log2.LogError(val);
		}
		catch (Exception ex)
		{
			ManualLogSource log3 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(50, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemCityHallBathroom] Error spawning item ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(presetName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log3.LogError(val);
			ManualLogSource log4 = PluginController<Plugin, IEmptyBindings>.Log;
			val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SpawnItemCityHallBathroom] Stack trace: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.StackTrace);
			}
			log4.LogError(val);
		}
	}

	private static Interactable SpawnItemInCityHallBathroom(InteractablePreset itemPreset, Human owner, Human recipient, string itemNameForLog)
	{
		//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Expected O, but got Unknown
		//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ea: Expected O, but got Unknown
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Expected O, but got Unknown
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Expected O, but got Unknown
		//IL_0547: Unknown result type (might be due to invalid IL or missing references)
		//IL_054c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d9: Expected O, but got Unknown
		//IL_0655: Unknown result type (might be due to invalid IL or missing references)
		//IL_065c: Expected O, but got Unknown
		//IL_061b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0622: Expected O, but got Unknown
		//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05db: Unknown result type (might be due to invalid IL or missing references)
		//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_074b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0755: Expected O, but got Unknown
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Expected O, but got Unknown
		//IL_0794: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_086d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0874: Expected O, but got Unknown
		//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_080e: Unknown result type (might be due to invalid IL or missing references)
		List<NewRoom> list = new List<NewRoom>();
		CityData instance = CityData.Instance;
		Plugin.LogDebug("[SpawnItemCityHallBathroom] Searching for City Hall bathrooms");
		NewAddress val = null;
		Enumerator<NewGameLocation> enumerator = instance.gameLocationDirectory.GetEnumerator();
		while (enumerator.MoveNext())
		{
			NewGameLocation current = enumerator.Current;
			if ((Object)(object)current == (Object)null || (Object)(object)current.thisAsAddress == (Object)null || ((Object)current).name == null || !((Object)current).name.Contains("Public bathrooms"))
			{
				continue;
			}
			val = current.thisAsAddress;
			Plugin.LogDebug("[SpawnItemCityHallBathroom] Found Public bathrooms building: " + ((Object)val).name);
			break;
		}
		if ((Object)(object)val == (Object)null)
		{
			Plugin.LogDebug("[SpawnItemCityHallBathroom] Public bathrooms building not found, looking for City Hall");
			Enumerator<NewGameLocation> enumerator2 = instance.gameLocationDirectory.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				NewGameLocation current2 = enumerator2.Current;
				if ((Object)(object)current2 == (Object)null || (Object)(object)current2.thisAsAddress == (Object)null || ((Object)current2).name == null || (!((Object)current2).name.Contains("City Hall") && !((Object)current2).name.Contains("CityHall")))
				{
					continue;
				}
				val = current2.thisAsAddress;
				Plugin.LogDebug("[SpawnItemCityHallBathroom] Found City Hall: " + ((Object)val).name);
				break;
			}
		}
		bool flag = default(bool);
		if ((Object)(object)val == (Object)null)
		{
			ManualLogSource log = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(73, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SpawnItemCityHallBathroom] Could not find Public bathrooms or City Hall.");
			}
			log.LogError(val2);
			return null;
		}
		if (((NewGameLocation)val).rooms == null || ((NewGameLocation)val).rooms.Count == 0)
		{
			ManualLogSource log2 = PluginController<Plugin, IEmptyBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(51, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[SpawnItemCityHallBathroom] Building ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has no rooms.");
			}
			log2.LogError(val2);
			return null;
		}
		Plugin.LogDebug($"[SpawnItemCityHallBathroom] Checking {((NewGameLocation)val).rooms.Count} rooms in {((Object)val).name}");
		for (int i = 0; i < ((NewGameLocation)val).rooms.Count; i++)
		{
			NewRoom val3 = ((NewGameLocation)val).rooms[i];
			if ((Object)(object)val3 == (Object)null)
			{
				continue;
			}
			string text = ((val3.name != null) ? val3.name : "unnamed");
			string text2 = (((SoCustomComparison)(object)val3.preset != (SoCustomComparison)null) ? ((Object)val3.preset).name : "no preset");
			string text3 = (((Object)(object)val3.floor != (Object)null) ? ((Object)val3.floor).name : "unknown floor");
			bool flag2 = false;
			bool flag3 = false;
			if (text3.Contains("CityHall_GroundFloor"))
			{
				flag3 = true;
			}
			if (flag3)
			{
				if ((SoCustomComparison)(object)val3.preset != (SoCustomComparison)null && (text2.Contains("