Decompiled source of CommunityCaseLoader v0.2.5

CommunityCaseLoader.dll

Decompiled a month ago
using System;
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.Security;
using System.Security.Permissions;
using AssetBundleLoader;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
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("CommunityCaseLoader")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("An example mod that works on both IL2CPP and Mono game branches")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3352e9ad6f77987b094d1491340e593e9bf4ad6e")]
[assembly: AssemblyProduct("CommunityCaseLoader")]
[assembly: AssemblyTitle("CommunityCaseLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CommunityCaseLoader
{
	[BepInPlugin("CommunityCaseLoader", "CommunityCaseLoader", "1.0.0")]
	public class CommunityCaseLoaderPlugin : BasePlugin
	{
		public static ManualLogSource PluginLogger;

		public static ConfigEntry<bool> OverrideMurderDifficulty;

		public static ConfigEntry<bool> OverrideJobDifficulty;

		public static string DEBUG_LoadSpecificMurder;

		public static bool DEBUG_ShowMurderDebugMessages;

		public static bool DEBUG_EnableMODebugging;

		public static string DEBUG_LoadSpecificSideJob;

		public static bool DEBUG_ShowSideJobDebugMessages;

		public static bool DEBUG_ShowSideJobSpawnLocation;

		public static bool DEBUG_ListAllLoadedObjects;

		public static ConfigEntry<string> DEBUG_DebugSpecificInteractable;

		public override void Load()
		{
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			PluginLogger = ((BasePlugin)this).Log;
			OverrideMurderDifficulty = ((BasePlugin)this).Config.Bind<bool>("Case Generation", "Override max murder difficulty (Ensures all cases can spawn on a fresh game)", false, (ConfigDescription)null);
			OverrideJobDifficulty = ((BasePlugin)this).Config.Bind<bool>("Case Generation", "Override max job difficulty (Ensures all jobs can spawn on a fresh game)", false, (ConfigDescription)null);
			DEBUG_ListAllLoadedObjects = ((BasePlugin)this).Config.Bind<bool>("Debug", "List all loaded objects", false, (ConfigDescription)null).Value;
			DEBUG_LoadSpecificMurder = ((BasePlugin)this).Config.Bind<string>("Debug", "Force specific MurderMO", "", (ConfigDescription)null).Value;
			DEBUG_ShowMurderDebugMessages = ((BasePlugin)this).Config.Bind<bool>("Debug", "Show murder debug messages", false, (ConfigDescription)null).Value;
			DEBUG_EnableMODebugging = ((BasePlugin)this).Config.Bind<bool>("MurderMO Debugging", "List spawned murder objects and highlight them", false, (ConfigDescription)null).Value;
			DEBUG_LoadSpecificSideJob = ((BasePlugin)this).Config.Bind<string>("SideJob Debugging", "Force specific JobPreset", "", "Only one will spawn at a time in this mode for debugging purposes").Value;
			DEBUG_ShowSideJobDebugMessages = ((BasePlugin)this).Config.Bind<bool>("SideJob Debugging", "Show SideJob debug messages", false, (ConfigDescription)null).Value;
			DEBUG_ShowSideJobSpawnLocation = ((BasePlugin)this).Config.Bind<bool>("SideJob Debugging", "Log where the SideJob spawned", false, "Gives an easy way to find the forced SideJob without spoiling it").Value;
			DEBUG_DebugSpecificInteractable = ((BasePlugin)this).Config.Bind<string>("General Manifest Debugging", "Debug Specific Interactable", "", "Will print details of this interactable's spawns, and highlight it in the world");
			ManualLogSource pluginLogger = PluginLogger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CommunityCaseLoader");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			pluginLogger.LogInfo(val);
			Harmony val2 = new Harmony("CommunityCaseLoader");
			val2.PatchAll();
			ManualLogSource pluginLogger2 = PluginLogger;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CommunityCaseLoader");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
			}
			pluginLogger2.LogInfo(val);
			BundleLoader.loadObjectDelegates.Add(new LoadObjects(LoadObjectsCallback));
		}

		public List<ScriptableObject> LoadObjectsCallback(List<ScriptableObject> loadedScriptableObjects)
		{
			List<ScriptableObject> result = new List<ScriptableObject>();
			List<object> list = new List<object>();
			List<DirectoryInfo> list2 = (from dirPath in Directory.GetDirectories(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "*", SearchOption.AllDirectories)
				select new DirectoryInfo(dirPath) into dir
				where File.Exists(Path.Combine(dir.FullName, "murdermanifest.sodso.json"))
				select dir).ToList();
			foreach (DirectoryInfo item in list2)
			{
				dynamic val = NewtonsoftExtensions.NewtonsoftJson.JToken_Parse(File.ReadAllText(Path.Combine(item.FullName, "murdermanifest.sodso.json")));
				val["moName"] = item.Name;
				val["folderPath"] = item.FullName;
				dynamic loadBefore = val.Value<string>("loadBefore");
				if (loadBefore == null && loadBefore == "")
				{
					list.Add(val);
					continue;
				}
				dynamic val2 = list.Where((dynamic previousManifest) => previousManifest.Value<string>("moName") == loadBefore).FirstOrDefault();
				if (val2 != null)
				{
					list.Insert(list.IndexOf(val2), val);
				}
				else
				{
					list.Add(val);
				}
			}
			foreach (dynamic item2 in list)
			{
				LoadManifest(item2, ref result);
			}
			return result;
		}

		private static void LoadManifest(dynamic manifest, ref List<ScriptableObject> objectsToLoad)
		{
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_0954: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Expected O, but got Unknown
			//IL_0920: Unknown result type (might be due to invalid IL or missing references)
			//IL_0925: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Expected O, but got Unknown
			dynamic val = manifest.Value<string>("moName");
			dynamic val2 = manifest.Value<string>("folderPath");
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val3;
			if (manifest.Value<bool>("enabled"))
			{
				ManualLogSource pluginLogger = PluginLogger;
				val3 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Loading manifest: ");
					val3.AppendFormatted(val);
				}
				pluginLogger.LogInfo(val3);
				List<LoadedFileContent> list = new List<LoadedFileContent>();
				foreach (dynamic item in manifest["fileOrder"])
				{
					string text = Path.Combine(val2, item.ToString().Replace("REF:", "") + ".sodso.json");
					string text2 = Path.Combine(val2, item.ToString().Replace("REF:", "") + ".sodso_patch.json");
					if (File.Exists("\\\\?\\" + text))
					{
						string content = File.ReadAllText("\\\\?\\" + text);
						list.Add(new LoadedFileContent
						{
							Content = content,
							IsNewFile = true
						});
						continue;
					}
					if (File.Exists("\\\\?\\" + text2))
					{
						string content2 = File.ReadAllText("\\\\?\\" + text2);
						list.Add(new LoadedFileContent
						{
							Content = content2,
							IsNewFile = false
						});
						continue;
					}
					ManualLogSource pluginLogger2 = PluginLogger;
					BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Failed to load file: ");
						val4.AppendFormatted(item);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (File not found)");
					}
					pluginLogger2.LogError(val4);
				}
				{
					foreach (LoadedFileContent item2 in list)
					{
						ScriptableObject val5 = JsonLoader.LoadFileToGame(item2.Content, item2.IsNewFile);
						if (item2.IsNewFile)
						{
							objectsToLoad.Add(val5);
						}
						if (ReflectionExtensions.GetActualType((object)val5) == typeof(JobPreset))
						{
							JobPreset val6 = ReflectionExtensions.TryCast<JobPreset>((object)val5);
							Enumerator<StartingSpawnItem> enumerator3 = val6.spawnItems.GetEnumerator();
							while (enumerator3.MoveNext())
							{
								StartingSpawnItem current3 = enumerator3.Current;
								if (current3.vmailThread != "")
								{
									Toolbox_Start.vmailTreeMap[current3.vmailThread] = new JobPresetAndTag
									{
										JobPreset = val6,
										JobTag = current3.itemTag
									};
								}
							}
						}
						if (DEBUG_ListAllLoadedObjects)
						{
							ManualLogSource pluginLogger3 = PluginLogger;
							val3 = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Loading Object: ");
								((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val5).name);
							}
							pluginLogger3.LogInfo(val3);
						}
					}
					return;
				}
			}
			ManualLogSource pluginLogger4 = PluginLogger;
			val3 = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Not loading manifest: ");
				val3.AppendFormatted(val);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (Disabled)");
			}
			pluginLogger4.LogInfo(val3);
		}
	}
	[HarmonyPatch(typeof(Toolbox), "Start")]
	public class Toolbox_Start
	{
		public static Dictionary<string, JobPresetAndTag> vmailTreeMap = new Dictionary<string, JobPresetAndTag>();

		public static Dictionary<int, int> sideJobThreadIDMap = new Dictionary<int, int>();

		public static void Postfix()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			bool flag2 = default(bool);
			if (CommunityCaseLoaderPlugin.DEBUG_LoadSpecificMurder != "")
			{
				bool flag = false;
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(18, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Forcing MurderMO: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(CommunityCaseLoaderPlugin.DEBUG_LoadSpecificMurder);
				}
				pluginLogger.LogWarning(val);
				for (int num = Toolbox.Instance.allMurderMOs.Count - 1; num >= 0; num--)
				{
					if (((Object)Toolbox.Instance.allMurderMOs[num]).name != CommunityCaseLoaderPlugin.DEBUG_LoadSpecificMurder)
					{
						Toolbox.Instance.allMurderMOs[num].disabled = true;
					}
					else
					{
						flag = true;
						Toolbox.Instance.allMurderMOs[num].disabled = false;
					}
				}
				if (!flag)
				{
					ManualLogSource pluginLogger2 = CommunityCaseLoaderPlugin.PluginLogger;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("MurderMO not found: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(CommunityCaseLoaderPlugin.DEBUG_LoadSpecificMurder);
					}
					pluginLogger2.LogError(val2);
					ManualLogSource pluginLogger3 = CommunityCaseLoaderPlugin.PluginLogger;
					BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(17, 0, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Loaded MurderMOs:");
					}
					pluginLogger3.LogInfo(val3);
					for (int num2 = Toolbox.Instance.allMurderMOs.Count - 1; num2 >= 0; num2--)
					{
						ManualLogSource pluginLogger4 = CommunityCaseLoaderPlugin.PluginLogger;
						val3 = new BepInExInfoLogInterpolatedStringHandler(1, 1, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\t");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)Toolbox.Instance.allMurderMOs[num2]).name);
						}
						pluginLogger4.LogInfo(val3);
					}
				}
			}
			if (CommunityCaseLoaderPlugin.DEBUG_LoadSpecificSideJob != "")
			{
				ManualLogSource pluginLogger5 = CommunityCaseLoaderPlugin.PluginLogger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(17, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Forcing SideJob: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(CommunityCaseLoaderPlugin.DEBUG_LoadSpecificSideJob);
				}
				pluginLogger5.LogWarning(val);
				for (int num3 = SideJobController.Instance.jobTracking.Count - 1; num3 >= 0; num3--)
				{
					if (SideJobController.Instance.jobTracking[num3].name != CommunityCaseLoaderPlugin.DEBUG_LoadSpecificSideJob)
					{
						SideJobController.Instance.jobTracking.RemoveAt(num3);
					}
					else
					{
						SideJobController.Instance.jobTracking[num3].preset.disabled = false;
						SideJobController.Instance.jobTracking[num3].preset.maxJobs = 1;
						SideJobController.Instance.jobTracking[num3].preset.immediatePostCountThreshold = 100;
					}
				}
			}
			else
			{
				CommunityCaseLoaderPlugin.DEBUG_ShowSideJobDebugMessages = false;
				CommunityCaseLoaderPlugin.DEBUG_ShowSideJobSpawnLocation = false;
			}
		}
	}
	[HarmonyPatch]
	public class Toolbox_NewVmailThread
	{
		[HarmonyTargetMethod]
		internal static MethodBase CalculateMethod()
		{
			return (from mi in typeof(Toolbox).GetMethods()
				where mi.Name == "NewVmailThread" && mi.GetParameters().Length == 10
				select mi).First();
		}

		public static void Postfix(MessageThreadSave __result, Human from, ref Human to1, ref Human to2, ref Human to3, ref List<Human> cc, string treeID, float timeStamp, int progress = 999)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			if (!Toolbox_Start.vmailTreeMap.ContainsKey(treeID))
			{
				return;
			}
			Enumerator<int, SideJob> enumerator = SideJobController.Instance.allJobsDictionary.GetEnumerator();
			bool flag = default(bool);
			while (enumerator.MoveNext())
			{
				KeyValuePair<int, SideJob> current = enumerator.Current;
				if (current.Value.purpID != from.humanID || !(current.Value.presetStr == ((SoCustomComparison)Toolbox_Start.vmailTreeMap[treeID].JobPreset).presetName))
				{
					continue;
				}
				Toolbox_Start.sideJobThreadIDMap[current.value.jobID] = __result.threadID;
				if (CommunityCaseLoaderPlugin.DEBUG_ShowSideJobDebugMessages)
				{
					ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Mapped jobID ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current.value.jobID);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to threadID ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__result.threadID);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on creation");
					}
					pluginLogger.LogInfo(val);
				}
				break;
			}
		}
	}
	[HarmonyPatch(typeof(SaveStateController), "LoadSaveState")]
	public class SaveStateController_LoadSaveState
	{
		public static void Postfix(SaveStateController __instance)
		{
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			Enumerator<int, MessageThreadSave> enumerator = GameplayController.Instance.messageThreads.GetEnumerator();
			bool flag = default(bool);
			while (enumerator.MoveNext())
			{
				KeyValuePair<int, MessageThreadSave> current = enumerator.Current;
				if (!Toolbox_Start.vmailTreeMap.ContainsKey(current.Value.treeID))
				{
					continue;
				}
				int num = current.Value.senders[0];
				Enumerator<int, SideJob> enumerator2 = SideJobController.Instance.allJobsDictionary.Values.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					SideJob current2 = enumerator2.Current;
					if (!(((SoCustomComparison)Toolbox_Start.vmailTreeMap[current.Value.treeID].JobPreset).presetName == ((SoCustomComparison)current2.preset).presetName) || current2.purpID != num)
					{
						continue;
					}
					Toolbox_Start.sideJobThreadIDMap[current2.jobID] = current.Value.threadID;
					if (CommunityCaseLoaderPlugin.DEBUG_ShowSideJobDebugMessages)
					{
						ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Mapped jobID ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current2.jobID);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to threadID ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current.Value.threadID);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on load");
						}
						pluginLogger.LogInfo(val);
					}
				}
				break;
			}
		}
	}
	[HarmonyPatch(typeof(ResolveQuestion), "UpdateCorrect")]
	public class CaseResolveQuestion_UpdateCorrect
	{
		public static bool Prefix(ResolveQuestion __instance, Case forCase, ref bool __result)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (((forCase != null) ? forCase.job : null) != null && Toolbox_Start.sideJobThreadIDMap.ContainsKey(forCase.job.jobID))
			{
				string inputtedEvidence = __instance.inputtedEvidence;
				Enumerator<CaseElement> enumerator = forCase.caseElements.GetEnumerator();
				while (enumerator.MoveNext())
				{
					CaseElement current = enumerator.Current;
					if (current.id == inputtedEvidence)
					{
						EvidencePrintedVmail val = ((Il2CppObjectBase)current.pinnedController.evidence).TryCast<EvidencePrintedVmail>();
						if (val != null && Toolbox_Start.vmailTreeMap.ContainsKey(val.thread.treeID) && __instance.tag == Toolbox_Start.vmailTreeMap[val.thread.treeID].JobTag)
						{
							__instance.isCorrect = val.thread.threadID == Toolbox_Start.sideJobThreadIDMap[forCase.job.jobID];
							__result = __instance.isCorrect;
							return false;
						}
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CityConstructor), "StartGame")]
	public class CityConstructor_StartGame
	{
		public static void Prefix()
		{
			if (CommunityCaseLoaderPlugin.OverrideMurderDifficulty.Value)
			{
				MurderController.Instance.maxDifficultyLevel = 10;
			}
			if (CommunityCaseLoaderPlugin.OverrideJobDifficulty.Value)
			{
				GameplayController.Instance.SetJobDifficultyLevel(5);
			}
		}
	}
	public class JobPresetAndTag
	{
		public JobPreset JobPreset;

		public JobTag JobTag;
	}
	public class LoadedFileContent
	{
		public string Content;

		public bool IsNewFile;
	}
	internal class DebuggingHooks
	{
		[HarmonyPatch(typeof(MurderController), "PickNewVictim")]
		public class MurderController_PickNewVictim
		{
			public static void Postfix()
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Expected O, but got Unknown
				if (!CommunityCaseLoaderPlugin.DEBUG_ShowMurderDebugMessages)
				{
					return;
				}
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MurderMO: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((SoCustomComparison)MurderController.Instance.chosenMO).presetName);
				}
				pluginLogger.LogInfo(val);
				ManualLogSource pluginLogger2 = CommunityCaseLoaderPlugin.PluginLogger;
				val = new BepInExInfoLogInterpolatedStringHandler(29, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Murderer: ");
					BepInExInfoLogInterpolatedStringHandler obj = val;
					Human currentMurderer = MurderController.Instance.currentMurderer;
					((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>((currentMurderer != null) ? ((Object)currentMurderer).name : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Works: ");
					BepInExInfoLogInterpolatedStringHandler obj2 = val;
					Occupation job = MurderController.Instance.currentMurderer.job;
					object obj3;
					if (job == null)
					{
						obj3 = null;
					}
					else
					{
						Company employer = job.employer;
						obj3 = ((employer != null) ? employer.name : null);
					}
					((BepInExLogInterpolatedStringHandler)obj2).AppendFormatted<string>((string)obj3);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Lives: ");
					BepInExInfoLogInterpolatedStringHandler obj4 = val;
					Human currentMurderer2 = MurderController.Instance.currentMurderer;
					((BepInExLogInterpolatedStringHandler)obj4).AppendFormatted<string>((currentMurderer2 != null) ? ((Object)currentMurderer2.home).name : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				pluginLogger2.LogInfo(val);
				ManualLogSource pluginLogger3 = CommunityCaseLoaderPlugin.PluginLogger;
				val = new BepInExInfoLogInterpolatedStringHandler(28, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Victim: ");
					BepInExInfoLogInterpolatedStringHandler obj5 = val;
					Human currentVictim = MurderController.Instance.currentVictim;
					((BepInExLogInterpolatedStringHandler)obj5).AppendFormatted<string>((currentVictim != null) ? ((Object)currentVictim).name : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Works: ");
					BepInExInfoLogInterpolatedStringHandler obj6 = val;
					Human currentVictim2 = MurderController.Instance.currentVictim;
					object obj7;
					if (currentVictim2 == null)
					{
						obj7 = null;
					}
					else
					{
						Occupation job2 = currentVictim2.job;
						if (job2 == null)
						{
							obj7 = null;
						}
						else
						{
							Company employer2 = job2.employer;
							obj7 = ((employer2 != null) ? employer2.name : null);
						}
					}
					((BepInExLogInterpolatedStringHandler)obj6).AppendFormatted<string>((string)obj7);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Lives: ");
					BepInExInfoLogInterpolatedStringHandler obj8 = val;
					Human currentVictim3 = MurderController.Instance.currentVictim;
					((BepInExLogInterpolatedStringHandler)obj8).AppendFormatted<string>((currentVictim3 != null) ? ((Object)currentVictim3.home).name : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("))");
				}
				pluginLogger3.LogInfo(val);
			}
		}

		[HarmonyPatch(typeof(Interactable), "LoadInteractableToWorld")]
		public class Interactable_LoadInteractableToWorld
		{
			private const int HIGHLIGHTED_LAYER = 30;

			public static void Prefix(Interactable __instance, ref bool forceSpawnImmediate)
			{
				if (MurderController_SpawnItem.murderInteractables.Contains(__instance) || CommunityCaseLoaderPlugin.DEBUG_DebugSpecificInteractable.Value == ((Object)__instance.preset).name)
				{
					forceSpawnImmediate = true;
				}
			}

			public static void Postfix(Interactable __instance)
			{
				if (MurderController_SpawnItem.murderInteractables.Contains(__instance) || CommunityCaseLoaderPlugin.DEBUG_DebugSpecificInteractable.Value == ((Object)__instance.preset).name)
				{
					__instance.spawnedObject.layer = 30;
				}
			}
		}

		[HarmonyPatch(typeof(MurderController), "SpawnItem")]
		public class MurderController_SpawnItem
		{
			public static List<Interactable> murderInteractables = new List<Interactable>();

			public static void Postfix(MurderController __instance, Interactable __result)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				if (CommunityCaseLoaderPlugin.DEBUG_EnableMODebugging && (SoCustomComparison)(object)((__result != null) ? __result.preset : null) != (SoCustomComparison)null)
				{
					ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MurderMO (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)__instance.chosenMO).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") Spawning Item: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)__result.preset).name);
					}
					pluginLogger.LogInfo(val);
					murderInteractables.Add(__result);
				}
			}
		}

		[HarmonyPatch(typeof(Murder), "PlaceCallingCard")]
		public class MurderController_PlaceCallingCard
		{
			private const int HIGHLIGHTED_LAYER = 30;

			public static void Postfix(Murder __instance)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				if (CommunityCaseLoaderPlugin.DEBUG_EnableMODebugging && __instance.callingCard != null)
				{
					ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MurderMO (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)__instance.preset).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") Spawning Calling Card: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)__instance.callingCard.preset).name);
					}
					pluginLogger.LogInfo(val);
					MurderController_SpawnItem.murderInteractables.Add(__instance.callingCard);
					__instance.callingCard.spawnedObject.layer = 30;
				}
			}
		}

		[HarmonyPatch(typeof(MurderController), "SpawnItemsCheck")]
		public class MurderController_SpawnItemsCheck
		{
			internal static void Prefix(MurderController __instance)
			{
				Toolbox_NewVmailThread_Debug.LoggingEnabled = true;
				Toolbox_NewVmailThread_Debug.CurrentMurderMO = __instance.chosenMO;
			}

			internal static void Postfix()
			{
				Toolbox_NewVmailThread_Debug.LoggingEnabled = false;
				Toolbox_NewVmailThread_Debug.CurrentMurderMO = null;
			}
		}

		[HarmonyPatch]
		public class Toolbox_NewVmailThread_Debug
		{
			public static bool LoggingEnabled;

			public static MurderMO CurrentMurderMO;

			[HarmonyTargetMethod]
			internal static MethodBase CalculateMethod()
			{
				return (from mi in typeof(Toolbox).GetMethods()
					where mi.Name == "NewVmailThread" && mi.GetParameters().Length == 7
					select mi).First();
			}

			public static void Postfix(Human from, List<Human> otherParticipiants, string treeID, float timeStamp, int progress, CustomDataSource overrideDataSource, int newDataSourceID)
			{
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Expected O, but got Unknown
				if (!LoggingEnabled || !CommunityCaseLoaderPlugin.DEBUG_EnableMODebugging)
				{
					return;
				}
				string text = (((Object)(object)from != (Object)null) ? from.citizenName : "None");
				string text2 = "None";
				if (otherParticipiants != null && otherParticipiants.Count > 0)
				{
					text2 = "";
					Enumerator<Human> enumerator = otherParticipiants.GetEnumerator();
					while (enumerator.MoveNext())
					{
						Human current = enumerator.Current;
						text2 += (((Object)(object)current == (Object)null) ? "null," : (current.citizenName + ","));
					}
				}
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MurderMO (");
					MurderMO currentMurderMO = CurrentMurderMO;
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((currentMurderMO != null) ? ((SoCustomComparison)currentMurderMO).presetName : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") Sending VMail: '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(treeID);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', from ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Other participants: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
				}
				pluginLogger.LogInfo(val);
			}
		}

		[HarmonyPatch(typeof(SideJob), "PostJob")]
		public class SideJob_PostJob
		{
			public static void Postfix(SideJob __instance)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Expected O, but got Unknown
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Expected O, but got Unknown
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val;
				if (CommunityCaseLoaderPlugin.DEBUG_ShowSideJobDebugMessages || CommunityCaseLoaderPlugin.DEBUG_ShowSideJobSpawnLocation)
				{
					ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
					val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SideJob: Posted at ");
						BepInExInfoLogInterpolatedStringHandler obj = val;
						object obj2;
						if (__instance == null)
						{
							obj2 = null;
						}
						else
						{
							Interactable post = __instance.post;
							if (post == null)
							{
								obj2 = null;
							}
							else
							{
								NewNode node = post.node;
								if (node == null)
								{
									obj2 = null;
								}
								else
								{
									NewGameLocation gameLocation = node.gameLocation;
									obj2 = ((gameLocation != null) ? ((Object)gameLocation).name : null);
								}
							}
						}
						((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>((string)obj2);
					}
					pluginLogger.LogInfo(val);
				}
				if (!CommunityCaseLoaderPlugin.DEBUG_ShowSideJobDebugMessages)
				{
					return;
				}
				ManualLogSource pluginLogger2 = CommunityCaseLoaderPlugin.PluginLogger;
				val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SideJob: Posted about ");
					BepInExInfoLogInterpolatedStringHandler obj3 = val;
					object obj4;
					if (__instance == null)
					{
						obj4 = null;
					}
					else
					{
						Human purp = __instance.purp;
						obj4 = ((purp != null) ? ((Object)purp).name : null);
					}
					((BepInExLogInterpolatedStringHandler)obj3).AppendFormatted<string>((string)obj4);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Works at ");
					BepInExInfoLogInterpolatedStringHandler obj5 = val;
					object obj6;
					if (__instance == null)
					{
						obj6 = null;
					}
					else
					{
						Human purp2 = __instance.purp;
						if (purp2 == null)
						{
							obj6 = null;
						}
						else
						{
							Occupation job = purp2.job;
							if (job == null)
							{
								obj6 = null;
							}
							else
							{
								Company employer = job.employer;
								obj6 = ((employer != null) ? employer.name : null);
							}
						}
					}
					((BepInExLogInterpolatedStringHandler)obj5).AppendFormatted<string>((string)obj6);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				pluginLogger2.LogInfo(val);
			}
		}

		[HarmonyPatch(typeof(Interactable), "OnCreate")]
		public class Interactable_OnCreate
		{
			public static void Postfix(Interactable __instance)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Expected O, but got Unknown
				if (!(CommunityCaseLoaderPlugin.DEBUG_DebugSpecificInteractable.Value == ((Object)__instance.preset).name))
				{
					return;
				}
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Spawned ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)__instance.preset).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ");
					BepInExInfoLogInterpolatedStringHandler obj = val;
					object obj2;
					if (__instance == null)
					{
						obj2 = null;
					}
					else
					{
						NewNode node = __instance.node;
						if (node == null)
						{
							obj2 = null;
						}
						else
						{
							NewGameLocation gameLocation = node.gameLocation;
							if (gameLocation == null)
							{
								obj2 = null;
							}
							else
							{
								NewAddress thisAsAddress = gameLocation.thisAsAddress;
								obj2 = ((thisAsAddress != null) ? ((Object)thisAsAddress).name : null);
							}
						}
					}
					((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>((string)obj2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Belongs to ");
					BepInExInfoLogInterpolatedStringHandler obj3 = val;
					Human belongsTo = __instance.belongsTo;
					((BepInExLogInterpolatedStringHandler)obj3).AppendFormatted<string>(((belongsTo != null) ? belongsTo.citizenName : null) ?? "Nobody");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				pluginLogger.LogInfo(val);
				object obj4;
				if (__instance == null)
				{
					obj4 = null;
				}
				else
				{
					NewNode node2 = __instance.node;
					if (node2 == null)
					{
						obj4 = null;
					}
					else
					{
						NewGameLocation gameLocation2 = node2.gameLocation;
						obj4 = ((gameLocation2 != null) ? gameLocation2.thisAsAddress : null);
					}
				}
				if (Object.op_Implicit((Object)obj4))
				{
					return;
				}
				ManualLogSource pluginLogger2 = CommunityCaseLoaderPlugin.PluginLogger;
				val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unknown address, trying gameLocation: ");
					BepInExInfoLogInterpolatedStringHandler obj5 = val;
					object obj6;
					if (__instance == null)
					{
						obj6 = null;
					}
					else
					{
						NewNode node3 = __instance.node;
						if (node3 == null)
						{
							obj6 = null;
						}
						else
						{
							NewGameLocation gameLocation3 = node3.gameLocation;
							obj6 = ((gameLocation3 != null) ? ((Object)gameLocation3).name : null);
						}
					}
					((BepInExLogInterpolatedStringHandler)obj5).AppendFormatted<string>((string)obj6);
				}
				pluginLogger2.LogInfo(val);
			}
		}
	}
	internal class VanillaBugfixHooks
	{
		[HarmonyPatch]
		public class Toolbox_NewVmailThread
		{
			public static bool LoggingEnabled;

			public static MurderMO CurrentMurderMO;

			[HarmonyTargetMethod]
			internal static MethodBase CalculateMethod()
			{
				return (from mi in typeof(Toolbox).GetMethods()
					where mi.Name == "NewVmailThread" && mi.GetParameters().Length == 7
					select mi).First();
			}

			public static bool Prefix(Human from, List<Human> otherParticipiants, string treeID, float timeStamp, int progress, CustomDataSource overrideDataSource, int newDataSourceID)
			{
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				Human val = null;
				Human val2 = null;
				Human val3 = null;
				List<Human> val4 = new List<Human>();
				if (otherParticipiants.Count >= 1)
				{
					val = otherParticipiants[0];
				}
				if (otherParticipiants.Count >= 2)
				{
					val2 = otherParticipiants[1];
				}
				if (otherParticipiants.Count >= 3)
				{
					val3 = otherParticipiants[2];
				}
				if (otherParticipiants.Count >= 4)
				{
					for (int i = 4; i < otherParticipiants.Count; i++)
					{
						val4.Add(otherParticipiants[i]);
					}
				}
				Toolbox.Instance.NewVmailThread(from, val, val2, val3, val4, treeID, timeStamp, progress, overrideDataSource, newDataSourceID);
				return false;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CommunityCaseLoader";

		public const string PLUGIN_NAME = "CommunityCaseLoader";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CommunityCaseLoader.JobPresetExtensions
{
	internal class MotiveHooks
	{
		public static HashSet<string> PerpOnePerBusiness = new HashSet<string>();

		private static JobPickData currentJobUnderConstruction = null;
	}
}