Decompiled source of Ralsei v1.0.1

plugins/Ralsei.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Alexandria;
using Alexandria.Assetbundle;
using Alexandria.CharacterAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using Alexandria.PrefabAPI;
using Alexandria.SoundAPI;
using Alexandria.VisualAPI;
using BepInEx;
using Dungeonator;
using Gungeon;
using HarmonyLib;
using InControl;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using Pathfinding;
using Ralsei;
using Ralsei.Code;
using Ralsei.Code.VFX;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;

[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 MikuMikuMod
{
	public class WarmScarf : PassiveItem
	{
		private CustomScarfDoer scarfInstance;

		public static ScarfAttachmentDoer scarfRef;

		public float HealthDropChance = 0.0333f;

		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 = "Warm Scarf";
			GameObject val = new GameObject(text);
			WarmScarf warmScarf = val.AddComponent<WarmScarf>();
			tk2dSpriteCollectionData itemAndGunCollection = StaticSpriteCollections.ItemAndGunCollection;
			ItemBuilder.AddSpriteToObjectAssetbundle(text, itemAndGunCollection.GetSpriteIdByName("warmscarf"), itemAndGunCollection, val);
			string text2 = "Handmade";
			string text3 = "Provides additional health occasionally.\n\nA soft, handmade scarf made by you, with love.";
			ItemBuilder.SetupItem((PickupObject)(object)warmScarf, text2, text3, "rlsi");
			((PickupObject)warmScarf).quality = (ItemQuality)(-50);
			((PickupObject)warmScarf).CanBeDropped = false;
			PickupObject byId = PickupObjectDatabase.GetById(436);
			scarfRef = ((BlinkPassiveItem)((byId is BlinkPassiveItem) ? byId : null)).ScarfPrefab;
		}

		public override void Pickup(PlayerController player)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			((PassiveItem)this).Pickup(player);
			player.OnRoomClearEvent += Player_OnRoomClearEvent;
			scarfInstance = Object.Instantiate<GameObject>(((Component)scarfRef).gameObject).AddComponent<CustomScarfDoer>();
			scarfInstance.AttachTarget = (GameActor)(object)player;
			scarfInstance.ScarfMaterial = new Material(scarfRef.ScarfMaterial);
			scarfInstance.StartWidth = 0.075f;
			scarfInstance.EndWidth = 0.075f;
			scarfInstance.AnimationSpeed = 20f;
			scarfInstance.ScarfLength = 0.4f;
			scarfInstance.AngleLerpSpeed = 4f;
			scarfInstance.BackwardZOffset = -2f;
			scarfInstance.CatchUpScale = 0.99f;
			scarfInstance.SinSpeed = 9f;
			scarfInstance.AmplitudeMod = 0.135f;
			scarfInstance.WavelengthMod = 1.1f;
			scarfInstance.ScarfMaterial.SetColor("_OverrideColor", new Color(0.52f, 0.12f, 0.52f));
			scarfInstance.Initialize((GameActor)(object)player);
		}

		public override DebrisObject Drop(PlayerController player)
		{
			if (Object.op_Implicit((Object)(object)scarfInstance))
			{
				Object.Destroy((Object)(object)((Component)scarfInstance).gameObject);
				scarfInstance = null;
			}
			player.OnRoomClearEvent -= Player_OnRoomClearEvent;
			return ((PassiveItem)this).Drop(player);
		}

		public override void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)((PassiveItem)this).Owner))
			{
				((PassiveItem)this).Owner.OnRoomClearEvent -= Player_OnRoomClearEvent;
			}
			if (Object.op_Implicit((Object)(object)scarfInstance))
			{
				Object.Destroy((Object)(object)((Component)scarfInstance).gameObject);
				scarfInstance = null;
			}
			((PassiveItem)this).OnDestroy();
		}

		private void Player_OnRoomClearEvent(PlayerController obj)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00b9: 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_00d7: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			if (Random.value < HealthDropChance)
			{
				HealthDropChance = 0.0333f;
				IntVector2 bestRewardLocation = obj.CurrentRoom.GetBestRewardLocation(new IntVector2(1, 1), (RewardLocationStyle)0, true);
				DebrisObject val = LootEngine.SpawnItem(((Component)PickupObjectDatabase.GetById(73)).gameObject, ((IntVector2)(ref bestRewardLocation)).ToVector3(), Vector2.up, 0f, true, false, false);
				AkSoundEngine.PostEvent("Play_OBJ_med_kit_01", ((Component)obj).gameObject);
				for (int i = 0; i < 32; i++)
				{
					GlobalSparksDoer.DoRandomParticleBurst(1, Vector2.op_Implicit(((BraveBehaviour)val).sprite.WorldCenter + new Vector2(-0.125f, -0.125f)), Vector2.op_Implicit(((BraveBehaviour)val).sprite.WorldCenter + new Vector2(0.125f, 0.125f)), Vector2.op_Implicit(BraveUtility.RandomVector2(new Vector2(-1f, -1f), new Vector2(1f, 1f)) * Random.Range(1.5f, 2.5f)), 2f, 1f, (float?)0.1f, (float?)1f, (Color?)(Color.green * 3f), (SparksType)0);
				}
			}
			else
			{
				HealthDropChance += 0.0166f;
			}
		}

		public override void Update()
		{
			((PassiveItem)this).Update();
		}
	}
}
namespace Ralsei
{
	public static class AIActorModifiers
	{
		public class FriendlySpawnEnemyOnDeath : OnDeathBehavior
		{
			public float chanceToSpawn = 1f;

			public string spawnVfx;

			[Header("Enemies to Spawn")]
			public EnemySelection enemySelection = (EnemySelection)10;

			[EnemyIdentifier]
			public string[] enemyGuidsToSpawn;

			[ShowInInspectorIf("ShowRandomPrams", true)]
			public int minSpawnCount = 1;

			[ShowInInspectorIf("ShowRandomPrams", true)]
			public int maxSpawnCount = 1;

			[FormerlySerializedAs("spawnType")]
			[Header("Placement")]
			public SpawnPosition spawnPosition;

			[ShowInInspectorIf("ShowInsideColliderParams", true)]
			public int extraPixelWidth;

			[ShowInInspectorIf("ShowInsideRadiusParams", true)]
			public float spawnRadius = 1f;

			[Header("Spawn Parameters")]
			public float guaranteedSpawnGenerations;

			public string spawnAnim = "awaken";

			public bool spawnsCanDropLoot = true;

			public bool DoNormalReinforcement;

			private bool m_hasTriggered;

			private bool ShowRandomPrams()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				return (int)enemySelection == 20;
			}

			private bool ShowInsideColliderParams()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				return (int)spawnPosition == 0;
			}

