Decompiled source of EvidenceLinkModifiers v2.0.3

EvidenceObfuscation.dll

Decompiled 3 weeks 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+4972100ffad60d48e06f371d93aac0f7efb18621")]
[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
{
	[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 override void Load()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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);
			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_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Expected O, but got Unknown
			if (!EvidenceObfuscationPlugin.ModifyCityDirectory.Value)
			{
				return;
			}
			ManualLogSource pluginLogger = EvidenceObfuscationPlugin.PluginLogger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EvidenceObfuscationPlugin: 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[((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);
			}
			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 value = match.Groups[2].Value;
					return currentLinkToPhoneNumber.ContainsKey(value) ? $"<link={currentLinkToPhoneNumber[value]}>{match.Groups[2].Value}</link>" : match.Groups[0].Value;
				});
			}
			ManualLogSource pluginLogger2 = EvidenceObfuscationPlugin.PluginLogger;
			val = new BepInExInfoLogInterpolatedStringHandler(49, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EvidenceObfuscationPlugin: 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();
			}
		}
	}
}