Decompiled source of LethalMonReservedSlot v1.0.0

LethalMonReservedSlot.dll

Decompiled 3 weeks 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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ReservedItemSlotCore;
using ReservedItemSlotCore.Data;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalMonReservedSlot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Reserved item slot addon for LethalMon")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0a66ba63683fe400d5537e1e7907f958493fc57f")]
[assembly: AssemblyProduct("LethalMonReservedSlot")]
[assembly: AssemblyTitle("LethalMonReservedSlot")]
[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 LethalMonReservedSlot
{
	public sealed class Config
	{
		private static Config instance;

		public ConfigEntry<int> UnlockPrice { get; set; }

		public ConfigEntry<int> SlotPriority { get; set; }

		public ConfigEntry<PlayerBone> AttachTo { get; set; }

		public static Config Instance
		{
			get
			{
				if (instance == null)
				{
					instance = new Config();
				}
				return instance;
			}
		}

		public void Setup()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			UnlockPrice = Plugin.BepInExConfig().Bind<int>("General", "UnlockPrice", 50, new ConfigDescription("Cost of unlocking this slot (0 = unlocked at start).", (AcceptableValueBase)null, Array.Empty<object>()));
			SlotPriority = Plugin.BepInExConfig().Bind<int>("General", "SlotPriority", 20, new ConfigDescription("Priority for this item slot relative to other item slots.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			AttachTo = Plugin.BepInExConfig().Bind<PlayerBone>("General", "AttachTo", (PlayerBone)11, new ConfigDescription("Defines where the player holds the ball from other players point of view. (Restart required for now)", (AcceptableValueBase)null, Array.Empty<object>()));
			UnlockPrice.SettingChanged += delegate
			{
				Plugin.UnlockPriceChanged();
			};
			SlotPriority.SettingChanged += delegate
			{
				Plugin.SlotPriorityChanged();
			};
			AttachTo.SettingChanged += delegate
			{
				Plugin.AttachToChanged();
			};
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Niro.LethalMonReservedSlot", "LethalMonReservedSlot", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ReservedItemSlotCoreName = "FlipMods.ReservedItemSlotCore";

		public const string LethalMonName = "Feiryn.LethalMon";

		public const string modGUID = "Niro.LethalMonReservedSlot";

		public const string modName = "LethalMonReservedSlot";

		public const string modVersion = "1.0.0";

		private static readonly Vector3 BallRotationOffset = new Vector3(90f, 0f, 0f);

		private static readonly Vector3 BallPositionOffset = new Vector3(0.2f, 0.25f, 0f);

		private readonly Harmony harmony = new Harmony("Niro.LethalMonReservedSlot");

		private static Plugin instance;

		internal static ManualLogSource mls;

		public static ReservedItemSlotData pokeballSlotData = null;

		public static ReservedItemData pokeballData;

		public static ReservedItemData greatballData;

		public static ReservedItemData ultraballData;

		public static ReservedItemData masterballData;

		public static ConfigFile BepInExConfig()
		{
			return ((BaseUnityPlugin)instance).Config;
		}

		public void Awake()
		{
			if (instance == null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Niro.LethalMonReservedSlot");
			Config.Instance.Setup();
			if (Chainloader.PluginInfos.ContainsKey("FlipMods.ReservedItemSlotCore"))
			{
				CreateReservedItemSlots();
			}
			mls.LogMessage((object)"Plugin LethalMonReservedSlot loaded!");
		}

		private void CreateReservedItemSlots()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			pokeballSlotData = ReservedItemSlotData.CreateReservedItemSlotData("PokeballSlot", Config.Instance.SlotPriority.Value, Config.Instance.UnlockPrice.Value);
			if (Config.Instance.UnlockPrice.Value == 0)
			{
				UnlockItemSlot();
			}
			pokeballData = pokeballSlotData.AddItemToReservedItemSlot(new ReservedItemData("Pokeball", Config.Instance.AttachTo.Value, BallPositionOffset, BallRotationOffset));
			greatballData = pokeballSlotData.AddItemToReservedItemSlot(new ReservedItemData("Great Ball", Config.Instance.AttachTo.Value, BallPositionOffset, BallRotationOffset));
			ultraballData = pokeballSlotData.AddItemToReservedItemSlot(new ReservedItemData("Ultra Ball", Config.Instance.AttachTo.Value, BallPositionOffset, BallRotationOffset));
			masterballData = pokeballSlotData.AddItemToReservedItemSlot(new ReservedItemData("Master Ball", Config.Instance.AttachTo.Value, BallPositionOffset, BallRotationOffset));
		}

		internal static void AttachToChanged()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (pokeballSlotData != null)
			{
				pokeballData.holsteredParentBone = Config.Instance.AttachTo.Value;
				greatballData.holsteredParentBone = Config.Instance.AttachTo.Value;
				ultraballData.holsteredParentBone = Config.Instance.AttachTo.Value;
				masterballData.holsteredParentBone = Config.Instance.AttachTo.Value;
			}
		}

		internal static void SlotPriorityChanged()
		{
			if (pokeballSlotData != null)
			{
				pokeballSlotData.slotPriority = Config.Instance.SlotPriority.Value;
			}
		}

		internal static void UnlockPriceChanged()
		{
			if (pokeballSlotData != null)
			{
				int value = Config.Instance.UnlockPrice.Value;
				if (value <= 0)
				{
					UnlockItemSlot();
				}
				else
				{
					pokeballSlotData.purchasePrice = value;
				}
			}
		}

		internal static void UnlockItemSlot()
		{
			SessionManager.UnlockReservedItemSlot(pokeballSlotData);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}