			private bool ShowInsideRadiusParams()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				return (int)spawnPosition == 20;
			}

			public override void OnDestroy()
			{
				((OnDeathBehavior)this).OnDestroy();
			}

			public override void OnTrigger(Vector2 damageDirection)
			{
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Invalid comparison between Unknown and I4
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Invalid comparison between Unknown and I4
				if (m_hasTriggered)
				{
					return;
				}
				m_hasTriggered = true;
				if (guaranteedSpawnGenerations <= 0f && chanceToSpawn < 1f && Random.value > chanceToSpawn)
				{
					return;
				}
				if (!string.IsNullOrEmpty(spawnVfx))
				{
					((BraveBehaviour)this).aiAnimator.PlayVfx(spawnVfx, (Vector2?)null, (Vector2?)null, (Vector2?)null);
				}
				string[] array = null;
				if ((int)enemySelection == 10)
				{
					array = enemyGuidsToSpawn;
				}
				else if ((int)enemySelection == 20)
				{
					array = new string[Random.Range(minSpawnCount, maxSpawnCount)];
					for (int i = 0; i < array.Length; i++)
					{
						array[i] = BraveUtility.RandomElement<string>(enemyGuidsToSpawn);
					}
				}
				SpawnEnemies(array);
			}

			public void ManuallyTrigger(Vector2 damageDirection)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				((OnDeathBehavior)this).OnTrigger(damageDirection);
			}

			private void SpawnEnemies(string[] selectedEnemyGuids)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				//IL_038f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0395: Invalid comparison between Unknown and I4
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_05ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f6: Invalid comparison between Unknown and I4
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0609: Unknown result type (might be due to invalid IL or missing references)
				//IL_060e: 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_0095: 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_03c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_062e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0630: Unknown result type (might be due to invalid IL or missing references)
				//IL_063b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0640: Unknown result type (might be due to invalid IL or missing references)
				//IL_0645: Unknown result type (might be due to invalid IL or missing references)
				//IL_064c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0652: Invalid comparison between Unknown and I4
				//IL_041b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0421: 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_042b: Unknown result type (might be due to invalid IL or missing references)
				//IL_043c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0442: Unknown result type (might be due to invalid IL or missing references)
				//IL_0447: Unknown result type (might be due to invalid IL or missing references)
				//IL_044c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0455: Unknown result type (might be due to invalid IL or missing references)
				//IL_045b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0460: Unknown result type (might be due to invalid IL or missing references)
				//IL_0469: 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_0474: Unknown result type (might be due to invalid IL or missing references)
				//IL_0479: Unknown result type (might be due to invalid IL or missing references)
				//IL_047e: Unknown result type (might be due to invalid IL or missing references)
				//IL_048b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0492: Expected O, but got Unknown
				//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_050c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_0654: Unknown result type (might be due to invalid IL or missing references)
				//IL_0659: Unknown result type (might be due to invalid IL or missing references)
				//IL_0578: Unknown result type (might be due to invalid IL or missing references)
				//IL_0589: Unknown result type (might be due to invalid IL or missing references)
				//IL_058e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0593: Unknown result type (might be due to invalid IL or missing references)
				//IL_0595: Unknown result type (might be due to invalid IL or missing references)
				//IL_059a: 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_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: 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_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: 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_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: 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_06fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0698: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_06da: Unknown result type (might be due to invalid IL or missing references)
				//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_06de: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_0732: Unknown result type (might be due to invalid IL or missing references)
				//IL_073c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0741: Unknown result type (might be due to invalid IL or missing references)
				//IL_0746: Unknown result type (might be due to invalid IL or missing references)
				//IL_074f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0751: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f2: 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_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				//IL_021f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0224: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: 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_0286: Unknown result type (might be due to invalid IL or missing references)
				//IL_028b: Unknown result type (might be due to invalid IL or missing references)
				//IL_028d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0297: 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_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				if ((int)spawnPosition == 0)
				{
					IntVector2 val = Vector2Extensions.ToIntVector2(((BraveBehaviour)this).specRigidbody.UnitCenter, (VectorConversions)0);
					if (((GameActor)((BraveBehaviour)this).aiActor).IsFalling || GameManager.Instance.Dungeon.CellIsPit(Vector2Extensions.ToVector3ZUp(((BraveBehaviour)this).specRigidbody.UnitCenter, 0f)))
					{
						return;
					}
					RoomHandler roomFromPosition = GameManager.Instance.Dungeon.GetRoomFromPosition(val);
					List<SpeculativeRigidbody> list = new List<SpeculativeRigidbody>();
					list.Add(((BraveBehaviour)this).specRigidbody);
					Vector2 unitBottomLeft = ((BraveBehaviour)this).specRigidbody.UnitBottomLeft;
					for (int i = 0; i < selectedEnemyGuids.Length; i++)
					{
						AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[i]);
						AIActor val2 = AIActor.Spawn(orLoadByGuid, Vector2Extensions.ToIntVector2(((BraveBehaviour)this).specRigidbody.UnitCenter, (VectorConversions)0), roomFromPosition, false, (AwakenAnimationType)0, true);
						if (((BraveBehaviour)this).aiActor.IsBlackPhantom)
						{
							val2.ForceBlackPhantom = true;
						}
						if (Object.op_Implicit((Object)(object)val2))
						{
							((BraveBehaviour)val2).specRigidbody.Initialize();
							Vector2 val3 = unitBottomLeft - (((BraveBehaviour)val2).specRigidbody.UnitBottomLeft - Vector3Extensions.XY(((BraveBehaviour)val2).transform.position));
							Vector2 val4 = val3 + new Vector2(Mathf.Max(0f, ((BraveBehaviour)this).specRigidbody.UnitDimensions.x - ((BraveBehaviour)val2).specRigidbody.UnitDimensions.x), 0f);
							((BraveBehaviour)val2).transform.position = Vector2.op_Implicit(Vector2.Lerp(val3, val4, (selectedEnemyGuids.Length != 1) ? ((float)i / ((float)selectedEnemyGuids.Length - 1f)) : 0f));
							((BraveBehaviour)val2).specRigidbody.Reinitialize();
							val3 -= new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
							val4 += new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
							Vector2 val5 = Vector2.Lerp(val3, val4, (selectedEnemyGuids.Length != 1) ? ((float)i / ((float)selectedEnemyGuids.Length - 1f)) : 0.5f);
							IntVector2 val6 = PhysicsEngine.UnitToPixel(val5 - Vector3Extensions.XY(((BraveBehaviour)val2).transform.position));
							CollisionData val7 = null;
							if (PhysicsEngine.Instance.RigidbodyCastWithIgnores(((BraveBehaviour)val2).specRigidbody, val6, ref val7, true, true, (int?)null, false, list.ToArray()))
							{
								val6 = val7.NewPixelsToMove;
							}
							CollisionData.Pool.Free(ref val7);
							Transform transform = ((BraveBehaviour)val2).transform;
							transform.position += Vector2Extensions.ToVector3ZisY(PhysicsEngine.PixelToUnit(val6), 0f);
							((BraveBehaviour)val2).specRigidbody.Reinitialize();
							if (i == 0)
							{
								((BraveBehaviour)val2).aiAnimator.FacingDirection = 180f;
							}
							else if (i == selectedEnemyGuids.Length - 1)
							{
								((BraveBehaviour)val2).aiAnimator.FacingDirection = 0f;
							}
							HandleSpawn(val2);
							list.Add(((BraveBehaviour)val2).specRigidbody);
						}
					}
					for (int j = 0; j < list.Count; j++)
					{
						for (int k = 0; k < list.Count; k++)
						{
							if (j != k)
							{
								list[j].RegisterGhostCollisionException(list[k]);
							}
						}
					}
				}
				else if ((int)spawnPosition == 1)
				{
					for (int l = 0; l < selectedEnemyGuids.Length; l++)
					{
						AIActor orLoadByGuid2 = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[l]);
						AIActor spawnedActor = AIActor.Spawn(orLoadByGuid2, Vector2Extensions.ToIntVector2(((BraveBehaviour)this).specRigidbody.UnitCenter, (VectorConversions)0), ((BraveBehaviour)this).aiActor.ParentRoom, false, (AwakenAnimationType)0, true);
						if (!Object.op_Implicit((Object)(object)spawnedActor))
						{
							continue;
						}
						Vector2 cameraBottomLeft = Vector2.op_Implicit(BraveUtility.ViewportToWorldpoint(new Vector2(0f, 0f), (ViewportType)1));
						Vector2 cameraTopRight = Vector2.op_Implicit(BraveUtility.ViewportToWorldpoint(new Vector2(1f, 1f), (ViewportType)1));
						IntVector2 bottomLeft = Vector2Extensions.ToIntVector2(cameraBottomLeft, (VectorConversions)1);
						IntVector2 topRight = Vector2Extensions.ToIntVector2(cameraTopRight, (VectorConversions)0) - IntVector2.One;
						CellValidator val8 = (CellValidator)delegate(IntVector2 c)
						{
							//IL_00ac: 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_0086: Unknown result type (might be due to invalid IL or missing references)
							//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
							//IL_001d: Unknown result type (might be due to invalid IL or missing references)
							//IL_0025: Unknown result type (might be due to invalid IL or missing references)
							//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
							//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
							//IL_004d: Unknown result type (might be due to invalid IL or missing references)
							//IL_0055: Unknown result type (might be due to invalid IL or missing references)
							//IL_0112: Unknown result type (might be due to invalid IL or missing references)
							//IL_0123: Unknown result type (might be due to invalid IL or missing references)
							for (int num3 = 0; num3 < spawnedActor.Clearance.x; num3++)
							{
								for (int num4 = 0; num4 < spawnedActor.Clearance.y; num4++)
								{
									if (GameManager.Instance.Dungeon.data.isTopWall(c.x + num3, c.y + num4))
									{
										return false;
									}
									if (GameManager.Instance.Dungeon.data[c.x + num3, c.y + num4].isExitCell)
									{
										return false;
									}
								}
							}
							return c.x >= bottomLeft.x && c.y >= bottomLeft.y && c.x + spawnedActor.Clearance.x - 1 <= topRight.x && c.y + spawnedActor.Clearance.y - 1 <= topRight.y;
						};
						Func<IntVector2, float> func = delegate(IntVector2 c)
						{
							//IL_0008: Unknown result type (might be due to invalid IL or missing references)
							//IL_0022: Unknown result type (might be due to invalid IL or missing references)
							//IL_0047: Unknown result type (might be due to invalid IL or missing references)
							//IL_005a: 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_008b: Unknown result type (might be due to invalid IL or missing references)
							float num2 = float.MaxValue;
							num2 = Mathf.Min(num2, (float)c.x - cameraBottomLeft.x);
							num2 = Mathf.Min(num2, (float)c.y - cameraBottomLeft.y);
							num2 = Mathf.Min(num2, cameraTopRight.x - (float)c.x + (float)spawnedActor.Clearance.x);
							return Mathf.Min(num2, cameraTopRight.y - (float)c.y + (float)spawnedActor.Clearance.y);
						};
						Vector2 val9 = ((BraveBehaviour)spawnedActor).specRigidbody.UnitCenter - Vector3Extensions.XY(((BraveBehaviour)spawnedActor).transform.position);
						IntVector2? randomWeightedAvailableCell = spawnedActor.ParentRoom.GetRandomWeightedAvailableCell((IntVector2?)spawnedActor.Clearance, (CellTypes?)spawnedActor.PathableTiles, false, val8, func, 0.25f);
						if (!randomWeightedAvailableCell.HasValue)
						{
							Debug.LogError((object)"Screen Edge Spawn FAILED!", (Object)(object)spawnedActor);
							Object.Destroy((Object)(object)spawnedActor);
						}
						else
						{
							((BraveBehaviour)spawnedActor).transform.position = Vector2.op_Implicit(Pathfinder.GetClearanceOffset(randomWeightedAvailableCell.Value, spawnedActor.Clearance) - val9);
							((BraveBehaviour)spawnedActor).specRigidbody.Reinitialize();
							HandleSpawn(spawnedActor);
						}
					}
				}
				else if ((int)spawnPosition == 20)
				{
					Vector2 unitCenter = ((BraveBehaviour)this).specRigidbody.GetUnitCenter((ColliderType)2);
					List<SpeculativeRigidbody> list2 = new List<SpeculativeRigidbody>();
					list2.Add(((BraveBehaviour)this).specRigidbody);
					for (int m = 0; m < selectedEnemyGuids.Length; m++)
					{
						Vector2 val10 = unitCenter + Random.insideUnitCircle * spawnRadius;
						if ((int)GameManager.Instance.CurrentLevelOverrideState == 5)
						{
							Scene activeScene = SceneManager.GetActiveScene();
							if (((Scene)(ref activeScene)).name == "fs_robot")
							{
								RoomHandler entrance = GameManager.Instance.Dungeon.data.Entrance;
								Vector2 val11 = ((IntVector2)(ref entrance.area.basePosition)).ToVector2() + new Vector2(7f, 7f);
								Vector2 val12 = ((IntVector2)(ref entrance.area.basePosition)).ToVector2() + new Vector2(38f, 36f);
								val10 = Vector2.Min(val12, Vector2.Max(val11, val10));
							}
						}
						AIActor orLoadByGuid3 = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[m]);
						AIActor val13 = AIActor.Spawn(orLoadByGuid3, Vector2Extensions.ToIntVector2(unitCenter, (VectorConversions)0), ((BraveBehaviour)this).aiActor.ParentRoom, true, (AwakenAnimationType)0, true);
						if (Object.op_Implicit((Object)(object)val13))
						{
							((BraveBehaviour)val13).specRigidbody.Initialize();
							Vector2 val14 = val10 - ((BraveBehaviour)val13).specRigidbody.GetUnitCenter((ColliderType)2);
							((BraveBehaviour)val13).specRigidbody.ImpartedPixelsToMove = PhysicsEngine.UnitToPixel(val14);
							HandleSpawn(val13);
							list2.Add(((BraveBehaviour)val13).specRigidbody);
						}
					}
					for (int n = 0; n < list2.Count; n++)
					{
						for (int num = 0; num < list2.Count; num++)
						{
							if (n != num)
							{
								list2[n].RegisterGhostCollisionException(list2[num]);
							}
						}
					}
				}
				else
				{
					Debug.LogError((object)("Unknown spawn type: " + ((object)(SpawnPosition)(ref spawnPosition)).ToString()));
				}
			}

			private void HandleSpawn(AIActor spawnedActor)
			{
				if (!string.IsNullOrEmpty(spawnAnim))
				{
					((BraveBehaviour)spawnedActor).aiAnimator.PlayUntilFinished(spawnAnim, false, (string)null, -1f, false);
				}
				((MonoBehaviour)spawnedActor).StartCoroutine(WaitTillSpawnedFully(spawnedActor));
				SpawnEnemyOnDeath component = ((Component)spawnedActor).GetComponent<SpawnEnemyOnDeath>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.guaranteedSpawnGenerations = Mathf.Max(0f, guaranteedSpawnGenerations - 1f);
				}
				if (!spawnsCanDropLoot)
				{
					spawnedActor.CanDropCurrency = false;
					spawnedActor.CanDropItems = false;
				}
				if (DoNormalReinforcement)
				{
					spawnedActor.HandleReinforcementFallIntoRoom(0.1f);
				}
			}

			public IEnumerator WaitTillSpawnedFully(AIActor aIActor)
			{
				if (!string.IsNullOrEmpty(spawnAnim))
				{
					while (((BraveBehaviour)aIActor).aiAnimator.IsPlaying(spawnAnim))
					{
						yield return null;
					}
				}
				yield return null;
				bool ralseified = false;
				PlayerController[] allPlayers = GameManager.Instance.AllPlayers;
				foreach (PlayerController entry in allPlayers)
				{
					if (entry.activeItems != null)
					{
						foreach (PlayerItem _ in entry.activeItems)
						{
							if (_ is Cake cake)
							{
								ralseified = true;
								aIActor.RalseifyEnemy(cake);
								break;
							}
						}
					}
					if (ralseified)
					{
						break;
					}
				}
			}
		}

		public class RalseiCharmedEnemyController : BraveBehaviour
		{
			public static List<AIActor> allCharmedAIActors = new List<AIActor>();

			public static List<RalseiCharmedEnemyController> allCharmed = new List<RalseiCharmedEnemyController>();

			public Cake CakeRef;

			private CompanionFollowPlayerBehavior companionController;

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

			private bool isCurrentlyStealthed = false;

			private float currentC;

			private bool isFloorLoad = false;

			private bool WhatArmyActive = false;

			private bool LuteActive = false;

			private float CollisionDamageMult = 1f;

			private float Tick;

			private bool inCombat;

			public void InitEnemy(Cake cake, CompanionFollowPlayerBehavior _companionController)
			{
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Expected O, but got Unknown
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Expected O, but got Unknown
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Expected O, but got Unknown
				allCharmed.Add(this);
				allCharmedAIActors.Add(((BraveBehaviour)this).aiActor);
				companionController = _companionController;
				CakeRef = cake;
				((PlayerItem)cake).LastOwner.OnRoomClearEvent += LastOwner_OnRoomClearEvent;
				PlayerController lastOwner = ((PlayerItem)cake).LastOwner;
				lastOwner.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Combine(lastOwner.OnNewFloorLoaded, new Action<PlayerController>(PlayerNewFloor));
				PlayerController lastOwner2 = ((PlayerItem)cake).LastOwner;
				lastOwner2.OnEnteredCombat = (Action)Delegate.Combine(lastOwner2.OnEnteredCombat, new Action(EnteredCombat));
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.OnPreDeath += HealthHaver_OnPreDeath;
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.OnDamaged += new OnDamagedEvent(HealthHaver_OnDamaged);
				if (!(((BraveBehaviour)this).aiActor.CollisionDamage > 0f))
				{
					return;
				}
				SpeculativeRigidbody specRigidbody = ((BraveBehaviour)((BraveBehaviour)this).aiActor).specRigidbody;
				specRigidbody.OnPreRigidbodyCollision = (OnPreRigidbodyCollisionDelegate)Delegate.Combine((Delegate?)(object)specRigidbody.OnPreRigidbodyCollision, (Delegate?)(OnPreRigidbodyCollisionDelegate)delegate(SpeculativeRigidbody myBody, PixelCollider myPixelCollider, SpeculativeRigidbody otherBody, PixelCollider otherPixelCollider)
				{
					//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
					if (!isCurrentlyStealthed)
					{
						if ((Object)(object)((BraveBehaviour)myBody).aiActor != (Object)null && (Object)(object)((Component)((BraveBehaviour)myBody).aiActor).GetComponent<RalseiCharmedEnemyController>() == (Object)null)
						{
							float num = ((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.maximumHealth * 0.05f * ((BraveBehaviour)this).aiActor.CollisionDamage + 0.5f;
							if (((BraveBehaviour)myBody).aiActor.CollisionSetsPlayerOnFire)
							{
								num *= 0.5f;
								((GameActor)((BraveBehaviour)myBody).aiActor).ApplyEffect((GameActorEffect)(object)Cake.hotLeadEffect, 1f, (Projectile)null);
							}
							num *= CollisionDamageMult;
							((BraveBehaviour)((BraveBehaviour)myBody).aiActor).healthHaver.ApplyDamage(num, Vector2.zero, "Collision", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
						}
					}
				});
			}

			private void LastOwner_OnDidUnstealthyAction(PlayerController obj)
			{
				((GameActor)((BraveBehaviour)this).aiActor).SetIsStealthed(false, ";3");
				HealthHaver healthHaver = ((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver;
				healthHaver.AllDamageMultiplier /= 0.2f;
				((BraveBehaviour)((BraveBehaviour)this).aiActor).behaviorSpeculator.CooldownScale = currentC;
				((PlayerItem)CakeRef).LastOwner.OnDidUnstealthyAction -= LastOwner_OnDidUnstealthyAction;
			}

			private void StartedStealth(PlayerController obj)
			{
				currentC = ((BraveBehaviour)((BraveBehaviour)this).aiActor).behaviorSpeculator.CooldownScale;
				((BraveBehaviour)((BraveBehaviour)this).aiActor).behaviorSpeculator.CooldownScale = 0f;
				((GameActor)((BraveBehaviour)this).aiActor).SetIsStealthed(true, ";3");
				HealthHaver healthHaver = ((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver;
				healthHaver.AllDamageMultiplier *= 0.2f;
				((PlayerItem)CakeRef).LastOwner.OnDidUnstealthyAction += LastOwner_OnDidUnstealthyAction;
			}

			private void HealthHaver_OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
			{
				((MonoBehaviour)this).StartCoroutine(DoInvulnerabilityTime(Mathf.Max(Mathf.Min(0.5f, resultValue / 100f), 0.125f)));
			}

			public IEnumerator DoInvulnerabilityTime(float Duration)
			{
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.IsVulnerable = false;
				yield return (object)new WaitForSeconds(Duration);
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.IsVulnerable = true;
			}

			public void EnteredCombat()
			{
				inCombat = true;
			}

			public void PlayerNewFloor(PlayerController playerController)
			{
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.SetHealthMaximum(((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.maximumHealth * 1.15f, (float?)null, false);
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.ApplyHealing(Mathf.Min(125f, ((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.maximumHealth * 0.3f));
			}

			private void HealthHaver_OnPreDeath(Vector2 obj)
			{
				PlayerController lastOwner = ((PlayerItem)CakeRef).LastOwner;
				lastOwner.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Remove(lastOwner.OnNewFloorLoaded, new Action<PlayerController>(PlayerNewFloor));
				((PlayerItem)CakeRef).LastOwner.OnRoomClearEvent -= LastOwner_OnRoomClearEvent;
				((PlayerItem)CakeRef).LastOwner.OnDidUnstealthyAction -= LastOwner_OnDidUnstealthyAction;
				((PlayerItem)CakeRef).LastOwner.companions.Remove(((BraveBehaviour)this).aiActor);
				CakeRef.AllCharmedEnemies.Remove(this);
			}

			private void LastOwner_OnRoomClearEvent(PlayerController obj)
			{
				inCombat = false;
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.SetHealthMaximum(((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.maximumHealth * 0.98f, (float?)null, false);
				((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.ApplyHealing(Mathf.Min(50f, ((BraveBehaviour)((BraveBehaviour)this).aiActor).healthHaver.maximumHealth * 0.125f));
				DoHealParticles();
			}

			public void DoHealParticles()
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: 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_0042: 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_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_0068: 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_007c: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < 12; i++)
				{
					EmitParams newParams = default(EmitParams);
					((EmitParams)(ref newParams)).position = Vector2.op_Implicit(((BraveBehaviour)((BraveBehaviour)this).aiActor).sprite.WorldCenter + BraveUtility.RandomVector2(new Vector2(-0.5f, -0.5f), new Vector2(0.5f, 0.5f)));
					((EmitParams)(ref newParams)).velocity = Vector2.op_Implicit(BraveUtility.RandomVector2(new Vector2(0f, 1f), new Vector2(0f, 3f)));
					((EmitParams)(ref newParams)).startLifetime = 0.5f;
					((EmitParams)(ref newParams)).startSize = 0.5f;
					ParticleBase.EmitParticles("HealParticle", 1, newParams);
				}
			}

			public void Update()
			{
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)ScarfWeapon.RalseiSlash.targetVFX != (Object)null && (Object)(object)ScarfWeapon.RalseiSlash.targetVFX.TargetInst == (Object)(object)((BraveBehaviour)this).aiActor)
				{
					Object.Destroy((Object)(object)ScarfWeapon.RalseiSlash.targetVFX);
					ScarfWeapon.RalseiSlash.targetVFX = null;
				}
				if (Object.op_Implicit((Object)(object)((PlayerItem)CakeRef).LastOwner))
				{
					bool isStealthed = ((GameActor)((PlayerItem)CakeRef).LastOwner).IsStealthed;
					if (isStealthed != isCurrentlyStealthed)
					{
						isCurrentlyStealthed = isStealthed;
						if (isCurrentlyStealthed)
						{
							StartedStealth(((PlayerItem)CakeRef).LastOwner);
						}
						else
						{
							LastOwner_OnDidUnstealthyAction(((PlayerItem)CakeRef).LastOwner);
						}
					}
					if (((PlayerItem)CakeRef).LastOwner.CurrentRoom != null)
					{
						((BraveBehaviour)this).aiActor.parentRoom = ((PlayerItem)CakeRef).LastOwner.CurrentRoom;
					}
				}
				bool flag = (Object)(object)GameManager.Instance.Dungeon == (Object)null;
				if (isFloorLoad != flag)
				{
					isFloorLoad = flag;
					if (isFloorLoad)
					{
						((Behaviour)((BraveBehaviour)this).behaviorSpeculator).enabled = false;
						((Behaviour)((BraveBehaviour)this).aiActor).enabled = false;
						((Behaviour)((BraveBehaviour)this).aiAnimator).enabled = false;
						((BraveBehaviour)this).behaviorSpeculator.Interrupt();
					}
					else
					{
						((Behaviour)((BraveBehaviour)this).behaviorSpeculator).enabled = true;
						((Behaviour)((BraveBehaviour)this).aiActor).enabled = true;
						((Behaviour)((BraveBehaviour)this).aiAnimator).enabled = true;
					}
				}
				if (inCombat)
				{
					if ((Object)(object)ScarfWeapon.RalseiSlash.targetVFX != (Object)null)
					{
						((BraveBehaviour)this).aiActor.OverrideTarget = ((BraveBehaviour)ScarfWeapon.RalseiSlash.targetVFX.TargetInst).specRigidbody;
					}
					Tick += BraveTime.DeltaTime;
					if (Tick > 0.5f)
					{
						Tick = 0f;
						companionController.TemporarilyDisabled = ((PlayerItem)CakeRef).LastOwner.CurrentRoom == Vector3Extensions.GetAbsoluteRoom(((BraveBehaviour)((BraveBehaviour)this).aiActor).transform.position);
					}
				}
				else
				{
					companionController.TemporarilyDisabled = false;
				}
				if (!((Object)(object)((PlayerItem)CakeRef).LastOwner != (Object)null))
				{
					return;
				}
				bool flag2 = CustomSynergies.PlayerHasActiveSynergy(((PlayerItem)CakeRef).LastOwner, "You And What Army");
				if (Object.op_Implicit((Object)(object)((GameActor)((PlayerItem)CakeRef).LastOwner).CurrentGun))
				{
					bool luteCompanionBuffActive = ((GameActor)((PlayerItem)CakeRef).LastOwner).CurrentGun.LuteCompanionBuffActive;
					if (LuteActive != luteCompanionBuffActive)
					{
						LuteActive = luteCompanionBuffActive;
						if (!LuteActive)
						{
							AIActor aiActor = ((BraveBehaviour)this).aiActor;
							aiActor.MovementSpeed /= 2f;
							CollisionDamageMult /= 2.5f;
						}
						else
						{
							AIActor aiActor2 = ((BraveBehaviour)this).aiActor;
							aiActor2.MovementSpeed *= 2f;
							CollisionDamageMult *= 2.5f;
						}
					}
				}
				if (WhatArmyActive != flag2)
				{
					WhatArmyActive = flag2;
					if (!WhatArmyActive)
					{
						AIActor aiActor3 = ((BraveBehaviour)this).aiActor;
						aiActor3.MovementSpeed /= 1.5f;
						BehaviorSpeculator behaviorSpeculator = ((BraveBehaviour)((BraveBehaviour)this).aiActor).behaviorSpeculator;
						behaviorSpeculator.CooldownScale /= 1.25f;
						CollisionDamageMult /= 2.5f;
					}
					else
					{
						AIActor aiActor4 = ((BraveBehaviour)this).aiActor;
						aiActor4.MovementSpeed *= 1.5f;
						BehaviorSpeculator behaviorSpeculator2 = ((BraveBehaviour)((BraveBehaviour)this).aiActor).behaviorSpeculator;
						behaviorSpeculator2.CooldownScale *= 1.25f;
						CollisionDamageMult *= 2.5f;
					}
				}
			}

			public override void OnDestroy()
			{
				allCharmedAIActors.Remove(((BraveBehaviour)this).aiActor);
				allCharmed.Remove(this);
				if (Object.op_Implicit((Object)(object)CakeRef))
				{
					PlayerController lastOwner = ((PlayerItem)CakeRef).LastOwner;
					lastOwner.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Remove(lastOwner.OnNewFloorLoaded, new Action<PlayerController>(PlayerNewFloor));
					((PlayerItem)CakeRef).LastOwner.OnRoomClearEvent -= LastOwner_OnRoomClearEvent;
					((PlayerItem)CakeRef).LastOwner.OnDidUnstealthyAction -= LastOwner_OnDidUnstealthyAction;
					((PlayerItem)CakeRef).LastOwner.companions.Remove(((BraveBehaviour)this).aiActor);
					CakeRef.AllCharmedEnemies.Remove(this);
				}
				((BraveBehaviour)this).OnDestroy();
			}
		}

		public class CompanionisedEnemyBulletModifiers : BraveBehaviour
		{
			private List<AIBeamShooter> aIBeamShooters = new List<AIBeamShooter>();

			public PlayerController enemyOwner;

			public bool scaleDamage;

			public bool scaleSize;

			public bool scaleSpeed;

			public bool doPostProcess;

			public float baseBulletDamage;

			public float jammedDamageMultiplier;

			public bool TintBullets;

			public Color TintColor;

			public bool BulletsAreUnBlankable = false;

			public CompanionisedEnemyBulletModifiers()
			{
				//IL_0049: 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)
				scaleDamage = false;
				scaleSize = false;
				scaleSpeed = false;
				doPostProcess = false;
				baseBulletDamage = 10f;
				TintBullets = false;
				TintColor = Color.grey;
				jammedDamageMultiplier = 2f;
			}

			public void Start()
			{
				aIBeamShooters = ((Component)((BraveBehaviour)this).aiActor).GetComponents<AIBeamShooter>().ToList();
				AIBulletBank bulletBank = ((BraveBehaviour)((BraveBehaviour)this).aiActor).bulletBank;
				if (Object.op_Implicit((Object)(object)bulletBank))
				{
					foreach (Entry bullet in bulletBank.Bullets)
					{
						SpawnManager.PoolManager.Remove(bullet.BulletObject.transform);
						bullet.BulletObject.GetComponent<Projectile>().BulletScriptSettings.preventPooling = true;
					}
				}
				if ((Object)(object)((BraveBehaviour)((BraveBehaviour)this).aiActor).aiShooter != (Object)null)
				{
					AIShooter aiShooter = ((BraveBehaviour)((BraveBehaviour)this).aiActor).aiShooter;
					aiShooter.PostProcessProjectile = (Action<Projectile>)Delegate.Combine(aiShooter.PostProcessProjectile, new Action<Projectile>(PostProcessSpawnedEnemyProjectiles));
				}
				if ((Object)(object)((BraveBehaviour)((BraveBehaviour)this).aiActor).bulletBank != (Object)null)
				{
					AIBulletBank bulletBank2 = ((BraveBehaviour)((BraveBehaviour)this).aiActor).bulletBank;
					bulletBank2.OnProjectileCreated = (Action<Projectile>)Delegate.Combine(bulletBank2.OnProjectileCreated, new Action<Projectile>(PostProcessSpawnedEnemyProjectiles));
				}
			}

			public void Update()
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				foreach (AIBeamShooter aIBeamShooter in aIBeamShooters)
				{
					if ((Object)(object)aIBeamShooter.LaserBeam != (Object)null && aIBeamShooter.LaserBeam.HitsPlayers)
					{
						aIBeamShooter.LaserBeam.HitsPlayers = false;
						aIBeamShooter.LaserBeam.AdjustPlayerBeamTint(TintColor, 10, 0f);
					}
				}
			}

			private void PostProcessSpawnedEnemyProjectiles(Projectile proj)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				if (TintBullets)
				{
					proj.AdjustPlayerProjectileTint(TintColor, 1, 0f);
				}
				if ((Object)(object)((BraveBehaviour)this).aiActor != (Object)null)
				{
					if (!((Object)(object)((BraveBehaviour)((BraveBehaviour)this).aiActor).aiActor != (Object)null))
					{
						return;
					}
					SpawnManager.PoolManager.Remove(((BraveBehaviour)proj).transform);
					proj.baseData.damage = baseBulletDamage;
					proj.ImmuneToBlanks = BulletsAreUnBlankable;
					proj.ImmuneToSustainedBlanks = BulletsAreUnBlankable;
					if ((Object)(object)enemyOwner != (Object)null)
					{
						if (scaleDamage)
						{
							ProjectileData baseData = proj.baseData;
							baseData.damage *= enemyOwner.stats.GetStatValue((StatType)5);
						}
						if (scaleSize)
						{
							proj.RuntimeUpdateScale(enemyOwner.stats.GetStatValue((StatType)15));
						}
						if (scaleSpeed)
						{
							ProjectileData baseData2 = proj.baseData;
							baseData2.speed *= enemyOwner.stats.GetStatValue((StatType)6);
							proj.UpdateSpeed();
						}
						if (doPostProcess)
						{
							enemyOwner.DoPostProcessProjectile(proj);
						}
					}
					if (((BraveBehaviour)this).aiActor.IsBlackPhantom)
					{
						proj.baseData.damage = baseBulletDamage * jammedDamageMultiplier;
					}
				}
				else
				{
					ETGModConsole.Log((object)"Shooter is NULL", false);
				}
			}
		}

		public static void RalseifyEnemy(this AIActor CurrentEnemy, Cake cake)
		{
			//IL_001a: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Expected O, but got Unknown
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_089c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: 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)
			PlayerController lastOwner = ((PlayerItem)cake).LastOwner;
			((GameActor)CurrentEnemy).RemoveEffect((GameActorEffect)(object)Cake.charmingRoundsEffect);
			((BraveBehaviour)CurrentEnemy).sprite.color = Color.green;
			((Behaviour)((BraveBehaviour)CurrentEnemy).behaviorSpeculator).enabled = false;
			CurrentEnemy.IgnoreForRoomClear = true;
			CurrentEnemy.CanTargetEnemies = true;
			CurrentEnemy.CanTargetPlayers = false;
			CurrentEnemy.OverrideTarget = null;
			if ((Object)(object)ScarfWeapon.RalseiSlash.targetVFX != (Object)null && (Object)(object)ScarfWeapon.RalseiSlash.targetVFX.TargetInst == (Object)(object)CurrentEnemy)
			{
				Object.Destroy((Object)(object)((Component)ScarfWeapon.RalseiSlash.targetVFX).gameObject);
				ScarfWeapon.RalseiSlash.targetVFX = null;
			}
			CompanionController val = ((Component)CurrentEnemy).gameObject.AddComponent<CompanionController>();
			val.companionID = (CompanionIdentifier)0;
			val.CanCrossPits = true;
			val.CanInterceptBullets = true;
			val.Initialize(lastOwner);
			CurrentEnemy.CompanionOwner = lastOwner;
			lastOwner.CurrentRoom.DeregisterEnemy(CurrentEnemy, false);
			AIAnimator aiAnimator = ((BraveBehaviour)CurrentEnemy).aiAnimator;
			CompanionFollowPlayerBehavior val2 = new CompanionFollowPlayerBehavior();
			val2.CanRollOverPits = false;
			val2.CatchUpOutAnimation = aiAnimator.MoveAnimation.Prefix;
			val2.DisableInCombat = false;
			val2.CatchUpRadius = 8f;
			val2.CatchUpAccelTime = 5f;
			val2.CatchUpSpeed = (CurrentEnemy.MovementSpeed *= 1.15f);
			val2.CatchUpMaxSpeed = Mathf.Max(CurrentEnemy.MovementSpeed * 1.3f, 6f);
			val2.CatchUpAnimation = aiAnimator.MoveAnimation.Prefix;
			val2.RollAnimation = aiAnimator.MoveAnimation.Prefix;
			val2.TemporarilyDisabled = false;
			for (int num = ((BraveBehaviour)CurrentEnemy).behaviorSpeculator.MovementBehaviors.Count - 1; num > -1; num--)
			{
				MovementBehaviorBase val3 = ((BraveBehaviour)CurrentEnemy).behaviorSpeculator.MovementBehaviors[num];
				SeekTargetBehavior val4 = (SeekTargetBehavior)(object)((val3 is SeekTargetBehavior) ? val3 : null);
				if (val4 != null)
				{
					val4.ReturnToSpawn = false;
					val2.PathInterval = val4.PathInterval;
					val2.IdealRadius = val4.CustomRange;
					val2.DisableInCombat = true;
				}
				FleeTargetBehavior val5 = (FleeTargetBehavior)(object)((val3 is FleeTargetBehavior) ? val3 : null);
				if (val5 != null)
				{
					((BraveBehaviour)CurrentEnemy).behaviorSpeculator.MovementBehaviors.Remove((MovementBehaviorBase)(object)val5);
				}
				MoveErraticallyBehavior val6 = (MoveErraticallyBehavior)(object)((val3 is MoveErraticallyBehavior) ? val3 : null);
				if (val6 != null)
				{
					((BraveBehaviour)CurrentEnemy).behaviorSpeculator.MovementBehaviors.Remove((MovementBehaviorBase)(object)val6);
				}
			}
			for (int i = 0; i < ((BraveBehaviour)CurrentEnemy).behaviorSpeculator.AttackBehaviors.Count; i++)
			{
				AttackBehaviorBase val7 = ((BraveBehaviour)CurrentEnemy).behaviorSpeculator.AttackBehaviors[i];
				((MirrorImageBehavior)(((val7 is MirrorImageBehavior) ? val7 : null)?)).m_allImages.ForEach(delegate(AIActor self)
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					((BraveBehaviour)((BraveBehaviour)self).aiActor).healthHaver.ApplyDamage(100000000f, Vector2.zero, "Fuck off", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
				});
				DisplaceBehavior val8 = (DisplaceBehavior)(object)((val7 is DisplaceBehavior) ? val7 : null);
				if (val8 != null && Object.op_Implicit((Object)(object)val8.m_image))
				{
					((BraveBehaviour)val8.m_image).healthHaver.ApplyDamage(100000000f, Vector2.zero, "Fuck off", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
				}
				BuffEnemiesBehavior val9 = (BuffEnemiesBehavior)(object)((val7 is BuffEnemiesBehavior) ? val7 : null);
				if (val9 != null)
				{
					((BehaviorBase)val9).EndContinuousUpdate();
				}
				AttackBehaviorGroup val10 = (AttackBehaviorGroup)(object)((val7 is AttackBehaviorGroup) ? val7 : null);
				if (val10 == null)
				{
					continue;
				}
				foreach (AttackGroupItem attackBehavior in val10.AttackBehaviors)
				{
					AttackBehaviorBase behavior = attackBehavior.Behavior;
					((MirrorImageBehavior)(((behavior is MirrorImageBehavior) ? behavior : null)?)).m_allImages.ForEach(delegate(AIActor self)
					{
						//IL_0011: Unknown result type (might be due to invalid IL or missing references)
						((BraveBehaviour)((BraveBehaviour)self).aiActor).healthHaver.ApplyDamage(100000000f, Vector2.zero, "Fuck off", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
					});
					AttackBehaviorBase behavior2 = attackBehavior.Behavior;
					BuffEnemiesBehavior val11 = (BuffEnemiesBehavior)(object)((behavior2 is BuffEnemiesBehavior) ? behavior2 : null);
					if (val11 != null)
					{
						((BehaviorBase)val11).EndContinuousUpdate();
					}
					AttackBehaviorBase behavior3 = attackBehavior.Behavior;
					DisplaceBehavior val12 = (DisplaceBehavior)(object)((behavior3 is DisplaceBehavior) ? behavior3 : null);
					if (val12 != null && Object.op_Implicit((Object)(object)val12.m_image))
					{
						((BraveBehaviour)val12.m_image).healthHaver.ApplyDamage(100000000f, Vector2.zero, "Fuck off", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
					}
				}
			}
			if (((BraveBehaviour)CurrentEnemy).behaviorSpeculator.AttackBehaviorGroup != null)
			{
				foreach (AttackGroupItem attackBehavior2 in ((BraveBehaviour)CurrentEnemy).behaviorSpeculator.AttackBehaviorGroup.AttackBehaviors)
				{
					AttackBehaviorBase behavior4 = attackBehavior2.Behavior;
					((MirrorImageBehavior)(((behavior4 is MirrorImageBehavior) ? behavior4 : null)?)).m_allImages.ForEach(delegate(AIActor self)
					{
						//IL_0011: Unknown result type (might be due to invalid IL or missing references)
						((BraveBehaviour)((BraveBehaviour)self).aiActor).healthHaver.ApplyDamage(100000000f, Vector2.zero, "Fuck off", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
					});
					AttackBehaviorBase behavior5 = attackBehavior2.Behavior;
					BuffEnemiesBehavior val13 = (BuffEnemiesBehavior)(object)((behavior5 is BuffEnemiesBehavior) ? behavior5 : null);
					if (val13 != null)
					{
						((BehaviorBase)val13).EndContinuousUpdate();
					}
					AttackBehaviorBase behavior6 = attackBehavior2.Behavior;
					DisplaceBehavior val14 = (DisplaceBehavior)(object)((behavior6 is DisplaceBehavior) ? behavior6 : null);
					if (val14 != null && Object.op_Implicit((Object)(object)val14.m_image))
					{
						((BraveBehaviour)val14.m_image).healthHaver.ApplyDamage(100000000f, Vector2.zero, "Fuck off", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
					}
				}
			}
			CurrentEnemy.CompanionSettings = new ActorCompanionSettings
			{
				WarpsToRandomPoint = false
			};
			((BraveBehaviour)CurrentEnemy).behaviorSpeculator.MovementBehaviors.Add((MovementBehaviorBase)(object)val2);
			((Behaviour)((BraveBehaviour)CurrentEnemy).behaviorSpeculator).enabled = true;
			((BraveBehaviour)CurrentEnemy).behaviorSpeculator.RefreshBehaviors();
			((Component)CurrentEnemy).gameObject.transform.parent = null;
			Object.DontDestroyOnLoad((Object)(object)((Component)CurrentEnemy).gameObject);
			((BehaviorBase)val2).Start();
			for (int num2 = ((GameActor)CurrentEnemy).m_activeEffects.Count - 1; num2 > -1; num2--)
			{
				if (((GameActor)CurrentEnemy).m_activeEffects[num2] is RalseiCharmable ralseiCharmable)
				{
					((GameActor)CurrentEnemy).RemoveEffect(((GameActorEffect)ralseiCharmable).effectIdentifier);
				}
			}
			SpawnEnemyOnDeath component = ((Component)CurrentEnemy).gameObject.GetComponent<SpawnEnemyOnDeath>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ConvertSpawnModifier();
			}
			CrazedController component2 = ((Component)CurrentEnemy).gameObject.GetComponent<CrazedController>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				Object.Destroy((Object)(object)component2);
			}
			CompanionisedEnemyBulletModifiers companionisedEnemyBulletModifiers = ((Component)val).gameObject.AddComponent<CompanionisedEnemyBulletModifiers>();
			companionisedEnemyBulletModifiers.jammedDamageMultiplier *= 2.5f;
			companionisedEnemyBulletModifiers.baseBulletDamage = 3f;
			companionisedEnemyBulletModifiers.TintBullets = true;
			companionisedEnemyBulletModifiers.TintColor = new Color(0.333f, 1f, 0.8f);
			companionisedEnemyBulletModifiers.BulletsAreUnBlankable = true;
			CustomScarfDoer customScarfDoer = Object.Instantiate<GameObject>(((Component)ScarfWeapon.scarfRef).gameObject).AddComponent<CustomScarfDoer>();
			customScarfDoer.AttachTarget = (GameActor)(object)CurrentEnemy;
			customScarfDoer.ScarfMaterial = new Material(ScarfWeapon.scarfRef.ScarfMaterial);
			customScarfDoer.StartWidth = 0.1f;
			customScarfDoer.EndWidth = 0.125f;
			customScarfDoer.AnimationSpeed = 12f;
			customScarfDoer.ScarfLength = 0.5f;
			customScarfDoer.AngleLerpSpeed = 4f;
			customScarfDoer.BackwardZOffset = -0.75f;
			customScarfDoer.CatchUpScale = 0.9f;
			customScarfDoer.SinSpeed = 9f;
			customScarfDoer.AmplitudeMod = 0.135f;
			customScarfDoer.WavelengthMod = 1.1f;
			customScarfDoer.ScarfMaterial.SetColor("_OverrideColor", new Color(0f, 0.8f, 0.125f));
			customScarfDoer.Initialize((GameActor)(object)CurrentEnemy);
			customScarfDoer.AdditionalOffset = new Vector3(0f, 0.0625f);
			float num3 = (float)((BraveBehaviour)CurrentEnemy).specRigidbody.HitboxPixelCollider.Height / 32f;
			EnemyHealthBarRalsei component3 = ((GameActor)(object)CurrentEnemy).SmartPlayEffectOnActor(Cake.EffectPrefab.gameObject, new Vector3(-0.625f, 0f - num3 - 0.25f), attached: true, IgnorePools: true, alreadyMiddleCenter: true, useHitbox: true).GetComponent<EnemyHealthBarRalsei>();
			component3.InitEffect(CurrentEnemy);
			HealthHaver healthHaver = ((BraveBehaviour)CurrentEnemy).healthHaver;
			healthHaver.maximumHealth *= 5f;
			((BraveBehaviour)CurrentEnemy).healthHaver.CursedMaximum = ((BraveBehaviour)CurrentEnemy).healthHaver.maximumHealth;
			((BraveBehaviour)CurrentEnemy).healthHaver.FullHeal();
			lastOwner.companions.Add(CurrentEnemy);
			((MonoBehaviour)CurrentEnemy).StartCoroutine(DoWait(CurrentEnemy));
			IEnumerable<PixelCollider> enumerable = ((BraveBehaviour)CurrentEnemy).specRigidbody.PixelColliders.Where((PixelCollider self) => (int)self.CollisionLayer == 2);
			if (enumerable != null)
			{
				enumerable.FirstOrDefault().CollisionLayer = (CollisionLayer)0;
			}
			enumerable = ((BraveBehaviour)CurrentEnemy).specRigidbody.PixelColliders.Where((PixelCollider self) => (int)self.CollisionLayer == 3);
			if (enumerable != null)
			{
				enumerable.FirstOrDefault().CollisionLayer = (CollisionLayer)1;
			}
			((BraveBehaviour)CurrentEnemy).specRigidbody.Reinitialize();
			RalseiCharmedEnemyController ralseiCharmedEnemyController = ((Component)CurrentEnemy).gameObject.AddComponent<RalseiCharmedEnemyController>();
			ralseiCharmedEnemyController.InitEnemy(cake, val2);
			cake.AllCharmedEnemies.Add(ralseiCharmedEnemyController);
		}

		public static IEnumerator DoWait(AIActor aIActor)
		{
			yield return null;
			BulletLimbController limbs = ((Component)aIActor).gameObject.GetComponent<BulletLimbController>();
			if ((Object)(object)limbs != (Object)null)
			{
				limbs.DestroyProjectiles();
			}
		}

		public static FriendlySpawnEnemyOnDeath ConvertSpawnModifier(this SpawnEnemyOnDeath spawnEnemyOnDeath)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			FriendlySpawnEnemyOnDeath friendlySpawnEnemyOnDeath = ((Component)spawnEnemyOnDeath).gameObject.AddComponent<FriendlySpawnEnemyOnDeath>();
			friendlySpawnEnemyOnDeath.enemyGuidsToSpawn = spawnEnemyOnDeath.enemyGuidsToSpawn;
			friendlySpawnEnemyOnDeath.enemySelection = spawnEnemyOnDeath.enemySelection;
			friendlySpawnEnemyOnDeath.extraPixelWidth = spawnEnemyOnDeath.extraPixelWidth;
			friendlySpawnEnemyOnDeath.spawnAnim = spawnEnemyOnDeath.spawnAnim;
			friendlySpawnEnemyOnDeath.chanceToSpawn = spawnEnemyOnDeath.chanceToSpawn;
			((OnDeathBehavior)friendlySpawnEnemyOnDeath).deathType = ((OnDeathBehavior)spawnEnemyOnDeath).deathType;
			friendlySpawnEnemyOnDeath.DoNormalReinforcement = spawnEnemyOnDeath.DoNormalReinforcement;
			friendlySpawnEnemyOnDeath.guaranteedSpawnGenerations = spawnEnemyOnDeath.guaranteedSpawnGenerations;
			friendlySpawnEnemyOnDeath.minSpawnCount = spawnEnemyOnDeath.minSpawnCount;
			friendlySpawnEnemyOnDeath.maxSpawnCount = spawnEnemyOnDeath.maxSpawnCount;
			((OnDeathBehavior)friendlySpawnEnemyOnDeath).triggerName = ((OnDeathBehavior)spawnEnemyOnDeath).triggerName;
			friendlySpawnEnemyOnDeath.spawnVfx = spawnEnemyOnDeath.spawnVfx;
			friendlySpawnEnemyOnDeath.spawnsCanDropLoot = spawnEnemyOnDeath.spawnsCanDropLoot;
			friendlySpawnEnemyOnDeath.spawnRadius = spawnEnemyOnDeath.spawnRadius;
			friendlySpawnEnemyOnDeath.spawnPosition = spawnEnemyOnDeath.spawnPosition;
			((OnDeathBehavior)friendlySpawnEnemyOnDeath).preDeathDelay = ((OnDeathBehavior)spawnEnemyOnDeath).preDeathDelay;
			((OnDeathBehavior)friendlySpawnEnemyOnDeath).m_deathDir = ((OnDeathBehavior)spawnEnemyOnDeath).m_deathDir;
			((BraveBehaviour)friendlySpawnEnemyOnDeath).m_cachedCache = ((BraveBehaviour)spawnEnemyOnDeath).m_cachedCache;
			Object.Destroy((Object)(object)spawnEnemyOnDeath);
			return friendlySpawnEnemyOnDeath;
		}
	}
	public class AudioResourceLoader
	{
		public static void loadFromFolder(string modName, string FilePathFolder)
		{
			ResourceLoaderSoundbanks resourceLoaderSoundbanks = new ResourceLoaderSoundbanks();
			resourceLoaderSoundbanks.AutoloadFromPath(FilePathFolder, modName);
		}

		public static void loadFromAssembly(string bankName, string modName)
		{
			ResourceLoaderSoundbanks resourceLoaderSoundbanks = new ResourceLoaderSoundbanks();
			resourceLoaderSoundbanks.AutoloadFromAssembly(Assembly.GetExecutingAssembly(), bankName, modName);
		}
	}
	public class ResourceLoaderSoundbanks
	{
		public void AutoloadFromAssembly(Assembly assembly, string bankName, string prefix)
		{
			if ((object)assembly == null)
			{
				throw new ArgumentNullException("assembly", "Assembly cannot be null.");
			}
			if (prefix == null)
			{
				throw new ArgumentNullException("prefix", "Prefix name cannot be null.");
			}
			prefix = prefix.Trim();
			if (prefix == "")
			{
				throw new ArgumentException("Prefix name cannot be an empty (or whitespace only) string.", "prefix");
			}
			List<string> list = new List<string>(assembly.GetManifestResourceNames());
			for (int i = 0; i < list.Count; i++)
			{
				string text = list[i];
				string text2 = text;
				text2 = text2.Replace('/', Path.DirectorySeparatorChar);
				text2 = text2.Replace('\\', Path.DirectorySeparatorChar);
				if (!text2.Contains(bankName))
				{
					continue;
				}
				text2 = text2.Substring(text2.IndexOf(bankName));
				if (text2.LastIndexOf(".bnk") == text2.Length - ".bnk".Length)
				{
					text2 = text2.Substring(0, text2.Length - ".bnk".Length);
					if (text2.IndexOf(Path.DirectorySeparatorChar) == 0)
					{
						text2 = text2.Substring(1);
					}
					text2 = prefix + ":" + text2;
					Debug.Log((object)$"{typeof(ResourceLoaderSoundbanks)}: Soundbank found, attempting to autoload: name='{text2}' resource='{text}'");
					using Stream stream = assembly.GetManifestResourceStream(text);
					LoadSoundbankFromStream(stream, text2);
				}
			}
		}

		public void AutoloadFromPath(string path, string prefix)
		{
			if (string.IsNullOrEmpty(path))
			{
				throw new ArgumentNullException("path", "Path cannot be null.");
			}
			if (string.IsNullOrEmpty(prefix))
			{
				throw new ArgumentNullException("prefix", "Prefix name cannot be null.");
			}
			prefix = prefix.Trim();
			if (string.IsNullOrEmpty(prefix))
			{
				throw new ArgumentException("Prefix name cannot be an empty (or whitespace only) string.", "prefix");
			}
			path = path.Replace('/', Path.DirectorySeparatorChar);
			path = path.Replace('\\', Path.DirectorySeparatorChar);
			if (!Directory.Exists(path))
			{
				Debug.LogError((object)$"{typeof(ResourceLoaderSoundbanks)}: No autoload directory in path, not autoloading anything. Path='{path}'.");
				return;
			}
			List<string> list = new List<string>(Directory.GetFiles(path, "*.bnk", SearchOption.AllDirectories));
			for (int i = 0; i < list.Count; i++)
			{
				string text = list[i];
				string text2 = text;
				text2 = text2.Replace('/', Path.DirectorySeparatorChar);
				text2 = text2.Replace('\\', Path.DirectorySeparatorChar);
				text2 = text2.Substring(text2.IndexOf(path) + path.Length);
				text2 = text2.Substring(0, text2.Length - ".bnk".Length);
				if (text2.IndexOf(Path.DirectorySeparatorChar) == 0)
				{
					text2 = text2.Substring(1);
				}
				text2 = prefix + ":" + text2;
				Debug.Log((object)$"{typeof(ResourceLoaderSoundbanks)}: Soundbank found, attempting to autoload: name='{text2}' file='{text}'");
				using FileStream stream = File.OpenRead(text);
				LoadSoundbankFromStream(stream, text2);
			}
		}

		private void LoadSoundbankFromStream(Stream stream, string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = StreamToByteArray(stream);
			IntPtr intPtr = Marshal.AllocHGlobal(array.Length);
			try
			{
				Marshal.Copy(array, 0, intPtr, array.Length);
				uint num = default(uint);
				AKRESULT val = AkSoundEngine.LoadAndDecodeBankFromMemory(intPtr, (uint)array.Length, false, name, false, ref num);
				Debug.Log((object)$"Result of soundbank load: {val}.");
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}

		public static byte[] StreamToByteArray(Stream input)
		{
			byte[] array = new byte[16384];
			using MemoryStream memoryStream = new MemoryStream();
			int count;
			while ((count = input.Read(array, 0, array.Length)) > 0)
			{
				memoryStream.Write(array, 0, count);
			}
			return memoryStream.ToArray();
		}
	}
	public class BehaviorPatches
	{
		[HarmonyPatch(typeof(SummonEnemyBehavior), "ContinuousUpdate")]
		public class ChangeUpSummonEnemiesBehavior
		{
			[HarmonyPatch]
			public static bool Prefix(SummonEnemyBehavior __instance, ref ContinuousBehaviorResult __result)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Invalid comparison between Unknown and I4
				//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d9: Invalid comparison between Unknown and I4
				//IL_0383: Unknown result type (might be due to invalid IL or missing references)
				//IL_0389: Invalid comparison between Unknown and I4
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0350: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Invalid comparison between Unknown and I4
				//IL_0270: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0297: Unknown result type (might be due to invalid IL or missing references)
				if (AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(((BehaviorBase)__instance).m_aiActor))
				{
					if ((int)__instance.m_state == 1)
					{
						if (__instance.m_timer <= 0f)
						{
							__instance.m_spawnedActor = AIActor.Spawn(__instance.m_enemyPrefab, __instance.m_spawnCell.Value, ((BehaviorBase)__instance).m_aiActor.ParentRoom, false, (AwakenAnimationType)2, true);
							((MonoBehaviour)__instance.m_spawnedActor).StartCoroutine(WaitUntilActive(__instance.m_spawnedActor));
							((BraveBehaviour)__instance.m_spawnedActor).healthHaver.SetHealthMaximum(((BraveBehaviour)__instance.m_spawnedActor).healthHaver.GetMaxHealth() * 0.3f, (float?)null, false);
							((BraveBehaviour)__instance.m_spawnedActor).aiAnimator.PlayDefaultSpawnState();
							__instance.m_allSpawnedActors.Add(__instance.m_spawnedActor);
							__instance.m_spawnedActor.CanDropCurrency = false;
							if ((Object)(object)__instance.OverrideCorpse != (Object)null)
							{
								__instance.m_spawnedActor.CorpseObject = __instance.OverrideCorpse;
							}
							if (__instance.BlackPhantomChance > 0f && (__instance.BlackPhantomChance >= 1f || Random.value < __instance.BlackPhantomChance))
							{
								__instance.m_spawnedActor.ForceBlackPhantom = true;
							}
							__instance.m_spawnCount++;
							__instance.m_lifetimeSpawnCount++;
							if (__instance.m_spawnCount < __instance.m_numToSpawn)
							{
								__instance.PrepareSpawn();
								IntVector2? spawnCell = __instance.m_spawnCell;
								if (spawnCell.HasValue)
								{
									if (!string.IsNullOrEmpty(__instance.TargetVfx))
									{
										if (__instance.TargetVfxLoops)
										{
											((BehaviorBase)__instance).m_aiAnimator.StopVfx(__instance.TargetVfx);
										}
										AIAnimator aiAnimator = ((BehaviorBase)__instance).m_aiAnimator;
										string targetVfx = __instance.TargetVfx;
										Vector2? val = Pathfinder.GetClearanceOffset(__instance.m_spawnCell.Value, __instance.m_enemyClearance);
										aiAnimator.PlayVfx(targetVfx, (Vector2?)null, (Vector2?)null, val);
									}
									__instance.m_timer = __instance.SummonTime;
									__result = (ContinuousBehaviorResult)0;
									return false;
								}
							}
							__instance.m_spawnClip = ((BraveBehaviour)__instance.m_spawnedActor).spriteAnimator.CurrentClip;
							if (__instance.m_spawnClip != null && (int)__instance.m_spawnClip.wrapMode > 0)
							{
								__instance.m_state = (State)2;
								__result = (ContinuousBehaviorResult)0;
								return false;
							}
							if (!string.IsNullOrEmpty(__instance.PostSummonAnim))
							{
								__instance.m_state = (State)3;
								((BehaviorBase)__instance).m_aiAnimator.PlayUntilFinished(__instance.PostSummonAnim, false, (string)null, -1f, false);
								__result = (ContinuousBehaviorResult)0;
								return false;
							}
							__result = (ContinuousBehaviorResult)1;
							return false;
						}
					}
					else if ((int)__instance.m_state == 2)
					{
						if (!Object.op_Implicit((Object)(object)__instance.m_spawnedActor) || !Object.op_Implicit((Object)(object)((BraveBehaviour)__instance.m_spawnedActor).healthHaver) || ((BraveBehaviour)__instance.m_spawnedActor).healthHaver.IsDead || !((BraveBehaviour)__instance.m_spawnedActor).spriteAnimator.IsPlaying(__instance.m_spawnClip))
						{
							if (!string.IsNullOrEmpty(__instance.PostSummonAnim))
							{
								__instance.m_state = (State)3;
								((BehaviorBase)__instance).m_aiAnimator.PlayUntilFinished(__instance.PostSummonAnim, false, (string)null, -1f, false);
								__result = (ContinuousBehaviorResult)0;
								return false;
							}
							__result = (ContinuousBehaviorResult)1;
							return false;
						}
					}
					else if ((int)__instance.m_state == 3 && !((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).spriteAnimator.IsPlaying(__instance.PostSummonAnim))
					{
						__result = (ContinuousBehaviorResult)1;
						return false;
					}
					__result = (ContinuousBehaviorResult)0;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(MirrorImageController), "SetHost")]
		public class ChangeUpMirrorImageController
		{
			[HarmonyPostfix]
			public static void Prefix(MirrorImageController __instance, AIActor host)
			{
				if (AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(host))
				{
					Cake cake = Toolbox.isCakedUp();
					if (Object.op_Implicit((Object)(object)cake))
					{
						((BraveBehaviour)__instance).aiActor.RalseifyEnemy(cake);
						((MonoBehaviour)__instance).StartCoroutine(KillMirror(((BraveBehaviour)__instance).aiActor));
					}
				}
			}

			public static IEnumerator KillMirror(AIActor aIActor)
			{
				yield return (object)new WaitForSeconds(20f);
				if (Object.op_Implicit((Object)(object)aIActor))
				{
					((BraveBehaviour)aIActor).healthHaver.ApplyDamage(100000f, Vector2.zero, "Mirror Host Death", (CoreDamageTypes)0, (DamageCategory)5, false, (PixelCollider)null, false);
				}
			}
		}

		[HarmonyPatch(typeof(BuffEnemiesBehavior), "Update")]
		public class ChangeUpBuffEnemiesBehavior
		{
			[HarmonyPrefix]
			public static bool Prefix(BuffEnemiesBehavior __instance, ref BehaviorResult __result)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Invalid comparison between Unknown and I4
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected I4, but got Unknown
				if (AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(((BehaviorBase)__instance).m_aiActor))
				{
					BehaviorResult val = (BehaviorResult)0;
					if ((int)val > 0)
					{
						__result = (BehaviorResult)(int)val;
						return false;
					}
					if (!((AttackBehaviorBase)__instance).IsReady())
					{
						__result = (BehaviorResult)0;
						return false;
					}
					if (__instance.m_searchTimer > 0f)
					{
						__result = (BehaviorResult)0;
						return false;
					}
					List<AIActor> list = new List<AIActor>();
					list.AddRange(AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors);
					BuffEnemiesBehavior.s_activeEnemies = list;
					BuffEnemiesBehavior.s_activeEnemies.Remove(((BehaviorBase)__instance).m_aiActor);
					for (int num = BuffEnemiesBehavior.s_activeEnemies.Count - 1; num >= 0; num--)
					{
						if (!__instance.IsGoodBuffTarget(BuffEnemiesBehavior.s_activeEnemies[num]))
						{
							BuffEnemiesBehavior.s_activeEnemies.RemoveAt(num);
						}
					}
					if (BuffEnemiesBehavior.s_activeEnemies.Count == 0)
					{
						__result = (BehaviorResult)0;
						return false;
					}
					while ((float)__instance.m_buffedEnemies.Count < __instance.EnemiesToBuff && BuffEnemiesBehavior.s_activeEnemies.Count > 0)
					{
						int index = Random.Range(0, BuffEnemiesBehavior.s_activeEnemies.Count);
						__instance.m_buffedEnemies.Add(BuffEnemiesBehavior.s_activeEnemies[index]);
						BuffEnemiesBehavior.s_activeEnemies.RemoveAt(index);
					}
					for (int i = 0; i < __instance.m_buffedEnemies.Count; i++)
					{
						__instance.BuffEnemy(__instance.m_buffedEnemies[i]);
					}
					__instance.m_searchTimer = __instance.SearchInterval;
					if (!string.IsNullOrEmpty(__instance.BuffAnimation))
					{
						((BehaviorBase)__instance).m_aiAnimator.PlayUntilCancelled(__instance.BuffAnimation, true, (string)null, -1f, false);
					}
					if (!string.IsNullOrEmpty(__instance.BuffVfx))
					{
						((BehaviorBase)__instance).m_aiAnimator.PlayVfx(__instance.BuffVfx, (Vector2?)null, (Vector2?)null, (Vector2?)null);
					}
					if (Object.op_Implicit((Object)(object)((BehaviorBase)__instance).m_aiActor) && Object.op_Implicit((Object)(object)((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).knockbackDoer))
					{
						((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).knockbackDoer.SetImmobile(true, "BuffEnemiesBehavior");
					}
					__result = (BehaviorResult)4;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(DestroyBulletsBehavior), "Upkeep")]
		public class ChangeUpDestroyBulletsBehavior
		{
			[HarmonyPrefix]
			public static bool Prefix(DestroyBulletsBehavior __instance)
			{
				//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Expected O, but got Unknown
				//IL_0248: Unknown result type (might be due to invalid IL or missing references)
				//IL_024d: 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_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
				if (AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(((BehaviorBase)__instance).m_aiActor))
				{
					((BehaviorBase)__instance).DecrementTimer(ref ((BasicAttackBehavior)__instance).m_cooldownTimer, true);
					((BehaviorBase)__instance).DecrementTimer(ref ((BasicAttackBehavior)__instance).m_resetCooldownOnDamageCooldown, true);
					if (((BasicAttackBehavior)__instance).HealthThresholds.Length != 0)
					{
						float currentHealthPercentage = ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).healthHaver.GetCurrentHealthPercentage();
						if (currentHealthPercentage < ((BasicAttackBehavior)__instance).m_lowestRecordedHealthPercentage)
						{
							for (int i = 0; i < ((BasicAttackBehavior)__instance).HealthThresholds.Length; i++)
							{
								if (((BasicAttackBehavior)__instance).HealthThresholds[i] >= currentHealthPercentage && ((BasicAttackBehavior)__instance).HealthThresholds[i] < ((BasicAttackBehavior)__instance).m_lowestRecordedHealthPercentage)
								{
									((BasicAttackBehavior)__instance).m_healthThresholdCredits = ((BasicAttackBehavior)__instance).m_healthThresholdCredits + 1;
								}
							}
							((BasicAttackBehavior)__instance).m_lowestRecordedHealthPercentage = currentHealthPercentage;
						}
					}
					if (BasicAttackBehavior.DrawDebugFiringArea)
					{
						if (Time.frameCount != BasicAttackBehavior.m_lastFrame)
						{
							BasicAttackBehavior.m_arcCount = 0;
							BasicAttackBehavior.m_lastFrame = Time.frameCount;
						}
						if (Object.op_Implicit((Object)(object)((BehaviorBase)__instance).m_aiActor.TargetRigidbody) && ((BasicAttackBehavior)__instance).targetAreaStyle != null)
						{
							((BasicAttackBehavior)__instance).targetAreaStyle.DrawDebugLines(((BasicAttackBehavior)__instance).GetOrigin(((BasicAttackBehavior)__instance).targetAreaStyle.targetAreaOrigin), ((BehaviorBase)__instance).m_aiActor.TargetRigidbody.GetUnitCenter((ColliderType)2), ((BehaviorBase)__instance).m_aiActor);
						}
					}
					((BehaviorBase)__instance).DecrementTimer(ref __instance.m_timer, false);
					if (((BasicAttackBehavior)__instance).m_behaviorSpeculator.AttackCooldown <= 0f && ((BasicAttackBehavior)__instance).m_behaviorSpeculator.GlobalCooldown <= 0f && ((BasicAttackBehavior)__instance).m_cooldownTimer < __instance.SkippableCooldown)
					{
						bool flag = false;
						GameObject val = new GameObject("silencer_bombshee");
						SilencerInstance val2 = val.AddComponent<SilencerInstance>();
						val2.ForceNoDamage = true;
						Cake cake = Toolbox.isCakedUp();
						if (Object.op_Implicit((Object)(object)cake))
						{
							val2.TriggerSilencer(((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).specRigidbody.UnitCenter, 50f, __instance.Radius * 10f, (GameObject)null, 0f, 0f, 0f, 0f, 0f, 0f, 0.25f, ((Object)(object)cake != (Object)null) ? ((PlayerItem)cake).LastOwner : null, false, true);
						}
						Vector2 unitCenter = ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).specRigidbody.HitboxPixelCollider.UnitCenter;
						ReadOnlyCollection<Projectile> allProjectiles = StaticReferenceManager.AllProjectiles;
						for (int j = 0; j < allProjectiles.Count; j++)
						{
							Projectile val3 = allProjectiles[j];
							GameActor owner = val3.Owner;
							AIActor val4 = (AIActor)(object)((owner is AIActor) ? owner : null);
							if (val4 != null && !AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(val4) && Object.op_Implicit((Object)(object)((BraveBehaviour)val3).specRigidbody) && Vector2.Distance(unitCenter, ((BraveBehaviour)val3).specRigidbody.UnitCenter) <= __instance.SkippableRadius)
							{
								flag = true;
								break;
							}
						}
						if (flag)
						{
							((BasicAttackBehavior)__instance).m_cooldownTimer = 0f;
						}
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(DisplaceBehavior), "SpawnImage")]
		public class ChangeUpDisplaceBehavior
		{
			[HarmonyPrefix]
			public static bool Prefix(DisplaceBehavior __instance)
			{
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				if (AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(((BehaviorBase)__instance).m_aiActor))
				{
					Cake cake = Toolbox.isCakedUp();
					if (Object.op_Implicit((Object)(object)cake))
					{
						if (Object.op_Implicit((Object)(object)((BasicAttackBehavior)__instance).m_behaviorSpeculator) && ((BasicAttackBehavior)__instance).m_behaviorSpeculator.MovementBehaviors.Count == 0)
						{
							return false;
						}
						AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(((BehaviorBase)__instance).m_aiActor.EnemyGuid);
						__instance.m_image = AIActor.Spawn(orLoadByGuid, ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).specRigidbody.UnitBottomLeft, ((BehaviorBase)__instance).m_aiActor.ParentRoom, false, (AwakenAnimationType)2, true);
						((BraveBehaviour)__instance.m_image).transform.position = ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).transform.position;
						((BraveBehaviour)__instance.m_image).specRigidbody.Reinitialize();
						((BraveBehaviour)((BraveBehaviour)__instance.m_image).aiAnimator).healthHaver.SetHealthMaximum(__instance.ImageHealthMultiplier * ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).healthHaver.GetMaxHealth() * 0.0625f, (float?)null, false);
						((MonoBehaviour)__instance.m_image).StartCoroutine(WaitUntilActive(__instance.m_image));
						DisplacedImageController val = ((Component)__instance.m_image).gameObject.AddComponent<DisplacedImageController>();
						val.Init();
						val.SetHost(((BehaviorBase)__instance).m_aiActor);
						if (Object.op_Implicit((Object)(object)((BasicAttackBehavior)__instance).m_behaviorSpeculator) && ((BasicAttackBehavior)__instance).m_behaviorSpeculator.MovementBehaviors != null && ((BasicAttackBehavior)__instance).m_behaviorSpeculator.MovementBehaviors.Count > 0)
						{
							MovementBehaviorBase obj = ((BasicAttackBehavior)__instance).m_behaviorSpeculator.MovementBehaviors[0];
							FleeTargetBehavior val2 = (FleeTargetBehavior)(object)((obj is FleeTargetBehavior) ? obj : null);
							if (val2 != null)
							{
								val2.ForceRun = true;
							}
						}
						if (!__instance.m_hasInstantSpawned)
						{
							((BraveBehaviour)__instance.m_image).behaviorSpeculator.GlobalCooldown = __instance.InitialImageAttackDelay;
						}
						return false;
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(TargetEnemiesBehavior), "Update")]
		public class ChangeUpTargetEnemiesBehavior
		{
			[HarmonyPrefix]
			public static bool Prefix(TargetEnemiesBehavior __instance, ref BehaviorResult __result)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Invalid comparison between Unknown and I4
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected I4, but got Unknown
				//IL_032d: 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_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0224: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0234: Unknown result type (might be due to invalid IL or missing references)
				if (AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(((BehaviorBase)__instance).m_aiActor))
				{
					BehaviorResult val = (BehaviorResult)0;
					if ((int)val > 0)
					{
						__result = (BehaviorResult)(int)val;
						return false;
					}
					if (__instance.m_losTimer > 0f)
					{
						__result = (BehaviorResult)0;
						return false;
					}
					__instance.m_losTimer = __instance.SearchInterval;
					if (Object.op_Implicit((Object)(object)((BehaviorBase)__instance).m_aiActor.PlayerTarget))
					{
						if (((BehaviorBase)__instance).m_aiActor.PlayerTarget.IsFalling)
						{
							((BehaviorBase)__instance).m_aiActor.PlayerTarget = null;
							((BehaviorBase)__instance).m_aiActor.ClearPath();
							__result = (BehaviorResult)1;
							return false;
						}
						if (Object.op_Implicit((Object)(object)((BraveBehaviour)((BehaviorBase)__instance).m_aiActor.PlayerTarget).healthHaver) && ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor.PlayerTarget).healthHaver.IsDead)
						{
							((BehaviorBase)__instance).m_aiActor.PlayerTarget = null;
							((BehaviorBase)__instance).m_aiActor.ClearPath();
							__result = (BehaviorResult)1;
							return false;
						}
					}
					else
					{
						((BehaviorBase)__instance).m_aiActor.PlayerTarget = null;
					}
					if (!__instance.ObjectPermanence)
					{
						((BehaviorBase)__instance).m_aiActor.PlayerTarget = null;
					}
					if ((Object)(object)((BehaviorBase)__instance).m_aiActor.PlayerTarget != (Object)null)
					{
						__result = (BehaviorResult)0;
						return false;
					}
					if (!((BehaviorBase)__instance).m_aiActor.CanTargetEnemies)
					{
						__result = (BehaviorResult)0;
						return false;
					}
					List<AIActor> allCharmedAIActors = AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors;
					if (allCharmedAIActors != null && allCharmedAIActors.Count > 0)
					{
						AIActor playerTarget = null;
						float num = float.MaxValue;
						RaycastResult val3 = default(RaycastResult);
						for (int i = 0; i < allCharmedAIActors.Count; i++)
						{
							AIActor val2 = allCharmedAIActors[i];
							if ((Object)(object)val2 == (Object)(object)((BehaviorBase)__instance).m_aiActor)
							{
								continue;
							}
							float num2 = Vector2.Distance(((GameActor)((BehaviorBase)__instance).m_aiActor).CenterPosition, ((GameActor)val2).CenterPosition);
							if (!(num2 < num))
							{
								continue;
							}
							if (__instance.LineOfSight)
							{
								int standardPlayerVisibilityMask = CollisionMask.StandardPlayerVisibilityMask;
								if (!PhysicsEngine.Instance.Raycast(((GameActor)((BehaviorBase)__instance).m_aiActor).CenterPosition, ((GameActor)val2).CenterPosition - ((GameActor)((BehaviorBase)__instance).m_aiActor).CenterPosition, num2, ref val3, true, true, standardPlayerVisibilityMask, (CollisionLayer?)null, false, (Func<SpeculativeRigidbody, bool>)null, ((BraveBehaviour)((BehaviorBase)__instance).m_aiActor).specRigidbody))
								{
									RaycastResult.Pool.Free(ref val3);
									continue;
								}
								if ((Object)(object)val3.SpeculativeRigidbody == (Object)null || (Object)(object)((Component)val3.SpeculativeRigidbody).GetComponent<PlayerController>() == (Object)null)
								{
									RaycastResult.Pool.Free(ref val3);
									continue;
								}
								RaycastResult.Pool.Free(ref val3);
							}
							playerTarget = val2;
							num = num2;
						}
						((BehaviorBase)__instance).m_aiActor.PlayerTarget = (GameActor)(object)playerTarget;
					}
					if ((Object)(object)((BehaviorBase)__instance).m_aiShooter != (Object)null && (Object)(object)((BehaviorBase)__instance).m_aiActor.PlayerTarget != (Object)null)
					{
						((BehaviorBase)__instance).m_aiShooter.AimAtPoint(((BehaviorBase)__instance).m_aiActor.PlayerTarget.CenterPosition);
					}
					if (!((BehaviorBase)__instance).m_aiActor.HasBeenEngaged)
					{
						((BehaviorBase)__instance).m_aiActor.HasBeenEngaged = true;
						__result = (BehaviorResult)2;
						return false;
					}
					__result = (BehaviorResult)1;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(BulletLimbController), "PostBodyMovement")]
		public class ChangeUpBulletLimbController
		{
			[HarmonyPostfix]
			public static void Postfix(BulletLimbController __instance, SpeculativeRigidbody specRigidbody, Vector2 unitDelta, IntVector2 pixelDelta)
			{
				if (!AIActorModifiers.RalseiCharmedEnemyController.allCharmedAIActors.Contains(__instance.m_body))
				{
					return;
				}
				int count = __instance.m_projectiles.Count;
				for (int i = 0; i < count; i++)
				{
					Projectile val = __instance.m_projectiles[i];
					if (val.collidesWithPlayer)
					{
						val.DieInAir(!((Component)val).gameObject.activeSelf, true, true, false);
					}
				}
			}
		}

		public static IEnumerator WaitUntilActive(AIActor aIActor)
		{
			while ((int)aIActor.State != 2)
			{
				yield return null;
			}
			yield return null;
			if (Object.op_Implicit((Object)(object)aIActor))
			{
				Cake c = Toolbox.isCakedUp();
				if (Object.op_Implicit((Object)(object)c))
				{
					aIActor.RalseifyEnemy(c);
				}
			}
		}
	}
	public class LabelablePlayerItem : PlayerItem
	{
		public string currentLabel;

		public void SetLabel(string label)
		{
			currentLabel = label;
		}
	}
	public class EnemyHealthBarRalsei : MonoBehaviour
	{
		private AIActor MyEnemy;

		public tk2dSprite HealthbarSprite;

		public tk2dSprite Heart;

		public void InitEffect(AIActor aIActor)
		{
			MyEnemy = aIActor;
		}

		public void Update()
		{
			//IL_0034: 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_0060: 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)
			float num = ((BraveBehaviour)MyEnemy).healthHaver.currentHealth / ((BraveBehaviour)MyEnemy).healthHaver.GetMaxHealth();
			((tk2dBaseSprite)HealthbarSprite).scale = new Vector3(num, 1f, 1f);
			((tk2dBaseSprite)HealthbarSprite).color = GetColor(num);
			Transform transform = ((BraveBehaviour)Heart).transform;
			transform.localPosition = new Vector3(transform.localPosition.x, Easing.DoLerpT(Mathf.PingPong(Time.timeSinceLevelLoad, 1f) - 0.5f) * 0.25f);
		}

		public Color GetColor(float value)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			return Color.Lerp(Color.red, new Color(0.5f, 1f, 0.2f), value);
		}
	}
	public class Cake : LabelablePlayerItem
	{
		public static GameObject EffectPrefab;

		public static GameActorCharmEffect charmingRoundsEffect = ((Component)PickupObjectDatabase.GetById(527)).GetComponent<BulletStatusEffectItem>().CharmModifierEffect;

		public static GameActorFireEffect hotLeadEffect = ((Component)PickupObjectDatabase.GetById(295)).GetComponent<BulletStatusEffectItem>().FireModifierEffect;

		public RalseiTargetVFX targetVFXInst = null;

		public float StoredHearts = 10f;

		public float StoredArmor = 0f;

		public List<AIActorModifiers.RalseiCharmedEnemyController> AllCharmedEnemies = new List<AIActorModifiers.RalseiCharmedEnemyController>();

		public float HealthDropChance = 0.02f;

		private bool Inited = false;

		private float E = 0f;

		public AIActor CurrentEnemy = null;

		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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_01ba: 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_01df: Expected O, but got Unknown
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: 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)
			string text = "Slice Of Cake";
			GameObject val = new GameObject(text);
			Cake cake = val.AddComponent<Cake>();
			tk2dSpriteCollectionData itemAndGunCollection = StaticSpriteCollections.ItemAndGunCollection;
			ItemBuilder.AddSpriteToObjectAssetbundle(text, itemAndGunCollection.GetSpriteIdByName("ralseicake"), itemAndGunCollection, val);
			string text2 = "For Sharing!";
			string text3 = "Allows you to turn enemies to your side, once they have been shown enough love, using up a charge. Charges are restored by using the active on heart pickups. Passively provides a chance for additional health drops.\n\nMade purely out of milk.";
			ItemBuilder.SetupItem((PickupObject)(object)cake, text2, text3, "rlsi");
			ItemBuilder.SetCooldownType((PlayerItem)(object)cake, (CooldownType)0, 1f);
			((PlayerItem)cake).consumable = false;
			((PickupObject)cake).quality = (ItemQuality)(-50);
			((PickupObject)cake).CanBeDropped = false;
			ItemBuilder.AddPassiveStatModifier((PickupObject)(object)cake, (StatType)8, 1f, (ModifyMethod)0);
			new Hook((MethodBase)typeof(GameUIItemController).GetMethod("UpdateItem", BindingFlags.Instance | BindingFlags.Public), typeof(Cake).GetMethod("UpdateCustomLabel"));
			GameObject val2 = PrefabBuilder.BuildObject("HealthbarRalsei");
			EnemyHealthBarRalsei enemyHealthBarRalsei = val2.AddComponent<EnemyHealthBarRalsei>();
			Object.DontDestroyOnLoad((Object)(object)val2);
			val2.layer = LayerMask.NameToLayer("FG_Critical");
			tk2dSprite val3 = val2.AddComponent<tk2dSprite>();
			((tk2dBaseSprite)val3).SetSprite(StaticSpriteCollections.ItemAndGunCollection, "ralsei_charm_bar_002");
			enemyHealthBarRalsei.HealthbarSprite = val3;
			((tk2dBaseSprite)val3).HeightOffGround = -10f;
			((tk2dBaseSprite)val3).SortingOrder = 20;
			((tk2dBaseSprite)val3).usesOverrideMaterial = true;
			Material val4 = new Material(Shader.Find("tk2d/CutoutVertexColorTilted"));
			val4.mainTexture = ((BraveBehaviour)val3).renderer.material.mainTexture;
			((BraveBehaviour)val3).renderer.material = val4;
			GameObject val5 = PrefabBuilder.BuildObject("HealthbarRalseiBack");
			val5.layer = LayerMask.NameToLayer("FG_Critical");
			val3 = val5.AddComponent<tk2dSprite>();
			((tk2dBaseSprite)val3).SetSprite(StaticSpriteCollections.ItemAndGunCollection, "ralsei_charm_bar_002");
			((tk2dBaseSprite)val3).HeightOffGround = -20f;
			((tk2dBaseSprite)val3).SortingOrder = 8;
			((tk2dBaseSprite)val3).color = new Color(0f, 0.2f, 0.05f);
			((tk2dBaseSprite)val3).usesOverrideMaterial = true;
			val4 = new Material(Shader.Find("tk2d/CutoutVertexColorTilted"));
			val4.mainTexture = ((BraveBehaviour)val3).renderer.material.mainTexture;
			((BraveBehaviour)val3).renderer.material = val4;
			val5.transform.SetParent(val2.transform);
			GameObject val6 = PrefabBuilder.BuildObject("HealthbarRalseiBack");
			val6.layer = LayerMask.NameToLayer("FG_Critical");
			val3 = val6.AddComponent<tk2dSprite>();
			((tk2dBaseSprite)val3).SetSprite(StaticSpriteCollections.ItemAndGunCollection, "ralsei_charm_heart_004");
			((tk2dBaseSprite)val3).HeightOffGround = -10f;
			((tk2dBaseSprite)val3).SortingOrder = 8;
			((tk2dBaseSprite)val3).usesOverrideMaterial = true;
			val4 = new Material(Shader.Find("tk2d/CutoutVertexColorTilted"));
			val4.mainTexture = ((BraveBehaviour)val3).renderer.material.mainTexture;
			((BraveBehaviour)val3).renderer.material = val4;
			val6.transform.SetParent(val2.transform);
			Transform transform = val6.transform;
			transform.localPosition -= new Vector3(0.375f, 0f);
			enemyHealthBarRalsei.Heart = val3;
			EffectPrefab = val2;
			CustomSynergies.Add("A Hearty Meal", new List<string> { "rlsi:slice_of_cake" }, new List<string> { "antibody" }, false);
			CustomSynergies.Add("You And What Army", new List<string> { "rlsi:slice_of_cake" }, new List<string> { "battle_standard" }, false);
			CustomSynergies.Add("Pacify", new List<string> { "rlsi:slice_of_cake" }, new List<string> { "charm_horn" }, false);
			CustomSynergies.Add("Memories Of Home", new List<string> { "rlsi:slice_of_cake" }, new List<string> { "really_special_lute" }, false);
			CustomSynergies.Add("Group Huddle", new List<string> { "rlsi:slice_of_cake" }, new List<string> { "old_kn