Decompiled source of DaPedroAerialItems v0.0.1

Plugins/AerialItems.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 R2API;
using RoR2;
using RoR2.ExpansionManagement;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AerialItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AerialItems")]
[assembly: AssemblyTitle("AerialItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 AerialItems
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("DaPedro.AerialItems", "AerialItems", "0.0.1")]
	public class AirItems : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TakeDamage <0>__SarmletDamage;

			public static StatHookEventHandler <1>__SolusCoreItem;

			public static hook_FixedUpdate <2>__BrassAir;

			public static hook_RecalculateStats <3>__BrassArmor;

			public static hook_TakeDamageProcess <4>__BrassDmgTaken;

			public static hook_TakeDamage <5>__TitaniumDamage;

			public static StatHookEventHandler <6>__SpongeItem;
		}

		public const string PluginGUID = "DaPedro.AerialItems";

		public const string PluginAuthor = "DaPedro";

		public const string PluginName = "AerialItems";

		public const string PluginVersion = "0.0.1";

		private static ItemDef steelArmlet;

		private static ItemDef solusCore;

		private static ItemDef brassPlating;

		private static ItemDef titaniumCube;

		private static ItemDef pinkSponge;

		public void Awake()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Expected O, but got Unknown
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Expected O, but got Unknown
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Expected O, but got Unknown
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Expected O, but got Unknown
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Expected O, but got Unknown
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Expected O, but got Unknown
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Expected O, but got Unknown
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Expected O, but got Unknown
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Expected O, but got Unknown
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Expected O, but got Unknown
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Expected O, but got Unknown
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Expected O, but got Unknown
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			steelArmlet = ScriptableObject.CreateInstance<ItemDef>();
			solusCore = ScriptableObject.CreateInstance<ItemDef>();
			brassPlating = ScriptableObject.CreateInstance<ItemDef>();
			titaniumCube = ScriptableObject.CreateInstance<ItemDef>();
			pinkSponge = ScriptableObject.CreateInstance<ItemDef>();
			((Object)steelArmlet).name = "SARMLET_NAME";
			steelArmlet.nameToken = "SARMLET_NAME";
			steelArmlet.pickupToken = "SARMLET_PICKUP";
			steelArmlet.descriptionToken = "SARMLET_DESC";
			steelArmlet.loreToken = "SARMLET_LORE";
			steelArmlet.tier = (ItemTier)0;
			steelArmlet._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
			steelArmlet.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)1,
				(ItemTag)31
			};
			steelArmlet.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			steelArmlet.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			((Object)solusCore).name = "SOLUSCORE_NAME";
			solusCore.nameToken = "SOLUSCORE_NAME";
			solusCore.pickupToken = "SOLUSCORE_PICKUP";
			solusCore.descriptionToken = "SOLUSCORE_DESC";
			solusCore.loreToken = "SOLUSCORE_LORE";
			solusCore.tier = (ItemTier)1;
			solusCore._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			ItemDef obj = solusCore;
			ItemTag[] array = new ItemTag[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj.tags = (ItemTag[])(object)array;
			solusCore.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			solusCore.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			((Object)brassPlating).name = "BPLATE_NAME";
			brassPlating.nameToken = "BPLATE_NAME";
			brassPlating.pickupToken = "BPLATE_PICKUP";
			brassPlating.descriptionToken = "BPLATE_DESC";
			brassPlating.loreToken = "BPLATE_LORE";
			brassPlating.tier = (ItemTier)2;
			brassPlating._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
			brassPlating.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)3,
				(ItemTag)31
			};
			brassPlating.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			brassPlating.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			((Object)titaniumCube).name = "TCUBE_NAME";
			titaniumCube.nameToken = "TCUBE_NAME";
			titaniumCube.pickupToken = "TCUBE_PICKUP";
			titaniumCube.descriptionToken = "TCUBE_DESC";
			titaniumCube.loreToken = "TCUBE_LORE";
			titaniumCube.tier = (ItemTier)3;
			titaniumCube._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/LunarTierDef.asset").WaitForCompletion();
			titaniumCube.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)1,
				(ItemTag)5
			};
			titaniumCube.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			titaniumCube.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			((Object)pinkSponge).name = "SPONGE_NAME";
			pinkSponge.nameToken = "SPONGE_NAME";
			pinkSponge.pickupToken = "SPONGE_PICKUP";
			pinkSponge.descriptionToken = "SPONGE_DESC";
			pinkSponge.loreToken = "SPONGE_LORE";
			pinkSponge.tier = (ItemTier)7;
			pinkSponge._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/DLC1/Common/VoidTier2Def.asset").WaitForCompletion();
			pinkSponge.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)2,
				(ItemTag)3
			};
			pinkSponge.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			pinkSponge.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			pinkSponge.requiredExpansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
			RegularToVoid();
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(steelArmlet, val));
			ItemAPI.Add(new CustomItem(solusCore, val));
			ItemAPI.Add(new CustomItem(brassPlating, val));
			ItemAPI.Add(new CustomItem(titaniumCube, val));
			ItemAPI.Add(new CustomItem(pinkSponge, val));
			object obj2 = <>O.<0>__SarmletDamage;
			if (obj2 == null)
			{
				hook_TakeDamage val2 = SarmletDamage;
				<>O.<0>__SarmletDamage = val2;
				obj2 = (object)val2;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj2;
			object obj3 = <>O.<1>__SolusCoreItem;
			if (obj3 == null)
			{
				StatHookEventHandler val3 = SolusCoreItem;
				<>O.<1>__SolusCoreItem = val3;
				obj3 = (object)val3;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj3;
			object obj4 = <>O.<2>__BrassAir;
			if (obj4 == null)
			{
				hook_FixedUpdate val4 = BrassAir;
				<>O.<2>__BrassAir = val4;
				obj4 = (object)val4;
			}
			CharacterBody.FixedUpdate += (hook_FixedUpdate)obj4;
			object obj5 = <>O.<3>__BrassArmor;
			if (obj5 == null)
			{
				hook_RecalculateStats val5 = BrassArmor;
				<>O.<3>__BrassArmor = val5;
				obj5 = (object)val5;
			}
			CharacterBody.RecalculateStats += (hook_RecalculateStats)obj5;
			object obj6 = <>O.<4>__BrassDmgTaken;
			if (obj6 == null)
			{
				hook_TakeDamageProcess val6 = BrassDmgTaken;
				<>O.<4>__BrassDmgTaken = val6;
				obj6 = (object)val6;
			}
			HealthComponent.TakeDamageProcess += (hook_TakeDamageProcess)obj6;
			object obj7 = <>O.<5>__TitaniumDamage;
			if (obj7 == null)
			{
				hook_TakeDamage val7 = TitaniumDamage;
				<>O.<5>__TitaniumDamage = val7;
				obj7 = (object)val7;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj7;
			object obj8 = <>O.<6>__SpongeItem;
			if (obj8 == null)
			{
				StatHookEventHandler val8 = SpongeItem;
				<>O.<6>__SpongeItem = val8;
				obj8 = (object)val8;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj8;
		}

		private void RegularToVoid()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			ItemRelationshipProvider val = ScriptableObject.CreateInstance<ItemRelationshipProvider>();
			val.relationshipType = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion();
			val.relationships = (Pair[])(object)new Pair[1]
			{
				new Pair
				{
					itemDef1 = solusCore,
					itemDef2 = pinkSponge
				}
			};
			ContentAddition.AddItemRelationshipProvider(val);
		}

		private static void SarmletDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			CharacterBody val = (Object.op_Implicit((Object)(object)damageInfo.attacker) ? damageInfo.attacker.GetComponent<CharacterBody>() : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.inventory != (Object)null && (Object)(object)val.characterMotor != (Object)null)
			{
				int itemCount = val.inventory.GetItemCount(steelArmlet);
				if (itemCount > 0 && !val.characterMotor.isGrounded)
				{
					float num = 0.13f + 0.5f * (((float)itemCount - 1f) / (float)itemCount);
					damageInfo.damage *= 1f + num;
				}
			}
			orig.Invoke(self, damageInfo);
		}

		private static void SolusCoreItem(CharacterBody body, StatHookEventArgs args)
		{
			if (!Object.op_Implicit((Object)(object)body.inventory))
			{
				return;
			}
			int itemCount = body.inventory.GetItemCount(solusCore);
			if (itemCount > 0)
			{
				args.jumpCountAdd++;
				if (Object.op_Implicit((Object)(object)body.characterMotor) && !body.characterMotor.isGrounded)
				{
					args.baseRegenAdd += 4f + 2f * (float)(itemCount - 1);
				}
			}
		}

		private static void BrassAir(orig_FixedUpdate orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)self.inventory))
			{
				int itemCount = self.inventory.GetItemCount(brassPlating);
				if (itemCount > 0)
				{
					bool flag = Object.op_Implicit((Object)(object)self.characterMotor) && !self.characterMotor.isGrounded;
					self.statsDirty = true;
				}
			}
		}

		private static void BrassArmor(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)self.inventory))
			{
				int itemCount = self.inventory.GetItemCount(brassPlating);
				if (itemCount > 0 && Object.op_Implicit((Object)(object)self.characterMotor) && !self.characterMotor.isGrounded)
				{
					self.armor += 125f + 25f * (((float)itemCount - 1f) / (float)itemCount);
				}
			}
		}

		private static void BrassDmgTaken(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo)
		{
			CharacterBody body = self.body;
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inventory))
			{
				int itemCount = body.inventory.GetItemCount(brassPlating);
				if (itemCount > 0 && Object.op_Implicit((Object)(object)body.characterMotor) && !body.characterMotor.isGrounded)
				{
					damageInfo.damage *= 0.7f;
				}
			}
			orig.Invoke(self, damageInfo);
		}

		private static void TitaniumDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			CharacterBody val = (Object.op_Implicit((Object)(object)damageInfo.attacker) ? damageInfo.attacker.GetComponent<CharacterBody>() : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.inventory != (Object)null && (Object)(object)val.characterMotor != (Object)null)
			{
				int itemCount = val.inventory.GetItemCount(titaniumCube);
				if (itemCount > 0)
				{
					if (val.characterMotor.isGrounded)
					{
						float num = 0.35f + 0.1f * (float)(itemCount - 1) / (1f + 0.1f * (float)(itemCount - 1));
						damageInfo.damage *= 1f + num;
					}
					else
					{
						float num2 = 0.45f + 0.15f * (float)(itemCount - 1) / (1f + 0.15f * (float)(itemCount - 1));
						damageInfo.damage *= Mathf.Max(0.01f, 1f - num2);
					}
				}
			}
			orig.Invoke(self, damageInfo);
		}

		public static void SpongeItem(CharacterBody sender, StatHookEventArgs args)
		{
			int itemCount = sender.inventory.GetItemCount(pinkSponge);
			if (itemCount > 0)
			{
				args.jumpCountAdd++;
				if ((Object)(object)sender.healthComponent != (Object)null && sender.healthComponent.shield > 0f)
				{
					args.baseJumpPowerAdd += sender.baseJumpPower * 0.2f + (0.5f * (float)itemCount - 1f);
				}
				float num = 0.1f + 0.05f * (float)(itemCount - 1);
				args.baseShieldAdd += sender.maxHealth * num;
			}
		}
	}
	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);
		}
	}
}