Decompiled source of DoomslugItemMod v1.2.2

DoomslugItemMod.dll

Decompiled 6 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExamplePlugin.Items;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Projectile;
using R2API;
using RoR2;
using RoR2.Projectile;
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("DoomslugItemMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5918cd2ad870f50ba9e34be98f694bbf447c74f0")]
[assembly: AssemblyProduct("DoomslugItemMod")]
[assembly: AssemblyTitle("DoomslugItemMod")]
[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 ExamplePlugin
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Doomslug.Test", "Test", "1.0.0")]
	public class Initialize : BaseUnityPlugin
	{
		public const string PluginGUID = "Doomslug.Test";

		public const string PluginAuthor = "Doomslug";

		public const string PluginName = "Test";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "doomslugbundle"));
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Error("AssetBundle failed to load!");
			}
			MicrobialBullets.Init(val);
			Biomissles.Init(val);
			SourSaltShaker.Init(val);
		}

		private void Update()
		{
			MicrobialBullets.Update();
			Biomissles.Update();
			SourSaltShaker.Update();
		}
	}
	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);
		}
	}
}
namespace ExamplePlugin.Items
{
	public class BiomisslesMarker : MonoBehaviour
	{
	}
	public class Biomissles
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnHitEnemy <0>__GlobalEventManager_OnHitEnemy;

			public static hook_Awake <1>__ProjectileController_Awake;

