Decompiled source of EngineerUnlimitedTurrets v1.1.0

plugins/EngineerUnlimitedTurrets/EngineerUnlimitedTurrets.dll

Decompiled a day 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.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("tinymario")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Engineer turret limit scales as max(3, charges)")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+ad04bafb57eafc5687066cb720f999b19fc2c48f")]
[assembly: AssemblyProduct("EngineerUnlimitedTurrets")]
[assembly: AssemblyTitle("EngineerUnlimitedTurrets")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EngineerUnlimitedTurrets
{
	[BepInPlugin("com.tinymario.EngineerUnlimitedTurrets", "EngineerUnlimitedTurrets", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "com.tinymario.EngineerUnlimitedTurrets";

		public const string Name = "EngineerUnlimitedTurrets";

		public const string Version = "1.1.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(CharacterMaster_GetDeployableSameSlotLimit);
			Log.LogInfo((object)"EngineerUnlimitedTurrets 1.1.0 loaded — EngiTurret limit scales as max(3, charges)");
		}

		private int CharacterMaster_GetDeployableSameSlotLimit(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot != 1)
			{
				return orig.Invoke(self, slot);
			}
			int num = 3;
			try
			{
				CharacterBody body = self.GetBody();
				if ((Object)(object)body != (Object)null && (Object)(object)body.skillLocator != (Object)null)
				{
					GenericSkill val = body.skillLocator.specialBonusStockSkill ?? body.skillLocator.special;
					if ((Object)(object)val != (Object)null)
					{
						num = val.maxStock;
					}
					else if ((Object)(object)self.inventory != (Object)null)
					{
						num = 1 + self.inventory.GetItemCount(Items.EquipmentMagazineVoid);
					}
				}
				else if ((Object)(object)self.inventory != (Object)null)
				{
					num = 1 + self.inventory.GetItemCount(Items.EquipmentMagazineVoid);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("turret limit fallback: " + ex.Message));
				num = 3;
			}
			return Mathf.Max(3, num);
		}
	}
}