Decompiled source of WhiteCollarSideJobs v1.0.0

WhiteCollarSideJobs.dll

Decompiled 4 hours 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 HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SOD.Common.Extensions;
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+76cd74cab15116a3bb93d1bd79352529a2719d18")]
[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")
			{
				List<Human> list = EnumerableExtensions.Select<Occupation, Human>(from.job.employer.companyRoster, (Func<Occupation, Human>)((Occupation occ) => occ.employee)).ToList();
				string seed = $"{treeID}_{from.humanID}";
				to1 = SelectRandomCoworker(list, new List<int> { from.humanID }, new List<string> { "Receptionist" }, ref seed);
				CreateDistractionVmails(from, list, timeStamp, ref seed);
			}
		}

		private static void CreateDistractionVmails(Human perp, List<Human> coworkers, float timeStamp, ref string seed)
		{
			Company employer = perp.job.employer;
			List<string> ineligibleTitles = new List<string> { "Receptionist" };
			List<int> list = new List<int>
			{
				perp.humanID,
				employer.director.humanID
			};
			Toolbox.Instance.NewVmailThread(perp.job.employer.director, perp.job.employer.director, (Human)null, (Human)null, EnumerableExtensions.ToListIl2Cpp<Human>(EnumerableExtensions.Select<Occupation, Human>(perp.job.employer.companyRoster, (Func<Occupation, Human>)((Occupation occupation) => occupation.employee))), "488c7cb9-5229-45fe-b35a-a08f213136ab", timeStamp + Toolbox.Instance.Rand(-48f, -12f, false), 999, (CustomDataSource)0, -1);
			int num = Math.Min(3, (coworkers.Count - list.Count) / 2 - 1);
			for (int i = 0; i < num; i++)
			{
				Human val = SelectRandomCoworker(coworkers, list, ineligibleTitles, ref seed);
				list.Add(val.humanID);
				Human val2 = SelectRandomCoworker(coworkers, list, ineligibleTitles, ref seed);
				list.Add(val2.humanID);
				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, List<string> ineligibleTitles, ref string seed)
		{
			List<Human> list = employees.Where((Human employee) => !ineligibleEmployeeIds.Contains(employee.humanID) && !ineligibleTitles.Contains(((SoCustomComparison)employee.job.preset).presetName)).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 = TypeExtensions.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", 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", 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, 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();
			int psuedoRandomNumberContained = Toolbox.Instance.GetPsuedoRandomNumberContained(0, list.Count, ref seed);
			return list[psuedoRandomNumberContained];
		}
	}
	[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";
	}
}