Decompiled source of Captain Lysate Fix v1.0.1

LysateBeacons.dll

Decompiled 2 months 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.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Utils;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LysateBeacons")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cdbdfa5ce0bddd8135a7eac9a9792b889f8b2538")]
[assembly: AssemblyProduct("LysateBeacons")]
[assembly: AssemblyTitle("LysateBeacons")]
[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 LysateBeacons
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("zombieseatflesh7.LysateBeacons", "LysateBeacons", "1.0.1")]
	public class LysateBeacons : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Stage> <0>__OnServerStageBegin;

			public static hook_FixedUpdate <1>__CaptainSupplyDropController_FixedUpdate;
		}

		public const string PluginGUID = "zombieseatflesh7.LysateBeacons";

		public const string PluginAuthor = "zombieseatflesh7";

		public const string PluginName = "LysateBeacons";

		public const string PluginVersion = "1.0.1";

		public static Dictionary<CaptainSupplyDropController, StockData> beaconStocks;

		public void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			Stage.onServerStageBegin += OnServerStageBegin;
			object obj = <>O.<1>__CaptainSupplyDropController_FixedUpdate;
			if (obj == null)
			{
				hook_FixedUpdate val = CaptainSupplyDropController_FixedUpdate;
				<>O.<1>__CaptainSupplyDropController_FixedUpdate = val;
				obj = (object)val;
			}
			CaptainSupplyDropController.FixedUpdate += (hook_FixedUpdate)obj;
		}

		private static void OnServerStageBegin(Stage stage)
		{
			beaconStocks = new Dictionary<CaptainSupplyDropController, StockData>();
		}

		private static void CaptainSupplyDropController_FixedUpdate(orig_FixedUpdate orig, CaptainSupplyDropController self)
		{
			StockData stockData = null;
			if (!beaconStocks.ContainsKey(self))
			{
				stockData = new StockData();
				stockData.lysateStacks = Reflection.GetFieldValue<CharacterBody>((object)self, "characterBody").inventory.GetItemCount(Items.EquipmentMagazineVoid);
				stockData.extraStocks = stockData.lysateStacks;
				beaconStocks.Add(self, stockData);
				orig.Invoke(self);
			}
			stockData = beaconStocks[self];
			int num = Reflection.GetFieldValue<CharacterBody>((object)self, "characterBody").inventory.GetItemCount(Items.EquipmentMagazineVoid) - stockData.lysateStacks;
			if (num != 0)
			{
				stockData.lysateStacks += num;
				stockData.extraStocks += num;
			}
			if (stockData.extraStocks > 0 && self.supplyDrop1Skill.stock == 0)
			{
				self.supplyDrop1Skill.AddOneStock();
				stockData.extraStocks--;
			}
			if (stockData.extraStocks > 0 && self.supplyDrop2Skill.stock == 0)
			{
				self.supplyDrop2Skill.AddOneStock();
				stockData.extraStocks--;
			}
			if (stockData.extraStocks < 0 && self.supplyDrop2Skill.stock > 0)
			{
				self.supplyDrop2Skill.RemoveAllStocks();
				stockData.extraStocks++;
			}
			if (stockData.extraStocks < 0 && self.supplyDrop1Skill.stock > 0)
			{
				self.supplyDrop1Skill.RemoveAllStocks();
				stockData.extraStocks++;
			}
			orig.Invoke(self);
		}
	}
	public class StockData
	{
		public int lysateStacks = 0;

		public int extraStocks = 0;
	}
}