Decompiled source of CruncherListFix v1.0.0

CruncherListFix.dll

Decompiled 3 days 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 BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CruncherListFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CruncherListFix")]
[assembly: AssemblyTitle("CruncherListFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 CruncherListFix
{
	public static class ListFix
	{
		[HarmonyPatch(typeof(VMailApp), "OnSetup")]
		public static class MailScope
		{
			[HarmonyPrefix]
			public static void Prefix()
			{
				_buildingList = true;
			}

			[HarmonyFinalizer]
			public static void Finalizer()
			{
				_buildingList = false;
			}
		}

		[HarmonyPatch(typeof(ComputerLogin), "OnSetup")]
		public static class LoginScope
		{
			[HarmonyPrefix]
			public static void Prefix()
			{
				_buildingList = true;
			}

			[HarmonyFinalizer]
			public static void Finalizer()
			{
				_buildingList = false;
			}
		}

		[HarmonyPatch(typeof(ComputerOSMultiSelect), "SpawnList")]
		public static class Spawn
		{
			[HarmonyPrefix]
			public static void Prefix(out List<NewAddress>? __state)
			{
				__state = null;
				if (!_buildingList)
				{
					return;
				}
				Player instance = Player.Instance;
				List<NewAddress> val = ((instance != null) ? instance.apartmentsOwned : null);
				if (val != null && val.Count != 0)
				{
					List<NewAddress> list = new List<NewAddress>();
					Enumerator<NewAddress> enumerator = val.GetEnumerator();
					while (enumerator.MoveNext())
					{
						NewAddress current = enumerator.Current;
						list.Add(current);
					}
					val.Clear();
					__state = list;
				}
			}

			[HarmonyPostfix]
			public static void Postfix(List<NewAddress>? __state)
			{
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Expected O, but got Unknown
				if (__state == null)
				{
					return;
				}
				Player instance = Player.Instance;
				List<NewAddress> val = ((instance != null) ? instance.apartmentsOwned : null);
				if (val == null)
				{
					return;
				}
				val.Clear();
				foreach (NewAddress item in __state)
				{
					val.Add(item);
				}
				if (Plugin.Cfg.DebugLogging.Value)
				{
					ManualLogSource log = Plugin.Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("kept the list whole, restored ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(__state.Count);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" owned apartments");
					}
					log.LogInfo(val2);
				}
			}
		}

		private static bool _buildingList;
	}
	[BepInPlugin("ekem.cruncherlistfix", "Cruncher List Fix", "1.0.0")]
	public class Plugin : BasePlugin
	{
		public static ManualLogSource Log { get; private set; }

		public static Settings Cfg { get; private set; }

		public override void Load()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			Cfg = new Settings(((BasePlugin)this).Config);
			new Harmony("ekem.cruncherlistfix").PatchAll();
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(9, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Cruncher List Fix");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded.");
			}
			log.LogInfo(val);
		}
	}
	public class Settings
	{
		public readonly ConfigEntry<bool> DebugLogging;

		public Settings(ConfigFile config)
		{
			DebugLogging = config.Bind<bool>("Debug", "DebugLogging", false, "Log each time a list on your own cruncher is protected from being cut down.");
		}
	}
	public static class PluginInfo
	{
		public const string Guid = "ekem.cruncherlistfix";

		public const string Name = "Cruncher List Fix";

		public const string Version = "1.0.0";
	}
}