Decompiled source of EvidenceLinkModifiers v2.1.2

EvidenceObfuscation.dll

Decompiled 2 months 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 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+1c387449124796b6a34dac849f84292b2c56225c")]
[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 Prefix()
			{
			}

			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);
					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);
					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;
			}

			private 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);
					}
				}
			}
		}
	}
	[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 override void Load()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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);
			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 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();
			}
		}
	}
}