Decompiled source of StationLockProliferator v1.0.0

StationLockProliferator.dll

Decompiled a month ago
using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 StationLockProliferator
{
	[BepInPlugin("com.lll.stationlockproliferator", "StationLockProliferator", "1.0.0")]
	public class StationLockProliferatorPlugin : BaseUnityPlugin
	{
		public const string GUID = "com.lll.stationlockproliferator";

		public const string NAME = "StationLockProliferator";

		public const string VERSION = "1.0.0";

		public static ConfigEntry<float> ProliferatorPoints;

		public static ConfigEntry<bool> EnableCustomProliferator;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			EnableCustomProliferator = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableCustomProliferator", true, "Enable custom proliferator points when using station lock mode");
			ProliferatorPoints = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ProliferatorPoints", 4f, new ConfigDescription("Proliferator points per item when locking station storage (MK1=1, MK2=2, MK3=4)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			_harmony = new Harmony("com.lll.stationlockproliferator");
			_harmony.PatchAll(typeof(StationLockPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"StationLockProliferator 1.0.0 loaded!");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch]
	public static class StationLockPatch
	{
		[HarmonyPatch(typeof(UIStationStorage), "OnKeepModeButtonClick")]
		[HarmonyPostfix]
		public static void OnKeepModeButtonClick_Postfix(UIStationStorage __instance)
		{
			if (StationLockProliferatorPlugin.EnableCustomProliferator.Value && __instance.station != null && __instance.index < __instance.station.storage.Length)
			{
				ref StationStore reference = ref __instance.station.storage[__instance.index];
				if (reference.keepMode > 0 && reference.keepMode <= 2)
				{
					reference.keepIncRatio = StationLockProliferatorPlugin.ProliferatorPoints.Value;
				}
			}
		}

		[HarmonyPatch(typeof(UIControlPanelStationStorage), "OnKeepModeButtonClick")]
		[HarmonyPostfix]
		public static void OnKeepModeButtonClick_ControlPanel_Postfix(UIControlPanelStationStorage __instance)
		{
			if (StationLockProliferatorPlugin.EnableCustomProliferator.Value && __instance.station != null && __instance.index < __instance.station.storage.Length)
			{
				ref StationStore reference = ref __instance.station.storage[__instance.index];
				if (reference.keepMode > 0 && reference.keepMode <= 2)
				{
					reference.keepIncRatio = StationLockProliferatorPlugin.ProliferatorPoints.Value;
				}
			}
		}
	}
}