			public static StatHookEventHandler <2>__RecalculateStats;
		}

		public static string IconName = "Placeholder_Icon";

		public static ItemDef ItemDef;

		public static ModdedProcType BiomisslesProcType;

		private static bool isFiringBiomissle = false;

		private static GameObject missilePrefab;

		public static void Init(AssetBundle bundle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			BiomisslesProcType = ProcTypeAPI.ReserveProcType();
			if (!Object.op_Implicit((Object)(object)bundle))
			{
				Log.Error("AssetBundle failed to load!");
			}
			CreateItem(bundle);
			AddHooks();
		}

		private static void CreateItem(AssetBundle bundle)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			ItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)ItemDef).name = "DOOMSLUG_BIOMISSLES";
			ItemDef.nameToken = "DOOMSLUG_BIOMISSLES_NAME";
			ItemDef.pickupToken = "DOOMSLUG_BIOMISSLES_PICKUP";
			ItemDef.descriptionToken = "DOOMSLUG_BIOMISSLES_DESC";
			ItemDef.loreToken = "DOOMSLUG_BIOMISSLES_DESC_LORE";
			LanguageAPI.Add("DOOMSLUG_BIOMISSLES_NAME", "Biomissles");
			LanguageAPI.Add("DOOMSLUG_BIOMISSLES_PICKUP", "Fire missles on crit");
			LanguageAPI.Add("DOOMSLUG_BIOMISSLES_DESC", "On crit fire 5 (+5 per stack) missles that deal 20% Total Damage");
			ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
			ItemDef.pickupIconSprite = bundle.LoadAsset<Sprite>(IconName);
			ItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			ItemDef.canRemove = true;
			ItemDef.hidden = false;
			missilePrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/MissileProjectile.prefab").WaitForCompletion();
			if (!Object.op_Implicit((Object)(object)missilePrefab))
			{
				Log.Error("Biomissles: missile prefab failed to load!");
			}
			else
			{
				Log.Info("Biomissles: missile prefab loaded successfully!");
			}
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(ItemDef, val));
		}

		private static void AddHooks()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//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
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>O.<0>__GlobalEventManager_OnHitEnemy;
			if (obj == null)
			{
				hook_OnHitEnemy val = GlobalEventManager_OnHitEnemy;
				<>O.<0>__GlobalEventManager_OnHitEnemy = val;
				obj = (object)val;
			}
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj;
			object obj2 = <>O.<1>__ProjectileController_Awake;
			if (obj2 == null)
			{
				hook_Awake val2 = ProjectileController_Awake;
				<>O.<1>__ProjectileController_Awake = val2;
				obj2 = (object)val2;
			}
			ProjectileController.Awake += (hook_Awake)obj2;
			object obj3 = <>O.<2>__RecalculateStats;
			if (obj3 == null)
			{
				StatHookEventHandler val3 = RecalculateStats;
				<>O.<2>__RecalculateStats = val3;
				obj3 = (object)val3;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj3;
		}

		private static void ProjectileController_Awake(orig_Awake orig, ProjectileController self)
		{
			orig.Invoke(self);
			if (isFiringBiomissle)
			{
				self.procCoefficient = 0.2f;
			}
		}

		private static void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_005f: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damageInfo, victim);
			if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				return;
			}
			CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.inventory))
			{
				return;
			}
			int itemCount = component.inventory.GetItemCount(ItemDef.itemIndex);
			if (itemCount <= 0 || ProcTypeAPI.HasModdedProc(damageInfo.procChainMask, BiomisslesProcType) || !damageInfo.crit || damageInfo.procCoefficient == 0f)
			{
				return;
			}
			CharacterBody component2 = victim.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)component2.healthComponent))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)missilePrefab))
			{
				Log.Error("Biomissles: missile prefab is null, cannot fire!");
				return;
			}
			Log.Info("Biomissles proc fired!");
			ProcTypeAPI.AddModdedProc(ref damageInfo.procChainMask, BiomisslesProcType);
			int num = 3 * itemCount;
			HurtBox mainHurtBox = component2.mainHurtBox;
			Collider val = ((mainHurtBox != null) ? mainHurtBox.collider : null);
			float num2 = 0f;
			if ((Object)(object)val != (Object)null)
			{
				Bounds bounds = val.bounds;
				num2 = Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z);
			}
			Vector3 position = component2.corePosition + Vector3.up * (1.5f * num2 + 1f);
			isFiringBiomissle = true;
			for (int i = 0; i < num; i++)
			{
				Vector3 val2 = Util.ApplySpread(Vector3.up, 0f, 20f, 1f, 1f, 0f, 0f);
				FireProjectileInfo val3 = default(FireProjectileInfo);
				val3.projectilePrefab = missilePrefab;
				val3.position = position;
				val3.rotation = Util.QuaternionSafeLookRotation(val2);
				val3.owner = ((Component)component).gameObject;
				val3.damage = damageInfo.damage * 0.2f;
				val3.force = 0f;
				val3.crit = damageInfo.crit;
				val3.damageColorIndex = (DamageColorIndex)3;
				val3.procChainMask = damageInfo.procChainMask;
				FireProjectileInfo val4 = val3;
				ProjectileManager.instance.FireProjectile(val4);
			}
			isFiringBiomissle = false;
		}

		private static void RecalculateStats(CharacterBody body, StatHookEventArgs args)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body.inventory))
			{
				int itemCount = body.inventory.GetItemCount(ItemDef.itemIndex);
				if (itemCount > 0)
				{
					args.critAdd += 5f;
				}
			}
		}

		public static void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)285))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed F4. Spawning our Biomissles at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(ItemDef.itemIndex), transform.position, transform.forward * 20f);
			}
		}
	}
	public class MicrobialBulletsMarker : MonoBehaviour
	{
	}
	public class MicrobialBullets
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnHitEnemy <0>__GlobalEventManager_OnHitEnemy;

			public static hook_Awake <1>__DelayBlast_Awake;

			public static hook_Detonate <2>__DelayBlast_Detonate;
		}

		public static string IconName = "Microbial_Bullet_Icon2";

		public static ItemDef ItemDef;

		private static bool isFiringFakeDeathReport = false;

		public static ModdedProcType MicrobialBulletsProcType;

		public static void Init(AssetBundle bundle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			MicrobialBulletsProcType = ProcTypeAPI.ReserveProcType();
			if (!Object.op_Implicit((Object)(object)bundle))
			{
				Log.Error("AssetBundle failed to load!");
			}
			CreateItem(bundle);
			AddHooks();
		}

		private static void CreateItem(AssetBundle bundle)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			ItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)ItemDef).name = "DOOMSLUG_MICROBIAL_BULLETS";
			ItemDef.nameToken = "DOOMSLUG_MICROBIAL_BULLETS_NAME";
			ItemDef.pickupToken = "DOOMSLUG_MICROBIAL_BULLETS_PICKUP";
			ItemDef.descriptionToken = "DOOMSLUG_MICROBIAL_BULLETS_DESC";
			ItemDef.loreToken = "DOOMSLUG_MICROBIAL_BULLETS_DESC_LORE";
			LanguageAPI.Add("DOOMSLUG_MICROBIAL_BULLETS_NAME", "Microbial Bullets");
			LanguageAPI.Add("DOOMSLUG_MICROBIAL_BULLETS_PICKUP", "Chance to trigger on kill effects");
			LanguageAPI.Add("DOOMSLUG_MICROBIAL_BULLETS_DESC", "3% (+2% per stack) chance to trigger all on kill effects on hit.");
			ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			ItemDef.pickupIconSprite = bundle.LoadAsset<Sprite>(IconName);
			ItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			ItemDef.canRemove = true;
			ItemDef.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(ItemDef, val));
		}

		private static void AddHooks()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//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
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>O.<0>__GlobalEventManager_OnHitEnemy;
			if (obj == null)
			{
				hook_OnHitEnemy val = GlobalEventManager_OnHitEnemy;
				<>O.<0>__GlobalEventManager_OnHitEnemy = val;
				obj = (object)val;
			}
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj;
			object obj2 = <>O.<1>__DelayBlast_Awake;
			if (obj2 == null)
			{
				hook_Awake val2 = DelayBlast_Awake;
				<>O.<1>__DelayBlast_Awake = val2;
				obj2 = (object)val2;
			}
			DelayBlast.Awake += (hook_Awake)obj2;
			object obj3 = <>O.<2>__DelayBlast_Detonate;
			if (obj3 == null)
			{
				hook_Detonate val3 = DelayBlast_Detonate;
				<>O.<2>__DelayBlast_Detonate = val3;
				obj3 = (object)val3;
			}
			DelayBlast.Detonate += (hook_Detonate)obj3;
		}

		private static void DelayBlast_Awake(orig_Awake orig, DelayBlast self)
		{
			orig.Invoke(self);
			if (isFiringFakeDeathReport)
			{
				((Component)self).gameObject.AddComponent<MicrobialBulletsMarker>();
			}
		}

		private static void DelayBlast_Detonate(orig_Detonate orig, DelayBlast self)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((Component)self).GetComponent<MicrobialBulletsMarker>()))
			{
				ProcTypeAPI.AddModdedProc(ref self.procChainMask, MicrobialBulletsProcType);
			}
			orig.Invoke(self);
		}

		private static void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			orig.Invoke(self, damageInfo, victim);
			if (isFiringFakeDeathReport || !Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				return;
			}
			CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.inventory))
			{
				return;
			}
			int itemCount = component.inventory.GetItemCount(ItemDef.itemIndex);
			if (itemCount > 0 && !ProcTypeAPI.HasModdedProc(damageInfo.procChainMask, MicrobialBulletsProcType) && Util.CheckRoll(1f + 2f * (float)itemCount * damageInfo.procCoefficient, component.master))
			{
				CharacterBody component2 = victim.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.healthComponent) && component2.healthComponent.alive)
				{
					Log.Info("Microbial Bullets proc fired!");
					ProcTypeAPI.AddModdedProc(ref damageInfo.procChainMask, MicrobialBulletsProcType);
					DamageReport val = new DamageReport(damageInfo, component2.healthComponent, damageInfo.damage, component2.healthComponent.combinedHealth);
					isFiringFakeDeathReport = true;
					GlobalEventManager.instance.OnCharacterDeath(val);
					isFiringFakeDeathReport = false;
				}
			}
		}

		public static void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)284))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed F3. Spawning our Microbial Bullets at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(ItemDef.itemIndex), transform.position, transform.forward * 20f);
			}
		}
	}
	public class SourSaltShakerMarker : MonoBehaviour
	{
	}
	public class SourSaltShaker
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnHitEnemy <0>__GlobalEventManager_OnHitEnemy;

			public static StatHookEventHandler <1>__RecalculateStats;
		}

		public static string IconName = "Salt-Shaker-Status-Image";

		public static ItemDef ItemDef;

		public static BuffDef SaltBuff;

		public static void Init(AssetBundle bundle)
		{
			if (!Object.op_Implicit((Object)(object)bundle))
			{
				Log.Error("AssetBundle failed to load!");
			}
			CreateItem(bundle);
			CreateBuff(bundle);
			AddHooks();
		}

		private static void CreateItem(AssetBundle bundle)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			ItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)ItemDef).name = "DOOMSLUG_SOURSALTSHAKER";
			ItemDef.nameToken = "DOOMSLUG_SOURSALTSHAKER_NAME";
			ItemDef.pickupToken = "DOOMSLUG_SOURSALTSHAKER_PICKUP";
			ItemDef.descriptionToken = "DOOMSLUG_SOURSALTSHAKER_DESC";
			ItemDef.loreToken = "DOOMSLUG_SOURSALTSHAKER_DESC_LORE";
			LanguageAPI.Add("DOOMSLUG_SOURSALTSHAKER_NAME", "Sour Salt Shaker");
			LanguageAPI.Add("DOOMSLUG_SOURSALTSHAKER_PICKUP", "Enemies that have been crit take damage on hit");
			LanguageAPI.Add("DOOMSLUG_SOURSALTSHAKER_DESC", "On crit enemies take 20% Base Damage on hit for the next 1 (+1 per stack) seconds");
			ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			ItemDef.pickupIconSprite = bundle.LoadAsset<Sprite>(IconName);
			ItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			ItemDef.canRemove = true;
			ItemDef.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(ItemDef, val));
		}

		private static void AddHooks()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//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
			object obj = <>O.<0>__GlobalEventManager_OnHitEnemy;
			if (obj == null)
			{
				hook_OnHitEnemy val = GlobalEventManager_OnHitEnemy;
				<>O.<0>__GlobalEventManager_OnHitEnemy = val;
				obj = (object)val;
			}
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj;
			object obj2 = <>O.<1>__RecalculateStats;
			if (obj2 == null)
			{
				StatHookEventHandler val2 = RecalculateStats;
				<>O.<1>__RecalculateStats = val2;
				obj2 = (object)val2;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj2;
		}

		private static void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, damageInfo, victim);
			CharacterBody component = victim.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.healthComponent))
			{
				return;
			}
			if (component.HasBuff(SaltBuff))
			{
				int buffCount = component.GetBuffCount(SaltBuff);
				DamageInfo val = new DamageInfo
				{
					attacker = damageInfo.attacker,
					inflictor = damageInfo.attacker,
					damage = (float)buffCount * damageInfo.attacker.GetComponent<CharacterBody>().damage * 0.2f * damageInfo.procCoefficient,
					position = component.corePosition,
					procCoefficient = 0f,
					damageColorIndex = (DamageColorIndex)3,
					procChainMask = default(ProcChainMask),
					damageType = DamageTypeCombo.op_Implicit((DamageType)2048)
				};
				component.healthComponent.TakeDamage(val);
			}
			if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				return;
			}
			CharacterBody component2 = damageInfo.attacker.GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.inventory))
			{
				int itemCount = component2.inventory.GetItemCount(ItemDef.itemIndex);
				if (itemCount > 0 && damageInfo.crit && damageInfo.procCoefficient != 0f)
				{
					Log.Info("Sour Salt Shaker applied!");
					component.AddTimedBuff(SaltBuff, (float)itemCount);
				}
			}
		}

		private static void RecalculateStats(CharacterBody body, StatHookEventArgs args)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body.inventory))
			{
				int itemCount = body.inventory.GetItemCount(ItemDef.itemIndex);
				if (itemCount > 0)
				{
					args.critAdd += 5f;
				}
			}
		}

		public static void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)286))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed F5. Spawning our SourSaltShaker at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(ItemDef.itemIndex), transform.position, transform.forward * 20f);
			}
		}

		private static void CreateBuff(AssetBundle bundle)
		{
			SaltBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)SaltBuff).name = "DOOMSLUG_SALT";
			LanguageAPI.Add("DOOMSLUG_SALT", "Salt");
			SaltBuff.canStack = true;
			SaltBuff.isDebuff = true;
			SaltBuff.isCooldown = false;
			SaltBuff.iconSprite = bundle.LoadAsset<Sprite>(IconName);
			ContentAddition.AddBuffDef(SaltBuff);
		}
	}
}