Decompiled source of PlayerDialogAdditions v0.13.0

DialogAdditions.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 DialogAdditions.NewDialogOptions;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using SOD.Common.Extensions;
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("DialogAdditions")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Adds extra dialog to Shadows of Doubt")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ed4ce69a58d430953604554204c40d6463720ce1")]
[assembly: AssemblyProduct("DialogAdditions")]
[assembly: AssemblyTitle("DialogAdditions")]
[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 DialogAdditions
{
	[BepInPlugin("DialogAdditions", "DialogAdditions", "1.0.0")]
	public class DialogAdditionPlugin : BasePlugin
	{
		public static Dictionary<string, DialogPreset> dialogPresetRefs = new Dictionary<string, DialogPreset>();

		public static Dictionary<string, CustomDialogPreset> customDialogInterceptors = new Dictionary<string, CustomDialogPreset>();

		public static ManualLogSource PluginLogger;

		public static ConfigEntry<bool> TalkToPartnerCanFail;

		public static ConfigEntry<float> TalkToPartnerBaseSuccess;

		public static ConfigEntry<float> SeenUnusualLikeBlock;

		public static ConfigEntry<bool> ConfirmSuspiciousPhotos;

		public static ConfigEntry<bool> AddAskForPasscode;

		private static DialogAdditionPlugin instance;

		public override void Load()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			PluginLogger = ((BasePlugin)this).Log;
			instance = this;
			TalkToPartnerCanFail = ((BasePlugin)this).Config.Bind<bool>("Talk to Partner", "Can asking for the partner fail?", false, (ConfigDescription)null);
			TalkToPartnerBaseSuccess = ((BasePlugin)this).Config.Bind<float>("Talk to Partner", "Base chance of success (before trait modifications, in the range 0 to 1)?", 0.25f, (ConfigDescription)null);
			SeenUnusualLikeBlock = ((BasePlugin)this).Config.Bind<float>("Have you seen anything?", "How well liked does the perp have to be before acquaintances protect them? (in the range 0 to 1)?", 0.45f, (ConfigDescription)null);
			ConfirmSuspiciousPhotos = ((BasePlugin)this).Config.Bind<bool>("Do you know this person?", "If the NPC has seen something someone suspicous, and you present a photo, will they confirm it?", true, (ConfigDescription)null);
			AddAskForPasscode = ((BasePlugin)this).Config.Bind<bool>("What is your passcode?", "Should asking for passcodes be enabled?", true, new ConfigDescription("Restart Required", (AcceptableValueBase)null, Array.Empty<object>()));
			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>("DialogAdditions");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			pluginLogger.LogInfo(val);
			Harmony val2 = new Harmony("DialogAdditions");
			val2.PatchAll();
			ManualLogSource pluginLogger2 = PluginLogger;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("DialogAdditions");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
			}
			pluginLogger2.LogInfo(val);
			BundleLoader.loadObjectDelegates.Add(new LoadObjects(LoadObjectsCallback));
		}

		public List<ScriptableObject> LoadObjectsCallback(List<ScriptableObject> loadedScriptableObjects)
		{
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			List<ScriptableObject> list = new List<ScriptableObject>();
			Enumerator<ScriptableObject> enumerator = loadedScriptableObjects.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ScriptableObject current = enumerator.Current;
				if (ReflectionExtensions.GetActualType((object)current) == typeof(DialogPreset))
				{
					DialogPreset val = ReflectionExtensions.TryCast<DialogPreset>((object)current);
					dialogPresetRefs[((Object)val).name] = val;
				}
			}
			CustomDialogPreset[] array = new CustomDialogPreset[2]
			{
				new TalkToPartner(TalkToPartnerCanFail.Value, TalkToPartnerBaseSuccess.Value),
				new SeenThisPersonWithOthers()
			};
			foreach (CustomDialogPreset customDialogPreset in array)
			{
				list.Add((ScriptableObject)(object)customDialogPreset.Preset);
				customDialogInterceptors[customDialogPreset.Name] = customDialogPreset;
			}
			string path = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
			if (Directory.Exists(Path.Combine(path, "plugins")))
			{
				path = Path.Combine(path, "plugins");
			}
			List<string> list2 = new List<string>();
			if (AddAskForPasscode.Value)
			{
				list2.Add("WhatIsYourPasscode/WhatIsYourPasscodeTemplate");
				list2.Add("WhatIsYourPasscode/WhatIsYourPasscodeBribe2");
				list2.Add("WhatIsYourPasscode/WhatIsYourPasscodeBribe1");
				list2.Add("WhatIsYourPasscode/WhatIsYourPasscode");
			}
			bool flag = default(bool);
			foreach (string item2 in list2)
			{
				string text = Path.Combine(path, item2 + ".sodso.json");
				if (File.Exists(text))
				{
					string text2 = File.ReadAllText(text);
					DialogPreset item = ReflectionExtensions.TryCast<DialogPreset>((object)JsonLoader.LoadFileToGame(text2));
					list.Add((ScriptableObject)(object)item);
					continue;
				}
				ManualLogSource pluginLogger = PluginLogger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("File ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item2);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" not found, looking ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
				}
				pluginLogger.LogError(val2);
			}
			return list;
		}
	}
	public abstract class CustomDialogPreset
	{
		public string Name { get; protected set; }

		public DialogPreset Preset { get; protected set; }

		public abstract bool IsAvailable(DialogPreset preset, Citizen saysTo, SideJob jobRef);

		public abstract void RunDialogMethod(DialogController instance, Citizen saysTo, Interactable saysToInteractable, NewNode where, Actor saidBy, bool success, NewRoom roomRef, SideJob jobRef);

		public abstract ForceSuccess ShouldDialogSucceedOverride(DialogController instance, DialogOption dialog, Citizen saysTo, NewNode where, Actor saidBy);
	}
	[HarmonyPatch(typeof(DialogController), "Start")]
	public class DialogController_Start
	{
		[HarmonyPostfix]
		private static void Postfix(DialogController __instance)
		{
			MethodInfo val = null;
			Enumerator<DialogPreset, MethodInfo> enumerator = __instance.dialogRef.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<DialogPreset, MethodInfo> current = enumerator.Current;
				if (((Object)current.Key).name == "WarnNotewriter")
				{
					val = current.Value;
				}
			}
			foreach (KeyValuePair<string, CustomDialogPreset> customDialogInterceptor in DialogAdditionPlugin.customDialogInterceptors)
			{
				DialogController.Instance.dialogRef.Add(customDialogInterceptor.Value.Preset, val);
			}
		}
	}
	[HarmonyPatch(typeof(DialogController), "WarnNotewriter")]
	public class DialogController_WarnNotewriter
	{
		[HarmonyPrefix]
		internal static bool Prefix(DialogController __instance, Citizen saysTo, Interactable saysToInteractable, NewNode where, Actor saidBy, bool success, NewRoom roomRef, SideJob jobRef)
		{
			if (DialogAdditionPlugin.customDialogInterceptors.ContainsKey(((Object)__instance.preset).name) && DialogAdditionPlugin.customDialogInterceptors[((Object)__instance.preset).name] != null)
			{
				DialogAdditionPlugin.customDialogInterceptors[((Object)__instance.preset).name].RunDialogMethod(__instance, saysTo, saysToInteractable, where, saidBy, success, roomRef, jobRef);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(DialogController), "TestSpecialCaseAvailability")]
	public class DialogController_TestSpecialCaseAvailability
	{
		[HarmonyPrefix]
		internal static bool Prefix(ref bool __result, DialogPreset preset, Citizen saysTo, SideJob jobRef)
		{
			if (DialogAdditionPlugin.customDialogInterceptors.ContainsKey(((Object)preset).name) && DialogAdditionPlugin.customDialogInterceptors[((Object)preset).name] != null)
			{
				if (!Object.op_Implicit((Object)(object)saysTo))
				{
					__result = false;
				}
				else
				{
					__result = DialogAdditionPlugin.customDialogInterceptors[((Object)preset).name].IsAvailable(preset, saysTo, jobRef);
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(DialogController), "ExecuteDialog")]
	public class DialogController_ExecuteDialog
	{
		[HarmonyPrefix]
		internal static void Prefix(DialogController __instance, DialogOption dialog, Interactable saysTo, NewNode where, Actor saidBy, ref ForceSuccess forceSuccess)
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected I4, but got Unknown
			if ((int)forceSuccess == 0 && DialogAdditionPlugin.customDialogInterceptors.ContainsKey(((Object)dialog.preset).name) && DialogAdditionPlugin.customDialogInterceptors[((Object)dialog.preset).name] != null)
			{
				Citizen saysTo2 = (Citizen)((dynamic)saysTo.isActor).Cast<Citizen>();
				forceSuccess = (ForceSuccess)(int)DialogAdditionPlugin.customDialogInterceptors[((Object)dialog.preset).name].ShouldDialogSucceedOverride(__instance, dialog, saysTo2, where, saidBy);
			}
		}
	}
	internal class ModifyDDSScopes
	{
		[HarmonyPatch(typeof(Toolbox), "Start")]
		public class Toolbox_Start
		{
			public static void Postfix()
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected O, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Expected O, but got Unknown
				Toolbox.Instance.scopeDictionary["citizen"].containedScopes.Add(new ContainedScope
				{
					name = "currentgroup",
					type = Toolbox.Instance.scopeDictionary["group"]
				});
				GameplayControls.Instance.humanScope.containedScopes.Add(new ContainedScope
				{
					name = "currentgroup",
					type = Toolbox.Instance.scopeDictionary["group"]
				});
				Toolbox.Instance.scopeDictionary["group"].containedValues.Add("membercount");
				Toolbox.Instance.scopeDictionary["group"].containedValues.Add("type");
			}
		}

		[HarmonyPatch(typeof(Strings), "GetContainedValue")]
		private class Strings_GetContainedValue
		{
			private static bool Prefix(ref string __result, object baseObject, string withinScope, string newValue, object inputObject, object additionalObject)
			{
				string text = newValue.ToLower();
				if (withinScope == "group")
				{
					if (text == "membercount")
					{
						try
						{
							SocialGroup val = (SocialGroup)((dynamic)inputObject).Cast<SocialGroup>();
							__result = $"{val.members.Count}";
							return false;
						}
						catch
						{
						}
					}
					else if (text == "type")
					{
						try
						{
							SocialGroup val2 = (SocialGroup)((dynamic)inputObject).Cast<SocialGroup>();
							__result = Strings.Get("misc", val2.preset, (Casing)0, false, false, false, (Human)null);
							return false;
						}
						catch
						{
						}
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Strings), "GetScopeObject")]
		private class Strings_GetScopeObject
		{
			private static bool Prefix(ref object __result, object inputObject, string withinScope, string newType)
			{
				withinScope = withinScope.ToLower();
				newType = newType.ToLower();
				if (withinScope == "citizen" && newType == "currentgroup")
				{
					try
					{
						__result = GroupToSpeakAbout;
						return false;
					}
					catch
					{
					}
				}
				return true;
			}
		}

		public static SocialGroup GroupToSpeakAbout;
	}
	[HarmonyPatch(typeof(PhotoSelectButtonController), "OnLeftClick")]
	public class PhotoSelectButtonController_OnLeftClick
	{
		public enum CallType
		{
			DoYouKnowThisPerson,
			SeenThisPersonWithOthers
		}

		[HarmonyPatch(typeof(Human), "RevealSighting", new Type[]
		{
			typeof(Human),
			typeof(Sighting)
		})]
		private class Human_RevealSighting_Murderer
		{
			private static bool Prefix(Human __instance, Human prospectCitizen)
			{
				int humanID = __instance.humanID;
				Human currentMurderer = MurderController.Instance.currentMurderer;
				if (humanID == ((currentMurderer != null) ? new int?(currentMurderer.humanID) : null) && MurderController.Instance.activeMurders.Exists(Predicate<Murder>.op_Implicit((Func<Murder, bool>)((Murder murder) => murder.victimID == prospectCitizen.humanID))))
				{
					((Actor)__instance).speechController.Speak("aeba5683-cb14-4df7-a95c-04025dfcd5d0", false, false, prospectCitizen, (SideJob)null);
					return false;
				}
				return true;
			}
		}

		public static CallType callType;

		internal static bool Prefix(PhotoSelectButtonController __instance)
		{
			bool flag = true;
			Human speaker = (Human)((dynamic)InteractionController.Instance.talkingTo.isActor).Cast<Human>();
			Human citizen = __instance.citizen;
			List<DataKey> tiedKeys = ((Evidence)((Actor)__instance.citizen).evidenceEntry).GetTiedKeys(__instance.element.dk);
			CallType callType = PhotoSelectButtonController_OnLeftClick.callType;
			CallType callType2 = callType;
			if (callType2 == CallType.SeenThisPersonWithOthers)
			{
				SeenThisPersonWithOthersCallback(speaker, citizen, tiedKeys);
				flag = false;
			}
			else
			{
				flag = DoYouKnowThisPersonAdditions(speaker, citizen, tiedKeys);
			}
			PhotoSelectButtonController_OnLeftClick.callType = CallType.DoYouKnowThisPerson;
			if (!flag)
			{
				__instance.thisWindow.CloseWindow(true);
			}
			return flag;
		}

		private static void SeenThisPersonWithOthersCallback(Human speaker, Human askTarget, List<DataKey> askTargetKeys)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			List<SocialGroup> val = new List<SocialGroup>();
			Acquaintance val2 = default(Acquaintance);
			if (!askTargetKeys.Contains((DataKey)1) && (!DialogController.Instance.askTargetKeys.Contains((DataKey)0) || !speaker.FindAcquaintanceExists(askTarget, ref val2)))
			{
				((Actor)speaker).speechController.Speak("a6815309-f9d4-40b0-8a1e-3ec3550c64a2", false, false, askTarget, (SideJob)null);
				return;
			}
			Enumerator<SocialGroup> enumerator = askTarget.groups.GetEnumerator();
			while (enumerator.MoveNext())
			{
				SocialGroup current = enumerator.Current;
				if (current.GetMeetingPlace().id != speaker.job.employer.address.id)
				{
					continue;
				}
				Enumerator<WeekDay> enumerator2 = current.weekDays.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					WeekDay current2 = enumerator2.Current;
					if (speaker.job.workDaysList.Contains(current2) && Toolbox.Instance.DecimalTimeRangeOverlap(new Vector2(speaker.job.startTimeDecimalHour, speaker.job.startTimeDecimalHour + speaker.job.workHours), new Vector2(current.decimalStartTime, current.decimalStartTime + current.GetPreset().meetUpLength), true))
					{
						val.Add(current);
						break;
					}
				}
			}
			for (int num = val.Count - 1; num >= 0; num--)
			{
				if (val[num].members.Count < 2)
				{
					val.RemoveAt(num);
				}
			}
			if (val.Count == 0)
			{
				((Actor)speaker).speechController.Speak("b37bf9be-fd05-4000-af08-8eef590f54c2", false, false, askTarget, (SideJob)null);
				return;
			}
			if (val.Count == 1)
			{
				SpeakAboutGroup(val[0], speaker, askTarget);
				return;
			}
			int num2 = ((Object)speaker).name.ToCharArray().Aggregate(0, (int result, char c) => result + c);
			SpeakAboutGroup(val[num2 % val.Count], speaker, askTarget);
		}

		private static void SpeakAboutGroup(SocialGroup group, Human speaker, Human askTarget)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Invalid comparison between Unknown and I4
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Invalid comparison between Unknown and I4
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Invalid comparison between Unknown and I4
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Invalid comparison between Unknown and I4
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Invalid comparison between Unknown and I4
			GroupPreset preset = group.GetPreset();
			ModifyDDSScopes.GroupToSpeakAbout = group;
			if (group.members.Count == 2)
			{
				((Actor)speaker).speechController.Speak("d5af67b2-9c85-41f1-a703-add0be0b1ddf", false, false, askTarget, (SideJob)null);
			}
			else if (group.members.Count <= 4)
			{
				((Actor)speaker).speechController.Speak("76ec3908-68e5-4238-bc2e-57545ce46850", false, false, askTarget, (SideJob)null);
			}
			else
			{
				((Actor)speaker).speechController.Speak("669bd28e-22fd-4db7-8b64-c4425ed7b0e7", false, false, askTarget, (SideJob)null);
			}
			if ((int)preset.groupType == 0)
			{
				((Actor)speaker).speechController.Speak("35388bb9-002d-4afc-960c-c22e33693030", false, false, askTarget, (SideJob)null);
			}
			else if ((int)preset.groupType == 3)
			{
				((Actor)speaker).speechController.Speak("c96c565c-819d-4bf8-804d-d0af4565a60f", false, false, askTarget, (SideJob)null);
			}
			else if ((int)preset.groupType == 1 || (int)preset.groupType == 2)
			{
				((Actor)speaker).speechController.Speak("dc1396c0-561d-45f4-a1c1-63c14bf5b29c", false, false, askTarget, (SideJob)null);
				if ((int)preset.groupType == 2)
				{
					((Actor)speaker).speechController.Speak("e5cb4b85-b636-4d64-87d7-9607bd589863", false, false, askTarget, (SideJob)null);
				}
			}
			if (group.members.Count == 2)
			{
				Human val = CityData.Instance.citizenDictionary[EnumerableExtensions.Where<int>(group.members, (Func<int, bool>)((int memberId) => memberId != askTarget.humanID)).First()];
				Acquaintance val2 = default(Acquaintance);
				if (speaker.FindAcquaintanceExists(askTarget, ref val2))
				{
					((Actor)speaker).speechController.Speak("846d9642-f500-41d4-97a2-c2821ae7c2ba", false, false, val, (SideJob)null);
					return;
				}
				((Actor)speaker).speechController.Speak("b700b7d9-69f4-479a-b448-2a4234f3d4fb", false, false, val, (SideJob)null);
				((Actor)speaker).speechController.Speak("80409e68-0be4-4657-8afd-9a519a386f4f", false, false, val, (SideJob)null);
				return;
			}
			bool flag = true;
			int num = 0;
			Enumerator<int> enumerator = group.members.GetEnumerator();
			Acquaintance val4 = default(Acquaintance);
			while (enumerator.MoveNext())
			{
				int current = enumerator.Current;
				if (current != askTarget.humanID)
				{
					Human val3 = CityData.Instance.citizenDictionary[current];
					if (speaker.FindAcquaintanceExists(val3, ref val4))
					{
						((Actor)speaker).speechController.Speak("846d9642-f500-41d4-97a2-c2821ae7c2ba", false, false, val3, (SideJob)null);
					}
					else if (flag)
					{
						((Actor)speaker).speechController.Speak("a1711366-5c92-4b65-ab49-bc986c1e3fc8", false, false, val3, (SideJob)null);
						((Actor)speaker).speechController.Speak("80409e68-0be4-4657-8afd-9a519a386f4f", false, false, val3, (SideJob)null);
					}
					else
					{
						((Actor)speaker).speechController.Speak("1b8d9be3-baee-416d-8814-ec26a804d5bb", false, false, val3, (SideJob)null);
						((Actor)speaker).speechController.Speak("80409e68-0be4-4657-8afd-9a519a386f4f", false, false, val3, (SideJob)null);
					}
					flag = false;
					num++;
					if (num > 2)
					{
						break;
					}
				}
			}
		}

		private static bool DoYouKnowThisPersonAdditions(Human speaker, Human askTarget, List<DataKey> askTargetKeys)
		{
			if (!Object.op_Implicit((Object)(object)speaker))
			{
				return true;
			}
			if (speaker.humanID == askTarget.humanID && (askTargetKeys.Contains((DataKey)0) || askTargetKeys.Contains((DataKey)1)))
			{
				bool flag = InternalMethodClones.TestDialogForSuccess_useSuccessTest("Introduce", speaker);
				DialogController.Instance.askTarget = askTarget;
				DialogController.Instance.askTargetKeys = askTargetKeys;
				if (flag)
				{
					((Actor)speaker).speechController.Speak("4e8db6e9-04fe-4c5b-9bf6-05d8c3f8a230", false, false, askTarget, (SideJob)null);
					InternalMethodClones.MergeTargetKeys(askTarget, (DataKey)0);
					InternalMethodClones.MergeTargetKeys(askTarget, (DataKey)1);
					InternalMethodClones.MergeTargetKeys(askTarget, (DataKey)4);
				}
				else
				{
					((Actor)speaker).speechController.Speak("a6815309-f9d4-40b0-8a1e-3ec3550c64a2", false, false, askTarget, (SideJob)null);
				}
				return false;
			}
			if (DialogAdditionPlugin.ConfirmSuspiciousPhotos.Value && speaker.lastSightings.ContainsKey(askTarget))
			{
				int humanID = askTarget.humanID;
				Human currentMurderer = MurderController.Instance.currentMurderer;
				if (humanID == ((currentMurderer != null) ? new int?(currentMurderer.humanID) : null))
				{
					int humanID2 = speaker.humanID;
					Human currentMurderer2 = MurderController.Instance.currentMurderer;
					if (humanID2 != ((currentMurderer2 != null) ? new int?(currentMurderer2.humanID) : null) && InternalMethodClones.TestDialogForSuccess_useSuccessTest("SeenOrHeardUnusual", speaker) && InternalMethodClones.SeenOrHeardUnusual_LastSightingCheckOnly(speaker, askTarget))
					{
						((Actor)speaker).speechController.Speak("90f766cd-ae3f-482d-9cbb-5f72a69a0a4b", false, false, askTarget, (SideJob)null);
						return true;
					}
				}
			}
			return true;
		}
	}
	internal class InternalMethodClones
	{
		public static void MergeTargetKeys(Human askTarget, DataKey key)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<DataKey> enumerator = DialogController.Instance.askTargetKeys.GetEnumerator();
			while (enumerator.MoveNext())
			{
				DataKey current = enumerator.Current;
				((Evidence)((Actor)askTarget).evidenceEntry).MergeDataKeys(current, key);
			}
		}

		public static float GetChance(Citizen cit, List<TraitPickRule> pickRules, float baseChance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Invalid comparison between Unknown and I4
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Invalid comparison between Unknown and I4
			bool flag = true;
			Enumerator<TraitPickRule> enumerator = pickRules.GetEnumerator();
			while (enumerator.MoveNext())
			{
				TraitPickRule current = enumerator.Current;
				bool flag2 = false;
				if ((int)current.rule == 0)
				{
					Enumerator<CharacterTrait> enumerator2 = current.traitList.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						CharacterTrait current2 = enumerator2.Current;
						CharacterTrait searchTrait3 = current2;
						if (((Human)cit).characterTraits.Exists(Predicate<Trait>.op_Implicit((Func<Trait, bool>)((Trait item) => (SoCustomComparison)(object)item.trait == (SoCustomComparison)(object)searchTrait3))))
						{
							flag2 = true;
							break;
						}
					}
				}
				else if ((int)current.rule == 1)
				{
					flag2 = true;
					Enumerator<CharacterTrait> enumerator3 = current.traitList.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						CharacterTrait current3 = enumerator3.Current;
						CharacterTrait searchTrait4 = current3;
						if (!((Human)cit).characterTraits.Exists(Predicate<Trait>.op_Implicit((Func<Trait, bool>)((Trait item) => (SoCustomComparison)(object)item.trait == (SoCustomComparison)(object)searchTrait4))))
						{
							flag2 = false;
							break;
						}
					}
				}
				else if ((int)current.rule == 2)
				{
					flag2 = true;
					Enumerator<CharacterTrait> enumerator4 = current.traitList.GetEnumerator();
					while (enumerator4.MoveNext())
					{
						CharacterTrait current4 = enumerator4.Current;
						CharacterTrait searchTrait2 = current4;
						if (((Human)cit).characterTraits.Exists(Predicate<Trait>.op_Implicit((Func<Trait, bool>)((Trait item) => (SoCustomComparison)(object)item.trait == (SoCustomComparison)(object)searchTrait2))))
						{
							flag2 = false;
							break;
						}
					}
				}
				else if ((int)current.rule == 3 && Object.op_Implicit((Object)(object)((Human)cit).partner))
				{
					Enumerator<CharacterTrait> enumerator5 = current.traitList.GetEnumerator();
					while (enumerator5.MoveNext())
					{
						CharacterTrait current5 = enumerator5.Current;
						CharacterTrait searchTrait = current5;
						if (((Human)((Human)cit).partner).characterTraits.Exists(Predicate<Trait>.op_Implicit((Func<Trait, bool>)((Trait item) => (SoCustomComparison)(object)item.trait == (SoCustomComparison)(object)searchTrait))))
						{
							flag2 = true;
							break;
						}
					}
				}
				if (flag2)
				{
					baseChance += current.baseChance;
				}
				else if (current.mustPassForApplication)
				{
					flag = false;
				}
			}
			return (!flag) ? 0f : Mathf.Clamp01(baseChance);
		}

		public static bool TestDialogForSuccess_useSuccessTest(string presetName, Human cit)
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Invalid comparison between Unknown and I4
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Invalid comparison between Unknown and I4
			DialogPreset val = DialogAdditionPlugin.dialogPresetRefs[presetName];
			bool flag = true;
			float num = val.baseChance;
			if (Object.op_Implicit((Object)(object)cit) && val.modifySuccessChanceTraits.Count > 0)
			{
				num = InternalMethodClones.GetChance(((dynamic)cit).Cast<Citizen>(), val.modifySuccessChanceTraits, num);
			}
			if (Object.op_Implicit((Object)(object)cit) && ((Actor)cit).ai.restrained)
			{
				num += val.affectChanceIfRestrained;
			}
			if ((int)val.specialCase == 10)
			{
				num += UpgradeEffectController.Instance.GetUpgradeEffect((Effect)64);
			}
			float num2 = Mathf.Clamp01(num + UpgradeEffectController.Instance.GetUpgradeEffect((Effect)14));
			if ((int)val.specialCase == 27)
			{
				Human currentMurderer = MurderController.Instance.currentMurderer;
				if (((currentMurderer != null) ? new int?(currentMurderer.humanID) : null) != ((cit != null) ? new int?(cit.humanID) : null))
				{
					num2 = 0f;
					flag = false;
				}
			}
			string name = ((Object)cit).name;
			return (double)Toolbox.Instance.GetPsuedoRandomNumber(0f, 1f, ref name, false, false) <= (double)num2;
		}

		public static bool SeenOrHeardUnusual_LastSightingCheckOnly(Human speaker, Human saysTo)
		{
			float num = -99999f;
			Sighting val = null;
			Human val2 = null;
			if ((Object)(object)MurderController.Instance == (Object)null || MurderController.Instance.activeMurders == null)
			{
				Enumerator<Human, Sighting> enumerator = saysTo.lastSightings.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<Human, Sighting> current = enumerator.Current;
					if (!((Object)(object)current.Key == (Object)(object)saysTo) && current.Value.poi && !current.Value.phone && (double)current.Value.time > (double)num && current.Value.sound == 0)
					{
						num = current.Value.time;
						val2 = current.Key;
						val = current.Value;
					}
				}
			}
			return val != null;
		}
	}
	internal class SeenOrHeardUnusualOverrides
	{
		[HarmonyPatch(typeof(DialogController), "SeenOrHeardUnusual")]
		private class DialogController_SeenOrHeardUnusual
		{
			public static bool Prefix(Citizen saysTo)
			{
				float num = float.NegativeInfinity;
				Sighting val = null;
				Human val2 = null;
				Enumerator<Human, Sighting> enumerator = ((Human)saysTo).lastSightings.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<Human, Sighting> current = enumerator.Current;
					if (current.Value.poi && !current.Value.phone && (double)current.Value.time > (double)num)
					{
						num = current.Value.time;
						val2 = current.Key;
						val = current.Value;
					}
				}
				Acquaintance val3 = default(Acquaintance);
				if (val != null && val.sound == 0 && ((Human)saysTo).FindAcquaintanceExists(val2, ref val3))
				{
					if (val3.like > DialogAdditionPlugin.SeenUnusualLikeBlock.Value)
					{
						((Actor)saysTo).speechController.Speak("b8591738-092c-4de6-992e-33a44d6ab43f", false, false, (Human)null, (SideJob)null);
						return false;
					}
					((Actor)saysTo).speechController.Speak("51421182-3138-47a6-a8cf-3991990e9815", false, false, val2, (SideJob)null);
					return false;
				}
				return true;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DialogAdditions";

		public const string PLUGIN_NAME = "DialogAdditions";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DialogAdditions.NewDialogOptions
{
	internal class SeenThisPersonWithOthers : CustomDialogPreset
	{
		public SeenThisPersonWithOthers(bool canFail = false, float chanceToSucceed = 1f)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			base.Name = "SeenThisPersonWithOthers";
			DialogPreset val = ScriptableObject.CreateInstance<DialogPreset>();
			((Object)val).name = base.Name;
			val.msgID = "a8267eeb-1d40-442f-9edb-1176bfd51986";
			val.defaultOption = true;
			val.tiedToKey = (DataKey)4;
			val.useSuccessTest = true;
			val.baseChance = (canFail ? chanceToSucceed : 1f);
			val.ranking = 6;
			val.removeAfterSaying = false;
			val.affectChanceIfRestrained = -1f;
			if (canFail)
			{
				val.modifySuccessChanceTraits = DialogAdditionPlugin.dialogPresetRefs["DoYouKnowThisPerson"].modifySuccessChanceTraits;
			}
			val.responses.Add(new AISpeechPreset
			{
				dictionaryString = "Fail",
				ddsMessageID = "f897a39e-975b-464a-ad9d-0674d57f4bf8",
				isSuccessful = false,
				chance = 1,
				useParsing = true
			});
			base.Preset = val;
		}

		public override bool IsAvailable(DialogPreset preset, Citizen saysTo, SideJob jobRef)
		{
			return ((Actor)saysTo).isAtWork;
		}

		public override void RunDialogMethod(DialogController instance, Citizen saysTo, Interactable saysToInteractable, NewNode where, Actor saidBy, bool success, NewRoom roomRef, SideJob jobRef)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (success)
			{
				PhotoSelectButtonController_OnLeftClick.callType = PhotoSelectButtonController_OnLeftClick.CallType.SeenThisPersonWithOthers;
				SessionData.Instance.PauseGame(true, false, true);
				instance.askTarget = null;
				instance.askTargetKeys.Clear();
				instance.askWindow = InterfaceController.Instance.SpawnWindow((Evidence)null, (DataKey)0, (List<DataKey>)null, "SelectPhoto", true, false, InterfaceControls.Instance.handbookWindowPosition, (Interactable)null, (Case)null, (CaseElement)null, success);
			}
		}

		public override ForceSuccess ShouldDialogSucceedOverride(DialogController instance, DialogOption dialog, Citizen saysTo, NewNode where, Actor saidBy)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (ForceSuccess)0;
		}
	}
	internal class TalkToPartner : CustomDialogPreset
	{
		public TalkToPartner(bool canFail, float chanceToSucceed)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			base.Name = "TalkToPartner";
			DialogPreset val = ScriptableObject.CreateInstance<DialogPreset>();
			((Object)val).name = base.Name;
			val.msgID = "cfa7463c-a03d-4c2c-87e9-124a39290716";
			val.defaultOption = true;
			val.tiedToKey = (DataKey)4;
			val.useSuccessTest = true;
			val.baseChance = (canFail ? chanceToSucceed : 1f);
			val.ranking = 1;
			val.removeAfterSaying = false;
			val.affectChanceIfRestrained = -1f;
			if (canFail)
			{
				val.modifySuccessChanceTraits = DialogAdditionPlugin.dialogPresetRefs["Introduce"].modifySuccessChanceTraits;
			}
			val.responses.Add(new AISpeechPreset
			{
				dictionaryString = "Success",
				ddsMessageID = "1435a1d4-465f-49df-98c5-12ad5515ff8d",
				isSuccessful = true,
				chance = 1,
				useParsing = true,
				endsDialog = true,
				shout = true
			});
			base.Preset = val;
		}

		public override bool IsAvailable(DialogPreset preset, Citizen saysTo, SideJob jobRef)
		{
			return !((Actor)saysTo).isHomeless && ((Actor)saysTo).isHome;
		}

		public override void RunDialogMethod(DialogController instance, Citizen saysTo, Interactable saysToInteractable, NewNode where, Actor saidBy, bool success, NewRoom roomRef, SideJob jobRef)
		{
			if (success && Object.op_Implicit((Object)(object)saysTo) && ((Actor)saysTo).isHome && Object.op_Implicit((Object)(object)((Human)saysTo).partner) && ((Actor)((Human)saysTo).partner).isHome)
			{
				((Actor)((Human)saysTo).partner).ai.AnswerDoor(((NewGameLocation)((Human)saysTo).home).entrances[0].door, ((Actor)saysTo).currentGameLocation, (Actor)(object)Player.Instance);
				((Actor)saysTo).ai.currentGoal.Complete();
			}
			else if (!Object.op_Implicit((Object)(object)((Human)saysTo).partner))
			{
				((Actor)saysTo).speechController.Speak("4f7266c4-a631-482b-8798-074428d66a55", false, false, (Human)null, (SideJob)null);
			}
			else if (!((Actor)((Human)saysTo).partner).isHome)
			{
				((Actor)saysTo).speechController.Speak("9f436995-fd25-4116-8eab-68509be5721b", false, false, (Human)null, (SideJob)null);
			}
			else
			{
				((Actor)saysTo).speechController.Speak("b7d97901-3d58-4cdc-afc2-34003de5192b", false, false, (Human)null, (SideJob)null);
			}
		}

		public override ForceSuccess ShouldDialogSucceedOverride(DialogController instance, DialogOption dialog, Citizen saysTo, NewNode where, Actor saidBy)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!((Actor)saysTo).isHome || !Object.op_Implicit((Object)(object)((Human)saysTo).partner) || (Object.op_Implicit((Object)(object)((Human)saysTo).partner) && !((Actor)((Human)saysTo).partner).isHome))
			{
				return (ForceSuccess)2;
			}
			return (ForceSuccess)0;
		}
	}
}