Decompiled source of CommunityCaseLoader v0.1.2

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 Microsoft.CodeAnalysis;
using UnityEngine;

[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+fc3c57db40ee841cc62346a95df2c60fd3db385f")]
[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 string DEBUG_LoadSpecificMurder;

		public static bool DEBUG_ShowDebugMessages;

		public static bool CreateMapping;

		public static CharacterTrait homelessTrait;

		public override void Load()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			PluginLogger = ((BasePlugin)this).Log;
			DEBUG_LoadSpecificMurder = ((BasePlugin)this).Config.Bind<string>("Debug", "Force specific MurderMO", "", (ConfigDescription)null).Value;
			DEBUG_ShowDebugMessages = ((BasePlugin)this).Config.Bind<bool>("Debug", "Show murder debug messages", false, (ConfigDescription)null).Value;
			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);
		}
	}
	[HarmonyPatch(typeof(Toolbox), "Start")]
	public class Toolbox_Start
	{
		private static bool hasToolboxInit;

		public static void Postfix()
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			if (hasToolboxInit)
			{
				return;
			}
			List<DirectoryInfo> list = (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 list)
			{
				LoadManifest(item.Name, item.FullName);
			}
			if (CommunityCaseLoaderPlugin.DEBUG_LoadSpecificMurder != "")
			{
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Forcing MurderMO: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(CommunityCaseLoaderPlugin.DEBUG_LoadSpecificMurder);
				}
				pluginLogger.LogInfo(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;
					}
				}
			}
			CommunityCaseLoaderPlugin.homelessTrait = ScriptableObject.CreateInstance<CharacterTrait>();
			((Object)CommunityCaseLoaderPlugin.homelessTrait).name = "Quirk-Homeless";
			CommunityCaseLoaderPlugin.homelessTrait.isTrait = true;
			Toolbox.Instance.allCharacterTraits.Add(CommunityCaseLoaderPlugin.homelessTrait);
			hasToolboxInit = true;
		}

		private static void LoadManifest(string moName, string folderPath)
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Expected O, but got Unknown
			dynamic val = NewtonsoftExtensions.NewtonsoftJson.JToken_Parse(File.ReadAllText(Path.Combine(folderPath, "murdermanifest.sodso.json")));
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2;
			if (val.Value<bool>("enabled"))
			{
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				val2 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading MurderMO: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(moName);
				}
				pluginLogger.LogInfo(val2);
				{
					foreach (dynamic item in val["fileOrder"])
					{
						dynamic val3 = Path.Combine(folderPath, item.ToString().Replace("REF:", "") + ".sodso.json");
						if (File.Exists(val3))
						{
							JsonLoader.LoadFileToGame(File.ReadAllText(val3));
							continue;
						}
						ManualLogSource pluginLogger2 = CommunityCaseLoaderPlugin.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);
					}
					return;
				}
			}
			ManualLogSource pluginLogger3 = CommunityCaseLoaderPlugin.PluginLogger;
			val2 = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Not Loading MurderMO: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(moName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (Disabled)");
			}
			pluginLogger3.LogInfo(val2);
		}
	}
	[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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			if (CommunityCaseLoaderPlugin.DEBUG_ShowDebugMessages)
			{
				ManualLogSource pluginLogger = CommunityCaseLoaderPlugin.PluginLogger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Murderer: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)MurderController.Instance.currentMurderer).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Works: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MurderController.Instance.currentMurderer.job.employer.name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				pluginLogger.LogInfo(val);
				ManualLogSource pluginLogger2 = CommunityCaseLoaderPlugin.PluginLogger;
				val = new BepInExInfoLogInterpolatedStringHandler(18, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Victim: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)MurderController.Instance.currentVictim).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Works: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MurderController.Instance.currentVictim.job.employer.name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				pluginLogger2.LogInfo(val);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CommunityCaseLoader";

		public const string PLUGIN_NAME = "CommunityCaseLoader";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}