Decompiled source of Box Of Gears v2.0.0

BoxOfGears.dll

Decompiled 3 months 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 HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.Items;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BoxOfGears1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a07721a95ebe15334a92dd11fd4279a6913bd2d2")]
[assembly: AssemblyProduct("BoxOfGears1")]
[assembly: AssemblyTitle("BoxOfGears1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[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 IEye.BoxOfGears
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("IEye.BoxOfGears", "Box_Of_Gears", "2.0.0")]
	public class BoxOfGearsPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "IEye.BoxOfGears";

		public const string PluginName = "Box_Of_Gears";

		public const string PluginVersion = "2.0.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			BoxOfGearsItem.Init();
		}
	}
	public class BoxOfGearsItem
	{
		private class BoxItemBehavior : BaseItemBodyBehavior
		{
			[ItemDefAssociation]
			private static ItemDef GetItemDef()
			{
				return boxItemDef;
			}

			private void Update()
			{
				((BaseItemBodyBehavior)this).body.RecalculateStats();
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_RecalculateStats <0>__CharacterBody_RecalculateStats;
		}

		public static ItemDef boxItemDef;

		public static void Init()
		{
			//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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			boxItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)boxItemDef).name = "IEYE_GEARBOX_NAME";
			boxItemDef.nameToken = "IEYE_GEARBOX_NAME";
			boxItemDef.pickupToken = "IEYE_GEARBOX_PICKUP";
			boxItemDef.descriptionToken = "IEYE_GEARBOX_DESC";
			boxItemDef.loreToken = "IEYE_GEARBOX_LORE";
			boxItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
			boxItemDef.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			boxItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			boxItemDef.canRemove = false;
			boxItemDef.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(boxItemDef, val));
			object obj = <>O.<0>__CharacterBody_RecalculateStats;
			if (obj == null)
			{
				hook_RecalculateStats val2 = CharacterBody_RecalculateStats;
				<>O.<0>__CharacterBody_RecalculateStats = val2;
				obj = (object)val2;
			}
			CharacterBody.RecalculateStats += (hook_RecalculateStats)obj;
		}

		private static void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			int itemCount = self.inventory.GetItemCount(boxItemDef);
			double num = 1.0 / (double)Time.deltaTime;
			if (itemCount > 0)
			{
				self.moveSpeed *= (float)(num / 30.0) * (float)itemCount;
				self.attackSpeed *= (float)(num / 30.0) * (float)itemCount;
				self.damage *= (float)(num / 30.0) * (float)itemCount;
				self.maxJumpCount *= (int)(num / 30.0) * itemCount;
				self.regen *= (float)(num / 30.0) * (float)itemCount;
				self.armor *= (float)(num / 30.0) * (float)itemCount;
				self.acceleration = ((self.baseMoveSpeed == 0f) ? 0f : (self.moveSpeed / self.baseMoveSpeed * self.baseAcceleration));
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

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