Decompiled source of WhiteCollarSideJobs v1.0.4

WhiteCollarSideJobs.dll

Decompiled a month 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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CommunityCaseLoader;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
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("WhiteCollarSideJobs")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Adds WASD controlls to the case board")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ed4ce69a58d430953604554204c40d6463720ce1")]
[assembly: AssemblyProduct("WhiteCollarSideJobs")]
[assembly: AssemblyTitle("WhiteCollarSideJobs")]
[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 WhiteCollarSideJobs
{
	[BepInPlugin("WhiteCollarSideJobs", "WhiteCollarSideJobs", "1.0.0")]
	public class WhiteCollarSideJobs : BasePlugin
	{
		public static ManualLogSource PluginLogger;

		public static Dictionary<int, WhiteCollarVMailThreadData> threadData = new Dictionary<int, WhiteCollarVMailThreadData>();

		public const string VMailID_Guilty_JobPreset_SideJobFinanceInvestigatorOffice = "ad52f2e8-a66e-4670-a1e4-07f7f138279d";

		public const string VMailID_NotGuilty_JobPreset_SideJobFinanceInvestigatorOffice = "fb7c0f68-0dad-497f-90ec-534fa1678788";

		public const string VMailID_BossReminder_JobPreset_SideJobFinanceInvestigatorOffice = "488c7cb9-5229-45fe-b35a-a08f213136ab";

		public override void Load()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			PluginLogger = ((BasePlugin)this).Log;
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("WhiteCollarSideJobs");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			Harmony val2 = new Harmony("WhiteCollarSideJobs");
			val2.PatchAll();
			ManualLogSource log2 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("WhiteCollarSideJobs");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched and has injected types!");
			}
			log2.LogInfo(val);
		}
	}
	[HarmonyPatch]
	public class Toolbox_NewVmailThread
	{
		[HarmonyTargetMethod]
		internal static MethodBase CalculateMethod()
		{
			return (from mi in typeof(Toolbox).GetMethods()
				where mi.Name == "NewVmailThread" && mi.GetParameters().Length == 10
				select mi).First();
		}

		public static void Prefix(MessageThreadSave __result, Human from, ref Human to1, string treeID, ref float timeStamp, int progress)
		{
			if (treeID == "ad52f2e8-a66e-4670-a1e4-07f7f138279d")
			{
				string seed = $"{treeID}_{from.humanID}";
				CreateVMails_JobPreset_SideJobFinanceInvestigatorOffice(from, ref to1, timeStamp, ref seed);
			}
		}

		private static void CreateVMails_JobPreset_SideJobFinanceInvestigatorOffice(Human perp, ref Human to1, float timeStamp, ref string seed)
		{
			List<Human> list = (from employee in EnumerableExtensions.Select<Occupation, Human>(perp.job.employer.companyRoster, (Func<Occupation, Human>)((Occupation occ) => occ.employee))
				where (Object)(object)employee != (Object)null
				select employee).ToList();
			Company employer = perp.job.employer;
			List<int> list2 = new List<int> { perp.humanID };
			if (list.Count > 3 && (Object)(object)employer.director != (Object)null)
			{
				list2.Add(employer.director.humanID);
			}
			if (list.Count > 4 && (Object)(object)employer.receptionist != (Object)null)
			{
				list2.Add(employer.receptionist.humanID);
			}
			to1 = SelectRandomCoworker(list, list2, ref seed);
			Toolbox.Instance.NewVmailThread(perp.job.employer.director, perp.job.employer.director, (Human)null, (Human)null, EnumerableExtensions.ToListIl2Cpp<Human>((IEnumerable<Human>)list), "488c7cb9-5229-45fe-b35a-a08f213136ab", timeStamp + Toolbox.Instance.Rand(-48f, -12f, false), 999, (CustomDataSource)0, -1);
			int num = list.Count - list2.Count;
			int num2 = 0;
			num2 = Mathf.FloorToInt((float)(num / 2));
			for (int i = 0; i < num2; i++)
			{
				Human val = SelectRandomCoworker(list, list2, ref seed);
				list2.Add(val.humanID);
				Human val2 = SelectRandomCoworker(list, list2, ref seed);
				Toolbox.Instance.NewVmailThread(val, val2, (Human)null, (Human)null, (List<Human>)null, "fb7c0f68-0dad-497f-90ec-534fa1678788", timeStamp + Toolbox.Instance.Rand(-36f, 36f, false), 999, (CustomDataSource)0, -1);
			}
		}

		private static Human SelectRandomCoworker(List<Human> employees, List<int> ineligibleEmployeeIds, ref string seed)
		{
			List<Human> list = employees.Where((Human employee) => !ineligibleEmployeeIds.Contains(employee.humanID)).ToList();
			int psuedoRandomNumberContained = Toolbox.Instance.GetPsuedoRandomNumberContained(0, list.Count, ref seed);
			return list[psuedoRandomNumberContained];
		}
	}
	[HarmonyPatch(typeof(Strings), "GetContainedValue")]
	public class Strings_GetContainedValue
	{
		public static bool Prefix(ref string __result, string withinScope, string newValue, object baseObject)
		{
			if (newValue.StartsWith("custom_pie_whitecollar_") && ReflectionExtensions.GetActualType(baseObject).Name == "VmailParsingData")
			{
				MessageThreadSave thread = ReflectionExtensions.TryCast<VmailParsingData>(baseObject).thread;
				int threadID = thread.threadID;
				bool flag = thread.treeID == "ad52f2e8-a66e-4670-a1e4-07f7f138279d";
				string seed = $"{threadID}_{thread.recievers[0]}_{newValue}";
				if (!WhiteCollarSideJobs.threadData.TryGetValue(threadID, out var value))
				{
					value = ((!flag) ? new WhiteCollarVMailThreadData
					{
						generatedInvoiceNumber = Toolbox.Instance.GetPsuedoRandomNumberContained(10000, 99999, ref seed),
						generatedInvoiceCost = Toolbox.Instance.GetPsuedoRandomNumberContained(1000, 9999, ref seed),
						generatedInvoicePayeeName = SelectRandomCompanyOfPreset("MediumOffice", fallbackIsIllegal: false, ref seed, CityData.Instance.citizenDictionary[thread.recievers[0]].job.employer.companyID).name
					} : new WhiteCollarVMailThreadData
					{
						generatedInvoiceNumber = Toolbox.Instance.GetPsuedoRandomNumberContained(1000, 9999, ref seed),
						generatedInvoiceCost = Toolbox.Instance.GetPsuedoRandomNumberContained(500, 2500, ref seed),
						generatedInvoicePayeeName = SelectRandomCompanyOfPreset("LoanShark", fallbackIsIllegal: true, ref seed, CityData.Instance.citizenDictionary[thread.recievers[0]].job.employer.companyID).name
					});
				}
				switch (newValue)
				{
				case "custom_pie_whitecollar_invoicenumber":
					__result = value.generatedInvoiceNumber.ToString() ?? "";
					return false;
				case "custom_pie_whitecollar_invoicecost":
					__result = value.generatedInvoiceCost.ToString() ?? "";
					return false;
				case "custom_pie_whitecollar_payee":
					__result = value.generatedInvoicePayeeName;
					return false;
				case "custom_pie_whitecollar_invoicelength":
					__result = "five";
					return false;
				}
			}
			return true;
		}

		private static Company SelectRandomCompanyOfPreset(string presetName, bool fallbackIsIllegal, ref string seed, int notThisCompanyId = -1)
		{
			List<Company> list = EnumerableExtensions.Where<Company>(CityData.Instance.companyDirectory, (Func<Company, bool>)((Company company) => ((SoCustomComparison)company.preset).presetName == presetName && company.companyID != notThisCompanyId)).ToList();
			if (list.Count == 0)
			{
				list = EnumerableExtensions.Where<Company>(CityData.Instance.companyDirectory, (Func<Company, bool>)((Company company) => company.preset.isIllegal == fallbackIsIllegal && company.companyID != notThisCompanyId)).ToList();
			}
			int psuedoRandomNumberContained = Toolbox.Instance.GetPsuedoRandomNumberContained(0, list.Count - 1, ref seed);
			return list[psuedoRandomNumberContained];
		}
	}
	[HarmonyPatch(typeof(SideJob), "SpawnJobItem")]
	public class SideJob_SpawnJobItem
	{
		public static bool Prefix(SideJob __instance, ref InteractablePreset spawnItem)
		{
			if (((SoCustomComparison)spawnItem).presetName == "FAKE_DodgySalesRecord")
			{
				CommunityCaseLoaderPlugin.PluginLogger.LogInfo((object)"Found the dodgy sales record item to spawn");
				spawnItem = Toolbox.Instance.GetInteractablePreset("CheatersPoem");
				__instance.purp.job.employer.AddSalesRecord(__instance.purp, spawnItem, SessionData.Instance.gameTime);
				CommunityCaseLoaderPlugin.PluginLogger.LogInfo((object)"Replaced with note, added sales record");
				return true;
			}
			return true;
		}
	}
	[Serializable]
	public class WhiteCollarVMailThreadData
	{
		public int threadID;

		public int generatedInvoiceNumber;

		public int generatedInvoiceCost;

		public string generatedInvoicePayeeName;
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WhiteCollarSideJobs";

		public const string PLUGIN_NAME = "WhiteCollarSideJobs";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}