Decompiled source of Pies Generic Patch v1.0.1

Pies_Generic_Patch.dll

Decompiled a month 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SOD.Common.BepInEx;
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("Pies_Generic_Patch")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Bugfixes for Shadows of Doubt. Currently fixes: Group meetups, Retires not existing")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1bf21606efa970fde7bdf2ef32096ce4302f1b9e")]
[assembly: AssemblyProduct("Pies_Generic_Patch")]
[assembly: AssemblyTitle("Pies_Generic_Patch")]
[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 Pies_Generic_Patch
{
	[BepInPlugin("Pies_Generic_Patch", "Pies_Generic_Patch", "1.0.0")]
	public class Pies_Generic_PatchPlugin : PluginController<Pies_Generic_PatchPlugin>
	{
		private static ConfigEntry<bool> Enabled;

		public static ConfigEntry<bool> DebugLogging;

		private static ConfigEntry<bool> PatchEnabled_AddRetirees;

		private static ConfigEntry<bool> PatchEnabled_FixGroups;

		public override void Load()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			Enabled = base.Config.Bind<bool>("General", "Enabled", true, "Is the mod enabled at all? (Game restart required)");
			DebugLogging = base.Config.Bind<bool>("Debugging", "Logging", false, "Is debug logging enabled?");
			if (Enabled.Value)
			{
				ManualLogSource log = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Pies_Generic_Patch");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
				}
				log.LogInfo(val);
				Harmony val2 = new Harmony("Pies_Generic_Patch");
				val2.PatchAll();
				ManualLogSource log2 = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
				val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Pies_Generic_Patch");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
				}
				log2.LogInfo(val);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Pies_Generic_Patch";

		public const string PLUGIN_NAME = "Pies_Generic_Patch";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Pies_Generic_Patch.BugFixes
{
	public class AddRetirees
	{
		[HarmonyPatch(typeof(Creator), "SetComplete")]
		public class CitizenCreator_SetComplete
		{
			public static void Prefix(object __instance)
			{
				if (ReflectionExtensions.GetActualType(__instance) == typeof(CitizenCreator) && CityConstructor.Instance.generateNew)
				{
					OverrideCitizensToRetired();
				}
			}
		}

		public static void DoPatch(Harmony harmony)
		{
			harmony.PatchAll(typeof(CitizenCreator_SetComplete));
		}

		public static void OverrideCitizensToRetired()
		{
			//IL_00ba: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			bool flag = default(bool);
			for (int num = CityData.Instance.citizenDirectory.Count - 1; num >= 0; num--)
			{
				Citizen val = CityData.Instance.citizenDirectory[num];
				if (!((Actor)val).isHomeless && ((SoCustomComparison)((Human)val).job.preset).presetName == ((SoCustomComparison)CitizenCreator.Instance.unemployedPreset).presetName)
				{
					if (Pies_Generic_PatchPlugin.DebugLogging.Value)
					{
						ManualLogSource log = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Overriding ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Human)val).citizenName);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": From unemployed to retired");
						}
						log.LogInfo(val2);
					}
					Occupation val3 = new Occupation
					{
						preset = CitizenCreator.Instance.retiredPreset,
						employer = null,
						paygrade = 0f
					};
					val3.name = Strings.Get("jobs", ((Object)val3.preset).name, (Casing)0, false, false, false, (Human)null);
					((Human)val).SetJob(val3);
				}
			}
		}
	}
	public class FixGroups
	{
		[HarmonyPatch(typeof(Company), "IsOpenAtDecimalTime")]
		public class Company_IsOpenAtDecimalTime
		{
			public static bool Prefix(ref bool __result, Company __instance, WeekDay day, float hour)
			{
				//IL_000c: 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)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Expected I4, but got Unknown
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Expected I4, but got Unknown
				float x = __instance.preset.workHours.retailOpenHours.x;
				float y = __instance.preset.workHours.retailOpenHours.y;
				if (1 == 0)
				{
				}
				bool flag = (int)day switch
				{
					0 => __instance.preset.workHours.monday, 
					1 => __instance.preset.workHours.tuesday, 
					2 => __instance.preset.workHours.wednesday, 
					3 => __instance.preset.workHours.thursday, 
					4 => __instance.preset.workHours.friday, 
					5 => __instance.preset.workHours.saturday, 
					6 => __instance.preset.workHours.sunday, 
					_ => false, 
				};
				if (1 == 0)
				{
				}
				bool flag2 = flag;
				WeekDay val = (WeekDay)((day + 6) % 7);
				if (1 == 0)
				{
				}
				flag = (int)val switch
				{
					0 => __instance.preset.workHours.monday, 
					1 => __instance.preset.workHours.tuesday, 
					2 => __instance.preset.workHours.wednesday, 
					3 => __instance.preset.workHours.thursday, 
					4 => __instance.preset.workHours.friday, 
					5 => __instance.preset.workHours.saturday, 
					6 => __instance.preset.workHours.sunday, 
					_ => false, 
				};
				if (1 == 0)
				{
				}
				bool flag3 = flag;
				if (x <= y && (!(x < 1f) || !(y > 23f)))
				{
					__result = flag2 && hour >= x && hour <= y;
				}
				else
				{
					bool flag4 = flag2 && hour >= x;
					bool flag5 = flag3 && hour <= y;
					__result = flag4 || flag5;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(GroupsController), "CreateGroups")]
		public class GroupsController_CreateGroups
		{
			public static bool ReadyForGroups;

			public static bool Prefix()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				if (!ReadyForGroups)
				{
					if (Pies_Generic_PatchPlugin.DebugLogging.Value)
					{
						ManualLogSource log = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
						bool flag = default(bool);
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 0, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipping groups");
						}
						log.LogInfo(val);
					}
					return false;
				}
				return true;
			}

			public static void Postfix()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Expected O, but got Unknown
				//IL_029e: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a5: Expected O, but got Unknown
				//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0303: Expected O, but got Unknown
				//IL_035b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0362: Expected O, but got Unknown
				if (!ReadyForGroups)
				{
					return;
				}
				bool flag = default(bool);
				if (Pies_Generic_PatchPlugin.DebugLogging.Value)
				{
					ManualLogSource log = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CreateGroups running");
					}
					log.LogInfo(val);
				}
				HashSet<string> hashSet = new HashSet<string>();
				Enumerator<SocialGroup> enumerator = GroupsController.Instance.groups.GetEnumerator();
				while (enumerator.MoveNext())
				{
					SocialGroup current = enumerator.Current;
					if (current.meetingPlace <= 0)
					{
						continue;
					}
					GroupPreset preset = current.GetPreset();
					NewAddress meetingPlace = current.GetMeetingPlace();
					Enumerator<int> enumerator2 = current.members.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						int current2 = enumerator2.Current;
						Human val2 = CityData.Instance.citizenDictionary[current2];
						((Actor)val2).ai.CreateNewGoal(preset.meetUpGoal, 0f, preset.meetUpLength, (NewNode)null, (Interactable)null, (NewGameLocation)(object)meetingPlace, current, (Murder)null, -2).name = ((Object)preset.meetUpGoal).name + ": " + ((Object)preset).name;
						if (Pies_Generic_PatchPlugin.DebugLogging.Value)
						{
							ManualLogSource log2 = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
							BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Created goal for ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(val2.citizenName);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" - ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(current.preset);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current.id);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
							}
							log2.LogInfo(val);
						}
						if (current.preset == "CheatersMeet")
						{
							hashSet.Add(val2.citizenName);
						}
					}
				}
				HashSet<string> hashSet2 = new HashSet<string>();
				Enumerator<Citizen> enumerator3 = CityData.Instance.citizenDirectory.GetEnumerator();
				while (enumerator3.MoveNext())
				{
					Citizen current3 = enumerator3.Current;
					if ((Object)(object)((Human)current3).paramour == (Object)null || hashSet2.Contains(((Human)current3).citizenName) || hashSet2.Contains(((Human)((Human)current3).paramour).citizenName))
					{
						continue;
					}
					hashSet2.Add(((Human)current3).citizenName);
					hashSet2.Add(((Human)((Human)current3).paramour).citizenName);
					if (Pies_Generic_PatchPlugin.DebugLogging.Value)
					{
						ManualLogSource log3 = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Checking cheaters: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Human)current3).citizenName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" & ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Human)((Human)current3).paramour).citizenName);
						}
						log3.LogInfo(val);
						ManualLogSource log4 = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
						val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\t");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Human)current3).citizenName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has meeting: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(hashSet.Contains(((Human)current3).citizenName));
						}
						log4.LogInfo(val);
						ManualLogSource log5 = PluginController<Pies_Generic_PatchPlugin, IEmptyBindings>.Log;
						val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\t");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Human)((Human)current3).paramour).citizenName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has meeting: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(hashSet.Contains(((Human)((Human)current3).paramour).citizenName));
						}
						log5.LogInfo(val);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Creator), "SetComplete")]
		public class CitizenCreator_SetComplete
		{
			public static void Prefix(object __instance)
			{
				if (ReflectionExtensions.GetActualType(__instance) == typeof(RelationshipCreator) && CityConstructor.Instance.generateNew)
				{
					GroupsController_CreateGroups.ReadyForGroups = true;
					GroupsController.Instance.CreateGroups();
				}
			}
		}

		public static void DoPatch(Harmony harmony)
		{
			harmony.PatchAll(typeof(Company_IsOpenAtDecimalTime));
			harmony.PatchAll(typeof(GroupsController_CreateGroups));
		}
	}
}