Decompiled source of EvidenceLinkModifiers v2.3.0

EvidenceObfuscation.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using EvidenceObfuscation;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SOD.Common;
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("EvidenceObfuscation")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("A small mod to change the city directory to list phone numbers instead of addresses")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+1bf21606efa970fde7bdf2ef32096ce4302f1b9e")]
[assembly: AssemblyProduct("EvidenceObfuscation")]
[assembly: AssemblyTitle("EvidenceObfuscation")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EvidenceObfuscation
{
	internal class EmployeeRecords
	{
		[HarmonyPatch(typeof(Toolbox), "Start")]
		public class Toolbox_Start
		{
			public static void Postfix(ref Toolbox __instance)
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Expected O, but got Unknown
				bool flag = default(bool);
				if (EvidenceObfuscationPlugin.EmployeeRecord_Printed_FingerprintsRemoved.Value)
				{
					Toolbox.Instance.evidencePresetDictionary["printedemployeerecord"].keyMergeOnDiscovery[0].mergeKeys.Remove((DataKey)2);
					EvidenceObfuscationPlugin.RemoveMessageMatching(Toolbox.Instance.allDDSTrees["10084020-1a7d-4048-8885-28c8985199e1"], "FingerprintPhoto");
					ManualLogSource pluginLogger = EvidenceObfuscationPlugin.PluginLogger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Removed fingerprints from printed employee records");
					}
					pluginLogger.LogInfo(val);
				}
				if (EvidenceObfuscationPlugin.EmployeeRecord_Filling_FingerprintsRemoved.Value)
				{
					Toolbox.Instance.evidencePresetDictionary["employeerecord"].keyMergeOnDiscovery[0].mergeKeys.Remove((DataKey)2);
					EvidenceObfuscationPlugin.RemoveMessageMatching(Toolbox.Instance.allDDSTrees["674940fb-2f4a-4f15-8675-5864a5296c8b"], "FingerprintPhoto");
					ManualLogSource pluginLogger2 = EvidenceObfuscationPlugin.PluginLogger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(62, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Removed fingerprints from employee records in filling cabinets");
					}
					pluginLogger2.LogInfo(val);
				}
				__instance.evidencePresetDictionary["employeephoto"].itemOwner = (BelongsToSetting)3;
				__instance.objectPresetDictionary["EmployeePhoto"].printsSource = (PrintsSource)0;
			}
		}
	}
	[BepInPlugin("EvidenceObfuscation", "EvidenceObfuscation", "1.0.5")]
	public class EvidenceObfuscationPlugin : BasePlugin
	{
		public static ManualLogSource PluginLogger;

		public static ConfigEntry<bool> ModifyCityDirectory;

		public static ConfigEntry<bool> ShowAddressInCitizenCard;

		public static ConfigEntry<bool> EmployeeRecord_Printed_FingerprintsRemoved;

		public static ConfigEntry<bool> EmployeeRecord_Filling_FingerprintsRemoved;

		public static ConfigEntry<bool> GovDatabase_FingerprintsRemoved;

		public static ConfigEntry<bool> MurderWeapon_EntryWoundRemoval;

		public static ConfigEntry<bool> MurderWeapon_GunTypeRemoved;

		public static ConfigEntry<bool> MurderWeapon_MeleeTypeRemoved;

		public override void Load()
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			PluginLogger = ((BasePlugin)this).Log;
			ModifyCityDirectory = ((BasePlugin)this).Config.Bind<bool>("City Directory", "Should the directory be modified to be phone numbers instead of addresses?", true, (ConfigDescription)null);
			ShowAddressInCitizenCard = ((BasePlugin)this).Config.Bind<bool>("City Directory", "Should the directory entry for citizens also include their address?", false, (ConfigDescription)null);
			EmployeeRecord_Printed_FingerprintsRemoved = ((BasePlugin)this).Config.Bind<bool>("Employee Record", "Should fingerprints be removed from employee records printed from a cruncher?", false, (ConfigDescription)null);
			EmployeeRecord_Filling_FingerprintsRemoved = ((BasePlugin)this).Config.Bind<bool>("Employee Record", "Should fingerprints be removed from employee records found in a filling cabinet?", false, (ConfigDescription)null);
			GovDatabase_FingerprintsRemoved = ((BasePlugin)this).Config.Bind<bool>("Government Database", "Should fingerprints be removed from the government database?", false, (ConfigDescription)null);
			MurderWeapon_EntryWoundRemoval = ((BasePlugin)this).Config.Bind<bool>("Murder Weapon", "Should entry wound evidence be removed?", false, "Recommended true, as these pieces of evidence are kind of broken anyway");
			MurderWeapon_GunTypeRemoved = ((BasePlugin)this).Config.Bind<bool>("Murder Weapon", "Should the gun type be removed from the inspection of the body?", false, (ConfigDescription)null);
			MurderWeapon_MeleeTypeRemoved = ((BasePlugin)this).Config.Bind<bool>("Murder Weapon", "Should the melee weapon type be removed from the inspection of the body?", false, (ConfigDescription)null);
			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>("EvidenceObfuscation");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			pluginLogger.LogInfo(val);
			Harmony val2 = new Harmony("EvidenceObfuscation");
			val2.PatchAll();
			ManualLogSource pluginLogger2 = PluginLogger;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("EvidenceObfuscation");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
			}
			pluginLogger2.LogInfo(val);
		}

		public static void RemoveMessageMatching(DDSTreeSave tree, string name)
		{
			for (int num = tree.messages.Count - 1; num >= 0; num--)
			{
				if (tree.messages[num].elementName == name)
				{
					tree.messages.RemoveAt(num);
				}
			}
		}
	}
	internal class GovDatabase
	{
		[HarmonyPatch(typeof(Toolbox), "Start")]
		public class Toolbox_Start
		{
			public static void Postfix(ref Toolbox __instance)
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Expected O, but got Unknown
				if (EvidenceObfuscationPlugin.GovDatabase_FingerprintsRemoved.Value)
				{
					Toolbox.Instance.evidencePresetDictionary["printedcitizenfile"].keyMergeOnDiscovery[0].mergeKeys.Remove((DataKey)2);
					EvidenceObfuscationPlugin.RemoveMessageMatching(Toolbox.Instance.allDDSTrees["bb788164-3ced-4f72-88b4-998ba1dc822d"], "FingerprintPhoto");
					ManualLogSource pluginLogger = EvidenceObfuscationPlugin.PluginLogger;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Removed fingerprints from government database records");
					}
					pluginLogger.LogInfo(val);
				}
				__instance.evidencePresetDictionary["employeephoto"].itemOwner = (BelongsToSetting)3;
				__instance.objectPresetDictionary["EmployeePhoto"].printsSource = (PrintsSource)0;
			}
		}
	}
	internal class MurderWeaponObfuscation
	{
		[HarmonyPatch(typeof(Toolbox), "Start")]
		public class Toolbox_Start
		{
			public static void Postfix(ref Toolbox __instance)
			{
				if (EvidenceObfuscationPlugin.MurderWeapon_GunTypeRemoved.Value)
				{
					Lib.DdsStrings.AddOrUpdateEntries("dds.blocks", new(string, string)[3]
					{
						("0917036a-5eca-4a45-84c9-bb65133678fb", "violently shot to death."),
						("1270e698-7641-4fd4-95f8-d8fc7fbe7ea9", "violently shot to death."),
						("4f651c7a-82a3-401b-8faa-7cb51ecc68f6", "violently shot to death.")
					});
				}
				if (EvidenceObfuscationPlugin.MurderWeapon_MeleeTypeRemoved.Value)
				{
					Lib.DdsStrings.AddOrUpdateEntries("dds.blocks", new(string, string)[2]
					{
						("9e504f7a-50f8-4f80-ba2c-08aa8b9d78d0", "violently killed."),
						("fc9c3aa9-2b34-4344-a712-c2fab79a4f32", "violently killed.")
					});
				}
			}
		}

		[HarmonyPatch(typeof(ActionController), "Inspect")]
		public class ActionController_Inspect
		{
			public static bool Prefix(Interactable what)
			{
				object obj;
				if (what == null)
				{
					obj = null;
				}
				else
				{
					InteractablePreset preset = what.preset;
					if (preset == null)
					{
						obj = null;
					}
					else
					{
						EvidencePreset spawnEvidence = preset.spawnEvidence;
						obj = ((spawnEvidence != null) ? spawnEvidence.subClass : null);
					}
				}
				if ((string?)obj == "Wound")
				{
					what.MarkInspected();
					return false;
				}
				return true;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EvidenceObfuscation";

		public const string PLUGIN_NAME = "EvidenceObfuscation";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace EvidenceLinkModifiers
{
	[HarmonyPatch(typeof(CityData), "CreateCityDirectory")]
	public class CityData_CreateCityDirectory
	{
		public static void Postfix(CityData __instance)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Expected O, but got Unknown
			if (!EvidenceObfuscationPlugin.ModifyCityDirectory.Value)
			{
				return;
			}
			ManualLogSource pluginLogger = EvidenceObfuscationPlugin.PluginLogger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Started updating city directory");
			}
			pluginLogger.LogInfo(val);
			Dictionary<string, int> currentLinkToPhoneNumber = new Dictionary<string, int>();
			Enumerator<Company> enumerator = CityData.Instance.companyDirectory.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Company current = enumerator.Current;
				if (GetPhoneEntry((current != null) ? current.address : null, out var evidenceLink) && ((current != null) ? current.name : null) != null)
				{
					currentLinkToPhoneNumber[current.name] = evidenceLink;
				}
			}
			Enumerator<NewAddress> enumerator2 = CityData.Instance.addressDirectory.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				NewAddress current2 = enumerator2.Current;
				if (GetPhoneEntry(current2, out var evidenceLink2))
				{
					currentLinkToPhoneNumber[((Object)current2).name] = evidenceLink2;
				}
			}
			Enumerator<Citizen> enumerator3 = CityData.Instance.citizenDirectory.GetEnumerator();
			Chapter val3 = default(Chapter);
			int num = default(int);
			while (enumerator3.MoveNext())
			{
				Citizen current3 = enumerator3.Current;
				if (Object.op_Implicit((Object)(object)ChapterController.Instance.chapterScript))
				{
					ChapterIntro val2 = (ChapterIntro)((dynamic)ChapterController.Instance.chapterScript).Cast<ChapterIntro>();
					if (Toolbox.Instance.IsStoryMissionActive(ref val3, ref num))
					{
						int? obj;
						if (val2 == null)
						{
							obj = null;
						}
						else
						{
							Human kidnapper = val2.kidnapper;
							obj = ((kidnapper != null) ? new int?(kidnapper.humanID) : null);
						}
						if (obj == ((current3 != null) ? new int?(((Human)current3).humanID) : null))
						{
							continue;
						}
					}
				}
				if (GetPhoneEntry((current3 != null) ? ((Human)current3).home : null, out var _))
				{
					List<DataKey> val4 = new List<DataKey>();
					val4.Add((DataKey)40);
					val4.Add((DataKey)33);
					if (EvidenceObfuscationPlugin.ShowAddressInCitizenCard.Value)
					{
						val4.Add((DataKey)14);
					}
					LinkData val5 = Strings.AddOrGetLink((Evidence)(object)((Actor)current3).evidenceEntry, val4);
					currentLinkToPhoneNumber[((Evidence)((NewGameLocation)((Human)current3).home).evidenceEntry).evID + "_" + ((Human)current3).GetInitialledName()] = val5.id;
				}
			}
			List<int> list = new List<int>();
			Enumerator<int, string> enumerator4 = __instance.cityDirText.GetEnumerator();
			while (enumerator4.MoveNext())
			{
				KeyValuePair<int, string> current4 = enumerator4.Current;
				list.Add(current4.Key);
			}
			Dictionary<int, Evidence> linkEvidenceMap = new Dictionary<int, Evidence>();
			Enumerator<Evidence, List<LinkData>> enumerator5 = Strings.Instance.evidenceLinkDictionary.GetEnumerator();
			while (enumerator5.MoveNext())
			{
				KeyValuePair<Evidence, List<LinkData>> current5 = enumerator5.Current;
				Enumerator<LinkData> enumerator6 = current5.Value.GetEnumerator();
				while (enumerator6.MoveNext())
				{
					LinkData current6 = enumerator6.Current;
					linkEvidenceMap[current6.id] = current5.Key;
				}
			}
			for (int i = 0; i < list.Count; i++)
			{
				int num2 = list[i];
				__instance.cityDirText[num2] = Regex.Replace(__instance.cityDirText[num2], "<link=(\\d+)>(.*)</link>", delegate(Match match)
				{
					string text = match.Groups[1].Value;
					int key = int.Parse(text);
					if (linkEvidenceMap.ContainsKey(key))
					{
						text = linkEvidenceMap[key].evID + "_" + match.Groups[2].Value;
					}
					return currentLinkToPhoneNumber.ContainsKey(text) ? $"<link={currentLinkToPhoneNumber[text]}>{match.Groups[2].Value}</link>" : match.Groups[0].Value;
				});
			}
			ManualLogSource pluginLogger2 = EvidenceObfuscationPlugin.PluginLogger;
			val = new BepInExInfoLogInterpolatedStringHandler(22, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Updated city directory");
			}
			pluginLogger2.LogInfo(val);
		}

		private static bool GetPhoneEntry(NewAddress phoneAddress, out int evidenceLink)
		{
			LinkData val = null;
			evidenceLink = -1;
			if (phoneAddress != null && ((NewGameLocation)phoneAddress).telephones?.Count > 0)
			{
				val = Strings.AddOrGetLink((Evidence)(object)((NewGameLocation)phoneAddress).telephones[0].telephoneEntry, (List<DataKey>)null);
				if (val != null)
				{
					evidenceLink = val.id;
				}
			}
			return val != null && evidenceLink != -1;
		}
	}
	[HarmonyPatch(typeof(ChapterController), "LoadPart", new Type[]
	{
		typeof(int),
		typeof(bool),
		typeof(bool)
	})]
	public class ChapterController_LoadPart
	{
		public static void Postfix()
		{
			Chapter val = default(Chapter);
			int num = default(int);
			if (Toolbox.Instance.IsStoryMissionActive(ref val, ref num))
			{
				CityData.Instance.CreateCityDirectory();
			}
		}
	}
}