Decompiled source of PlayerDialogAdditions v0.11.3

DialogAdditions.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using SOD.Common.Extensions;
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("DialogAdditions")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Adds extra dialog to Shadows of Doubt")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+89c3611b8f5d29e08ac7a8808e908020fca6a663")]
[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
{
	internal class BaseGameScheduleFix
	{
		[HarmonyPatch(typeof(NewAIController), "AITick")]
		public class NewAIController_AITick
		{
			public static void Postfix(NewAIController __instance)
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected O, but got Unknown
				if (!((Object)(object)__instance != (Object)null) || __instance.currentGoal == null || !__instance.currentGoal.name.Contains("MeetUpEvent"))
				{
					return;
				}
				ManualLogSource pluginLogger = DialogAdditionPlugin.PluginLogger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(9, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(__instance.currentGoal.name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(__instance.currentGoal.triggerTime);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" @ ");
					object obj;
					if (__instance == null)
					{
						obj = null;
					}
					else
					{
						Human human = __instance.human;
						obj = ((human != null) ? human.citizenName : null);
					}
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((string)obj);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ");
					object obj2;
					if (__instance == null)
					{
						obj2 = null;
					}
					else
					{
						NewAIGoal currentGoal = __instance.currentGoal;
						if (currentGoal == null)
						{
							obj2 = null;
						}
						else
						{
							NewGameLocation gameLocation = currentGoal.gameLocation;
							obj2 = ((gameLocation != null) ? ((Object)gameLocation).name : null);
						}
					}
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((string)obj2);
				}
				pluginLogger.LogInfo(val);
			}
		}

		[HarmonyPatch]
		public class SessionData_GetNextOrPreviousGameTimeForThisHour
		{
			[HarmonyTargetMethod]
			internal static MethodBase FindBaseMethod()
			{
				return (from mi in typeof(SessionData).GetMethods()
					where mi.Name == "GetNextOrPreviousGameTimeForThisHour" && mi.GetParameters().Length == 6
					select mi).First();
			}

			[HarmonyPrefix]
			public static bool GetNextOrPreviousGameTimeForThisHour(float newTime, float newDecimalClock, WeekDay newDay, List<WeekDay> days, float startHour, float endHour, ref float __result)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Expected I4, but got Unknown
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Invalid comparison between Unknown and I4
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				float num = newTime - newDecimalClock;
				if ((double)endHour >= (double)startHour)
				{
					if (days.Contains(newDay))
					{
						if ((double)newDecimalClock >= (double)startHour && (double)newDecimalClock <= (double)endHour)
						{
							float num2 = newDecimalClock - startHour;
							__result = newTime - num2;
							return false;
						}
						if ((double)newDecimalClock < (double)startHour)
						{
							__result = num + startHour;
							return false;
						}
					}
				}
				else if ((double)endHour < (double)startHour)
				{
					if ((double)newDecimalClock >= (double)endHour)
					{
						__result = num + startHour;
						return false;
					}
					WeekDay val = (WeekDay)(((int)SessionData.Instance.day == 0) ? 6 : (SessionData.Instance.day - 1));
					if (days.Contains(val))
					{
						__result = num - (24f - startHour);
						return false;
					}
				}
				int num3 = newDay + 1;
				if (num3 >= 7)
				{
					num3 = 0;
				}
				WeekDay val2 = (WeekDay)num3;
				float num4 = num + 24f;
				int num5 = 8;
				while (!days.Contains(val2) && num5 > 0)
				{
					val2 = (WeekDay)(((int)val2 != 6) ? (val2 + 1) : 0);
					num4 += 24f;
					num5--;
				}
				__result = num4 + startHour;
				return false;
			}
		}
	}
	[BepInPlugin("DialogAdditions", "DialogAdditions", "1.0.0")]
	public class DialogAdditionPlugin : BasePlugin
	{
		public static Dictionary<string, DialogPreset> dialogPresets = 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;

		private static DialogAdditionPlugin instance;

		public override void Load()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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);
			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);
		}
	}
	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]
		internal static void Postfix(DialogController __instance)
		{
			MethodInfo val = null;
			Enumerator<DialogPreset> enumerator = Toolbox.Instance.allDialog.GetEnumerator();
			while (enumerator.MoveNext())
			{
				DialogPreset current = enumerator.Current;
				if (((Object)current).name == "WarnNotewriter")
				{
					val = __instance.dialogRef[current];
				}
				DialogAdditionPlugin.dialogPresets[((Object)current).name] = current;
			}
			CustomDialogPreset[] array = new CustomDialogPreset[2]
			{
				new TalkToPartner(DialogAdditionPlugin.TalkToPartnerCanFail.Value, DialogAdditionPlugin.TalkToPartnerBaseSuccess.Value),
				new SeenThisPersonWithOthers()
			};
			foreach (CustomDialogPreset customDialogPreset in array)
			{
				Toolbox.Instance.allDialog.Add(customDialogPreset.Preset);
				if (customDialogPreset.Preset.defaultOption)
				{
					Toolbox.Instance.defaultDialogOptions.Add(customDialogPreset.Preset);
				}
				__instance.dialogRef.Add(customDialogPreset.Preset, val);
				DialogAdditionPlugin.customDialogInterceptors[customDialogPreset.Name] = customDialogPreset;
			}
		}
	}
	[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].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))
			{
				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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected I4, but got Unknown
			if ((int)forceSuccess == 0 && DialogAdditionPlugin.customDialogInterceptors.ContainsKey(((Object)dialog.preset).name))
			{
				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)
			{
				if (__instance.humanID == MurderController.Instance.currentMurderer.humanID && 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;

		private static CharacterTrait charImpulsive;

		private static CharacterTrait charAwkward;

		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 (speaker.humanID == askTarget.humanID && (askTargetKeys.Contains((DataKey)0) || askTargetKeys.Contains((DataKey)1)))
			{
				bool flag = InternalMethodClones.TestDialogForSuccess("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 (speaker.humanID == MurderController.Instance.currentMurderer.humanID)
			{
				if ((SoCustomComparison)(object)charImpulsive == (SoCustomComparison)null)
				{
					charImpulsive = EnumerableExtensions.Where<CharacterTrait>(Toolbox.Instance.allCharacterTraits, (Func<CharacterTrait, bool>)((CharacterTrait item) => ((Object)item).name == "Char-Impulsive")).First();
				}
				if ((SoCustomComparison)(object)charAwkward == (SoCustomComparison)null)
				{
					charAwkward = EnumerableExtensions.Where<CharacterTrait>(Toolbox.Instance.allCharacterTraits, (Func<CharacterTrait, bool>)((CharacterTrait item) => ((Object)item).name == "Char-Awkward")).First();
				}
				if ((speaker.TraitExists(charImpulsive) || speaker.TraitExists(charAwkward)) && MurderController.Instance.activeMurders.Exists(Predicate<Murder>.op_Implicit((Func<Murder, bool>)((Murder murder) => murder.victimID == askTarget.humanID))))
				{
					((Actor)speaker).speechController.Speak("a6815309-f9d4-40b0-8a1e-3ec3550c64a2", false, false, askTarget, (SideJob)null);
					return false;
				}
			}
			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(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.dialogPresets[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 && (Object)(object)MurderController.Instance.currentMurderer != (Object)(object)cit)
			{
				num2 = 0f;
				flag = false;
			}
			return (double)Toolbox.Instance.GetPsuedoRandomNumber(0f, 1f, ((Object)cit).name, false) <= (double)num2;
		}
	}
	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, (Human)null, (SideJob)null);
					return false;
				}
				return true;
			}
		}
	}
	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)1;
			val.useSuccessTest = true;
			val.baseChance = (canFail ? chanceToSucceed : 1f);
			val.ranking = 6;
			val.removeAfterSaying = false;
			val.affectChanceIfRestrained = -1f;
			if (canFail)
			{
				val.modifySuccessChanceTraits = DialogAdditionPlugin.dialogPresets["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)1;
			val.useSuccessTest = true;
			val.baseChance = (canFail ? chanceToSucceed : 1f);
			val.ranking = 1;
			val.removeAfterSaying = false;
			val.affectChanceIfRestrained = -1f;
			if (canFail)
			{
				val.modifySuccessChanceTraits = DialogAdditionPlugin.dialogPresets["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;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DialogAdditions";

		public const string PLUGIN_NAME = "DialogAdditions";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}