using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Alexandria.ItemAPI;
using BepInEx;
using Gungeon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TenebroseItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TenebroseItems")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8f847af4-9e26-4c9a-a758-83dcfdc487aa")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 TenebroseItems
{
	public class DragonBreath : PlayerItem
	{
		public GameObject flamesVfx;
		public GameActorFireEffect fireEffect;
		public static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			string text = "Fire Breath";
			string text2 = "TenebroseItems/Resources/DragonBreath";
			GameObject val = new GameObject(text);
			DragonBreath dragonBreath = val.AddComponent<DragonBreath>();
			ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
			string text3 = "Dragon's Fury";
			string text4 = "Allows the holder to breathe a stream of controllable flames.\n\nIs the ability to breathe fire inherently magical, or purely biological in nature? Who knows... What is known however, is that breathing fire is really, really cool.";
			ItemBuilder.SetupItem((PickupObject)(object)dragonBreath, text3, text4, "spapi");
			ItemBuilder.SetCooldownType((PlayerItem)(object)dragonBreath, (CooldownType)0, 5.5f);
			((PlayerItem)dragonBreath).consumable = false;
			((PickupObject)dragonBreath).quality = (ItemQuality)(-50);
			ref GameObject reference = ref dragonBreath.flamesVfx;
			PickupObject byId = PickupObjectDatabase.GetById(384);
			reference = ((Gun)((byId is Gun) ? byId : null)).muzzleFlashEffects.effects[0].effects[0].effect;
			ref GameActorFireEffect reference2 = ref dragonBreath.fireEffect;
			PickupObject byId2 = PickupObjectDatabase.GetById(295);
			reference2 = ((BulletStatusEffectItem)((byId2 is BulletStatusEffectItem) ? byId2 : null)).FireModifierEffect;
		}
		public override void Update()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			((PlayerItem)this).Update();
			if (!((PlayerItem)this).PickedUp || !((PlayerItem)this).IsCurrentlyActive || (Object)(object)base.LastOwner == (Object)null)
			{
				return;
			}
			PlayerController lastOwner = base.LastOwner;
			BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(lastOwner.PlayerIDX);
			lastOwner.IsGunLocked = true;
			if (lastOwner.IsDodgeRolling)
			{
				((PlayerItem)this).DoActiveEffect(lastOwner);
			}
			if ((Object)(object)instanceForPlayer == (Object)null)
			{
				return;
			}
			for (int i = -1; i <= 1; i++)
			{
				float num = (float)i * 5f;
				float num2 = Vector2Extensions.ToAngle(Vector3Extensions.XY(lastOwner.unadjustedAimPoint) - ((GameActor)lastOwner).CenterPosition) + num;
				GameObject val = SpawnManager.SpawnVFX(flamesVfx, Vector2.op_Implicit(((GameActor)lastOwner).CenterPosition), Quaternion.Euler(0f, 0f, num2));
				val.transform.localScale = new Vector3(2.4f, 0.5f, 0f);
				val.transform.parent = ((BraveBehaviour)lastOwner).transform;
				SpeculativeRigidbody val2 = IterativeRaycast(((GameActor)lastOwner).CenterPosition, BraveMathCollege.DegreesToVector(num2, 1f), 11.2f, int.MaxValue, ((BraveBehaviour)lastOwner).specRigidbody);
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((BraveBehaviour)val2).aiActor) && ((BraveBehaviour)val2).aiActor.IsNormalEnemy)
				{
					((GameActor)((BraveBehaviour)val2).aiActor).ApplyEffect((GameActorEffect)(object)fireEffect, 1f, (Projectile)null);
				}
			}
		}
		protected SpeculativeRigidbody IterativeRaycast(Vector2 rayOrigin, Vector2 rayDirection, float rayDistance, int collisionMask, SpeculativeRigidbody ignoreRigidbody)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			RaycastResult val = default(RaycastResult);
			while (PhysicsEngine.Instance.Raycast(rayOrigin, rayDirection, rayDistance, ref val, true, true, collisionMask, (CollisionLayer?)(CollisionLayer)4, false, (Func<SpeculativeRigidbody, bool>)null, ignoreRigidbody))
			{
				num++;
				SpeculativeRigidbody speculativeRigidbody = val.SpeculativeRigidbody;
				if (num < 3 && (Object)(object)speculativeRigidbody != (Object)null)
				{
					MinorBreakable component = ((Component)speculativeRigidbody).GetComponent<MinorBreakable>();
					if ((Object)(object)component != (Object)null)
					{
						component.Break(((Vector2)(ref rayDirection)).normalized * 3f);
						RaycastResult.Pool.Free(ref val);
						continue;
					}
				}
				RaycastResult.Pool.Free(ref val);
				return speculativeRigidbody;
			}
			return null;
		}
		public override void OnPreDrop(PlayerController user)
		{
			((PlayerItem)this).OnPreDrop(user);
			if (((PlayerItem)this).IsCurrentlyActive)
			{
				((PlayerItem)this).DoActiveEffect(user);
			}
		}
		public override void DoActiveEffect(PlayerController user)
		{
			((PlayerItem)this).DoActiveEffect(user);
			((PlayerItem)this).IsCurrentlyActive = false;
			user.IsGunLocked = false;
		}
		public override void DoEffect(PlayerController user)
		{
			AkSoundEngine.PostEvent("Play_BOSS_DragunGold_Roar_01", ((Component)this).gameObject);
			((PlayerItem)this).IsCurrentlyActive = true;
		}
		public override bool CanBeUsed(PlayerController user)
		{
			return ((PlayerItem)this).CanBeUsed(user) && (Object)(object)user != (Object)null && !user.IsDodgeRolling;
		}
	}
	public class DragonHandController : GunBehaviour
	{
		public static void Init()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			Gun val = Databases.Items.NewGun("Firedrake Hand", "dragon_hand");
			Game.Items.Rename("outdated_gun_mods:firedrake_hand", "spapi:firedrake_hand");
			((Component)val).gameObject.AddComponent<DragonHandController>();
			GunExt.SetShortDescription((PickupObject)(object)val, "Malevolent Flames");
			GunExt.SetLongDescription((PickupObject)(object)val, "Tenebrose has always had a particular affinity for setting things ablaze, weather it be because he's biologically predisposed to, or perhaps he has an innate love for destruction. We would ask him, but we prefer our faces not to be melted off via purplish flame.");
			GunExt.SetupSprite(val, (tk2dSpriteCollectionData)null, "dragon_hand_idle_001", 8);
			GunExt.SetAnimationFPS(val, val.shootAnimation, 16);
			GunExt.SetAnimationFPS(val, val.reloadAnimation, 8);
			PickupObject byId = PickupObjectDatabase.GetById(125);
			GunExt.AddProjectileModuleFrom(val, (Gun)(object)((byId is Gun) ? byId : null), true, false);
			PickupObject byId2 = PickupObjectDatabase.GetById(125);
			Projectile val2 = Object.Instantiate<Projectile>(((Gun)((byId2 is Gun) ? byId2 : null)).DefaultModule.projectiles[0]);
			((Component)val2).gameObject.SetActive(false);
			FakePrefab.MarkAsFakePrefab(((Component)val2).gameObject);
			Object.DontDestroyOnLoad((Object)(object)val2);
			val2.damageTypes = (CoreDamageTypes)0;
			val2.DefaultTintColor = new Color(0.5f, 0f, 1f);
			val2.HasDefaultTint = true;
			((Component)val2).GetComponent<PierceProjModifier>().penetration = 0;
			val2.FireApplyChance = 0.25f;
			ProjectileData baseData = val2.baseData;
			baseData.damage += 0.8f;
			val.DefaultModule.projectiles[0] = val2;
			val.DefaultModule.numberOfShotsInClip = 7;
			val.reloadTime = 1.4f;
			val.StarterGunForAchievement = true;
			val.gunHandedness = (GunHandedness)3;
			val.InfiniteAmmo = true;
			val.muzzleFlashEffects.type = (VFXPoolType)0;
			((Component)val.barrelOffset).transform.localPosition = new Vector3(0.1875f, 0.1875f, 0f);
			val.gunSwitchGroup = "BurningHand";
			((PickupObject)val).quality = (ItemQuality)(-50);
			val.gunClass = (GunClass)30;
			tk2dSpriteAnimator component = ((Component)val).GetComponent<tk2dSpriteAnimator>();
			tk2dSpriteAnimationClip clipByName = component.GetClipByName(val.emptyAnimation);
			tk2dSpriteAnimationClip clipByName2 = component.GetClipByName(val.reloadAnimation);
			tk2dSpriteAnimationClip clipByName3 = component.GetClipByName(val.shootAnimation);
			clipByName.wrapMode = (WrapMode)1;
			clipByName.loopStart = 1;
			tk2dSpriteAnimationFrame[] frames = clipByName.frames;
			foreach (tk2dSpriteAnimationFrame val3 in frames)
			{
				tk2dSpriteDefinition def = val3.spriteCollection.spriteDefinitions[val3.spriteId];
				MakeOffset(def, new Vector2(0.1875f, 0.125f));
			}
			for (int j = 0; j < clipByName2.frames.Length; j++)
			{
				tk2dSpriteAnimationFrame val4 = clipByName2.frames[j];
				tk2dSpriteDefinition def2 = val4.spriteCollection.spriteDefinitions[val4.spriteId];
				MakeOffset(def2, new Vector2(0.1875f, 0.125f));
				if (j == 1 || j == 6)
				{
					val4.triggerEvent = true;
					val4.eventAudio = "Play_WPN_blasphemy_shot_01";
				}
			}
			tk2dSpriteAnimationFrame[] frames2 = clipByName3.frames;
			foreach (tk2dSpriteAnimationFrame val5 in frames2)
			{
				tk2dSpriteDefinition def3 = val5.spriteCollection.spriteDefinitions[val5.spriteId];
				MakeOffset(def3, new Vector2(0.125f, 0f));
			}
			Databases.Items.Add(val, (tk2dSpriteCollectionData)null, "ANY");
		}
		public override void PostProcessProjectile(Projectile projectile)
		{
			int num = Random.Range(1, 7) + Random.Range(1, 7);
			float num2 = (float)num / 13f;
			float num3 = Mathf.Lerp(0.5f, 1.5f, num2);
			float num4 = Mathf.Lerp(1f, 5f, num2);
			projectile.AdditionalScaleMultiplier *= num3;
			ProjectileData baseData = projectile.baseData;
			baseData.damage *= num4;
		}
		public static void MakeOffset(tk2dSpriteDefinition def, Vector2 offset)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//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)
			float x = offset.x;
			float y = offset.y;
			def.position0 += new Vector3(x, y, 0f);
			def.position1 += new Vector3(x, y, 0f);
			def.position2 += new Vector3(x, y, 0f);
			def.position3 += new Vector3(x, y, 0f);
			def.boundsDataCenter += new Vector3(x, y, 0f);
			def.boundsDataExtents += new Vector3(x, y, 0f);
			def.untrimmedBoundsDataCenter += new Vector3(x, y, 0f);
			def.untrimmedBoundsDataExtents += new Vector3(x, y, 0f);
		}
	}
	[HarmonyPatch]
	public class HeartOfFire : PassiveItem
	{
		private DamageTypeModifier m_fireImmunity;
		public static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			string text = "Heart of Fire";
			string text2 = "TenebroseItems/Resources/HeartOfFire";
			GameObject val = new GameObject(text);
			HeartOfFire heartOfFire = val.AddComponent<HeartOfFire>();
			ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
			string text3 = "Heat in Every Beat";
			string text4 = "Grants the user immunity to fire, the ability to double jump and increases damage to enemies on fire.\n\nEvery dragon is born with one and Tenebrose is no exception. Within the gungeon dragons are exceedingly rare in the upper levels which normally will make something like it's heart a commodity that would most likely sell for a small fortune. With that knowledge in retrospect, it wasn't such a good idea to come down here was it?";
			ItemBuilder.SetupItem((PickupObject)(object)heartOfFire, text3, text4, "spapi");
			((PickupObject)heartOfFire).quality = (ItemQuality)(-50);
		}
		public override void Pickup(PlayerController player)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			((PassiveItem)this).Pickup(player);
			player.PostProcessProjectile += PostProcessProjectile;
			if (!((Object)(object)((BraveBehaviour)player).healthHaver == (Object)null))
			{
				m_fireImmunity = new DamageTypeModifier
				{
					damageType = (CoreDamageTypes)4,
					damageMultiplier = 0f
				};
				((BraveBehaviour)player).healthHaver.damageTypeModifiers.Add(m_fireImmunity);
			}
		}
		public void PostProcessProjectile(Projectile proj, float f)
		{
			ProjectileExt projectileExt = proj.Ext();
			projectileExt.ModifyDealtDamage = (Action<Projectile, HealthHaver, ModifyDamageEventArgs>)Delegate.Combine(projectileExt.ModifyDealtDamage, new Action<Projectile, HealthHaver, ModifyDamageEventArgs>(DouleFireDamage));
		}
		public void DouleFireDamage(Projectile proj, HealthHaver hh, ModifyDamageEventArgs args)
		{
			if (!((Object)(object)hh == (Object)null) && !((Object)(object)((BraveBehaviour)hh).gameActor == (Object)null) && ((BraveBehaviour)hh).gameActor.GetEffect("fire") != null)
			{
				args.ModifiedDamage *= 1.5f;
			}
		}
		public override void DisableEffect(PlayerController player)
		{
			((PassiveItem)this).DisableEffect(player);
			if (!((Object)(object)player == (Object)null))
			{
				player.PostProcessProjectile -= PostProcessProjectile;
				if (m_fireImmunity != null && !((Object)(object)((BraveBehaviour)player).healthHaver == (Object)null))
				{
					((BraveBehaviour)player).healthHaver.damageTypeModifiers.Remove(m_fireImmunity);
					m_fireImmunity = null;
				}
			}
		}
		[HarmonyPatch(typeof(PlayerController), "CheckDodgeRollDepth")]
		[HarmonyILManipulator]
		public static void ExtraDodgeRoll_Transpiler(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 1)
			}))
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(HeartOfFire), "ExtraDodgeRoll_Add", (Type[])null, (Type[])null);
				val.Emit(OpCodes.Ldloca, 1);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Call, (MethodBase)methodInfo);
			}
		}
		public static void ExtraDodgeRoll_Add(ref int current, PlayerController player)
		{
			if ((Object)(object)player == (Object)null || player.passiveItems == null)
			{
				return;
			}
			foreach (PassiveItem passiveItem in player.passiveItems)
			{
				if (!((Object)(object)passiveItem == (Object)null) && passiveItem is HeartOfFire)
				{
					current++;
				}
			}
		}
	}
	[BepInPlugin("spapi.etg.tenebroseitems", "Tenebrose Items", "1.0.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string MOD_GUID = "spapi.etg.tenebroseitems";
		public void Start()
		{
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
		}
		public void GMStart(GameManager man)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("spapi.etg.tenebroseitems").PatchAll();
			Assets.SetupSpritesFromAssembly(typeof(Plugin).Assembly, "TenebroseItems/Resources/MTGAPISpriteRoot");
			HeartOfFire.Init();
			DragonBreath.Init();
			DragonHandController.Init();
		}
	}
	[HarmonyPatch]
	public class ProjectileExt : MonoBehaviour
	{
		public Action<Projectile, HealthHaver, ModifyDamageEventArgs> ModifyDealtDamage;
		[HarmonyPatch(typeof(Projectile), "HandleDamage")]
		[HarmonyILManipulator]
		public static void ModifyProjectileDamage_Transpiler(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 4)
			}))
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(ProjectileExt), "ModifyProjectileDamage_Modify", (Type[])null, (Type[])null);
				val.Emit(OpCodes.Ldarg_1);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Call, (MethodBase)methodInfo);
			}
		}
		public static float ModifyProjectileDamage_Modify(float dmg, SpeculativeRigidbody rb, Projectile proj)
		{
			//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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			if ((Object)(object)rb == (Object)null)
			{
				return dmg;
			}
			HealthHaver healthHaver = ((BraveBehaviour)rb).healthHaver;
			if ((Object)(object)healthHaver == (Object)null)
			{
				return dmg;
			}
			ProjectileExt projectileExt = proj.Ext();
			if ((Object)(object)projectileExt != (Object)null && projectileExt.ModifyDealtDamage != null)
			{
				ModifyDamageEventArgs val = new ModifyDamageEventArgs
				{
					InitialDamage = dmg,
					ModifiedDamage = dmg
				};
				projectileExt.ModifyDealtDamage?.Invoke(proj, healthHaver, val);
				dmg = val.ModifiedDamage;
			}
			return dmg;
		}
	}
	public static class ExtTools
	{
		public static T AddComponent<T>(this Component c) where T : Component
		{
			return c.gameObject.AddComponent<T>();
		}
		public static T GetOrAddComponent<T>(this Component c) where T : Component
		{
			return GameObjectExtensions.GetOrAddComponent<T>(c.gameObject);
		}
		public static ProjectileExt Ext(this Projectile proj)
		{
			if ((Object)(object)proj == (Object)null)
			{
				return null;
			}
			return ((Component)(object)proj).GetOrAddComponent<ProjectileExt>();
		}
	}
}