Decompiled source of The Lich v1.0.6

plugins/LichItems/LichItems.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Alexandria.SoundAPI;
using BepInEx;
using Dungeonator;
using Gungeon;
using HarmonyLib;
using LichItems.ItemAPI;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
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("LichItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LichItems")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9ef0c54-e80e-4d2c-86ea-ad425c05c9e6")]
[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 LichItems
{
	public class CrossChamber
	{
		public class IgnoreEnemyCollisions : BraveBehaviour
		{
			public void Start()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				((BraveBehaviour)this).specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2));
				((BraveBehaviour)this).specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)3));
				((BraveBehaviour)this).healthHaver.OnDamaged += new OnDamagedEvent(HandleDamaged);
			}

			private void HandleDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
			{
				((BraveBehaviour)this).healthHaver.FullHeal();
			}
		}

		public static GameObject prefab;

		public static GameObject synergyPrefab;

		public static CustomSynergyType CrossfireSynergy;

		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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008e: Expected O, but got Unknown
			string text = "Cross Chamber";
			string resourcePath = "LichItems/Resources/Cross_Chamber";
			GameObject val = new GameObject(text);
			CompanionItem val2 = val.AddComponent<CompanionItem>();
			ItemBuilder.AddSpriteToObject(text, resourcePath, val);
			string shortDesc = "Marbled Minion";
			string longDesc = "A relic that summons one of the Lich's personal guards. While unable to attack, it can still block bullets for the owner.";
			((PickupObject)(object)val2).SetupItem(shortDesc, longDesc, "spapi");
			CrossfireSynergy = ETGModCompatibility.ExtendEnum<CustomSynergyType>("spapi.etg.lichitems", "CROSSFIRE");
			((PickupObject)val2).quality = (ItemQuality)(-50);
			val2.CompanionGuid = "Cross_Chamber";
			val2.Synergies = (CompanionTransformSynergy[])(object)new CompanionTransformSynergy[1]
			{
				new CompanionTransformSynergy
				{
					RequiredSynergy = CrossfireSynergy,
					SynergyCompanionGuid = "Synergy_Cross_Chamber"
				}
			};
			BuildPrefab();
			BuildSynergyPrefab();
		}

		public static AIShooter SetupBasicAIShooter(GameObject go, int gunid, Transform gunattachpoint, GameObject handobject)
		{
			AIShooter orAddComponent = GameObjectExtensions.GetOrAddComponent<AIShooter>(go);
			orAddComponent.equippedGunId = gunid;
			orAddComponent.shouldUseGunReload = true;
			orAddComponent.customShootCooldownPeriod = 1f;
			orAddComponent.gunAttachPoint = gunattachpoint;
			orAddComponent.handObject = handobject.GetComponent<PlayerHandController>();
			orAddComponent.AllowTwoHands = true;
			return orAddComponent;
		}

		public static void BuildPrefab()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			if (!((Object)(object)prefab != (Object)null) && !CompanionBuilder.companionDictionary.ContainsKey("Cross_Chamber"))
			{
				prefab = CompanionBuilder.BuildPrefab("Cross Chamber", "Cross_Chamber", "LichItems/Resources/CrossChamber/IdleRight/tomb_idle_right_001", new IntVector2(0, 0), new IntVector2(14, 16));
				CompanionController val = prefab.AddComponent<CompanionController>();
				val.CanInterceptBullets = true;
				SpeculativeRigidbody specRigidbody = ((BraveBehaviour)val).specRigidbody;
				specRigidbody.PixelColliders.Add(new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)0,
					ManualWidth = 14,
					ManualHeight = 16,
					ManualOffsetX = 0,
					ManualOffsetY = 0
				});
				specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2));
				specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)3));
				specRigidbody.CollideWithOthers = true;
				KnockbackDoer orAddComponent = GameObjectExtensions.GetOrAddComponent<KnockbackDoer>(((Component)val).gameObject);
				orAddComponent.weight = 100f;
				AIActor aiActor = ((BraveBehaviour)val).aiActor;
				aiActor.IsNormalEnemy = false;
				aiActor.CollisionDamage = 0f;
				aiActor.MovementSpeed = 3f;
				aiActor.CanDropCurrency = false;
				((Component)val).gameObject.AddComponent<IgnoreEnemyCollisions>();
				((BraveBehaviour)val).healthHaver.PreventAllDamage = false;
				prefab.AddAnimation("idle_right", "LichItems/Resources/CrossChamber/IdleRight", 4, CompanionBuilder.AnimationType.Idle, (DirectionType)2, (FlipType)0);
				prefab.AddAnimation("idle_left", "LichItems/Resources/CrossChamber/IdleLeft", 4, CompanionBuilder.AnimationType.Idle, (DirectionType)2, (FlipType)0);
				prefab.AddAnimation("run_right", "LichItems/Resources/CrossChamber/MoveRight", 10, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0);
				prefab.AddAnimation("run_left", "LichItems/Resources/CrossChamber/MoveLeft", 10, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0);
				prefab.AddAnimation("hit_left", "LichItems/Resources/CrossChamber/HitLeft", 6, CompanionBuilder.AnimationType.Hit, (DirectionType)2, (FlipType)0).wrapMode = (WrapMode)2;
				prefab.AddAnimation("hit_right", "LichItems/Resources/CrossChamber/HitRight", 6, CompanionBuilder.AnimationType.Hit, (DirectionType)2, (FlipType)0).wrapMode = (WrapMode)2;
				BehaviorSpeculator component = prefab.GetComponent<BehaviorSpeculator>();
				List<MovementBehaviorBase> movementBehaviors = component.MovementBehaviors;
				CompanionFollowPlayerBehavior val2 = new CompanionFollowPlayerBehavior();
				val2.IdleAnimations = new string[1] { "idle" };
				val2.DisableInCombat = false;
				movementBehaviors.Add((MovementBehaviorBase)(object)val2);
			}
		}

		public static void BuildSynergyPrefab()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_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: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Expected O, but got Unknown
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: 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_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Expected O, but got Unknown
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Expected O, but got Unknown
			if (!((Object)(object)synergyPrefab != (Object)null) && !CompanionBuilder.companionDictionary.ContainsKey("Synergy_Cross_Chamber"))
			{
				synergyPrefab = CompanionBuilder.BuildPrefab("Synergy Cross Chamber", "Synergy_Cross_Chamber", "LichItems/Resources/CrossChamber/IdleRight/tomb_idle_right_001", new IntVector2(0, 0), new IntVector2(14, 16));
				CompanionController val = synergyPrefab.AddComponent<CompanionController>();
				SpeculativeRigidbody specRigidbody = ((BraveBehaviour)val).specRigidbody;
				specRigidbody.PrimaryPixelCollider.CollisionLayer = (CollisionLayer)1;
				specRigidbody.PixelColliders.Add(new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)0,
					ManualWidth = 14,
					ManualHeight = 16,
					ManualOffsetX = 0,
					ManualOffsetY = 0
				});
				specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2));
				specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)3));
				specRigidbody.CollideWithOthers = true;
				KnockbackDoer orAddComponent = GameObjectExtensions.GetOrAddComponent<KnockbackDoer>(((Component)val).gameObject);
				orAddComponent.weight = 100f;
				AIActor aiActor = ((BraveBehaviour)val).aiActor;
				aiActor.IsNormalEnemy = false;
				aiActor.CollisionDamage = 0f;
				aiActor.MovementSpeed = 3f;
				aiActor.CanDropCurrency = false;
				val.CanInterceptBullets = true;
				((Component)val).gameObject.AddComponent<IgnoreEnemyCollisions>();
				((BraveBehaviour)val).healthHaver.PreventAllDamage = false;
				GameObject val2 = new GameObject("GunAttachPoint");
				FakePrefab.MarkAsFakePrefab(val2);
				Object.DontDestroyOnLoad((Object)(object)val2);
				Transform transform = val2.transform;
				transform.parent = synergyPrefab.transform;
				transform.localPosition = new Vector3(-0.0625f, 0.3125f, 0f);
				GameObject val3 = SpriteBuilder.SpriteFromResource("LichItems/Resources/CrossChamber/Hand/hand_001", new GameObject("SynergyCrossChamberHand"));
				FakePrefab.MarkAsFakePrefab(val3);
				Object.DontDestroyOnLoad((Object)(object)val3);
				SpriteBuilder.ConstructOffsetsFromAnchor(val3.GetComponent<tk2dBaseSprite>().GetCurrentSpriteDef(), (Anchor)4);
				PlayerHandController val4 = val3.AddComponent<PlayerHandController>();
				val4.ForceRenderersOff = false;
				val4.attachPoint = null;
				val4.handHeightFromGun = 0.05f;
				SetupBasicAIShooter(synergyPrefab, 38, transform, val3);
				synergyPrefab.AddAnimation("idle_right", "LichItems/Resources/CrossChamber/IdleRight", 4, CompanionBuilder.AnimationType.Idle, (DirectionType)2, (FlipType)0);
				synergyPrefab.AddAnimation("idle_left", "LichItems/Resources/CrossChamber/IdleLeft", 4, CompanionBuilder.AnimationType.Idle, (DirectionType)2, (FlipType)0);
				synergyPrefab.AddAnimation("run_right", "LichItems/Resources/CrossChamber/MoveRight", 10, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0);
				synergyPrefab.AddAnimation("run_left", "LichItems/Resources/CrossChamber/MoveLeft", 10, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0);
				synergyPrefab.AddAnimation("hit_left", "LichItems/Resources/CrossChamber/HitLeft", 6, CompanionBuilder.AnimationType.Hit, (DirectionType)2, (FlipType)0).wrapMode = (WrapMode)2;
				synergyPrefab.AddAnimation("hit_right", "LichItems/Resources/CrossChamber/HitRight", 6, CompanionBuilder.AnimationType.Hit, (DirectionType)2, (FlipType)0).wrapMode = (WrapMode)2;
				BehaviorSpeculator component = synergyPrefab.GetComponent<BehaviorSpeculator>();
				List<MovementBehaviorBase> movementBehaviors = component.MovementBehaviors;
				CompanionFollowPlayerBehavior val5 = new CompanionFollowPlayerBehavior();
				val5.IdleAnimations = new string[1] { "idle" };
				val5.DisableInCombat = false;
				movementBehaviors.Add((MovementBehaviorBase)(object)val5);
				component.TargetBehaviors = new List<TargetBehaviorBase>(1) { (TargetBehaviorBase)new TargetPlayerBehavior
				{
					Radius = 35f,
					LineOfSight = true,
					ObjectPermanence = true,
					SearchInterval = 0.25f,
					PauseOnTargetSwitch = false,
					PauseTime = 0.25f
				} };
				component.AttackBehaviors = new List<AttackBehaviorBase>(1) { (AttackBehaviorBase)new ShootGunBehavior
				{
					GroupCooldownVariance = -1f,
					LineOfSight = true,
					WeaponType = (WeaponType)0,
					OverrideBulletName = "default",
					BulletScript = null,
					FixTargetDuringAttack = false,
					StopDuringAttack = false,
					LeadAmount = 0f,
					LeadChance = 1f,
					RespectReload = true,
					MagazineCapacity = 6f,
					ReloadSpeed = 2f,
					EmptiesClip = false,
					SuppressReloadAnim = false,
					TimeBetweenShots = -1f,
					PreventTargetSwitching = false,
					OverrideAnimation = string.Empty,
					OverrideDirectionalAnimation = string.Empty,
					HideGun = false,
					UseLaserSight = false,
					UseGreenLaser = false,
					PreFireLaserTime = -1f,
					AimAtFacingDirectionWhenSafe = false
				} };
				AIBulletBank orAddComponent2 = GameObjectExtensions.GetOrAddComponent<AIBulletBank>(synergyPrefab);
				orAddComponent2.Bullets = new List<Entry>(1)
				{
					new Entry
					{
						Name = "default",
						OverrideProjectile = true,
						ProjectileData = new ProjectileData
						{
							damage = 5f,
							speed = 10f,
							range = 60f,
							force = 10f,
							damping = 0f,
							UsesCustomAccelerationCurve = false,
							AccelerationCurve = null,
							CustomAccelerationCurveDuration = 0f,
							IgnoreAccelCurveTime = 0f,
							onDestroyBulletScript = null
						},
						BulletObject = null
					}
				};
				orAddComponent2.useDefaultBulletIfMissing = false;
				orAddComponent2.transforms = new List<Transform>(1) { synergyPrefab.transform };
			}
		}
	}
	public class LichsBook : MonoBehaviour
	{
		public float Duration = 8f;

		public float Radius = 5f;

		private bool m_radialIndicatorActive;

		private HeatIndicatorController m_radialIndicator;

		public GameObject shadowPrefab;

		private readonly Dictionary<PlayerController, StatModifier> statModifiers = new Dictionary<PlayerController, StatModifier>();

		public IEnumerator Start()
		{
			HandleRadialIndicator();
			Object.Instantiate<GameObject>(shadowPrefab, ((Component)this).transform.position - Vector2Extensions.ToVector3ZUp(Vector2Extensions.WithX(((Component)this).GetComponent<tk2dBaseSprite>().GetRelativePositionFromAnchor((Anchor)7), 0f), 0f) + new Vector3(0f, 0.1875f), Quaternion.identity, ((Component)this).transform);
			yield return (object)new WaitForSeconds(Duration);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void Update()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			if (Dungeon.IsGenerating || GameManager.Instance.IsLoadingLevel)
			{
				return;
			}
			for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
			{
				PlayerController val = GameManager.Instance.AllPlayers[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				bool flag = statModifiers.ContainsKey(val);
				bool flag2 = Vector2.Distance(((GameActor)val).CenterPosition, Vector3Extensions.XY(((Component)this).transform.position)) < Radius;
				if (!flag && flag2)
				{
					StatModifier val2 = StatModifier.Create((StatType)10, (ModifyMethod)0, -1000f);
					val.ownerlessStatModifiers.Add(val2);
					val.stats.RecalculateStats(val, true, false);
					statModifiers.Add(val, val2);
				}
				else if (flag && !flag2)
				{
					StatModifier item = statModifiers[val];
					if (val.ownerlessStatModifiers.Contains(item))
					{
						val.ownerlessStatModifiers.Remove(item);
						val.stats.RecalculateStats(val, true, false);
					}
					statModifiers.Remove(val);
				}
			}
		}

		public void OnDestroy()
		{
			for (int i = 0; i < GameManager.Instance.AllPlayers.Length; i++)
			{
				PlayerController val = GameManager.Instance.AllPlayers[i];
				if (Object.op_Implicit((Object)(object)val) && statModifiers.TryGetValue(val, out var value))
				{
					if (val.ownerlessStatModifiers.Contains(value))
					{
						val.ownerlessStatModifiers.Remove(value);
						val.stats.RecalculateStats(val, true, false);
					}
					statModifiers.Remove(val);
				}
			}
			UnhandleRadialIndicator();
		}

		private void HandleRadialIndicator()
		{
			//IL_0025: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (!m_radialIndicatorActive)
			{
				m_radialIndicatorActive = true;
				ref HeatIndicatorController radialIndicator = ref m_radialIndicator;
				Object obj = Object.Instantiate(ResourceCache.Acquire("Global VFX/HeatIndicator"), ((Component)this).transform.position, Quaternion.identity, ((Component)this).transform);
				radialIndicator = ((GameObject)((obj is GameObject) ? obj : null)).GetComponent<HeatIndicatorController>();
				m_radialIndicator.CurrentColor = Color.white;
				m_radialIndicator.IsFire = false;
				m_radialIndicator.CurrentRadius = Radius;
			}
		}

		private void UnhandleRadialIndicator()
		{
			if (m_radialIndicatorActive)
			{
				m_radialIndicatorActive = false;
				if (Object.op_Implicit((Object)(object)m_radialIndicator))
				{
					m_radialIndicator.EndEffect();
				}
				m_radialIndicator = null;
			}
		}
	}
	public class LichsBookItem : PlayerItem
	{
		public GameObject LichsBookPrefab;

		private GameObject m_instanceBook;

		public tk2dSpriteAnimation replacementLibrary;

		public tk2dSprite replacementHandSprite;

		private PlayerController m_lastPlayer;

		private bool m_transformed;

		private readonly List<StatModifier> synergyModifiers = new List<StatModifier>();

		public static CustomSynergyType MasterOfTheGungeonSynergy;

		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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			string text = "Lich's Book";
			string resourcePath = "LichItems/Resources/lichsbook_item_001";
			GameObject val = new GameObject(text);
			LichsBookItem lichsBookItem = val.AddComponent<LichsBookItem>();
			ItemBuilder.AddSpriteToObject(text, resourcePath, val);
			string shortDesc = "Reload Spell";
			string longDesc = "The book of the Gungoen master. Place to create a zone of instant reload.";
			((PickupObject)(object)lichsBookItem).SetupItem(shortDesc, longDesc, "spapi");
			((PlayerItem)(object)lichsBookItem).SetCooldownType(ItemBuilder.CooldownType.Damage, 600f);
			((PlayerItem)lichsBookItem).consumable = false;
			((PickupObject)lichsBookItem).quality = (ItemQuality)2;
			Game.Items.Rename("spapi:lich's_book", "spapi:lichs_book");
			GameObject val2 = SpriteBuilder.SpriteFromResource("LichItems/Resources/lichsbook_shadow_001");
			val2.SetActive(false);
			FakePrefab.MarkAsFakePrefab(val2);
			Object.DontDestroyOnLoad((Object)(object)val2);
			tk2dBaseSprite component = val2.GetComponent<tk2dBaseSprite>();
			SpriteBuilder.ConstructOffsetsFromAnchor(component.GetCurrentSpriteDef(), (Anchor)1);
			Shader shader = ((BraveBehaviour)((Component)((Component)GameManager.Instance.RewardManager.A_Chest).gameObject.transform.Find("Shadow")).gameObject.GetComponent<tk2dSprite>()).renderer.material.shader;
			component.GetCurrentSpriteDef().material.shader = shader;
			component.GetCurrentSpriteDef().materialInst.shader = shader;
			GameObject val3 = SpriteBuilder.SpriteFromResource("LichItems/Resources/lichsbook_depoy_001");
			val3.SetActive(false);
			FakePrefab.MarkAsFakePrefab(val3);
			Object.DontDestroyOnLoad((Object)(object)val3);
			tk2dSpriteAnimator val4 = val3.gameObject.AddComponent<tk2dSpriteAnimator>();
			List<int> list = new List<int>
			{
				val3.GetComponent<tk2dBaseSprite>().spriteId,
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_002", val3.GetComponent<tk2dBaseSprite>().Collection),
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_003", val3.GetComponent<tk2dBaseSprite>().Collection),
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_004", val3.GetComponent<tk2dBaseSprite>().Collection),
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_005", val3.GetComponent<tk2dBaseSprite>().Collection),
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_006", val3.GetComponent<tk2dBaseSprite>().Collection),
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_007", val3.GetComponent<tk2dBaseSprite>().Collection),
				SpriteBuilder.AddSpriteToCollection("LichItems/Resources/lichsbook_depoy_008", val3.GetComponent<tk2dBaseSprite>().Collection)
			};
			foreach (int item in list)
			{
				SpriteBuilder.ConstructOffsetsFromAnchor(val3.GetComponent<tk2dBaseSprite>().Collection.spriteDefinitions[item], (Anchor)1);
			}
			SpriteBuilder.AddAnimation(val4, val3.GetComponent<tk2dBaseSprite>().Collection, list, "idle", (WrapMode)0).fps = 10f;
			val4.DefaultClipId = val4.GetClipIdByName("idle");
			val4.playAutomatically = true;
			val3.AddComponent<LichsBook>().shadowPrefab = val2;
			lichsBookItem.LichsBookPrefab = val3;
			MasterOfTheGungeonSynergy = ETGModCompatibility.ExtendEnum<CustomSynergyType>("spapi.etg.lichitems", "MASTER_OF_THE_GUNGEON");
			BuildLibrary(lichsBookItem);
		}

		public static tk2dSpriteDefinition CopyDefinitionFrom(tk2dSpriteDefinition other)
		{
			//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)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: 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_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Expected O, but got Unknown
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: 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)
			tk2dSpriteDefinition val = new tk2dSpriteDefinition
			{
				boundsDataCenter = new Vector3
				{
					x = other.boundsDataCenter.x,
					y = other.boundsDataCenter.y,
					z = other.boundsDataCenter.z
				},
				boundsDataExtents = new Vector3
				{
					x = other.boundsDataExtents.x,
					y = other.boundsDataExtents.y,
					z = other.boundsDataExtents.z
				},
				colliderConvex = other.colliderConvex,
				colliderSmoothSphereCollisions = other.colliderSmoothSphereCollisions,
				colliderType = other.colliderType,
				colliderVertices = other.colliderVertices,
				collisionLayer = other.collisionLayer,
				complexGeometry = other.complexGeometry,
				extractRegion = other.extractRegion,
				flipped = other.flipped,
				indices = other.indices,
				material = new Material(other.material),
				materialId = other.materialId,
				materialInst = new Material(other.materialInst),
				metadata = other.metadata,
				name = other.name,
				normals = other.normals,
				physicsEngine = other.physicsEngine,
				position0 = new Vector3
				{
					x = other.position0.x,
					y = other.position0.y,
					z = other.position0.z
				},
				position1 = new Vector3
				{
					x = other.position1.x,
					y = other.position1.y,
					z = other.position1.z
				},
				position2 = new Vector3
				{
					x = other.position2.x,
					y = other.position2.y,
					z = other.position2.z
				},
				position3 = new Vector3
				{
					x = other.position3.x,
					y = other.position3.y,
					z = other.position3.z
				},
				regionH = other.regionH,
				regionW = other.regionW,
				regionX = other.regionX,
				regionY = other.regionY,
				tangents = other.tangents,
				texelSize = new Vector2
				{
					x = other.texelSize.x,
					y = other.texelSize.y
				},
				untrimmedBoundsDataCenter = new Vector3
				{
					x = other.untrimmedBoundsDataCenter.x,
					y = other.untrimmedBoundsDataCenter.y,
					z = other.untrimmedBoundsDataCenter.z
				},
				untrimmedBoundsDataExtents = new Vector3
				{
					x = other.untrimmedBoundsDataExtents.x,
					y = other.untrimmedBoundsDataExtents.y,
					z = other.untrimmedBoundsDataExtents.z
				}
			};
			List<Vector2> list = new List<Vector2>();
			Vector2[] uvs = other.uvs;
			foreach (Vector2 val2 in uvs)
			{
				list.Add(new Vector2
				{
					x = val2.x,
					y = val2.y
				});
			}
			val.uvs = list.ToArray();
			List<Vector3> list2 = new List<Vector3>();
			Vector3[] colliderVertices = other.colliderVertices;
			foreach (Vector3 val3 in colliderVertices)
			{
				list2.Add(new Vector3
				{
					x = val3.x,
					y = val3.y,
					z = val3.z
				});
			}
			val.colliderVertices = list2.ToArray();
			return val;
		}

		private static void BuildLibrary(LichsBookItem targetBook)
		{
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			List<string> list = new List<string>();
			string[] resourceNames = ResourceExtractor.GetResourceNames();
			string text = "LichItems/Resources/InfinilichTransformation";
			foreach (string text2 in resourceNames)
			{
				if (text2.StartsWith(text.Replace('/', '.'), StringComparison.OrdinalIgnoreCase))
				{
					list.Add(text2);
				}
			}
			List<Texture2D> list2 = new List<Texture2D>();
			foreach (string item in list)
			{
				list2.Add(ResourceExtractor.GetTextureFromResource(item));
			}
			PickupObject byId = PickupObjectDatabase.GetById(163);
			tk2dSpriteAnimation val = Object.Instantiate<tk2dSpriteAnimation>(((BulletArmorItem)((byId is BulletArmorItem) ? byId : null)).knightLibrary);
			Object.DontDestroyOnLoad((Object)(object)val);
			tk2dSpriteCollectionData spriteCollection = val.clips[0].frames[0].spriteCollection;
			tk2dSpriteCollectionData val2 = Object.Instantiate<tk2dSpriteCollectionData>(spriteCollection);
			PickupObject byId2 = PickupObjectDatabase.GetById(607);
			tk2dSpriteDefinition val3 = CopyDefinitionFrom(((tk2dBaseSprite)((BankMaskItem)((byId2 is BankMaskItem) ? byId2 : null)).OverrideHandSprite).GetCurrentSpriteDef());
			val3.name = "knight_hand_001";
			int num = SpriteBuilder.AddSpriteToCollection(val3, val2);
			Object.DontDestroyOnLoad((Object)(object)val2);
			for (int j = 0; j < list2.Count; j++)
			{
				Texture2D val4 = list2[j];
				tk2dSpriteDefinition spriteDefinition = val2.GetSpriteDefinition(((Object)val4).name);
				if (spriteDefinition != null)
				{
					ETGMod.ReplaceTexture(spriteDefinition, val4, true);
					spriteDefinition.name = spriteDefinition.name.Replace("knight", "inflich");
					SpriteBuilder.MakeOffset(spriteDefinition, new Vector2(-0.0625f, 0f));
				}
			}
			tk2dSpriteAnimationClip[] clips = val.clips;
			foreach (tk2dSpriteAnimationClip val5 in clips)
			{
				for (int l = 0; l < val5.frames.Length; l++)
				{
					val5.frames[l].spriteCollection = val2;
				}
			}
			tk2dSpriteAnimationClip[] clips2 = val.clips;
			foreach (tk2dSpriteAnimationClip val6 in clips2)
			{
				tk2dSpriteAnimationFrame[] frames = val6.frames;
				foreach (tk2dSpriteAnimationFrame val7 in frames)
				{
					if (!string.IsNullOrEmpty(val7.eventAudio) && (!(val7.eventAudio != "Play_FS") || !(val7.eventAudio != "Play_CHR_boot_stairs_01")))
					{
						val7.eventAudio = "";
					}
				}
			}
			GameObject val8 = new GameObject("OverrideHandSprite");
			val8.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)val8);
			tk2dSprite val9 = val8.AddComponent<tk2dSprite>();
			((tk2dBaseSprite)val9).SetSprite(val2, num);
			targetBook.replacementHandSprite = val9;
			targetBook.replacementLibrary = val;
		}

		public override void Update()
		{
			((PlayerItem)this).Update();
			ProcessInfinilichStatus(base.LastOwner);
		}

		public override void OnDestroy()
		{
			if (m_transformed)
			{
				ProcessInfinilichStatus(null, forceDisable: true);
			}
			((PlayerItem)this).OnDestroy();
		}

		private void RevealAllRooms(PlayerController player)
		{
			if (!((Object)(object)Minimap.Instance == (Object)null))
			{
				Minimap.Instance.RevealAllRooms(true);
			}
		}

		private void ProcessInfinilichStatus(PlayerController player, bool forceDisable = false)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Invalid comparison between Unknown and I4
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Invalid comparison between Unknown and I4
			bool flag = Object.op_Implicit((Object)(object)player) && player.HasActiveBonusSynergy(MasterOfTheGungeonSynergy, false) && !forceDisable;
			if (flag && !m_transformed)
			{
				m_lastPlayer = player;
				if (Object.op_Implicit((Object)(object)player))
				{
					m_transformed = true;
					if ((Object)(object)Minimap.Instance != (Object)null)
					{
						Minimap.Instance.RevealAllRooms(true);
					}
					player.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Combine(player.OnNewFloorLoaded, new Action<PlayerController>(RevealAllRooms));
					player.carriedConsumables.InfiniteKeys = true;
					player.OverrideAnimationLibrary = replacementLibrary;
					player.SetOverrideShader(ShaderCache.Acquire(player.LocalShaderName));
					if ((int)player.characterIdentity == 9)
					{
						((Component)player).GetComponent<CharacterAnimationRandomizer>().AddOverrideAnimLibrary(replacementLibrary);
					}
					player.ChangeHandsToCustomType(((tk2dBaseSprite)replacementHandSprite).Collection, ((tk2dBaseSprite)replacementHandSprite).spriteId);
					StatModifier item = StatModifier.Create((StatType)8, (ModifyMethod)0, 1f);
					player.ownerlessStatModifiers.Add(item);
					player.stats.RecalculateStats(player, false, false);
					synergyModifiers.Add(item);
				}
			}
			else
			{
				if (!m_transformed || flag)
				{
					return;
				}
				m_transformed = false;
				if (!Object.op_Implicit((Object)(object)m_lastPlayer))
				{
					return;
				}
				PlayerController lastPlayer = m_lastPlayer;
				lastPlayer.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Remove(lastPlayer.OnNewFloorLoaded, new Action<PlayerController>(RevealAllRooms));
				m_lastPlayer.carriedConsumables.InfiniteKeys = false;
				m_lastPlayer.OverrideAnimationLibrary = null;
				m_lastPlayer.ClearOverrideShader();
				if ((int)m_lastPlayer.characterIdentity == 9)
				{
					((Component)m_lastPlayer).GetComponent<CharacterAnimationRandomizer>().RemoveOverrideAnimLibrary(replacementLibrary);
				}
				m_lastPlayer.RevertHandsToBaseType();
				foreach (StatModifier synergyModifier in synergyModifiers)
				{
					m_lastPlayer.ownerlessStatModifiers.Remove(synergyModifier);
				}
				m_lastPlayer.stats.RecalculateStats(m_lastPlayer, false, false);
				synergyModifiers.Clear();
				m_lastPlayer = null;
			}
		}

		public override bool CanBeUsed(PlayerController user)
		{
			return !Object.op_Implicit((Object)(object)m_instanceBook) && ((PlayerItem)this).CanBeUsed(user);
		}

		public override void DoEffect(PlayerController user)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			m_instanceBook = Object.Instantiate<GameObject>(LichsBookPrefab, Vector2Extensions.ToVector3ZisY(((GameActor)user).CenterPosition, 0f), Quaternion.identity, (Transform)null);
		}
	}
	public class LichsGun
	{
		public static List<string> shootFrames = new List<string>(5) { "lichsgun_fire_001", "lichsgun_fire_002", "lichsgun_fire_003", "lichsgun_fire_004", "lichsgun_idle_001" };

		public static List<string> reloadFrames = new List<string>(7) { "lichsgun_reload_001", "lichsgun_reload_001", "lichsgun_reload_002", "lichsgun_reload_003", "lichsgun_reload_002", "lichsgun_reload_003", "lichsgun_reload_004" };

		public static List<IntVector2> fireOffsets = new List<IntVector2>(4)
		{
			new IntVector2(0, 0),
			new IntVector2(-3, 1),
			new IntVector2(-2, 0),
			new IntVector2(1, -1)
		};

		public static List<IntVector2> reloadOffsets = new List<IntVector2>(4)
		{
			new IntVector2(1, -2),
			new IntVector2(-3, -1),
			new IntVector2(-3, 0),
			new IntVector2(-1, 1)
		};

		public static tk2dSpriteCollectionData VFXCollection
		{
			get
			{
				PickupObject byId = PickupObjectDatabase.GetById(95);
				return ((Gun)((byId is Gun) ? byId : null)).clipObject.GetComponent<tk2dBaseSprite>().Collection;
			}
		}

		public static void Init()
		{
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Expected O, but got Unknown
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Expected O, but got Unknown
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Expected O, but got Unknown
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Expected O, but got Unknown
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Expected O, but got Unknown
			Gun val = Databases.Items.NewGun("Lich's Gun", "lichsgun");
			Game.Items.Rename("outdated_gun_mods:lich's_gun", "spapi:lichs_gun");
			GunExt.SetShortDescription((PickupObject)(object)val, "The Freeshooter");
			GunExt.SetLongDescription((PickupObject)(object)val, "The gun of the Gungeon master. The bullets of this gun can be guided after being fired.");
			GunExt.SetupSprite(val, (tk2dSpriteCollectionData)null, "lichsgun_idle_001", 10);
			GunExt.SetAnimationFPS(val, val.shootAnimation, 12);
			GunExt.AddProjectileModuleFrom(val, "klobb", true, false);
			PickupObject byId = PickupObjectDatabase.GetById(183);
			InputGuidedProjectile val2 = LichsGun.CopyFields<InputGuidedProjectile>(Object.Instantiate<Projectile>(((Gun)((byId is Gun) ? byId : null)).DefaultModule.projectiles[0]));
			((Component)val2).gameObject.SetActive(false);
			FakePrefab.MarkAsFakePrefab(((Component)val2).gameObject);
			Object.DontDestroyOnLoad((Object)(object)val2);
			((Projectile)val2).baseData.damage = 5f;
			((Projectile)val2).shouldRotate = true;
			((Object)val2).name = "LichsGun_Projectile";
			((Projectile)val2).baseData.range = 18f;
			((Projectile)val2).baseData.speed = 22f;
			val2.trackingSpeed = 500f;
			val2.dumbfireTime = -1f;
			PickupObject byId2 = PickupObjectDatabase.GetById(183);
			SpriteBuilder.SetProjectileSpriteRight((Projectile)(object)val2, "lichsgun_projectile_001", 6, 6, lightened: false, (Anchor)4, anchorChangesCollider: true, fixesScale: false, null, null, null, null, ((Gun)((byId2 is Gun) ? byId2 : null)).DefaultModule.projectiles[0]);
			val.DefaultModule.projectiles[0] = (Projectile)(object)val2;
			val.DefaultModule.shootStyle = (ShootStyle)0;
			val.DefaultModule.angleVariance = 0f;
			val.DefaultModule.ammoType = (AmmoType)1;
			val.DefaultModule.cooldownTime = 0.1f;
			val.DefaultModule.numberOfShotsInClip = 6;
			val.reloadClipLaunchFrame = 0;
			val.gunSwitchGroup = "SAA";
			val.reloadTime = 1.1f;
			val.SetBaseMaxAmmo(350);
			((PickupObject)val).quality = (ItemQuality)(-50);
			((Component)val.barrelOffset).transform.localPosition = new Vector3(1.1875f, 0.5625f, 0f);
			val.gunClass = (GunClass)1;
			val.InfiniteAmmo = true;
			tk2dSpriteAnimator component = ((Component)val).GetComponent<tk2dSpriteAnimator>();
			tk2dSpriteAnimationClip clipByName = component.GetClipByName(val.shootAnimation);
			tk2dSpriteAnimationClip clipByName2 = component.GetClipByName(val.reloadAnimation);
			Vector2 offset = default(Vector2);
			for (int i = 0; i < clipByName.frames.Length; i++)
			{
				tk2dSpriteAnimationFrame val3 = clipByName.frames[i];
				tk2dSpriteDefinition def = val3.spriteCollection.spriteDefinitions[val3.spriteId];
				((Vector2)(ref offset))..ctor((float)fireOffsets[i].x / 16f, (float)fireOffsets[i].y / 16f);
				SpriteBuilder.MakeOffset(def, offset);
			}
			Vector2 offset2 = default(Vector2);
			for (int j = 0; j < clipByName2.frames.Length; j++)
			{
				tk2dSpriteAnimationFrame val4 = clipByName2.frames[j];
				tk2dSpriteDefinition def2 = val4.spriteCollection.spriteDefinitions[val4.spriteId];
				((Vector2)(ref offset2))..ctor((float)reloadOffsets[j].x / 16f, (float)reloadOffsets[j].y / 16f);
				SpriteBuilder.MakeOffset(def2, offset2);
			}
			clipByName.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[shootFrames.Count];
			for (int k = 0; k < shootFrames.Count; k++)
			{
				string text = shootFrames[k];
				clipByName.frames[k] = new tk2dSpriteAnimationFrame
				{
					spriteCollection = Databases.Items.WeaponCollection,
					spriteId = Databases.Items.WeaponCollection.GetSpriteIdByName(text)
				};
			}
			clipByName2.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[reloadFrames.Count];
			for (int l = 0; l < reloadFrames.Count; l++)
			{
				string text2 = reloadFrames[l];
				clipByName2.frames[l] = new tk2dSpriteAnimationFrame
				{
					spriteCollection = Databases.Items.WeaponCollection,
					spriteId = Databases.Items.WeaponCollection.GetSpriteIdByName(text2)
				};
			}
			List<int> list = new List<int>
			{
				VFXCollection.GetSpriteIdByName("lichsgun_vfx_001"),
				VFXCollection.GetSpriteIdByName("lichsgun_vfx_002"),
				VFXCollection.GetSpriteIdByName("lichsgun_vfx_003"),
				VFXCollection.GetSpriteIdByName("lichsgun_vfx_004")
			};
			GameObject val5 = new GameObject("LichsGunMuzzleflash");
			val5.SetActive(false);
			FakePrefab.MarkAsFakePrefab(val5);
			Object.DontDestroyOnLoad((Object)(object)val5);
			((tk2dBaseSprite)val5.AddComponent<tk2dSprite>()).SetSprite(VFXCollection, list[0]);
			tk2dSpriteAnimator val6 = val5.AddComponent<tk2dSpriteAnimator>();
			SpriteBuilder.AddAnimation(val6, val5.GetComponent<tk2dBaseSprite>().Collection, list, "flash", (WrapMode)2).fps = 16f;
			val6.playAutomatically = true;
			val6.DefaultClipId = val6.GetClipIdByName("flash");
			SpriteAnimatorKiller val7 = val5.AddComponent<SpriteAnimatorKiller>();
			val7.fadeTime = -1f;
			val7.delayDestructionTime = -1f;
			val7.animator = val6;
			foreach (int item in list)
			{
				SpriteBuilder.ConstructOffsetsFromAnchor(VFXCollection.spriteDefinitions[item], (Anchor)3);
			}
			VFXPool val8 = new VFXPool();
			val8.type = (VFXPoolType)1;
			VFXComplex[] array = new VFXComplex[1];
			VFXComplex val9 = new VFXComplex();
			val9.effects = (VFXObject[])(object)new VFXObject[1]
			{
				new VFXObject
				{
					effect = val5,
					alignment = (VFXAlignment)0,
					attached = false,
					orphaned = true,
					persistsOnDeath = false,
					destructible = true,
					usesZHeight = true,
					zHeight = -0.25f
				}
			};
			array[0] = val9;
			val8.effects = (VFXComplex[])(object)array;
			val.muzzleFlashEffects = val8;
			Databases.Items.Add(val, (tk2dSpriteCollectionData)null, "ANY");
			InitSynergyForm(val);
		}

		public static void InitSynergyForm(Gun original)
		{
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_0230: 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)
			Gun val = Databases.Items.NewGun("Synergy Lich's Gun", "lichsgun2");
			Game.Items.Rename("outdated_gun_mods:synergy_lich's_gun", "spapi:lichs_gun+master_of_the_gungeon");
			GunExt.SetShortDescription((PickupObject)(object)val, "The Freeshooter");
			GunExt.SetLongDescription((PickupObject)(object)val, "The gun of the Gungeon master. The bullets of this gun can be guided after being fired.");
			GunExt.SetupSprite(val, (tk2dSpriteCollectionData)null, "lichsgun2_idle_001", 10);
			GunExt.SetAnimationFPS(val, val.shootAnimation, 12);
			GunExt.AddProjectileModuleFrom(val, "klobb", true, false);
			PickupObject byId = PickupObjectDatabase.GetById(183);
			InputGuidedProjectile val2 = LichsGun.CopyFields<InputGuidedProjectile>(Object.Instantiate<Projectile>(((Gun)((byId is Gun) ? byId : null)).DefaultModule.projectiles[0]));
			((Component)val2).gameObject.SetActive(false);
			FakePrefab.MarkAsFakePrefab(((Component)val2).gameObject);
			Object.DontDestroyOnLoad((Object)(object)val2);
			((Projectile)val2).baseData.damage = 3f;
			((Projectile)val2).shouldRotate = true;
			((Object)val2).name = "LichsGun2_Projectile";
			((Projectile)val2).baseData.range = 100f;
			((Projectile)val2).baseData.speed = 14f;
			val2.dumbfireTime = -1f;
			PickupObject byId2 = PickupObjectDatabase.GetById(183);
			SpriteBuilder.SetProjectileSpriteRight((Projectile)(object)val2, "lichsgun_projectile_001", 6, 6, lightened: false, (Anchor)4, anchorChangesCollider: true, fixesScale: false, null, null, null, null, ((Gun)((byId2 is Gun) ? byId2 : null)).DefaultModule.projectiles[0]);
			val.DefaultModule.projectiles[0] = (Projectile)(object)val2;
			val.DefaultModule.shootStyle = (ShootStyle)4;
			val.DefaultModule.angleVariance = 0f;
			val.DefaultModule.burstShotCount = 17;
			val.DefaultModule.burstCooldownTime = 0.06f;
			val.DefaultModule.ammoType = (AmmoType)1;
			val.DefaultModule.cooldownTime = 0.1f;
			val.DefaultModule.numberOfShotsInClip = 17;
			val.reloadClipLaunchFrame = 0;
			val.doesScreenShake = false;
			((PickupObject)val).quality = (ItemQuality)(-100);
			((Component)val.barrelOffset).transform.localPosition = new Vector3(1.1875f, 0.5625f, 0f);
			val.gunClass = (GunClass)1;
			val.gunSwitchGroup = "Hammer";
			val.gunHandedness = (GunHandedness)3;
			VFXPool val3 = new VFXPool();
			val3.type = (VFXPoolType)0;
			val3.effects = (VFXComplex[])(object)new VFXComplex[0];
			val.muzzleFlashEffects = val3;
			val.reloadTime = 1.1f;
			val.SetBaseMaxAmmo(700);
			val.gunSwitchGroup = "SPAPI_LichsGunSynergy";
			SoundManager.AddCustomSwitchData("WPN_Guns", "SPAPI_LichsGunSynergy", "Play_WPN_Gun_Shot_01", (SwitchedEvent[])(object)new SwitchedEvent[1] { SwitchedEvent.op_Implicit("Play_WPN_h4mmer_shot_01") });
			SoundManager.AddCustomSwitchData("WPN_Guns", "SPAPI_LichsGunSynergy", "Play_WPN_gun_reload_01", (SwitchedEvent[])(object)new SwitchedEvent[1] { SwitchedEvent.op_Implicit("Play_BOSS_lichC_morph_01") });
			Databases.Items.Add(val, (tk2dSpriteCollectionData)null, "ANY");
			TransformGunSynergyProcessor val4 = ((Component)original).gameObject.AddComponent<TransformGunSynergyProcessor>();
			val4.NonSynergyGunId = ((PickupObject)original).PickupObjectId;
			val4.SynergyGunId = ((PickupObject)val).PickupObjectId;
			val4.SynergyToCheck = LichsBookItem.MasterOfTheGungeonSynergy;
		}

		public static T CopyFields<T>(Projectile sample2) where T : Projectile
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			T val = ((Component)sample2).gameObject.AddComponent<T>();
			((Projectile)val).PossibleSourceGun = sample2.PossibleSourceGun;
			((Projectile)val).SpawnedFromOtherPlayerProjectile = sample2.SpawnedFromOtherPlayerProjectile;
			((Projectile)val).PlayerProjectileSourceGameTimeslice = sample2.PlayerProjectileSourceGameTimeslice;
			((Projectile)val).BulletScriptSettings = sample2.BulletScriptSettings;
			((Projectile)val).damageTypes = sample2.damageTypes;
			((Projectile)val).allowSelfShooting = sample2.allowSelfShooting;
			((Projectile)val).collidesWithPlayer = sample2.collidesWithPlayer;
			((Projectile)val).collidesWithProjectiles = sample2.collidesWithProjectiles;
			((Projectile)val).collidesOnlyWithPlayerProjectiles = sample2.collidesOnlyWithPlayerProjectiles;
			((Projectile)val).projectileHitHealth = sample2.projectileHitHealth;
			((Projectile)val).collidesWithEnemies = sample2.collidesWithEnemies;
			((Projectile)val).shouldRotate = sample2.shouldRotate;
			((Projectile)val).shouldFlipVertically = sample2.shouldFlipVertically;
			((Projectile)val).shouldFlipHorizontally = sample2.shouldFlipHorizontally;
			((Projectile)val).ignoreDamageCaps = sample2.ignoreDamageCaps;
			((Projectile)val).baseData = sample2.baseData;
			((Projectile)val).AppliesPoison = sample2.AppliesPoison;
			((Projectile)val).PoisonApplyChance = sample2.PoisonApplyChance;
			((Projectile)val).healthEffect = sample2.healthEffect;
			((Projectile)val).AppliesSpeedModifier = sample2.AppliesSpeedModifier;
			((Projectile)val).SpeedApplyChance = sample2.SpeedApplyChance;
			((Projectile)val).speedEffect = sample2.speedEffect;
			((Projectile)val).AppliesCharm = sample2.AppliesCharm;
			((Projectile)val).CharmApplyChance = sample2.CharmApplyChance;
			((Projectile)val).charmEffect = sample2.charmEffect;
			((Projectile)val).AppliesFreeze = sample2.AppliesFreeze;
			((Projectile)val).FreezeApplyChance = sample2.FreezeApplyChance;
			((Projectile)val).freezeEffect = sample2.freezeEffect;
			((Projectile)val).AppliesFire = sample2.AppliesFire;
			((Projectile)val).FireApplyChance = sample2.FireApplyChance;
			((Projectile)val).fireEffect = sample2.fireEffect;
			((Projectile)val).AppliesStun = sample2.AppliesStun;
			((Projectile)val).StunApplyChance = sample2.StunApplyChance;
			((Projectile)val).AppliedStunDuration = sample2.AppliedStunDuration;
			((Projectile)val).AppliesBleed = sample2.AppliesBleed;
			((Projectile)val).bleedEffect = sample2.bleedEffect;
			((Projectile)val).AppliesCheese = sample2.AppliesCheese;
			((Projectile)val).CheeseApplyChance = sample2.CheeseApplyChance;
			((Projectile)val).cheeseEffect = sample2.cheeseEffect;
			((Projectile)val).BleedApplyChance = sample2.BleedApplyChance;
			((Projectile)val).CanTransmogrify = sample2.CanTransmogrify;
			((Projectile)val).ChanceToTransmogrify = sample2.ChanceToTransmogrify;
			((Projectile)val).TransmogrifyTargetGuids = sample2.TransmogrifyTargetGuids;
			((Projectile)val).BossDamageMultiplier = sample2.BossDamageMultiplier;
			((Projectile)val).SpawnedFromNonChallengeItem = sample2.SpawnedFromNonChallengeItem;
			((Projectile)val).TreatedAsNonProjectileForChallenge = sample2.TreatedAsNonProjectileForChallenge;
			((Projectile)val).hitEffects = sample2.hitEffects;
			((Projectile)val).CenterTilemapHitEffectsByProjectileVelocity = sample2.CenterTilemapHitEffectsByProjectileVelocity;
			((Projectile)val).wallDecals = sample2.wallDecals;
			((Projectile)val).persistTime = sample2.persistTime;
			((Projectile)val).angularVelocity = sample2.angularVelocity;
			((Projectile)val).angularVelocityVariance = sample2.angularVelocityVariance;
			((Projectile)val).spawnEnemyGuidOnDeath = sample2.spawnEnemyGuidOnDeath;
			((Projectile)val).HasFixedKnockbackDirection = sample2.HasFixedKnockbackDirection;
			((Projectile)val).FixedKnockbackDirection = sample2.FixedKnockbackDirection;
			((Projectile)val).pierceMinorBreakables = sample2.pierceMinorBreakables;
			((Projectile)val).objectImpactEventName = sample2.objectImpactEventName;
			((Projectile)val).enemyImpactEventName = sample2.enemyImpactEventName;
			((Projectile)val).onDestroyEventName = sample2.onDestroyEventName;
			((Projectile)val).additionalStartEventName = sample2.additionalStartEventName;
			((Projectile)val).IsRadialBurstLimited = sample2.IsRadialBurstLimited;
			((Projectile)val).MaxRadialBurstLimit = sample2.MaxRadialBurstLimit;
			((Projectile)val).AdditionalBurstLimits = sample2.AdditionalBurstLimits;
			((Projectile)val).AppliesKnockbackToPlayer = sample2.AppliesKnockbackToPlayer;
			((Projectile)val).PlayerKnockbackForce = sample2.PlayerKnockbackForce;
			((Projectile)val).HasDefaultTint = sample2.HasDefaultTint;
			((Projectile)val).DefaultTintColor = sample2.DefaultTintColor;
			((Projectile)val).IsCritical = sample2.IsCritical;
			((Projectile)val).BlackPhantomDamageMultiplier = sample2.BlackPhantomDamageMultiplier;
			((Projectile)val).PenetratesInternalWalls = sample2.PenetratesInternalWalls;
			((Projectile)val).neverMaskThis = sample2.neverMaskThis;
			((Projectile)val).isFakeBullet = sample2.isFakeBullet;
			((Projectile)val).CanBecomeBlackBullet = sample2.CanBecomeBlackBullet;
			((Projectile)val).TrailRenderer = sample2.TrailRenderer;
			((Projectile)val).CustomTrailRenderer = sample2.CustomTrailRenderer;
			((Projectile)val).ParticleTrail = sample2.ParticleTrail;
			((Projectile)val).DelayedDamageToExploders = sample2.DelayedDamageToExploders;
			((Projectile)val).OnHitEnemy = sample2.OnHitEnemy;
			((Projectile)val).OnWillKillEnemy = sample2.OnWillKillEnemy;
			((Projectile)val).OnBecameDebris = sample2.OnBecameDebris;
			((Projectile)val).OnBecameDebrisGrounded = sample2.OnBecameDebrisGrounded;
			((Projectile)val).IsBlackBullet = sample2.IsBlackBullet;
			((Projectile)val).statusEffectsToApply = sample2.statusEffectsToApply;
			((Projectile)val).AdditionalScaleMultiplier = sample2.AdditionalScaleMultiplier;
			((Projectile)val).ModifyVelocity = sample2.ModifyVelocity;
			((Projectile)val).CurseSparks = sample2.CurseSparks;
			((Projectile)val).PreMoveModifiers = sample2.PreMoveModifiers;
			((Projectile)val).OverrideMotionModule = sample2.OverrideMotionModule;
			((Projectile)val).Shooter = sample2.Shooter;
			((Projectile)val).Owner = sample2.Owner;
			((Projectile)val).Speed = sample2.Speed;
			((Projectile)val).Direction = sample2.Direction;
			((Projectile)val).DestroyMode = sample2.DestroyMode;
			((Projectile)val).Inverted = sample2.Inverted;
			((Projectile)val).LastVelocity = sample2.LastVelocity;
			((Projectile)val).ManualControl = sample2.ManualControl;
			((Projectile)val).ForceBlackBullet = sample2.ForceBlackBullet;
			((Projectile)val).IsBulletScript = sample2.IsBulletScript;
			((Projectile)val).OverrideTrailPoint = sample2.OverrideTrailPoint;
			((Projectile)val).SkipDistanceElapsedCheck = sample2.SkipDistanceElapsedCheck;
			((Projectile)val).ImmuneToBlanks = sample2.ImmuneToBlanks;
			((Projectile)val).ImmuneToSustainedBlanks = sample2.ImmuneToSustainedBlanks;
			((Projectile)val).ForcePlayerBlankable = sample2.ForcePlayerBlankable;
			((Projectile)val).IsReflectedBySword = sample2.IsReflectedBySword;
			((Projectile)val).LastReflectedSlashId = sample2.LastReflectedSlashId;
			((Projectile)val).TrailRendererController = sample2.TrailRendererController;
			((Projectile)val).braveBulletScript = sample2.braveBulletScript;
			((Projectile)val).TrapOwner = sample2.TrapOwner;
			((Projectile)val).SuppressHitEffects = sample2.SuppressHitEffects;
			Object.Destroy((Object)(object)sample2);
			return val;
		}
	}
	[BepInPlugin("spapi.etg.lichitems", "Lich Items", "1.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LichModule : BaseUnityPlugin
	{
		private class InstantDestroyDustup : MonoBehaviour
		{
			public void Start()
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public const string GUID = "spapi.etg.lichitems";

		public void Awake()
		{
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
		}

		public void GMStart(GameManager gm)
		{
			//IL_0006: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("spapi.etg.lichitems").PatchAll();
			ItemBuilder.Init();
			CrossChamber.Init();
			LichsBookItem.Init();
			LichsGun.Init();
			CustomSynergies.Add("Master of the Gungeon", LichsBookItem.MasterOfTheGungeonSynergy, new List<string>(3) { "spapi:lichs_gun", "spapi:lichs_book", "lichs_eye_bullets" });
			CustomSynergies.Add("Crossfire", CrossChamber.CrossfireSynergy, new List<string>(2) { "spapi:cross_chamber", "magnum" });
			ETGMod.StartGlobalCoroutine(DelayedStartCR());
		}

		private IEnumerator DelayedStartCR()
		{
			yield return null;
			Object obj2 = BraveResources.Load("PlayerLich", ".prefab");
			GameObject obj = (GameObject)(object)((obj2 is GameObject) ? obj2 : null);
			PlayerController player = default(PlayerController);
			int num;
			if (!((Object)(object)obj == (Object)null))
			{
				player = obj.GetComponent<PlayerController>();
				num = ((player == null) ? 1 : 0);
			}
			else
			{
				num = 1;
			}
			if (num != 0)
			{
				yield break;
			}
			GameObject dustup = new GameObject("InvisibleInstantDestroyDustup");
			dustup.SetActive(false);
			FakePrefab.MarkAsFakePrefab(dustup);
			Object.DontDestroyOnLoad((Object)(object)dustup);
			dustup.AddComponent<InstantDestroyDustup>();
			((GameActor)player).OverrideDustUp = dustup;
			tk2dSpriteAnimationClip[] clips = ((BraveBehaviour)player).spriteAnimator.Library.clips;
			foreach (tk2dSpriteAnimationClip clip in clips)
			{
				tk2dSpriteAnimationFrame[] frames = clip.frames;
				foreach (tk2dSpriteAnimationFrame frame in frames)
				{
					if (!string.IsNullOrEmpty(frame.eventAudio) && (!(frame.eventAudio != "Play_FS") || !(frame.eventAudio != "Play_CHR_boot_stairs_01")))
					{
						frame.eventAudio = "";
					}
				}
			}
		}
	}
}
namespace LichItems.ItemAPI
{
	public static class CompanionBuilder
	{
		public enum AnimationType
		{
			Move,
			Idle,
			Fidget,
			Flight,
			Hit,
			Talk,
			Other
		}

		private static GameObject behaviorSpeculatorPrefab;

		public static Dictionary<string, GameObject> companionDictionary = new Dictionary<string, GameObject>();

		public static void Init()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			string companionGuid = ((Component)Game.Items["dog"]).GetComponent<CompanionItem>().CompanionGuid;
			AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(companionGuid);
			behaviorSpeculatorPrefab = Object.Instantiate<GameObject>(((Component)orLoadByGuid).gameObject);
			foreach (Transform item in behaviorSpeculatorPrefab.transform)
			{
				Transform val = item;
				if ((Object)(object)val != (Object)(object)behaviorSpeculatorPrefab.transform)
				{
					Object.DestroyImmediate((Object)(object)val);
				}
			}
			Component[] components = behaviorSpeculatorPrefab.GetComponents<Component>();
			foreach (Component val2 in components)
			{
				if ((object)((object)val2).GetType() != typeof(BehaviorSpeculator))
				{
					Object.DestroyImmediate((Object)(object)val2);
				}
			}
			Object.DontDestroyOnLoad((Object)(object)behaviorSpeculatorPrefab);
			FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab);
			behaviorSpeculatorPrefab.SetActive(false);
			Hook val3 = new Hook((MethodBase)typeof(EnemyDatabase).GetMethod("GetOrLoadByGuid", BindingFlags.Static | BindingFlags.Public), typeof(CompanionBuilder).GetMethod("GetOrLoadByGuid"));
		}

		public static AIActor GetOrLoadByGuid(Func<string, AIActor> orig, string guid)
		{
			foreach (string key in companionDictionary.Keys)
			{
				if (key == guid)
				{
					return companionDictionary[key].GetComponent<AIActor>();
				}
			}
			return orig(guid);
		}

		public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize)
		{
			//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)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			if (companionDictionary.ContainsKey(guid))
			{
				ETGModConsole.Log((object)"CompanionBuilder: Tried to create two companion prefabs with the same GUID!", false);
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(behaviorSpeculatorPrefab);
			((Object)val).name = name;
			tk2dSprite component = SpriteBuilder.SpriteFromResource(defaultSpritePath, val).GetComponent<tk2dSprite>();
			component.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = false;
			val.AddComponent<tk2dSpriteAnimator>();
			val.AddComponent<AIAnimator>();
			HealthHaver val2 = val.AddComponent<HealthHaver>();
			val2.RegisterBodySprite((tk2dBaseSprite)(object)component, false, 0);
			val2.PreventAllDamage = true;
			val2.SetHealthMaximum(15000f, (float?)null, false);
			val2.FullHeal();
			AIActor val3 = val.AddComponent<AIActor>();
			val3.State = (ActorState)2;
			val3.EnemyGuid = guid;
			BehaviorSpeculator component2 = val.GetComponent<BehaviorSpeculator>();
			component2.MovementBehaviors = new List<MovementBehaviorBase>();
			component2.AttackBehaviors = new List<AttackBehaviorBase>();
			component2.TargetBehaviors = new List<TargetBehaviorBase>();
			component2.OverrideBehaviors = new List<OverrideBehaviorBase>();
			component2.OtherBehaviors = new List<BehaviorBase>();
			EnemyDatabaseEntry item = new EnemyDatabaseEntry
			{
				myGuid = guid,
				placeableWidth = 2,
				placeableHeight = 2,
				isNormalEnemy = false
			};
			((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries.Add(item);
			companionDictionary.Add(guid, val);
			Object.DontDestroyOnLoad((Object)(object)val);
			FakePrefab.MarkAsFakePrefab(val);
			val.SetActive(false);
			return val;
		}

		public static tk2dSpriteAnimationClip AddAnimation(this GameObject obj, string name, string spriteDirectory, int fps, AnimationType type, DirectionType directionType = 0, FlipType flipType = 0)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected I4, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			AIAnimator orAddComponent = GameObjectExtensions.GetOrAddComponent<AIAnimator>(obj);
			DirectionalAnimation val = orAddComponent.GetDirectionalAnimation(name, directionType, type);
			if (val == null)
			{
				DirectionalAnimation val2 = new DirectionalAnimation();
				val2.AnimNames = new string[0];
				val2.Flipped = (FlipType[])(object)new FlipType[0];
				val2.Type = directionType;
				val2.Prefix = string.Empty;
				val = val2;
			}
			val.AnimNames = val.AnimNames.Concat(new string[1] { name }).ToArray();
			val.Flipped = val.Flipped.Concat((IEnumerable<FlipType>)(object)new FlipType[1] { (FlipType)(int)flipType }).ToArray();
			orAddComponent.AssignDirectionalAnimation(name, val, type);
			return BuildAnimation(orAddComponent, name, spriteDirectory, fps);
		}

		public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps)
		{
			tk2dSpriteCollectionData val = ((Component)aiAnimator).GetComponent<tk2dSpriteCollectionData>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SpriteBuilder.ConstructCollection(((Component)aiAnimator).gameObject, ((Object)aiAnimator).name + "_collection");
			}
			string[] resourceNames = ResourceExtractor.GetResourceNames();
			List<int> list = new List<int>();
			for (int i = 0; i < resourceNames.Length; i++)
			{
				if (resourceNames[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase))
				{
					list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], val));
				}
			}
			tk2dSpriteAnimationClip val2 = SpriteBuilder.AddAnimation(((BraveBehaviour)aiAnimator).spriteAnimator, val, list, name, (WrapMode)0);
			val2.fps = fps;
			return val2;
		}

		public static DirectionalAnimation GetDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionType directionType, AnimationType type)
		{
			DirectionalAnimation val = null;
			switch (type)
			{
			case AnimationType.Idle:
				val = aiAnimator.IdleAnimation;
				break;
			case AnimationType.Move:
				val = aiAnimator.MoveAnimation;
				break;
			case AnimationType.Flight:
				val = aiAnimator.FlightAnimation;
				break;
			case AnimationType.Hit:
				val = aiAnimator.HitAnimation;
				break;
			case AnimationType.Talk:
				val = aiAnimator.TalkAnimation;
				break;
			}
			if (val != null)
			{
				return val;
			}
			return null;
		}

		public static void AssignDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionalAnimation animation, AnimationType type)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_007f: Expected O, but got Unknown
			switch (type)
			{
			case AnimationType.Idle:
				aiAnimator.IdleAnimation = animation;
				return;
			case AnimationType.Move:
				aiAnimator.MoveAnimation = animation;
				return;
			case AnimationType.Flight:
				aiAnimator.FlightAnimation = animation;
				return;
			case AnimationType.Hit:
				aiAnimator.HitAnimation = animation;
				return;
			case AnimationType.Talk:
				aiAnimator.TalkAnimation = animation;
				return;
			case AnimationType.Fidget:
				aiAnimator.IdleFidgetAnimations.Add(animation);
				return;
			}
			aiAnimator.OtherAnimations.Add(new NamedDirectionalAnimation
			{
				anim = animation,
				name = name
			});
		}
	}
	public static class CustomSynergies
	{
		public static AdvancedSynergyEntry Add(string name, CustomSynergyType synergyType, List<string> mandatoryConsoleIDs, List<string> optionalConsoleIDs = null, bool ignoreLichEyeBullets = true)
		{
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			if (mandatoryConsoleIDs == null || mandatoryConsoleIDs.Count == 0)
			{
				ETGModConsole.Log((object)("Synergy " + name + " has no mandatory items/guns."), false);
				return null;
			}
			List<int> list = new List<int>();
			List<int> list2 = new List<int>();
			List<int> list3 = new List<int>();
			List<int> list4 = new List<int>();
			string text = ETGMod.ToID(name).ToUpperInvariant();
			string text2 = "#SPAPI_" + text;
			foreach (string mandatoryConsoleID in mandatoryConsoleIDs)
			{
				PickupObject val = Game.Items[mandatoryConsoleID];
				if (Object.op_Implicit((Object)(object)val) && val is Gun)
				{
					list2.Add(val.PickupObjectId);
					continue;
				}
				bool flag = Object.op_Implicit((Object)(object)val);
				bool flag2 = flag;
				if (flag2)
				{
					bool flag3 = ((val is PlayerItem || val is PassiveItem) ? true : false);
					flag2 = flag3;
				}
				if (flag2)
				{
					list.Add(val.PickupObjectId);
				}
			}
			if (optionalConsoleIDs != null)
			{
				foreach (string optionalConsoleID in optionalConsoleIDs)
				{
					PickupObject val2 = Game.Items[optionalConsoleID];
					if (Object.op_Implicit((Object)(object)val2) && val2 is Gun)
					{
						list4.Add(val2.PickupObjectId);
						continue;
					}
					bool flag4 = Object.op_Implicit((Object)(object)val2);
					bool flag5 = flag4;
					if (flag5)
					{
						bool flag3 = ((val2 is PlayerItem || val2 is PassiveItem) ? true : false);
						flag5 = flag3;
					}
					if (flag5)
					{
						list3.Add(val2.PickupObjectId);
					}
				}
			}
			AdvancedSynergyEntry val3 = new AdvancedSynergyEntry
			{
				NameKey = text2,
				MandatoryItemIDs = list,
				MandatoryGunIDs = list2,
				OptionalItemIDs = list3,
				OptionalGunIDs = list4,
				bonusSynergies = new List<CustomSynergyType>(1) { synergyType },
				statModifiers = new List<StatModifier>(),
				IgnoreLichEyeBullets = ignoreLichEyeBullets,
				ActiveWhenGunUnequipped = true
			};
			Databases.Strings.Synergy.Set(text2, name);
			Add(val3);
			return val3;
		}

		public static void Add(AdvancedSynergyEntry synergyEntry)
		{
			GameManager.Instance.SynergyManager.synergies = CollectionExtensions.AddToArray<AdvancedSynergyEntry>(GameManager.Instance.SynergyManager.synergies, synergyEntry);
		}

		public static bool HasMTGConsoleID(this PlayerController player, string consoleID)
		{
			if (!Game.Items.ContainsID(consoleID))
			{
				return false;
			}
			return player.HasPickupID(Game.Items[consoleID].PickupObjectId);
		}
	}
	public class FakePrefab : Component
	{
		internal static HashSet<GameObject> ExistingFakePrefabs = new HashSet<GameObject>();

		public static bool IsFakePrefab(Object o)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (o is GameObject)
			{
				return ExistingFakePrefabs.Contains((GameObject)o);
			}
			if (o is Component)
			{
				return ExistingFakePrefabs.Contains(((Component)o).gameObject);
			}
			return false;
		}

		public static void MarkAsFakePrefab(GameObject obj)
		{
			ExistingFakePrefabs.Add(obj);
		}

		public static GameObject Clone(GameObject obj)
		{
			bool flag = IsFakePrefab((Object)(object)obj);
			bool activeSelf = obj.activeSelf;
			if (activeSelf)
			{
				obj.SetActive(false);
			}
			GameObject val = Object.Instantiate<GameObject>(obj);
			if (activeSelf)
			{
				obj.SetActive(true);
			}
			ExistingFakePrefabs.Add(val);
			if (flag)
			{
			}
			return val;
		}

		public static Object Instantiate(Object o, Object new_o)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0022: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			if (o is GameObject && ExistingFakePrefabs.Contains((GameObject)o))
			{
				((GameObject)new_o).SetActive(true);
			}
			else if (o is Component && ExistingFakePrefabs.Contains(((Component)o).gameObject))
			{
				((Component)new_o).gameObject.SetActive(true);
			}
			return new_o;
		}
	}
	public static class FakePrefabHooks
	{
		public delegate TResult Func<T1, T2, T3, T4, T5, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);

		public static void Init()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			Hook val = new Hook((MethodBase)typeof(PlayerController).GetMethod("AcquirePassiveItemPrefabDirectly"), typeof(FakePrefabHooks).GetMethod("AcquirePassiveItemPrefabDirectly"));
			Hook val2 = new Hook((MethodBase)typeof(PlayerItem).GetMethod("Pickup"), typeof(FakePrefabHooks).GetMethod("ActivePickup"));
			Hook val3 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3]
			{
				typeof(Object),
				typeof(Transform),
				typeof(bool)
			}), typeof(FakePrefabHooks).GetMethod("InstantiateOPI"));
			Hook val4 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[2]
			{
				typeof(Object),
				typeof(Transform)
			}), typeof(FakePrefabHooks).GetMethod("InstantiateOP"));
			Hook val5 = new Hook((MethodBase)typeof(Object).GetMethod("orig_Instantiate", new Type[1] { typeof(Object) }), typeof(FakePrefabHooks).GetMethod("InstantiateO"));
			Hook val6 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3]
			{
				typeof(Object),
				typeof(Vector3),
				typeof(Quaternion)
			}), typeof(FakePrefabHooks).GetMethod("InstantiateOPR"));
			Hook val7 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[4]
			{
				typeof(Object),
				typeof(Vector3),
				typeof(Quaternion),
				typeof(Transform)
			}), typeof(FakePrefabHooks).GetMethod("InstantiateOPRP"));
		}

		public static void AcquirePassiveItemPrefabDirectly(Action<PlayerController, PassiveItem> orig, PlayerController self, PassiveItem item)
		{
			bool flag = FakePrefab.IsFakePrefab((Object)(object)((Component)item).gameObject);
			if (flag)
			{
				((Component)item).gameObject.SetActive(true);
			}
			orig(self, item);
			if (flag)
			{
				((Component)item).gameObject.SetActive(false);
			}
		}

		public static void ActivePickup(Action<PlayerItem, PlayerController> orig, PlayerItem self, PlayerController player)
		{
			bool flag = FakePrefab.IsFakePrefab((Object)(object)((Component)self).gameObject);
			if (flag)
			{
				((Component)self).gameObject.SetActive(true);
			}
			orig(self, player);
			if (flag)
			{
				((Component)self).gameObject.SetActive(false);
			}
		}

		public static Object InstantiateOPI(Func<Object, Transform, bool, Object> orig, Object original, Transform parent, bool instantiateInWorldSpace)
		{
			return FakePrefab.Instantiate(original, orig(original, parent, instantiateInWorldSpace));
		}

		public static Object InstantiateOP(Func<Object, Transform, Object> orig, Object original, Transform parent)
		{
			return FakePrefab.Instantiate(original, orig(original, parent));
		}

		public static Object InstantiateO(Func<Object, Object> orig, Object original)
		{
			return FakePrefab.Instantiate(original, orig(original));
		}

		public static Object InstantiateOPR(Func<Object, Vector3, Quaternion, Object> orig, Object original, Vector3 position, Quaternion rotation)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return FakePrefab.Instantiate(original, orig(original, position, rotation));
		}

		public static Object InstantiateOPRP(Func<Object, Vector3, Quaternion, Transform, Object> orig, Object original, Vector3 position, Quaternion rotation, Transform parent)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return FakePrefab.Instantiate(original, orig(original, position, rotation, parent));
		}
	}
	public static class ItemBuilder
	{
		public enum CooldownType
		{
			Timed,
			Damage,
			PerRoom,
			None
		}

		public enum ShopType
		{
			Goopton,
			Flynt,
			Cursula,
			Trorc,
			OldRed
		}

		public static Dictionary<ShopType, GenericLootTable> shopInventories;

		public static void Init()
		{
			FakePrefabHooks.Init();
			CompanionBuilder.Init();
			LoadShopTables();
		}

		private static void LoadShopTables()
		{
			shopInventories = new Dictionary<ShopType, GenericLootTable>();
			shopInventories.Add(ShopType.Flynt, LoadShopTable("Shop_Key_Items_01"));
			shopInventories.Add(ShopType.Trorc, LoadShopTable("Shop_Truck_Items_01"));
			shopInventories.Add(ShopType.Cursula, LoadShopTable("Shop_Curse_Items_01"));
			shopInventories.Add(ShopType.Goopton, LoadShopTable("Shop_Goop_Items_01"));
			shopInventories.Add(ShopType.OldRed, LoadShopTable("Shop_Blank_Items_01"));
		}

		public static GenericLootTable LoadShopTable(string assetName)
		{
			return ResourceManager.LoadAssetBundle("shared_auto_001").LoadAsset<GenericLootTable>(assetName);
		}

		public static GameObject AddSpriteToObject(string name, string resourcePath, GameObject obj = null)
		{
			GameObject val = SpriteBuilder.SpriteFromResource(resourcePath, obj);
			FakePrefab.MarkAsFakePrefab(val);
			obj.SetActive(false);
			((Object)val).name = name;
			return val;
		}

		public static void SetupItem(this PickupObject item, string shortDesc, string longDesc, string idPool = "ItemAPI")
		{
			try
			{
				((BraveBehaviour)item).encounterTrackable = null;
				Databases.Items.SetupItem(item, ((Object)item).name);
				SpriteBuilder.AddToAmmonomicon(((BraveBehaviour)item).sprite.GetCurrentSpriteDef());
				((BraveBehaviour)item).encounterTrackable.journalData.AmmonomiconSprite = ((BraveBehaviour)item).sprite.GetCurrentSpriteDef().name;
				GunExt.SetName(item, ((Object)item).name);
				GunExt.SetShortDescription(item, shortDesc);
				GunExt.SetLongDescription(item, longDesc);
				if (item is PlayerItem)
				{
					((PlayerItem)((item is PlayerItem) ? item : null)).consumable = false;
				}
				Game.Items.Add(idPool + ":" + ((Object)item).name.ToLower().Replace(" ", "_"), item);
				Databases.Items.Add(item, false, "ANY");
			}
			catch (Exception ex)
			{
				ETGModConsole.Log((object)ex.Message, false);
				ETGModConsole.Log((object)ex.StackTrace, false);
			}
		}

		public static void AddToSubShop(this PickupObject po, ShopType type, float weight = 1f)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			WeightedGameObjectCollection defaultItemDrops = shopInventories[type].defaultItemDrops;
			WeightedGameObject val = new WeightedGameObject();
			val.pickupId = po.PickupObjectId;
			val.weight = weight;
			val.rawGameObject = ((Component)po).gameObject;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			defaultItemDrops.Add(val);
		}

		public static void SetCooldownType(this PlayerItem item, CooldownType cooldownType, float value)
		{
			item.damageCooldown = -1f;
			item.roomCooldown = -1;
			item.timeCooldown = -1f;
			switch (cooldownType)
			{
			case CooldownType.Timed:
				item.timeCooldown = value;
				break;
			case CooldownType.Damage:
				item.damageCooldown = value;
				break;
			case CooldownType.PerRoom:
				item.roomCooldown = (int)value;
				break;
			}
		}

		public static StatModifier AddPassiveStatModifier(this PickupObject po, StatType statType, float amount, ModifyMethod method = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			StatModifier val = new StatModifier();
			val.amount = amount;
			val.statToBoost = statType;
			val.modifyType = method;
			po.AddPassiveStatModifier(val);
			return val;
		}

		public static void AddPassiveStatModifier(this PickupObject po, StatModifier modifier)
		{
			if (po is PlayerItem)
			{
				PlayerItem val = (PlayerItem)(object)((po is PlayerItem) ? po : null);
				if (val.passiveStatModifiers == null)
				{
					val.passiveStatModifiers = (StatModifier[])(object)new StatModifier[1] { modifier };
				}
				else
				{
					val.passiveStatModifiers = val.passiveStatModifiers.Concat((IEnumerable<StatModifier>)(object)new StatModifier[1] { modifier }).ToArray();
				}
				return;
			}
			if (po is PassiveItem)
			{
				PassiveItem val2 = (PassiveItem)(object)((po is PassiveItem) ? po : null);
				if (val2.passiveStatModifiers == null)
				{
					val2.passiveStatModifiers = (StatModifier[])(object)new StatModifier[1] { modifier };
				}
				else
				{
					val2.passiveStatModifiers = val2.passiveStatModifiers.Concat((IEnumerable<StatModifier>)(object)new StatModifier[1] { modifier }).ToArray();
				}
				return;
			}
			throw new NotSupportedException("Object must be of type PlayerItem or PassiveItem");
		}

		public static bool RemovePassiveStatModifier(this PickupObject po, StatModifier modifier)
		{
			bool flag = false;
			if (po is PlayerItem)
			{
				PlayerItem val = (PlayerItem)(object)((po is PlayerItem) ? po : null);
				if (val.passiveStatModifiers == null)
				{
					return false;
				}
				List<StatModifier> list = val.passiveStatModifiers.ToList();
				flag = list.Remove(modifier);
				val.passiveStatModifiers = list.ToArray();
			}
			else
			{
				if (!(po is PassiveItem))
				{
					throw new NotSupportedException("Object must be of type PlayerItem or PassiveItem");
				}
				PassiveItem val2 = (PassiveItem)(object)((po is PassiveItem) ? po : null);
				if (val2.passiveStatModifiers == null)
				{
					return false;
				}
				List<StatModifier> list2 = val2.passiveStatModifiers.ToList();
				flag = list2.Remove(modifier);
				val2.passiveStatModifiers = list2.ToArray();
			}
			return flag;
		}

		public static IEnumerator HandleDuration(PlayerItem item, float duration, PlayerController user, Action<PlayerController> OnFinish)
		{
			if (!item.IsCurrentlyActive)
			{
				SetPrivateType<PlayerItem>(item, "m_isCurrentlyActive", value: true);
				SetPrivateType<PlayerItem>(item, "m_activeElapsed", 0f);
				SetPrivateType<PlayerItem>(item, "m_activeDuration", duration);
				item.OnActivationStatusChanged?.Invoke(item);
				GetPrivateType<PlayerItem, float>(item, "m_activeElapsed");
				GetPrivateType<PlayerItem, float>(item, "m_activeDuration");
				while (GetPrivateType<PlayerItem, float>(item, "m_activeElapsed") < GetPrivateType<PlayerItem, float>(item, "m_activeDuration") && item.IsCurrentlyActive)
				{
					yield return null;
				}
				SetPrivateType<PlayerItem>(item, "m_isCurrentlyActive", value: false);
				item.OnActivationStatusChanged?.Invoke(item);
				OnFinish?.Invoke(user);
			}
		}

		private static void SetPrivateType<T>(T obj, string field, bool value)
		{
			FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic);
			field2.SetValue(obj, value);
		}

		private static void SetPrivateType<T>(T obj, string field, float value)
		{
			FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic);
			field2.SetValue(obj, value);
		}

		private static T2 GetPrivateType<T, T2>(T obj, string field)
		{
			FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic);
			return (T2)field2.GetValue(obj);
		}
	}
	public static class ResourceExtractor
	{
		private static string spritesDirectory = Path.Combine(ETGMod.ResourcesDirectory, "sprites");

		public static List<Texture2D> GetTexturesFromDirectory(string directoryPath)
		{
			if (!Directory.Exists(directoryPath))
			{
				ETGModConsole.Log((object)(directoryPath + " not found."), false);
				return null;
			}
			List<Texture2D> list = new List<Texture2D>();
			string[] files = Directory.GetFiles(directoryPath);
			foreach (string text in files)
			{
				if (text.EndsWith(".png"))
				{
					Texture2D item = BytesToTexture(File.ReadAllBytes(text), Path.GetFileName(text).Replace(".png", ""));
					list.Add(item);
				}
			}
			return list;
		}

		public static Texture2D GetTextureFromFile(string fileName, string extension = ".png")
		{
			fileName = fileName.Replace(extension, "");
			string text = Path.Combine(spritesDirectory, fileName + extension);
			if (!File.Exists(text))
			{
				ETGModConsole.Log((object)(text + " not found."), false);
				return null;
			}
			return BytesToTexture(File.ReadAllBytes(text), fileName);
		}

		public static List<string> GetCollectionFiles()
		{
			List<string> list = new List<string>();
			string[] files = Directory.GetFiles(spritesDirectory);
			foreach (string text in files)
			{
				if (text.EndsWith(".png"))
				{
					list.Add(Path.GetFileName(text).Replace(".png", ""));
				}
			}
			return list;
		}

		public static Texture2D BytesToTexture(byte[] bytes, string resourceName)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, bytes);
			((Texture)val).filterMode = (FilterMode)0;
			((Object)val).name = resourceName;
			return val;
		}

		public static string[] GetLinesFromEmbeddedResource(string filePath)
		{
			string text = BytesToString(ExtractEmbeddedResource(filePath));
			return text.Split(new char[1] { '\n' });
		}

		public static string[] GetLinesFromFile(string filePath)
		{
			string text = BytesToString(File.ReadAllBytes(filePath));
			return text.Split(new char[1] { '\n' });
		}

		public static string BytesToString(byte[] bytes)
		{
			return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
		}

		public static List<string> GetResourceFolders()
		{
			List<string> list = new List<string>();
			string path = Path.Combine(ETGMod.ResourcesDirectory, "sprites");
			if (Directory.Exists(path))
			{
				string[] directories = Directory.GetDirectories(path);
				foreach (string path2 in directories)
				{
					list.Add(Path.GetFileName(path2));
				}
			}
			return list;
		}

		public static byte[] ExtractEmbeddedResource(string filePath)
		{
			filePath = filePath.Replace("/", ".");
			filePath = filePath.Replace("\\", ".");
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			using Stream stream = callingAssembly.GetManifestResourceStream(filePath);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return array;
		}

		public static Texture2D GetTextureFromResource(string resourceName)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			byte[] array = ExtractEmbeddedResource(resourceName);
			if (array == null)
			{
				ETGModConsole.Log((object)("No bytes found in " + resourceName), false);
				return null;
			}
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			string text = resourceName.Substring(0, resourceName.LastIndexOf('.'));
			if (text.LastIndexOf('.') >= 0)
			{
				text = text.Substring(text.LastIndexOf('.') + 1);
			}
			((Object)val).name = text;
			return val;
		}

		public static string[] GetResourceNames()
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			string[] manifestResourceNames = callingAssembly.GetManifestResourceNames();
			if (manifestResourceNames == null)
			{
				ETGModConsole.Log((object)"No manifest resources found.", false);
				return null;
			}
			return manifestResourceNames;
		}
	}
	public static class SpriteBuilder
	{
		private static tk2dSpriteCollectionData itemCollection = ((BraveBehaviour)PickupObjectDatabase.GetById(155)).sprite.Collection;

		private static tk2dSpriteCollectionData ammonomiconCollection = AmmonomiconController.ForceInstance.EncounterIconCollection;

		private static tk2dSprite baseSprite = ((Component)PickupObjectDatabase.GetById(155)).GetComponent<tk2dSprite>();

		public static GameObject SpriteFromFile(string spriteName, GameObject obj = nu