Decompiled source of The Dimension Hopper v1.0.1

plugins/DimensionHopper.dll

Decompiled 2 months 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 Alexandria;
using Alexandria.Assetbundle;
using Alexandria.CharacterAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using BepInEx;
using DimensionHopper;
using Dungeonator;
using Gungeon;
using Pathfinding;
using Planetside;
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("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Planetside
{
	public class DimensionalAnchor : PlayerItem
	{
		public static GameObject Text;

		public static AIActor theGuy;

		public static VFXPool HighPriestClapVFX;

		public static GenericLootTable lootTable;

		public static ParticleSystem particleSystemVoid;

		public static bool isSmoking;

		private Coroutine coroutine;

		private MeshRenderer VoidTextInstance;

		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: 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_0390: Expected O, but got Unknown
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Expected O, but got Unknown
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			string text = "Dimensional Anchor";
			GameObject val = new GameObject(text);
			DimensionalAnchor dimensionalAnchor = val.AddComponent<DimensionalAnchor>();
			tk2dSpriteCollectionData item_Collection = StaticCollections.Item_Collection;
			ItemBuilder.AddSpriteToObjectAssetbundle(text, item_Collection.GetSpriteIdByName("anchor"), item_Collection, val);
			string text2 = "Weight Of The World";
			string text3 = "Anchors you to this dimension.\n\nOpening the anchor, even in short bursts, causes unpredictable results.";
			ItemBuilder.SetupItem((PickupObject)(object)dimensionalAnchor, text2, text3, "tdh");
			ItemBuilder.SetCooldownType((PlayerItem)(object)dimensionalAnchor, (CooldownType)2, 8f);
			((PlayerItem)dimensionalAnchor).consumable = false;
			((PickupObject)dimensionalAnchor).quality = (ItemQuality)(-50);
			ItemBuilder.AddPassiveStatModifier((PickupObject)(object)dimensionalAnchor, (StatType)14, -2f, (ModifyMethod)0);
			GameObject val2 = FakePrefab.Clone(((Component)((Component)((BraveBehaviour)PickupObjectDatabase.GetById(597)).transform.GetChild(6)).transform).gameObject);
			val2.gameObject.SetActive(true);
			particleSystemVoid = val2.GetComponent<ParticleSystem>();
			GameManager.Instance.RainbowRunForceExcludedIDs.Add(((PickupObject)dimensionalAnchor).PickupObjectId);
			GameObjectExtensions.SetLayerRecursively(val2.gameObject, LayerMask.NameToLayer("Unpixelated"));
			SizeOverLifetimeModule sizeOverLifetime = particleSystemVoid.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			AnimationCurve val3 = new AnimationCurve();
			val3.AddKey(0f, 0.01f);
			val3.AddKey(0.3f, 1f);
			val3.AddKey(1f, 0f);
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1.5f, val3);
			RoomRewardAPI.OnRoomRewardDetermineContents = (Action<RoomHandler, ValidRoomRewardContents, float>)Delegate.Combine(RoomRewardAPI.OnRoomRewardDetermineContents, new Action<RoomHandler, ValidRoomRewardContents, float>(ORDC));
			lootTable = LootUtility.CreateLootTable((List<GenericLootTable>)null, (DungeonPrerequisite[])null);
			LootUtility.AddItemsToPool(lootTable, new Dictionary<int, float> { { 127, 1f } });
			AIAnimator aiAnimator = ((BraveBehaviour)EnemyDatabase.GetOrLoadByGuid("6c43fddfd401456c916089fdd1c99b1c")).aiAnimator;
			List<NamedVFXPool> otherVFX = aiAnimator.OtherVFX;
			foreach (NamedVFXPool item in otherVFX)
			{
				if (!(item.name == "mergo"))
				{
					continue;
				}
				VFXComplex[] effects = item.vfxPool.effects;
				foreach (VFXComplex val4 in effects)
				{
					VFXObject[] effects2 = val4.effects;
					foreach (VFXObject sample in effects2)
					{
						VFXObject val5 = Toolbox.CopyFields<VFXObject>(sample);
						HighPriestClapVFX = new VFXPool();
						HighPriestClapVFX.type = (VFXPoolType)4;
						VFXPool highPriestClapVFX = HighPriestClapVFX;
						VFXComplex[] array = new VFXComplex[1];
						VFXComplex val6 = new VFXComplex();
						val6.effects = (VFXObject[])(object)new VFXObject[1] { val5 };
						array[0] = val6;
						highPriestClapVFX.effects = (VFXComplex[])(object)array;
					}
				}
			}
			AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(EnemyGUIDs.Bullet_Kin_GUID);
			GameObject val7 = Object.Instantiate<GameObject>(((Component)orLoadByGuid).gameObject);
			Object.DontDestroyOnLoad((Object)(object)val7);
			FakePrefab.MarkAsFakePrefab(val7);
			val7.SetActive(false);
			AIActor component = val7.GetComponent<AIActor>();
			component.procedurallyOutlined = true;
			component.AssignedCurrencyToDrop = 0;
			component.AdditionalSafeItemDrops = new List<PickupObject>();
			component.AdditionalSimpleItemDrops = new List<PickupObject>();
			float maxHealth = ((BraveBehaviour)component).healthHaver.GetMaxHealth();
			((BraveBehaviour)component).healthHaver.SetHealthMaximum(maxHealth * 50f, (float?)null, false);
			((BraveBehaviour)component).healthHaver.AllDamageMultiplier = 0.1f;
			component.CanTargetEnemies = true;
			component.CanTargetPlayers = true;
			component.IsHarmlessEnemy = true;
			component.IgnoreForRoomClear = true;
			CompanionController val8 = ((Component)component).gameObject.AddComponent<CompanionController>();
			val8.companionID = (CompanionIdentifier)9;
			val8.CanCrossPits = true;
			CompanionFollowPlayerBehavior val9 = new CompanionFollowPlayerBehavior();
			val9.CanRollOverPits = false;
			val9.DisableInCombat = true;
			val9.PathInterval = 0.25f;
			val9.IdealRadius = 4f;
			val9.CatchUpRadius = 8f;
			val9.CatchUpAccelTime = 5f;
			val9.CatchUpSpeed = (component.MovementSpeed *= 1.2f);
			val9.CatchUpMaxSpeed = (component.MovementSpeed *= 1.3f);
			val9.TemporarilyDisabled = true;
			BehaviorSpeculator component2 = ((Component)component).GetComponent<BehaviorSpeculator>();
			component2.MovementBehaviors.Add((MovementBehaviorBase)(object)val9);
			theGuy = component;
		}

		public override void Pickup(PlayerController player)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			if (base.m_pickedUpThisRun)
			{
				AkSoundEngine.PostEvent("Play_OBJ_dice_bless_01", ((Component)player).gameObject);
				for (int i = 0; i < 4; i++)
				{
					PickupObject byId = PickupObjectDatabase.GetById(538);
					SpawnManager.SpawnVFX(((SilverBulletsPassiveItem)((byId is SilverBulletsPassiveItem) ? byId : null)).SynergyPowerVFX, Vector2Extensions.ToVector3ZisY(((BraveBehaviour)player).sprite.WorldCenter, 0f) + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 100f), Quaternion.identity).GetComponent<tk2dBaseSprite>().PlaceAtPositionByAnchor(Vector2Extensions.ToVector3ZisY(((BraveBehaviour)player).sprite.WorldCenter, 0f), (Anchor)4);
				}
				for (int j = 0; j < 8; j++)
				{
					ParticleSystem obj = particleSystemVoid;
					EmitParams val = default(EmitParams);
					((EmitParams)(ref val)).position = ((BraveBehaviour)player).transform.position;
					((EmitParams)(ref val)).rotation = BraveUtility.RandomAngle();
					((EmitParams)(ref val)).velocity = Vector2.op_Implicit(BraveUtility.RandomVector2(new Vector2(-1f, -1f), new Vector2(1f, 1f)));
					obj.Emit(val, 1);
				}
			}
			((PlayerItem)this).Pickup(player);
		}

		public override void DoEffect(PlayerController user)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0075: 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_0089: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: 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_032d: Expected O, but got Unknown
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Expected O, but got Unknown
			AkSoundEngine.PostEvent("Play_ENV_time_shatter_01", ((Component)user).gameObject);
			Exploder.DoDistortionWave(((BraveBehaviour)user).sprite.WorldCenter, 2f, 0.25f, 30f, 1f);
			for (int i = 0; i < 32; i++)
			{
				ParticleSystem obj = particleSystemVoid;
				EmitParams val = default(EmitParams);
				((EmitParams)(ref val)).position = ((BraveBehaviour)user).transform.position;
				((EmitParams)(ref val)).rotation = BraveUtility.RandomAngle();
				((EmitParams)(ref val)).velocity = Vector2.op_Implicit(BraveUtility.RandomVector2(new Vector2(-1f, -1f), new Vector2(1f, 1f)));
				obj.Emit(val, 1);
			}
			if (Random.value < 0.05f)
			{
				base.remainingRoomCooldown -= 4;
				int num = Random.Range(0, 10);
				AkSoundEngine.PostEvent("Play_OBJ_dice_bless_01", ((Component)user).gameObject);
				switch (num)
				{
				case 0:
				{
					AkSoundEngine.PostEvent("Play_OBJ_prize_won_01", ((Component)user).gameObject);
					Confetti(((BraveBehaviour)base.LastOwner).sprite.WorldCenter);
					Toolbox.NotifyCustom("Wait, What?", "A free chest?!?", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					IntVector2 bestRewardLocation = ((DungeonPlaceableBehaviour)user).GetAbsoluteParentRoom().GetBestRewardLocation(new IntVector2(2, 1), (RewardLocationStyle)2, true);
					Chest val5 = user.CurrentRoom.SpawnRoomRewardChest((WeightedGameObjectCollection)null, bestRewardLocation);
					val5.ForceUnlock();
					if ((Object)(object)val5 != (Object)null)
					{
						if ((double)Random.value > 0.2)
						{
							val5.contents = new List<PickupObject>();
							val5.contents.Clear();
							val5.contents.Add(PickupObjectDatabase.GetById(127));
						}
						val5.RegisterChestOnMinimap(((DungeonPlaceableBehaviour)user).GetAbsoluteParentRoom());
						Confetti(((BraveBehaviour)val5).sprite.WorldCenter);
					}
					break;
				}
				case 1:
					Toolbox.NotifyCustom("Wait, What?", "It's the mod developer?!?", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					((MonoBehaviour)this).StartCoroutine(DoWackyStuff(user));
					break;
				case 2:
					Toolbox.NotifyCustom("Wait, What?", "He has arrived!", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					((MonoBehaviour)this).StartCoroutine(SpawnTheSwarm(user));
					break;
				case 3:
					Toolbox.NotifyCustom("Wait, What?", "Ammo refills?!?", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					((MonoBehaviour)this).StartCoroutine(SpawnTheAmmo(user));
					break;
				case 4:
					Toolbox.NotifyCustom("Wait, What?", "BEES!!!", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					((MonoBehaviour)this).StartCoroutine(SpawnTheBees(user));
					break;
				case 5:
				{
					Toolbox.NotifyCustom("Wait, What?", "Armored Up!", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					HealthHaver healthHaver = ((BraveBehaviour)user).healthHaver;
					healthHaver.Armor += 2f;
					((GameActor)user).PlayEffectOnActor((GameObject)ResourceCache.Acquire("Global VFX/VFX_Healing_Sparkles_001"), new Vector3(0f, 0f), true, false, false);
					AkSoundEngine.PostEvent("Play_OBJ_heart_heal_01", ((Component)user).gameObject);
					break;
				}
				case 6:
				{
					Toolbox.NotifyCustom("Wait, What?", "Just 2 Glass Guon Stones?", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					for (int k = 0; k < 2; k++)
					{
						GameObject val4 = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(565)).gameObject, Vector3.zero, Quaternion.identity);
						PickupObject component2 = val4.GetComponent<PickupObject>();
						if ((Object)(object)component2 != (Object)null)
						{
							component2.CanBeDropped = false;
							component2.Pickup(user);
						}
					}
					break;
				}
				case 7:
				{
					Vector3 position = ((BraveBehaviour)user).transform.position;
					Toolbox.NotifyCustom("Wait, What?", "We have a problem.", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					PickupObject byId = PickupObjectDatabase.GetById(645);
					AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(((MulticompanionItem)((byId is MulticompanionItem) ? byId : null)).CompanionGuid);
					for (int l = 0; l < 6; l++)
					{
						GameObject val6 = Object.Instantiate<GameObject>(((Component)orLoadByGuid).gameObject, position, Quaternion.identity);
						CompanionController orAddComponent = GameObjectExtensions.GetOrAddComponent<CompanionController>(val6);
						orAddComponent.Initialize(user);
						if (Object.op_Implicit((Object)(object)((BraveBehaviour)orAddComponent).specRigidbody))
						{
							PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(((BraveBehaviour)orAddComponent).specRigidbody, (int?)null, false);
						}
					}
					break;
				}
				case 8:
					Toolbox.NotifyCustom("Wait, What?", "Bomb has been planted.", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					((MonoBehaviour)this).StartCoroutine(SpawnTheBombs(user));
					break;
				case 9:
				{
					Toolbox.NotifyCustom("Wait, What?", "This guns gone wrong!", "guh", StaticCollections.Item_Collection, (NotificationColor)2);
					GameObject gameObject = ((Component)PickupObjectDatabase.GetRandomGun()).gameObject;
					DebrisObject val2 = LootEngine.SpawnItem(gameObject, Vector2.op_Implicit(((BraveBehaviour)user).sprite.WorldCenter), Vector2.zero, 0f, false, false, false);
					Gun componentInChildren = ((Component)val2).GetComponentInChildren<Gun>();
					if (!Object.op_Implicit((Object)(object)componentInChildren))
					{
						break;
					}
					((BraveBehaviour)componentInChildren).sprite.usesOverrideMaterial = true;
					Material material = ((BraveBehaviour)componentInChildren).renderer.material;
					material.shader = ShaderCache.Acquire("Brave/Internal/Glitch");
					material.SetFloat("_GlitchInterval", 0.2f);
					material.SetFloat("_DispProbability", 0.6f);
					material.SetFloat("_DispIntensity", 0.05f);
					material.SetFloat("_ColorProbability", 0.4f);
					material.SetFloat("_ColorIntensity", 0.2f);
					MeshRenderer component = ((Component)componentInChildren).GetComponent<MeshRenderer>();
					if (!Object.op_Implicit((Object)(object)component))
					{
						break;
					}
					Material[] array = ((Renderer)component).sharedMaterials;
					for (int j = 0; j < array.Length; j++)
					{
						if ((Object)(object)array[j].shader == (Object)(object)material)
						{
							return;
						}
					}
					Array.Resize(ref array, array.Length + 1);
					Material val3 = new Material(material);
					val3.SetTexture("_MainTex", array[0].GetTexture("_MainTex"));
					array[^1] = val3;
					((Renderer)component).sharedMaterials = array;
					componentInChildren.reloadTime *= (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					componentInChildren.SetBaseMaxAmmo((int)((float)componentInChildren.maxAmmo * (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f))));
					float num2 = (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					float num3 = (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					float num4 = (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					float num5 = (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					float num6 = (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					float num7 = (BraveUtility.RandomBool() ? Random.Range(1f, 10f) : Random.Range(0.1f, 1f));
					if (Object.op_Implicit((Object)(object)componentInChildren.Volley) && componentInChildren.Volley.projectiles != null)
					{
						foreach (ProjectileModule projectile in componentInChildren.Volley.projectiles)
						{
							projectile.cooldownTime *= num2;
							projectile.numberOfShotsInClip = (int)((float)projectile.numberOfShotsInClip * num3);
							projectile.angleVariance *= num5;
							projectile.burstShotCount = (int)((float)projectile.burstShotCount * num6);
							projectile.burstCooldownTime *= num7;
							if (projectile.chargeProjectiles != null && projectile.chargeProjectiles.Count > 0)
							{
								foreach (ChargeProjectile chargeProjectile in projectile.chargeProjectiles)
								{
									chargeProjectile.ChargeTime *= num4;
								}
							}
						}
						break;
					}
					ProjectileModule defaultModule = componentInChildren.DefaultModule;
					defaultModule.cooldownTime *= num2;
					componentInChildren.DefaultModule.numberOfShotsInClip = (int)((float)componentInChildren.DefaultModule.numberOfShotsInClip * num3);
					ProjectileModule defaultModule2 = componentInChildren.DefaultModule;
					defaultModule2.angleVariance *= num5;
					componentInChildren.DefaultModule.burstShotCount = (int)((float)componentInChildren.DefaultModule.burstShotCount * num6);
					ProjectileModule defaultModule3 = componentInChildren.DefaultModule;
					defaultModule3.burstCooldownTime *= num7;
					if (componentInChildren.DefaultModule.chargeProjectiles == null || componentInChildren.DefaultModule.chargeProjectiles.Count <= 0)
					{
						break;
					}
					{
						foreach (ChargeProjectile chargeProjectile2 in componentInChildren.DefaultModule.chargeProjectiles)
						{
							chargeProjectile2.ChargeTime *= num4;
						}
						break;
					}
				}
				}
			}
			else
			{
				LootEngine.DoDefaultPurplePoof(((BraveBehaviour)user).specRigidbody.UnitBottomCenter, false);
				AkSoundEngine.PostEvent("Play_ENM_darken_world_01", ((Component)GameManager.Instance.BestActivePlayer).gameObject);
				((MonoBehaviour)user).StartCoroutine(DoCurseCloud(user));
				((MonoBehaviour)this).Invoke("Say", 2.5f);
			}
		}

		private IEnumerator SpawnTheBombs(PlayerController user)
		{
			RoomHandler room = user.CurrentRoom;
			PickupObject byId = PickupObjectDatabase.GetById(108);
			GameObject b = ((SpawnObjectPlayerItem)((byId is SpawnObjectPlayerItem) ? byId : null)).objectToSpawn;
			for (int i = 0; i < 50; i++)
			{
				yield return (object)new WaitForSeconds(0.2f);
				IntVector2 pos = room.GetRandomAvailableCell((IntVector2?)null, (CellTypes?)null, false, (CellValidator)null).Value;
				Object.Instantiate<GameObject>(b, Vector2.op_Implicit(((IntVector2)(ref pos)).ToCenterVector2()), Quaternion.identity);
				pos = default(IntVector2);
			}
		}

		private IEnumerator DoWackyStuff(PlayerController user)
		{
			Vector2 pos = ((BraveBehaviour)user).sprite.WorldCenter;
			HighPriestClapVFX.SpawnAtPosition(Vector2.op_Implicit(pos), 0f, (Transform)null, (Vector2?)null, (Vector2?)null, (float?)null, false, (SpawnMethod)null, (tk2dBaseSprite)null, false);
			yield return (object)new WaitForSeconds(1f);
			AIActor enemy = AIActor.Spawn(EnemyDatabase.GetOrLoadByGuid(EnemyGUIDs.Robots_Past_Rabbit_GUID), pos, user.CurrentRoom, false, (AwakenAnimationType)0, true);
			GameObject gameObject = (GameObject)Object.Instantiate(BraveResources.Load("DamagePopupLabel", ".prefab"), ((BraveBehaviour)GameUIRoot.Instance).transform);
			Vector3 worldPosition = ((BraveBehaviour)this).transform.position;
			dfLabel Label = gameObject.GetComponent<dfLabel>();
			dfLabel targetLabel = Label;
			((Component)targetLabel).gameObject.SetActive(true);
			targetLabel.Text = "Some Bunny";
			((dfControl)targetLabel).Color = Color32.op_Implicit(Color.white);
			((dfControl)targetLabel).Opacity = 1f;
			((Component)targetLabel).transform.position = Vector3Extensions.WithZ(dfFollowObject.ConvertWorldSpaces(worldPosition, GameManager.Instance.MainCameraController.Camera, GameUIRoot.Instance.Manager.RenderCamera), 0f);
			((Component)targetLabel).transform.position = dfVectorExtensions.QuantizeFloor(((Component)targetLabel).transform.position, ((dfControl)targetLabel).PixelsToUnits() / (Pixelator.Instance.ScaleTileScale / Pixelator.Instance.CurrentTileScale));
			dfFollowObject component = ((Component)targetLabel).gameObject.AddComponent<dfFollowObject>();
			component.attach = ((Component)enemy).gameObject;
			((Behaviour)component).enabled = true;
			component.mainCamera = GameManager.Instance.MainCameraController.Camera;
			component.anchor = (dfPivotPoint)4;
			component.offset += new Vector3(-0.5f, 1.5f);
		}

		private IEnumerator SpawnTheBees(PlayerController user)
		{
			_ = user.CurrentRoom;
			for (int i = 0; i < 200; i++)
			{
				yield return (object)new WaitForSeconds(0.05f);
				PickupObject byId = PickupObjectDatabase.GetById(14);
				GameObject spawnedBulletOBJ = SpawnManager.SpawnProjectile(((Component)((Gun)((byId is Gun) ? byId : null)).DefaultModule.projectiles[0]).gameObject, Vector2.op_Implicit(((BraveBehaviour)user).sprite.WorldCenter), Quaternion.Euler(0f, 0f, BraveUtility.RandomAngle()), true);
				Projectile component = spawnedBulletOBJ.GetComponent<Projectile>();
				if ((Object)(object)component != (Object)null)
				{
					component.Owner = (GameActor)(object)user;
					component.Shooter = ((BraveBehaviour)user).specRigidbody;
					user.DoPostProcessProjectile(component);
				}
			}
		}

		private IEnumerator SpawnTheAmmo(PlayerController user)
		{
			RoomHandler room = user.CurrentRoom;
			for (int i = 0; i < 25; i++)
			{
				yield return (object)new WaitForSeconds(0.2f);
				IntVector2 pos = room.GetRandomAvailableCell((IntVector2?)null, (CellTypes?)null, false, (CellValidator)null).Value;
				SpawnCrate(78, user, Vector2.op_Implicit(((IntVector2)(ref pos)).ToVector3()));
				pos = default(IntVector2);
			}
		}

		private static void SpawnCrate(int item, PlayerController p, Vector2 position)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			AkSoundEngine.PostEvent("Play_OBJ_supplydrop_activate_01", ((Component)p).gameObject);
			GameObject val = (GameObject)BraveResources.Load("EmergencyCrate", ".prefab");
			GameObject val2 = Object.Instantiate<GameObject>(val);
			EmergencyCrateController component = val2.GetComponent<EmergencyCrateController>();
			SupplyDropDoer.SimplerCrateBehaviour simplerCrateBehaviour = component.TurnIntoSimplerCrate();
			simplerCrateBehaviour.easyLootID = item;
			simplerCrateBehaviour.OnCrateLandedContext = (Action<Vector2, SupplyDropDoer.SimplerCrateBehaviour, DebrisObject>)Delegate.Combine(simplerCrateBehaviour.OnCrateLandedContext, (Action<Vector2, SupplyDropDoer.SimplerCrateBehaviour, DebrisObject>)delegate(Vector2 obj1, SupplyDropDoer.SimplerCrateBehaviour obj2, DebrisObject obj3)
			{
				((MonoBehaviour)GameManager.Instance).StartCoroutine(HandleManualCoinSpawnLifespan(((BraveBehaviour)obj3).sprite, 5f));
			});
			simplerCrateBehaviour.Trigger(new Vector3(-5f, -5f, -5f), Vector2Extensions.ToVector3ZUp(position, 0f) + new Vector3(15f, 15f, 15f), p.CurrentRoom);
		}

		private static IEnumerator HandleManualCoinSpawnLifespan(tk2dBaseSprite coins, float lifeTime)
		{
			float elapsed = 0f;
			while (elapsed < lifeTime * 0.75f)
			{
				if ((Object)(object)coins == (Object)null)
				{
					yield break;
				}
				elapsed += BraveTime.DeltaTime;
				yield return null;
			}
			float flickerTimer = 0f;
			while (elapsed < lifeTime)
			{
				elapsed += BraveTime.DeltaTime;
				flickerTimer += BraveTime.DeltaTime;
				if ((Object)(object)coins != (Object)null && Object.op_Implicit((Object)(object)((BraveBehaviour)coins).renderer))
				{
					bool enabled = flickerTimer % 0.2f > 0.15f;
					((BraveBehaviour)coins).renderer.enabled = enabled;
				}
				else if ((Object)(object)coins == (Object)null)
				{
					yield break;
				}
				yield return null;
			}
			Object.Destroy((Object)(object)((Component)coins).gameObject);
		}

		private IEnumerator SpawnTheSwarm(PlayerController user)
		{
			RoomHandler room = user.CurrentRoom;
			IntVector2 pos = room.GetRandomAvailableCell((IntVector2?)null, (CellTypes?)null, false, (CellValidator)null).Value;
			HighPriestClapVFX.SpawnAtPosition(Vector2.op_Implicit(((IntVector2)(ref pos)).ToVector2()), 0f, (Transform)null, (Vector2?)null, (Vector2?)null, (float?)null, false, (SpawnMethod)null, (tk2dBaseSprite)null, false);
			yield return (object)new WaitForSeconds(1f);
			AIActor aiactor = AIActor.Spawn(theGuy, pos, room, true, (AwakenAnimationType)0, true);
			CompanionController comp = ((Component)((BraveBehaviour)aiactor).gameActor).GetComponent<CompanionController>();
			comp.Initialize(user);
			aiactor.CompanionOwner = user;
			((BraveBehaviour)aiactor).specRigidbody.Reinitialize();
		}

		public void Confetti(Vector2 targetCenter)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0053: 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_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[3] { "Global VFX/Confetti_Blue_001", "Global VFX/Confetti_Yellow_001", "Global VFX/Confetti_Green_001" };
			for (int i = 0; i < 8; i++)
			{
				GameObject val = (GameObject)BraveResources.Load(array[Random.Range(0, 3)], ".prefab");
				WaftingDebrisObject component = Object.Instantiate<GameObject>(val).GetComponent<WaftingDebrisObject>();
				((BraveBehaviour)component).sprite.PlaceAtPositionByAnchor(Vector2Extensions.ToVector3ZUp(targetCenter, 0f) + new Vector3(0.5f, 0.5f, 0f), (Anchor)4);
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				insideUnitCircle.y = 0f - Mathf.Abs(insideUnitCircle.y);
				((DebrisObject)component).Trigger(Vector2Extensions.ToVector3ZUp(insideUnitCircle, 1.5f) * Random.Range(0.5f, 2f), 0.5f, 0f);
			}
		}

		public static void ORDC(RoomHandler room, ValidRoomRewardContents validRoomRewardContents, float chance)
		{
			if (validRoomRewardContents != null && isSmoking)
			{
				validRoomRewardContents.additionalRewardChance -= 1f;
			}
		}

		public void Say()
		{
			Toolbox.NotifyCustom("A Cursed Fog", "Clouds the surrounding rooms...", "curseSkull1", StaticCollections.Item_Collection, (NotificationColor)2);
		}

		public override bool CanBeUsed(PlayerController user)
		{
			return !user.IsInCombat;
		}

		public IEnumerator DoCurseCloud(PlayerController playerController)
		{
			while (!playerController.IsInCombat)
			{
				yield return null;
			}
			isSmoking = true;
			AkSoundEngine.PostEvent("Play_ENM_beholster_teleport_01", ((Component)playerController).gameObject);
			yield return (object)new WaitForSeconds(0.75f);
			if (playerController.CurrentRoom != null)
			{
				playerController.CurrentRoom.BecomeTerrifyingDarkRoom(3f, 0.99f, 1.3f, "");
			}
			while (playerController.IsInCombat)
			{
				if (!GameManager.Instance.IsPaused)
				{
					if (playerController.CurrentRoom != null && Random.value < 0.4f)
					{
						IntVector2? cell = playerController.CurrentRoom.GetRandomAvailableCell((IntVector2?)null, (CellTypes?)null, false, (CellValidator)null);
						if (cell.HasValue)
						{
							ParticleSystem obj = particleSystemVoid;
							EmitParams val = default(EmitParams);
							IntVector2 value = cell.Value;
							((EmitParams)(ref val)).position = ((IntVector2)(ref value)).ToCenterVector3(1f);
							((EmitParams)(ref val)).rotation = BraveUtility.RandomAngle();
							((EmitParams)(ref val)).velocity = Vector2.op_Implicit(BraveUtility.RandomVector2(new Vector2(-1f, -1f), new Vector2(1f, 1f)));
							obj.Emit(val, 1);
						}
					}
					foreach (AIActor entry in playerController.CurrentRoom.GetActiveEnemies((ActiveEnemyType)0))
					{
						if (!entry.IsBlackPhantom && (int)entry.State == 2)
						{
							entry.BecomeBlackPhantom();
							LootEngine.DoDefaultPurplePoof(((BraveBehaviour)entry).specRigidbody.UnitBottomCenter, false);
							? val2 = entry;
							Object obj2 = ResourceCache.Acquire("Global VFX/VFX_Curse");
							((GameActor)val2).PlayEffectOnActor((GameObject)(object)((obj2 is GameObject) ? obj2 : null), Vector3.zero, true, false, false);
							yield return (object)new WaitForSeconds(0.15f);
							break;
						}
					}
				}
				yield return null;
			}
			if ((int)playerController.CurrentRoom.area.PrototypeRoomCategory == 3)
			{
				IntVector2 intVector = IntVector2.Zero;
				intVector = (playerController.CurrentRoom.OverrideBossPedestalLocation.HasValue ? playerController.CurrentRoom.OverrideBossPedestalLocation.Value : ((playerController.CurrentRoom.area.IsProceduralRoom || !(playerController.CurrentRoom.area.runtimePrototypeData.rewardChestSpawnPosition != IntVector2.NegOne)) ? playerController.CurrentRoom.GetCenteredVisibleClearSpot(2, 2) : (playerController.CurrentRoom.area.basePosition + playerController.CurrentRoom.area.runtimePrototypeData.rewardChestSpawnPosition)));
				for (int i = -1; i < 2; i++)
				{
					Vector3 p = ((IntVector2)(ref intVector)).ToCenterVector3(0f) + new Vector3((float)(3 * i), -2.5f);
					((MonoBehaviour)this).StartCoroutine(SpawnBossPickup(p));
					yield return (object)new WaitForSeconds(0.125f);
				}
				intVector = default(IntVector2);
			}
			playerController.CurrentRoom.EndTerrifyingDarkRoom(3f, 0.99f, 1.3f, "");
			AkSoundEngine.PostEvent("Play_ENM_lighten_world_01", ((Component)GameManager.Instance.BestActivePlayer).gameObject);
			Toolbox.NotifyCustom("The Fog Fades...", "", "curseSkull2", StaticCollections.Item_Collection, (NotificationColor)2, forceSingleLine: true);
			base.remainingRoomCooldown = base.roomCooldown;
			yield return (object)new WaitForSeconds(0.5f);
			isSmoking = false;
		}

		private IEnumerator SpawnBossPickup(Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			HighPriestClapVFX.SpawnAtPosition(position, 0f, (Transform)null, (Vector2?)null, (Vector2?)null, (float?)null, false, (SpawnMethod)null, (tk2dBaseSprite)null, false);
			yield return (object)new WaitForSeconds(1f);
			FloorRewardData data = GameManager.Instance.RewardManager.CurrentRewardData;
			DebrisObject debrisObject = LootEngine.SpawnItem(data.SingleItemRewardTable.SelectByWeight(false), position, Vector2.zero, 0f, true, false, false);
			PickupObject obj = ((Component)debrisObject).GetComponent<PickupObject>();
			if ((Object)(object)obj != (Object)null)
			{
				obj.RespawnsIfPitfall = true;
			}
			Exploder.DoRadialPush(Vector2Extensions.ToVector3ZUp(((BraveBehaviour)debrisObject).sprite.WorldCenter, ((BraveBehaviour)debrisObject).sprite.WorldCenter.y), 8f, 3f);
			AkSoundEngine.PostEvent("Play_OBJ_item_spawn_01", ((Component)debrisObject).gameObject);
		}

		public override void Update()
		{
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			((PlayerItem)this).Update();
			if ((Object)(object)base.LastOwner == (Object)null)
			{
				if ((Object)(object)VoidTextInstance == (Object)null)
				{
					GameObject val = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(155)).GetComponent<SpawnObjectPlayerItem>().objectToSpawn.GetComponent<BlackHoleDoer>().HellSynergyVFX, ((BraveBehaviour)this).transform.position, Quaternion.Euler(0f, 0f, 0f));
					GameObjectExtensions.SetLayerRecursively(val.gameObject, LayerMask.NameToLayer("BG_Critical"));
					MeshRenderer component = val.GetComponent<MeshRenderer>();
					((Renderer)component).material.SetFloat("_UVDistCutoff", 0f);
					((Renderer)component).material.SetTexture("_PortalTex", (Texture)(object)StaticCollections.NebulaTexture);
					VoidTextInstance = component;
					coroutine = ((MonoBehaviour)GameManager.Instance).StartCoroutine(HoldPortalOpen(component));
					AkSoundEngine.PostEvent("Play_ENM_beholster_teleport_01", ((Component)component).gameObject);
				}
				else
				{
					((Component)VoidTextInstance).gameObject.transform.position = ((BraveBehaviour)this).transform.position + new Vector3(0.5f, 0f);
					if (Random.value < 0.3f)
					{
						GlobalSparksDoer.DoRandomParticleBurst(1, ((BraveBehaviour)this).transform.position + new Vector3(-0.25f, -1f), ((BraveBehaviour)this).transform.position + new Vector3(2f, 1f), Vector3.up * 1.3f, 12f, 1f, (float?)0.2f, (float?)6f, (Color?)null, (SparksType)6);
					}
				}
			}
			else if ((Object)(object)VoidTextInstance != (Object)null)
			{
				if (coroutine != null)
				{
					((MonoBehaviour)GameManager.Instance).StopCoroutine(coroutine);
					coroutine = null;
				}
				if ((Object)(object)VoidTextInstance != (Object)null)
				{
					AkSoundEngine.PostEvent("Play_ENM_blobulord_charge_01", ((Component)VoidTextInstance).gameObject);
					coroutine = ((MonoBehaviour)GameManager.Instance).StartCoroutine(HoldPortalOpen(VoidTextInstance, Thing: false));
					VoidTextInstance = null;
				}
			}
		}

		public override void OnPreDrop(PlayerController user)
		{
			((PlayerItem)this).OnPreDrop(user);
		}

		private IEnumerator HoldPortalOpen(MeshRenderer portal, bool Thing = true)
		{
			float elapsed = 0f;
			while (elapsed < 2f)
			{
				elapsed += BraveTime.DeltaTime;
				float t = (Thing ? EaseOut(elapsed * 0.5f) : (1f - EaseOut(elapsed * 0.5f)));
				if ((Object)(object)portal == (Object)null || (Object)(object)((Component)portal).gameObject == (Object)null)
				{
					break;
				}
				((Renderer)portal).material.SetFloat("_UVDistCutoff", Mathf.Lerp(0f, 0.13f, t));
				((Renderer)portal).material.SetFloat("_HoleEdgeDepth", Mathf.Lerp(0f, 1f, t));
				yield return null;
			}
		}

		public static float EaseIn(float t)
		{
			return t * t;
		}

		public static float EaseInInverse(float t)
		{
			return 1f - t * t;
		}

		public static float Flip(float t)
		{
			return 1f - t;
		}

		public static float EaseOut(float t)
		{
			return Flip(EaseIn(Flip(t)));
		}
	}
}
namespace DimensionHopper
{
	public static class SupplyDropDoer
	{
		public class SimplerCrateBehaviour : BraveBehaviour
		{
			public int easyLootID;

			public float despawnDelay;

			public bool preventAutoDespawn;

			public string driftAnimationName;

			public string landedAnimationName;

			public string chuteLandedAnimationName;

			public string crateDisappearAnimationName;

			public tk2dSpriteAnimator chuteAnimator;

			public GameObject landingTargetSprite;

			private bool m_hasBeenTriggered;

			private Vector3 m_currentPosition;

			private Vector3 m_currentVelocity;

			private RoomHandler m_parentRoom;

			private GameObject m_landingTarget;

			public Action<Vector2, SimplerCrateBehaviour> OnCrateLanded;

			public Action<Vector2, SimplerCrateBehaviour, DebrisObject> OnCrateLandedContext;

			public SimplerCrateBehaviour()
			{
				easyLootID = -1;
				despawnDelay = -1f;
				preventAutoDespawn = false;
			}

			public void Trigger(Vector3 startingVelocity, Vector3 startingPosition, RoomHandler room)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: 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)
				//IL_0047: 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_004a: 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)
				//IL_005c: 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)
				m_parentRoom = room;
				m_currentPosition = startingPosition;
				m_currentVelocity = startingVelocity;
				m_hasBeenTriggered = true;
				GameObjectExtensions.SetLayerRecursively(((Component)this).gameObject, LayerMask.NameToLayer("Unoccluded"));
				float num = startingPosition.z / (0f - startingVelocity.z);
				Vector3 val = startingPosition + num * startingVelocity;
				m_landingTarget = SpawnManager.SpawnVFX(landingTargetSprite, val, Quaternion.identity);
				((tk2dBaseSprite)m_landingTarget.GetComponentInChildren<tk2dSprite>()).UpdateZDepth();
			}

			private void Update()
			{
				//IL_0011: 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)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				if (m_hasBeenTriggered)
				{
					m_currentPosition += m_currentVelocity * BraveTime.DeltaTime;
					if (m_currentPosition.z <= 0f)
					{
						m_currentPosition.z = 0f;
						OnLanded();
					}
					((BraveBehaviour)this).transform.position = BraveUtility.QuantizeVector(Vector3Extensions.WithZ(m_currentPosition, m_currentPosition.y - m_currentPosition.z), (float)PhysicsEngine.Instance.PixelsPerUnit);
					((BraveBehaviour)this).sprite.HeightOffGround = m_currentPosition.z;
					((BraveBehaviour)this).sprite.UpdateZDepth();
				}
			}

			private void OnLanded()
			{
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				m_hasBeenTriggered = false;
				((Component)((BraveBehaviour)this).sprite).gameObject.layer = LayerMask.NameToLayer("FG_Critical");
				((BraveBehaviour)((BraveBehaviour)this).sprite).renderer.sortingLayerName = "Background";
				((BraveBehaviour)this).sprite.IsPerpendicular = false;
				((BraveBehaviour)this).sprite.HeightOffGround = -1f;
				m_currentPosition.z = -1f;
				((BraveBehaviour)this).spriteAnimator.Play(landedAnimationName);
				chuteAnimator.PlayAndDestroyObject(chuteLandedAnimationName, (Action)null);
				if (Object.op_Implicit((Object)(object)m_landingTarget))
				{
					SpawnManager.Despawn(m_landingTarget);
				}
				m_landingTarget = null;
				if (OnCrateLanded != null)
				{
					OnCrateLanded(((BraveBehaviour)this).sprite.WorldCenter, this);
				}
				if (easyLootID != -1)
				{
					DebrisObject val = LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(easyLootID)).gameObject, Vector2Extensions.ToVector3ZUp(((BraveBehaviour)this).sprite.WorldCenter, 0f) + new Vector3(-0.5f, 0.5f, 0f), Vector2.zero, 0f, false, false, false);
					if (despawnDelay < 0f && !preventAutoDespawn)
					{
						((MonoBehaviour)this).StartCoroutine(DestroyCrateWhenPickedUp(val));
					}
					OnCrateLandedContext?.Invoke(((BraveBehaviour)this).sprite.WorldCenter, this, val);
				}
				if (despawnDelay >= 0f && !preventAutoDespawn)
				{
					((MonoBehaviour)this).StartCoroutine(DestroyCrateDelayed());
				}
			}

			private IEnumerator DestroyCrateDelayed()
			{
				yield return (object)new WaitForSeconds(despawnDelay);
				if (Object.op_Implicit((Object)(object)m_landingTarget))
				{
					SpawnManager.Despawn(m_landingTarget);
				}
				RemoveCrate();
			}

			private IEnumerator DestroyCrateWhenPickedUp(DebrisObject spawned)
			{
				while (Object.op_Implicit((Object)(object)spawned))
				{
					yield return (object)new WaitForSeconds(0.25f);
				}
				RemoveCrate();
			}

			public void RemoveCrate()
			{
				if (Object.op_Implicit((Object)(object)m_landingTarget))
				{
					SpawnManager.Despawn(m_landingTarget);
				}
				m_landingTarget = null;
				if ((Object)(object)m_parentRoom.ExtantEmergencyCrate == (Object)(object)((Component)this).gameObject)
				{
					m_parentRoom.ExtantEmergencyCrate = null;
				}
				((BraveBehaviour)this).spriteAnimator.Play(crateDisappearAnimationName);
			}

			public void ClearLandingTarget()
			{
				if (Object.op_Implicit((Object)(object)m_landingTarget))
				{
					SpawnManager.Despawn(m_landingTarget);
				}
				m_landingTarget = null;
			}
		}

		private static GameObject simplerCratePrefab;

		public static SimplerCrateBehaviour SpawnSupplyDrop(Vector2 position, int lootIDToSpawn = -1, float crateDespawnDelay = -1f, bool preventAutoDespawn = false)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if ((Object)(object)simplerCratePrefab == (Object)null)
			{
				GameObject val = (GameObject)BraveResources.Load("EmergencyCrate", ".prefab");
				GameObject val2 = FakePrefabExtensions.InstantiateAndFakeprefab(val);
				EmergencyCrateController component = val2.GetComponent<EmergencyCrateController>();
				SimplerCrateBehaviour simplerCrateBehaviour = val2.AddComponent<SimplerCrateBehaviour>();
				simplerCrateBehaviour.driftAnimationName = component.driftAnimationName;
				simplerCrateBehaviour.landedAnimationName = component.landedAnimationName;
				simplerCrateBehaviour.chuteLandedAnimationName = component.chuteLandedAnimationName;
				simplerCrateBehaviour.crateDisappearAnimationName = component.crateDisappearAnimationName;
				simplerCrateBehaviour.chuteAnimator = component.chuteAnimator;
				simplerCrateBehaviour.landingTargetSprite = component.landingTargetSprite;
				Object.Destroy((Object)(object)component);
				simplerCratePrefab = val2;
			}
			GameObject val3 = Object.Instantiate<GameObject>(simplerCratePrefab);
			SimplerCrateBehaviour component2 = val3.GetComponent<SimplerCrateBehaviour>();
			component2.easyLootID = lootIDToSpawn;
			component2.despawnDelay = crateDespawnDelay;
			component2.preventAutoDespawn = preventAutoDespawn;
			component2.Trigger(new Vector3(-5f, -5f, -5f), new Vector3(position.x + 15f, position.y + 15f, 15f), Vector3Extensions.GetAbsoluteRoom(position));
			Vector3Extensions.GetAbsoluteRoom(position).ExtantEmergencyCrate = val3;
			return component2;
		}
	}
	public class Goggles : PassiveItem
	{
		private float LastCurse;

		public StatModifier Coolness;

		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			string text = "Goggles";
			GameObject val = new GameObject(text);
			Goggles goggles = val.AddComponent<Goggles>();
			tk2dSpriteCollectionData item_Collection = StaticCollections.Item_Collection;
			ItemBuilder.AddSpriteToObjectAssetbundle(text, item_Collection.GetSpriteIdByName("googles"), item_Collection, val);
			string text2 = "OSHA Certified";
			string text3 = "Curse now also grants some Coolness.\n\nOf great sentimental value.\nAlso acid resistant, but only useful for your eyes.";
			ItemBuilder.SetupItem((PickupObject)(object)goggles, text2, text3, "tdh");
			((PickupObject)goggles).quality = (ItemQuality)(-50);
			((PickupObject)goggles).CanBeDropped = false;
			ItemBuilder.AddPassiveStatModifier((PickupObject)(object)goggles, (StatType)14, 1f, (ModifyMethod)0);
		}

		public override void Update()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: 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_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			((PassiveItem)this).Update();
			if (!Object.op_Implicit((Object)(object)((PassiveItem)this).Owner))
			{
				return;
			}
			float statValue = ((PassiveItem)this).Owner.stats.GetStatValue((StatType)14);
			if (LastCurse != statValue)
			{
				if (statValue > LastCurse)
				{
					AkSoundEngine.PostEvent("Play_OBJ_compass_point_01", ((Component)((PassiveItem)this).Owner).gameObject);
					PickupObject byId = PickupObjectDatabase.GetById(577);
					SpawnManager.SpawnVFX(((Gun)((byId is Gun) ? byId : null)).DefaultModule.projectiles[0].hitEffects.enemy.effects[0].effects[0].effect, Vector2.op_Implicit(((BraveBehaviour)((PassiveItem)this).Owner).sprite.WorldTopCenter + new Vector2(0.25f, -0.5f)), Quaternion.identity);
					PickupObject byId2 = PickupObjectDatabase.GetById(577);
					SpawnManager.SpawnVFX(((Gun)((byId2 is Gun) ? byId2 : null)).DefaultModule.projectiles[0].hitEffects.enemy.effects[0].effects[0].effect, Vector2.op_Implicit(((BraveBehaviour)((PassiveItem)this).Owner).sprite.WorldTopCenter + new Vector2(0.25f, -0.5f)), Quaternion.identity);
				}
				if (statValue < LastCurse)
				{
					AkSoundEngine.PostEvent("Play_WPN_spirit_impact_01", ((Component)((PassiveItem)this).Owner).gameObject);
					PickupObject byId3 = PickupObjectDatabase.GetById(334);
					SpawnManager.SpawnVFX(((Gun)((byId3 is Gun) ? byId3 : null)).DefaultModule.projectiles[0].hitEffects.enemy.effects[0].effects[0].effect, Vector2.op_Implicit(((BraveBehaviour)((PassiveItem)this).Owner).sprite.WorldTopCenter + new Vector2(0.25f, -0.5f)), Quaternion.identity);
					PickupObject byId4 = PickupObjectDatabase.GetById(334);
					SpawnManager.SpawnVFX(((Gun)((byId4 is Gun) ? byId4 : null)).DefaultModule.projectiles[0].hitEffects.enemy.effects[0].effects[0].effect, Vector2.op_Implicit(((BraveBehaviour)((PassiveItem)this).Owner).sprite.WorldTopCenter + new Vector2(-0.25f, -0.5f)), Quaternion.identity);
				}
				LastCurse = statValue;
				if (((PassiveItem)this).Owner.ownerlessStatModifiers.Contains(Coolness))
				{
					((PassiveItem)this).Owner.ownerlessStatModifiers.Remove(Coolness);
				}
				Coolness = new StatModifier
				{
					statToBoost = (StatType)4,
					amount = statValue * 1.5f,
					modifyType = (ModifyMethod)0
				};
				((PassiveItem)this).Owner.ownerlessStatModifiers.Add(Coolness);
				((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, true, true);
			}
		}

		public override void Pickup(PlayerController player)
		{
			((PassiveItem)this).Pickup(player);
		}

		public override DebrisObject Drop(PlayerController player)
		{
			DebrisObject result = ((PassiveItem)this).Drop(player);
			if (((PassiveItem)this).Owner.ownerlessStatModifiers.Contains(Coolness))
			{
				((PassiveItem)this).Owner.ownerlessStatModifiers.Remove(Coolness);
			}
			LastCurse = -1f;
			return result;
		}

		public override void OnDestroy()
		{
			if ((Object)(object)((PassiveItem)this).Owner != (Object)null && ((PassiveItem)this).Owner.ownerlessStatModifiers.Contains(Coolness))
			{
				((PassiveItem)this).Owner.ownerlessStatModifiers.Remove(Coolness);
			}
			((PassiveItem)this).OnDestroy();
		}
	}
	public class BuffToJammedEnemies : MonoBehaviour
	{
		public Projectile Projectile;

		public void Start()
		{
			Projectile projectile = Projectile;
			projectile.BlackPhantomDamageMultiplier *= 1.5f;
		}
	}
	public class PlasmaPistol : GunBehaviour
	{
		public static void Add()
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_03a0: 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_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Expected O, but got Unknown
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			Gun val = Databases.Items.NewGun("Plasma Pistol", "plasmapistol");
			Game.Items.Rename("outdated_gun_mods:plasma_pistol", "tdh:plasma_pistol");
			((Component)val).gameObject.AddComponent<PlasmaPistol>();
			GunExt.SetShortDescription((PickupObject)(object)val, "From Another Place");
			GunExt.SetLongDescription((PickupObject)(object)val, "A standard edition weapon, from another dimension!\n\nSoftens the Jammed.");
			GunInt.SetupSpritePrebaked(val, StaticCollections.Weapon_Collection, "ellerygun2_idle_001", (string)null);
			((BraveBehaviour)val).spriteAnimator.Library = StaticCollections.Weapon_Animation;
			((BraveBehaviour)val).sprite.SortingOrder = 1;
			val.reloadAnimation = "plasmapistol2_reload";
			val.idleAnimation = "plasmapistol2_idle";
			val.shootAnimation = "plasmapistol2_fire";
			StaticCollections.Weapon_Animation.GetClipByName("plasmapistol2_reload").frames[14].eventAudio = "Play_BOSS_dragun_throw_01";
			StaticCollections.Weapon_Animation.GetClipByName("plasmapistol2_reload").frames[14].triggerEvent = true;
			PickupObject byId = PickupObjectDatabase.GetById(56);
			GunExt.AddProjectileModuleFrom(val, (Gun)(object)((byId is Gun) ? byId : null), true, false);
			ref string gunSwitchGroup = ref val.gunSwitchGroup;
			PickupObject byId2 = PickupObjectDatabase.GetById(89);
			gunSwitchGroup = ((Gun)((byId2 is Gun) ? byId2 : null)).gunSwitchGroup;
			val.DefaultModule.shootStyle = (ShootStyle)4;
			val.DefaultModule.sequenceStyle = (ProjectileSequenceStyle)0;
			val.reloadTime = 1.2f;
			val.DefaultModule.ammoCost = 1;
			val.DefaultModule.cooldownTime = 0.35f;
			val.DefaultModule.numberOfShotsInClip = 12;
			val.SetBaseMaxAmmo(600);
			val.InfiniteAmmo = true;
			((PickupObject)val).quality = (ItemQuality)(-50);
			val.DefaultModule.angleVariance = 13f;
			val.DefaultModule.burstShotCount = 2;
			val.DefaultModule.burstCooldownTime = 0.033f;
			val.gunClass = (GunClass)55;
			PickupObject byId3 = PickupObjectDatabase.GetById(156);
			Gun val2 = (Gun)(object)((byId3 is Gun) ? byId3 : null);
			val.DefaultModule.ammoType = val2.DefaultModule.ammoType;
			val.DefaultModule.customAmmoType = val2.DefaultModule.customAmmoType;
			Projectile val3 = Object.Instantiate<Projectile>(val.DefaultModule.projectiles[0]);
			((Component)val3).gameObject.SetActive(false);
			FakePrefab.MarkAsFakePrefab(((Component)val3).gameObject);
			Object.DontDestroyOnLoad((Object)(object)val3);
			val.DefaultModule.projectiles[0] = val3;
			val3.baseData.damage = 5.125f;
			ProjectileData baseData = val3.baseData;
			baseData.speed *= 1.3f;
			val3.shouldRotate = true;
			val3.pierceMinorBreakables = true;
			ref string objectImpactEventName = ref val3.objectImpactEventName;
			PickupObject byId4 = PickupObjectDatabase.GetById(577);
			objectImpactEventName = ((Gun)((byId4 is Gun) ? byId4 : null)).DefaultModule.projectiles[0].objectImpactEventName;
			ref string enemyImpactEventName = ref val3.enemyImpactEventName;
			PickupObject byId5 = PickupObjectDatabase.GetById(577);
			enemyImpactEventName = ((Gun)((byId5 is Gun) ? byId5 : null)).DefaultModule.projectiles[0].enemyImpactEventName;
			ref ProjectileImpactVFXPool hitEffects = ref val3.hitEffects;
			PickupObject byId6 = PickupObjectDatabase.GetById(577);
			hitEffects = ((Gun)((byId6 is Gun) ? byId6 : null)).DefaultModule.projectiles[0].hitEffects;
			BuffToJammedEnemies buffToJammedEnemies = ((Component)val3).gameObject.AddComponent<BuffToJammedEnemies>();
			buffToJammedEnemies.Projectile = val3;
			((BraveBehaviour)val3).sprite.usesOverrideMaterial = true;
			((BraveBehaviour)((BraveBehaviour)val3).sprite).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			((BraveBehaviour)((BraveBehaviour)val3).sprite).renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_ON");
			((BraveBehaviour)((BraveBehaviour)val3).sprite).renderer.material.SetFloat("_EmissivePower", 9f);
			((BraveBehaviour)((BraveBehaviour)val3).sprite).renderer.material.SetFloat("_EmissiveColorPower", 0.5f);
			val.AddGlowShaderToGun(new Color32(byte.MaxValue, (byte)143, (byte)206, byte.MaxValue), 3, 3);
			val.carryPixelOffset = new IntVector2(5, -2);
			ProjectileBuilders.SetProjectileCollisionRight(val3, "ellerygun_proj_001", StaticCollections.Projectile_Collection, 9, 4, false, (Anchor)4, (int?)null, (int?)null, true, false, (int?)null, (int?)null, (Projectile)null);
			val.muzzleOffset = Toolbox.GenerateTransformPoint(((Component)val).gameObject, new Vector2(0.875f, 0.5f), "muzzle_point").transform;
			val.barrelOffset = Toolbox.GenerateTransformPoint(((Component)val).gameObject, new Vector2(0.875f, 0.5f), "barrel_point").transform;
			Databases.Items.Add((PickupObject)(object)val, false, "ANY");
			GameObject val4 = new GameObject("LightObj");
			FakePrefab.MarkAsFakePrefab(val4);
			val4.transform.parent = ((BraveBehaviour)val).transform;
			Light val5 = val4.AddComponent<Light>();
			val5.color = Color.magenta;
			val5.range = 5f;
			val5.type = (LightType)3;
			val5.colorTemperature = 0.1f;
			val5.intensity = 10f;
			val.baseLightIntensity = 100f;
			val.light = val5;
			ref VFXPool muzzleFlashEffects = ref val.muzzleFlashEffects;
			PickupObject byId7 = PickupObjectDatabase.GetById(61);
			muzzleFlashEffects = ((Gun)((byId7 is Gun) ? byId7 : null)).muzzleFlashEffects;
			val.DefaultModule.ammoType = (AmmoType)14;
			ref string customAmmoType = ref val.DefaultModule.customAmmoType;
			PickupObject byId8 = PickupObjectDatabase.GetById(593);
			customAmmoType = ((Gun)((byId8 is Gun) ? byId8 : null)).DefaultModule.customAmmoType;
		}
	}
	public static class CrateExtensions
	{
		public static SupplyDropDoer.SimplerCrateBehaviour TurnIntoSimplerCrate(this EmergencyCrateController self)
		{
			GameObject gameObject = ((Component)self).gameObject;
			if ((Object)(object)gameObject != (Object)null)
			{
				SupplyDropDoer.SimplerCrateBehaviour simplerCrateBehaviour = gameObject.AddComponent<SupplyDropDoer.SimplerCrateBehaviour>();
				simplerCrateBehaviour.driftAnimationName = self.driftAnimationName;
				simplerCrateBehaviour.landedAnimationName = self.landedAnimationName;
				simplerCrateBehaviour.chuteLandedAnimationName = self.chuteLandedAnimationName;
				simplerCrateBehaviour.crateDisappearAnimationName = self.crateDisappearAnimationName;
				simplerCrateBehaviour.chuteAnimator = self.chuteAnimator;
				simplerCrateBehaviour.landingTargetSprite = self.landingTargetSprite;
				Object.Destroy((Object)(object)self);
				return simplerCrateBehaviour;
			}
			return null;
		}
	}
	public static class Toolbox
	{
		public static VFXObject CopyFields<T>(VFXObject sample2) where T : VFXObject
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			VFXObject val = new VFXObject();
			val.alignment = sample2.alignment;
			val.attached = sample2.attached;
			val.destructible = sample2.destructible;
			val.effect = sample2.effect;
			val.orphaned = sample2.orphaned;
			val.persistsOnDeath = sample2.persistsOnDeath;
			val.usesZHeight = sample2.usesZHeight;
			return val;
		}

		public static void NotifyCustom(string header, string text, string spriteName, tk2dSpriteCollectionData CollectionData, NotificationColor color = 0, bool forceSingleLine = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, CollectionData, CollectionData.GetSpriteIdByName(spriteName), color, false, forceSingleLine);
		}

		public static GameObject GenerateTransformPoint(GameObject attacher, Vector2 attachpoint, string name = "shootPoint")
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.parent = attacher.transform;
			val.transform.position = Vector2.op_Implicit(attachpoint);
			return ((Component)attacher.transform.Find(name)).gameObject;
		}

		public static void AddGlowShaderToGun(this Gun self, Color32 glowColor, int glowstrength, int colorGlowStrength = 0)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			Material val = new Material(((BraveBehaviour)((BraveBehaviour)EnemyDatabase.GetOrLoadByName("GunNut")).sprite).renderer.material);
			val.SetColor("_EmissiveColor", Color32.op_Implicit(glowColor));
			val.SetFloat("_EmissiveColorPower", (float)colorGlowStrength);
			val.SetFloat("_EmissivePower", (float)glowstrength);
			val.SetFloat("_EmissiveThresholdSensitivity", 0.2f);
			MeshRenderer component = ((Component)self).GetComponent<MeshRenderer>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			Material[] array = ((Renderer)component).sharedMaterials;
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i].shader == (Object)(object)val)
				{
					return;
				}
			}
			Array.Resize(ref array, array.Length + 1);
			Material val2 = new Material(val);
			val2.SetTexture("_MainTex", array[0].GetTexture("_MainTex"));
			array[^1] = val2;
			((Renderer)component).sharedMaterials = array;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("somebunny.etg.ellerymod", "+ The Dimension Hopper +", "1.0.1")]
	public class ElleryModModule : BaseUnityPlugin
	{
		public const string GUID = "somebunny.etg.ellerymod";

		public const string NAME = "+ The Dimension Hopper +";

		public const string VERSION = "1.0.1";

		public const string TEXT_COLOR = "#d000c8";

		public static string FilePathFolder;

		public static CustomCharacterData characterDataEllery;

		public static PlayableCharacters Ellery;

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

		public void GMStart(GameManager g)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_00fc: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			FilePathFolder = ETGMod.FolderPath((BaseUnityPlugin)(object)this);
			StaticCollections.InitCollections();
			PlasmaPistol.Add();
			DimensionalAnchor.Init();
			Goggles.Init();
			ToolsCharApi.EnableDebugLogging = true;
			CustomCharacterData data = Loader.BuildCharacterBundle("DimensionHopper/Ellery", StaticCollections.Ellery_Character_Collection, StaticCollections.assetBundle.LoadAsset<GameObject>("EllerySpriteAnimation").GetComponent<tk2dSpriteAnimation>(), StaticCollections.Ellery_Character_Collection, StaticCollections.assetBundle.LoadAsset<GameObject>("EllerySpriteAnimation").GetComponent<tk2dSpriteAnimation>(), "somebunny.etg.ellery", new Vector3(32.125f, 27.5f), false, new Vector3(32.625f, 28.5f), false, false, false, true, false, new GlowMatDoer(Color32.op_Implicit(new Color32((byte)121, (byte)234, byte.MaxValue, byte.MaxValue)), 14f, 10f), new GlowMatDoer(Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)54, byte.MaxValue)), 5f, 3f), 0, false, "", StaticCollections.assetBundle.LoadAsset<Texture2D>("ellery_bosscard_001"));
			characterDataEllery = data;
			data.pathForSprites = "DimensionHopper/Ellery";
			Tuple<CustomCharacterData, GameObject> value = CharacterBuilder.storedCharacters.Where((KeyValuePair<string, Tuple<CustomCharacterData, GameObject>> self) => self.Value.First == data).FirstOrDefault().Value;
			value.First.idleDoer.onSelectedAnimation = "select_choose";
			value.First.idleDoer.coreIdleAnimation = "select_idle";
			value.First.idleDoer.idleMax = 10000f;
			value.First.idleDoer.idleMin = 4000f;
			value.First.idleDoer.EeveeTex = null;
			value.First.idleDoer.IsEevee = false;
			value.First.idleDoer.AnimationLibraries = (tk2dSpriteAnimation[])(object)new tk2dSpriteAnimation[0];
			value.First.idleDoer.phases = null;
			PlayerController component = value.Second.GetComponent<PlayerController>();
			List<Texture2D> obj = new List<Texture2D>
			{
				StaticCollections.assetBundle.LoadAsset<Texture2D>("ellery_bosscard_001"),
				StaticCollections.assetBundle.LoadAsset<Texture2D>("ellery_bosscard_002"),
				StaticCollections.assetBundle.LoadAsset<Texture2D>("ellery_bosscard_003"),
				StaticCollections.assetBundle.LoadAsset<Texture2D>("ellery_bosscard_004")
			};
			List<Texture2D> list = obj;
			component.BosscardSprites = obj;
			List<Texture2D> list2 = list;
			data.animator.defaultClipId = 19;
			Ellery = ETGModCompatibility.ExtendEnum<PlayableCharacters>("somebunny.etg.ellerymod", "Ellery");
			GameStatsManager.Instance.SetCharacterSpecificFlag(ETGModCompatibility.ExtendEnum<PlayableCharacters>("somebunny.etg.ellerymod", characterDataEllery.nameShort), (CharacterSpecificGungeonFlags)0, true);
			Log("+ The Dimension Hopper + v1.0.1 started successfully.", "#d000c8");
		}

		public static void Log(string text, string color = "#FFFFFF")
		{
			ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
		}
	}
	internal class AssetBundleLoader
	{
		public static AssetBundle LoadAssetBundleFromLiterallyAnywhere(string name, bool logs = false)
		{
			AssetBundle result = null;
			if (File.Exists(ElleryModModule.FilePathFolder + "/" + name))
			{
				try
				{
					result = AssetBundle.LoadFromFile(Path.Combine(ElleryModModule.FilePathFolder, name));
					if (logs)
					{
						ETGModConsole.Log((object)"Successfully loaded assetbundle!", false);
					}
				}
				catch (Exception ex)
				{
					ETGModConsole.Log((object)"Failed loading asset bundle from file.", false);
					ETGModConsole.Log((object)ex.ToString(), false);
				}
			}
			else
			{
				ETGModConsole.Log((object)"AssetBundle NOT FOUND!", false);
			}
			return result;
		}
	}
	public static class StaticCollections
	{
		public static AssetBundle assetBundle;

		public static tk2dSpriteCollectionData Ellery_Character_Collection;

		public static tk2dSpriteCollectionData Weapon_Collection;

		public static tk2dSpriteCollectionData Item_Collection;

		public static tk2dSpriteCollectionData Projectile_Collection;

		public static tk2dSpriteAnimation Weapon_Animation;

		public static Texture2D NebulaTexture;

		public static void InitCollections()
		{
			assetBundle = AssetBundleLoader.LoadAssetBundleFromLiterallyAnywhere("thedimensionhopper");
			Ellery_Character_Collection = DoFastSetup(assetBundle, "EllerySpriteCollection", "ellery material.mat");
			if ((Object)(object)Ellery_Character_Collection == (Object)null)
			{
				ETGModConsole.Log((object)"Ellery_Character_Collection is NULL", false);
			}
			Weapon_Collection = DoFastSetup(assetBundle, "WeaponCollection", "weapon material.mat");
			if ((Object)(object)Weapon_Collection == (Object)null)
			{
				ETGModConsole.Log((object)"Weapon_Collection is NULL", false);
			}
			Item_Collection = DoFastSetup(assetBundle, "ItemCollection", "item material.mat");
			if ((Object)(object)Item_Collection == (Object)null)
			{
				ETGModConsole.Log((object)"Item_Collection is NULL", false);
			}
			Projectile_Collection = DoFastSetup(assetBundle, "ProjectileCollection", "projectile material.mat");
			if ((Object)(object)Projectile_Collection == (Object)null)
			{
				ETGModConsole.Log((object)"Projectile_Collection is NULL", false);
			}
			Weapon_Animation = assetBundle.LoadAsset<GameObject>("WeaponAnimation").GetComponent<tk2dSpriteAnimation>();
			NebulaTexture = assetBundle.LoadAsset<Texture2D>("nebula_reducednoise");
			SetupSpritesFromAssembly(Assembly.GetExecutingAssembly(), "DimensionHopper");
		}

		public static void SetupSpritesFromAssembly(Assembly asmb, string path)
		{
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			if ((object)asmb == null)
			{
				return;
			}
			path = path.Replace("/", ".").Replace("\\", ".");
			if (!path.EndsWith("."))
			{
				path += ".";
			}
			tk2dSpriteCollectionData weapon_Collection = Weapon_Collection;
			List<string> list = new List<string>();
			string[] manifestResourceNames = asmb.GetManifestResourceNames();
			string[] array = manifestResourceNames;
			foreach (string text in array)
			{
				if (!text.StartsWith(path) || text.Length <= path.Length)
				{
					continue;
				}
				string[] array2 = text.Substring(path.LastIndexOf(".") + 1).Split(new char[1] { '.' });
				if (array2.Length == 3)
				{
					string text2 = array2[2];
					if (text2.ToLowerInvariant() == "json" || text2.ToLowerInvariant() == "jtk2d")
					{
						list.Add(text);
					}
				}
			}
			foreach (string item in list)
			{
				string[] array3 = item.Substring(path.LastIndexOf(".") + 1).Split(new char[1] { '.' });
				string text3 = array3[0];
				string text4 = array3[1];
				if ((((Object)(object)weapon_Collection != (Object)null) ? weapon_Collection.spriteDefinitions : null) == null || weapon_Collection.Count <= 0)
				{
					continue;
				}
				int spriteIdByName = weapon_Collection.GetSpriteIdByName(text4, -1);
				if (spriteIdByName <= -1)
				{
					continue;
				}
				using Stream stream = asmb.GetManifestResourceStream(item);
				AssetSpriteData val = default(AssetSpriteData);
				try
				{
					val = JSONHelper.ReadJSON<AssetSpriteData>(stream);
				}
				catch
				{
					ETGModConsole.Log((object)("Error: invalid json at project path " + item), false);
					goto end_IL_01b3;
				}
				weapon_Collection.SetAttachPoints(spriteIdByName, val.attachPoints);
				end_IL_01b3:;
			}
		}

		public static tk2dSpriteCollectionData DoFastSetup(AssetBundle bundle, string CollectionName, string MaterialName)
		{
			tk2dSpriteCollectionData component = bundle.LoadAsset<GameObject>(CollectionName).GetComponent<tk2dSpriteCollectionData>();
			Material val = bundle.LoadAsset<Material>(MaterialName);
			Texture texture = val.GetTexture("_MainTex");
			texture.filterMode = (FilterMode)0;
			val.SetTexture("_MainTex", texture);
			component.material = val;
			component.materials = (Material[])(object)new Material[1] { val };
			component.materialInsts = (Material[])(object)new Material[1] { val };
			tk2dSpriteDefinition[] spriteDefinitions = component.spriteDefinitions;
			foreach (tk2dSpriteDefinition val2 in spriteDefinitions)
			{
				val2.material = component.materials[0];
				val2.materialInst = component.materials[0];
				val2.materialId = 0;
			}
			return component;
		}
	}
}