Decompiled source of StandaloneBellTower v1.0.0

plugins/StandaloneBellTower/StandaloneBellTower.dll

Decompiled 15 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPathsBetter;
using StandaloneBellTower.Components;
using StandaloneBellTower.States;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StandaloneBellTower")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c988079955e49d627ea90ee7f89be9a0c0585f20")]
[assembly: AssemblyProduct("StandaloneBellTower")]
[assembly: AssemblyTitle("StandaloneBellTower")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StandaloneBellTower
{
	internal static class BellTowerConfig
	{
		internal static ConfigEntry<string> Stages { get; private set; }

		internal static ConfigEntry<int> SpawnWeight { get; private set; }

		internal static ConfigEntry<int> DirectorCost { get; private set; }

		internal static ConfigEntry<int> MinimumStageCompletions { get; private set; }

		internal static ConfigEntry<int> MaxBells { get; private set; }

		internal static ConfigEntry<bool> SummonMonsters { get; private set; }

		internal static ConfigEntry<int> MaxSummonedMonsters { get; private set; }

		internal static void Init(ConfigFile config)
		{
			Stages = config.Bind<string>("Spawning", "Stages", "goolake, ancientloft, wispgraveyard, skymeadow", "Comma separated internal stage names the Bell Tower can spawn on (as a champion, so also as a teleporter boss). Modded stages work too.");
			SpawnWeight = config.Bind<int>("Spawning", "Spawn Weight", 1, "Director selection weight within the Champions category.");
			DirectorCost = config.Bind<int>("Spawning", "Director Cost", 750, "Credits the director has to spend to spawn a Bell Tower.");
			MinimumStageCompletions = config.Bind<int>("Spawning", "Minimum Stage Completions", 1, "How many stages have to be cleared before the Bell Tower can appear.");
			MaxBells = config.Bind<int>("Summons", "Max Bells", 4, "Maximum Brass Contraptions a single Bell Tower keeps alive. They act as extra launch points for its barrage.");
			SummonMonsters = config.Bind<bool>("Summons", "Summon Monsters", true, "Whether the Bell Tower can call in monsters from the current stage's spawn pool.");
			MaxSummonedMonsters = config.Bind<int>("Summons", "Max Summoned Monsters", 4, "Maximum monsters a single Bell Tower keeps alive through its summon. The original mod had no limit, which piled up enemies during long fights.");
		}

		internal static HashSet<string> GetStageNames()
		{
			return new HashSet<string>(from s in Stages.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
				select s.Trim() into s
				where s.Length > 0
				select s, StringComparer.OrdinalIgnoreCase);
		}
	}
	internal class BellTowerContent : IContentPackProvider
	{
		private const float deathSkeletonScaleFix = 100f;

		private const float deathEffectLifetime = 12f;

		private readonly ContentPack contentPack = new ContentPack();

		public static AssetBundle Bundle { get; private set; }

		public static GameObject BodyPrefab { get; private set; }

		public static GameObject MasterPrefab { get; private set; }

		public static GameObject BellMinionMasterPrefab { get; private set; }

		public static GameObject ProjectilePrefab { get; private set; }

		public static GameObject BeamPrefab { get; private set; }

		public static GameObject StompEffectPrefab { get; private set; }

		public static GameObject DeathEffectPrefab { get; private set; }

		public static CharacterSpawnCard SpawnCard { get; private set; }

		public string identifier => "Phreel.StandaloneBellTower";

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			AssetBundleCreateRequest bundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Main.PluginDirectory, "belltowerassets"));
			AsyncOperationHandle<Shader> standardShader = Addressables.LoadAssetAsync<Shader>((object)RoR2_Base_Shaders.HGStandard_shader);
			AsyncOperationHandle<Shader> cloudRemapShader = Addressables.LoadAssetAsync<Shader>((object)RoR2_Base_Shaders.HGCloudRemap_shader);
			AsyncOperationHandle<GameObject> bellBody = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Bell.BellBody_prefab);
			while (!((AsyncOperation)bundleRequest).isDone)
			{
				args.ReportProgress(((AsyncOperation)bundleRequest).progress * 0.5f);
				yield return null;
			}
			Bundle = bundleRequest.assetBundle;
			if (!Object.op_Implicit((Object)(object)Bundle))
			{
				Log.Error("Failed to load the belltowerassets bundle, the Bell Tower will not be available", "D:\\Games\\LostItems\\standalonebelltower\\codeprojectitself\\StandaloneBellTower\\BellTowerContent.cs", "LoadStaticContentAsync", 59);
				yield break;
			}
			AssetBundleRequest assetsRequest = Bundle.LoadAllAssetsAsync();
			while (!((AsyncOperation)assetsRequest).isDone)
			{
				args.ReportProgress(0.5f + ((AsyncOperation)assetsRequest).progress * 0.3f);
				yield return null;
			}
			while (!standardShader.IsDone || !cloudRemapShader.IsDone || !bellBody.IsDone)
			{
				yield return null;
			}
			FixShaders(standardShader.Result, cloudRemapShader.Result);
			BodyPrefab = Bundle.LoadAsset<GameObject>("BodyBellTower");
			MasterPrefab = Bundle.LoadAsset<GameObject>("BellTowerMonsterMaster");
			BellMinionMasterPrefab = Bundle.LoadAsset<GameObject>("BellMinionMonsterMaster");
			ProjectilePrefab = Bundle.LoadAsset<GameObject>("BellTowerBallSimple");
			BeamPrefab = Bundle.LoadAsset<GameObject>("BellBeam");
			StompEffectPrefab = Bundle.LoadAsset<GameObject>("StompParticles");
			DeathEffectPrefab = Bundle.LoadAsset<GameObject>("BellTowerDeathEffect");
			SpawnCard = Bundle.LoadAsset<CharacterSpawnCard>("cscBellTower");
			UnlockableDef logUnlockable = Bundle.LoadAsset<UnlockableDef>("Logs.BodyBellTower.0");
			Transform model = BodyPrefab.GetComponent<ModelLocator>().modelTransform;
			yield return ResolveSoundEvents(BodyPrefab);
			yield return BellTowerItemDisplays.Apply(((Component)model).GetComponent<CharacterModel>());
			SetupBody(model);
			SetupMinionMaster(bellBody.Result);
			SetupProjectile();
			SetupBeam();
			SetupDeathEffect(model);
			SkillDef[] array = SetupSkills();
			SkillFamily[] array2 = array.Select(GetFamily).ToArray();
			logUnlockable.cachedName = "Logs.BodyBellTower.0";
			((Object)BellMinionMasterPrefab).name = UniqueName(((Object)BellMinionMasterPrefab).name);
			((Object)ProjectilePrefab).name = UniqueName(((Object)ProjectilePrefab).name);
			SkillDef[] array3 = array;
			foreach (SkillDef val in array3)
			{
				((Object)val).name = UniqueName(((Object)val).name);
				val.skillName = ((Object)val).name;
			}
			SkillFamily[] array4 = array2;
			foreach (SkillFamily val2 in array4)
			{
				((Object)val2).name = UniqueName(((Object)val2).name);
			}
			contentPack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { BodyPrefab });
			contentPack.masterPrefabs.Add((GameObject[])(object)new GameObject[2] { MasterPrefab, BellMinionMasterPrefab });
			contentPack.projectilePrefabs.Add((GameObject[])(object)new GameObject[1] { ProjectilePrefab });
			contentPack.skillDefs.Add(array);
			contentPack.skillFamilies.Add(array2);
			contentPack.unlockableDefs.Add((UnlockableDef[])(object)new UnlockableDef[1] { logUnlockable });
			contentPack.entityStateTypes.Add(new Type[7]
			{
				typeof(SpawnState),
				typeof(FireBalls),
				typeof(Stomp),
				typeof(SummonBells),
				typeof(SummonMonsters),
				typeof(MinionDelayedSpawn),
				typeof(DeathState)
			});
			RegisterSpawns();
			args.ReportProgress(1f);
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}

		private static string UniqueName(string name)
		{
			return "StandaloneBellTower_" + name;
		}

		private static void FixShaders(Shader standard, Shader cloudRemap)
		{
			Material[] array = Bundle.LoadAllAssets<Material>();
			foreach (Material val in array)
			{
				string name = ((Object)val.shader).name;
				if (!(name == "StubbedShader/deferred/standard"))
				{
					if (name == "StubbedShader/fx/hgcloudremap")
					{
						val.shader = cloudRemap;
						val.EnableKeyword("USE_CLOUDS");
						val.EnableKeyword("VERTEXCOLOR");
						val.EnableKeyword("_EMISSION");
					}
				}
				else
				{
					val.shader = standard;
				}
			}
		}

		private static IEnumerator ResolveSoundEvents(GameObject prefab)
		{
			SoundEventProvider[] componentsInChildren = prefab.GetComponentsInChildren<SoundEventProvider>(true);
			foreach (SoundEventProvider provider in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)provider.target) && provider.target.data != null && !string.IsNullOrEmpty(provider.path))
				{
					AsyncOperationHandle<WwiseEventReference> handle = Addressables.LoadAssetAsync<WwiseEventReference>((object)provider.path);
					while (!handle.IsDone)
					{
						yield return null;
					}
					provider.target.data.WwiseObjectReference = handle.Result;
				}
				Object.DestroyImmediate((Object)(object)provider, true);
			}
		}

		private static void SetupBody(Transform model)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			BodyPrefab.GetComponent<CharacterBody>().preferredInitialStateType = new SerializableEntityStateType(typeof(SpawnState));
			EntityStateMachine[] components = BodyPrefab.GetComponents<EntityStateMachine>();
			foreach (EntityStateMachine val in components)
			{
				if (val.customName == "Body")
				{
					val.initialStateType = new SerializableEntityStateType(typeof(SpawnState));
					val.mainStateType = new SerializableEntityStateType(typeof(GenericCharacterMain));
				}
			}
			BodyPrefab.GetComponent<CharacterDeathBehavior>().deathState = new SerializableEntityStateType(typeof(DeathState));
			BodyPrefab.AddComponent<BellTowerMinionTracker>();
			((Component)model).GetComponent<HurtBoxGroup>().OnValidate();
			PruneDynamicBones(model);
			AddKinematicRigidbodies(model);
			Light[] componentsInChildren = ((Component)model).GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].shadows = (LightShadows)0;
			}
		}

		private static void SetupMinionMaster(GameObject bellBody)
		{
			BellMinionMasterPrefab.GetComponent<CharacterMaster>().bodyPrefab = bellBody;
			BaseAI[] components = BellMinionMasterPrefab.GetComponents<BaseAI>();
			for (int i = 0; i < components.Length; i++)
			{
				((Behaviour)components[i]).enabled = false;
			}
		}

		private static void SetupProjectile()
		{
			ProjectileOverlapAttack component = ProjectilePrefab.GetComponent<ProjectileOverlapAttack>();
			component.fireFrequency = 20f;
			component.impactEffect = null;
			GameObject ghostPrefab = ProjectilePrefab.GetComponent<ProjectileController>().ghostPrefab;
			if (Object.op_Implicit((Object)(object)ghostPrefab))
			{
				Collider[] componentsInChildren = ghostPrefab.GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i], true);
				}
			}
		}

		private static void SetupBeam()
		{
			NetworkTransform[] componentsInChildren = BeamPrefab.GetComponentsInChildren<NetworkTransform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i], true);
			}
			NetworkIdentity[] componentsInChildren2 = BeamPrefab.GetComponentsInChildren<NetworkIdentity>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i], true);
			}
		}

		private static void SetupDeathEffect(Transform model)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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)
			SkinnedMeshRenderer componentInChildren = DeathEffectPrefab.GetComponentInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer componentInChildren2 = ((Component)model).GetComponentInChildren<SkinnedMeshRenderer>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren) && !Object.op_Implicit((Object)(object)componentInChildren.sharedMesh) && Object.op_Implicit((Object)(object)componentInChildren2) && Object.op_Implicit((Object)(object)componentInChildren2.sharedMesh) && componentInChildren.bones.Length == componentInChildren2.sharedMesh.bindposes.Length)
			{
				Mesh val = Object.Instantiate<Mesh>(componentInChildren2.sharedMesh);
				((Object)val).name = "MeshBellTowerDebris";
				Matrix4x4 val2 = Matrix4x4.Scale(Vector3.one * 100f);
				Matrix4x4[] bindposes = val.bindposes;
				for (int i = 0; i < bindposes.Length; i++)
				{
					bindposes[i] = val2 * bindposes[i];
				}
				val.bindposes = bindposes;
				val.UploadMeshData(true);
				componentInChildren.sharedMesh = val;
				Bounds localBounds = ((Renderer)componentInChildren2).localBounds;
				((Bounds)(ref localBounds)).Expand(((Bounds)(ref localBounds)).size);
				((Renderer)componentInChildren).localBounds = localBounds;
			}
			PruneDynamicBones(DeathEffectPrefab.transform);
			DeathEffectPrefab.AddComponent<DestroyOnTimer>().duration = 12f;
		}

		private static SkillDef[] SetupSkills()
		{
			return new(string, Type)[4]
			{
				("skdfBTBallSimple", typeof(FireBalls)),
				("skdfBTSlam", typeof(Stomp)),
				("skdfBTSummon", typeof(SummonBells)),
				("skdfBTSummonAll", typeof(SummonMonsters))
			}.Select(delegate((string name, Type state) skill)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				SkillDef obj = Bundle.LoadAsset<SkillDef>(skill.name);
				obj.activationState = new SerializableEntityStateType(skill.state);
				return obj;
			}).ToArray();
		}

		private static SkillFamily GetFamily(SkillDef skillDef)
		{
			GenericSkill[] components = BodyPrefab.GetComponents<GenericSkill>();
			foreach (GenericSkill val in components)
			{
				if (Object.op_Implicit((Object)(object)val.skillFamily) && val.skillFamily.variants.Any((Variant v) => (Object)(object)v.skillDef == (Object)(object)skillDef))
				{
					return val.skillFamily;
				}
			}
			throw new InvalidOperationException("No skill family on the body uses " + ((Object)skillDef).name);
		}

		private static void RegisterSpawns()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0025: 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_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			((SpawnCard)SpawnCard).directorCreditCost = BellTowerConfig.DirectorCost.Value;
			DirectorCardHolder val = new DirectorCardHolder
			{
				Card = new DirectorCard
				{
					spawnCard = (SpawnCard)(object)SpawnCard,
					selectionWeight = BellTowerConfig.SpawnWeight.Value,
					minimumStageCompletions = BellTowerConfig.MinimumStageCompletions.Value,
					spawnDistance = (MonsterSpawnDistance)0,
					preventOverhead = false
				},
				MonsterCategory = (MonsterCategory)4
			};
			HashSet<string> stages = BellTowerConfig.GetStageNames();
			Helpers.AddNewMonsterToStagesWhere(val, false, (Predicate<StageInfo>)((StageInfo stage) => stages.Contains(((StageInfo)(ref stage)).ToInternalStageName())));
		}

		private static void PruneDynamicBones(Transform root)
		{
			DynamicBone[] componentsInChildren = ((Component)root).GetComponentsInChildren<DynamicBone>(true);
			foreach (DynamicBone val in componentsInChildren)
			{
				Transform parent = ((Component)val).transform.parent;
				if (Object.op_Implicit((Object)(object)parent) && Object.op_Implicit((Object)(object)((Component)parent).GetComponentInParent<DynamicBone>(true)))
				{
					Object.DestroyImmediate((Object)(object)val, true);
					continue;
				}
				val.m_DistantDisable = true;
				val.m_DistanceToObject = 150f;
			}
		}

		private static void AddKinematicRigidbodies(Transform model)
		{
			Collider[] componentsInChildren = ((Component)model).GetComponentsInChildren<Collider>(true);
			foreach (Collider val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<Rigidbody>(true)))
				{
					Rigidbody obj = ((Component)val).gameObject.AddComponent<Rigidbody>();
					obj.isKinematic = true;
					obj.useGravity = false;
					obj.interpolation = (RigidbodyInterpolation)0;
					obj.collisionDetectionMode = (CollisionDetectionMode)0;
				}
			}
		}
	}
	internal static class BellTowerItemDisplays
	{
		private struct Rule
		{
			public string displayPrefab;

			public Vector3 localPos;

			public Vector3 localAngles;

			public Vector3 localScale;
		}

		private static readonly (string equipment, Rule[] rules)[] ruleGroups = new(string, Rule[])[5]
		{
			(RoR2_Base_EliteFire.EliteFireEquipment_asset, new Rule[2]
			{
				new Rule
				{
					displayPrefab = RoR2_Base_EliteFire.DisplayEliteHorn_prefab,
					localPos = new Vector3(0.0014912f, 0.0033023f, -0.0020226f),
					localAngles = new Vector3(39.00001f, 90f, 180f),
					localScale = new Vector3(-0.0018772f, 0.0018772f, 0.0018772f)
				},
				new Rule
				{
					displayPrefab = RoR2_Base_EliteFire.DisplayEliteHorn_prefab,
					localPos = new Vector3(0.0014912f, 0.0033023f, 0.0020226f),
					localAngles = new Vector3(39f, 90f, 180f),
					localScale = new Vector3(0.0018772f, 0.0018772f, 0.0018772f)
				}
			}),
			(RoR2_Base_EliteLightning.EliteLightningEquipment_asset, new Rule[2]
			{
				new Rule
				{
					displayPrefab = RoR2_Base_EliteLightning.DisplayEliteRhinoHorn_prefab,
					localPos = new Vector3(0.0040176f, 0.0038402f, 0f),
					localAngles = new Vector3(63.39509f, 89.99995f, 179.9999f),
					localScale = new Vector3(0.005f, 0.005f, 0.005f)
				},
				new Rule
				{
					displayPrefab = RoR2_Base_EliteLightning.DisplayEliteRhinoHorn_prefab,
					localPos = new Vector3(0.0046917f, 0.0057269f, 0f),
					localAngles = new Vector3(39.23663f, 90f, 180f),
					localScale = new Vector3(0.005f, 0.005f, 0.005f)
				}
			}),
			(RoR2_Base_EliteIce.EliteIceEquipment_asset, new Rule[1]
			{
				new Rule
				{
					displayPrefab = RoR2_Base_EliteIce.DisplayEliteIceCrown_prefab,
					localPos = new Vector3(0f, 0.0021344f, 0f),
					localAngles = new Vector3(90f, 270f, 0f),
					localScale = new Vector3(0.0006854f, 0.0006854f, 0.0006854f)
				}
			}),
			(RoR2_Base_ElitePoison.ElitePoisonEquipment_asset, new Rule[1]
			{
				new Rule
				{
					displayPrefab = RoR2_Base_ElitePoison.DisplayEliteUrchinCrown_prefab,
					localPos = new Vector3(0f, 0.0033946f, 0f),
					localAngles = new Vector3(90f, 270f, 0f),
					localScale = new Vector3(0.0011159f, 0.0011159f, 0.0011159f)
				}
			}),
			(RoR2_Base_EliteHaunted.EliteHauntedEquipment_asset, new Rule[1]
			{
				new Rule
				{
					displayPrefab = RoR2_Base_EliteHaunted.DisplayEliteStealthCrown_prefab,
					localPos = new Vector3(0f, 0.0028796f, 0f),
					localAngles = new Vector3(90f, 270f, 0f),
					localScale = new Vector3(0.001309f, 0.001309f, 0.001309f)
				}
			})
		};

		internal static IEnumerator Apply(CharacterModel model)
		{
			Dictionary<string, AsyncOperationHandle<EquipmentDef>> equipmentLoads = new Dictionary<string, AsyncOperationHandle<EquipmentDef>>();
			Dictionary<string, AsyncOperationHandle<GameObject>> displayLoads = new Dictionary<string, AsyncOperationHandle<GameObject>>();
			(string, Rule[])[] array = ruleGroups;
			for (int i = 0; i < array.Length; i++)
			{
				(string, Rule[]) tuple = array[i];
				string item = tuple.Item1;
				Rule[] item2 = tuple.Item2;
				equipmentLoads[item] = Addressables.LoadAssetAsync<EquipmentDef>((object)item);
				Rule[] array2 = item2;
				for (int j = 0; j < array2.Length; j++)
				{
					Rule rule = array2[j];
					if (!displayLoads.ContainsKey(rule.displayPrefab))
					{
						displayLoads[rule.displayPrefab] = Addressables.LoadAssetAsync<GameObject>((object)rule.displayPrefab);
					}
				}
			}
			foreach (AsyncOperationHandle<EquipmentDef> handle in equipmentLoads.Values)
			{
				while (!handle.IsDone)
				{
					yield return null;
				}
			}
			foreach (AsyncOperationHandle<GameObject> handle2 in displayLoads.Values)
			{
				while (!handle2.IsDone)
				{
					yield return null;
				}
			}
			List<KeyAssetRuleGroup> list = new List<KeyAssetRuleGroup>();
			array = ruleGroups;
			for (int i = 0; i < array.Length; i++)
			{
				(string, Rule[]) tuple2 = array[i];
				string item3 = tuple2.Item1;
				Rule[] item4 = tuple2.Item2;
				EquipmentDef result = equipmentLoads[item3].Result;
				if (!Object.op_Implicit((Object)(object)result))
				{
					Log.Warning("Couldn't load equipment " + item3 + " for item displays", "D:\\Games\\LostItems\\standalonebelltower\\codeprojectitself\\StandaloneBellTower\\BellTowerItemDisplays.cs", "Apply", 80);
					continue;
				}
				List<ItemDisplayRule> list2 = new List<ItemDisplayRule>();
				Rule[] array2 = item4;
				for (int j = 0; j < array2.Length; j++)
				{
					Rule rule2 = array2[j];
					GameObject result2 = displayLoads[rule2.displayPrefab].Result;
					if (Object.op_Implicit((Object)(object)result2))
					{
						list2.Add(new ItemDisplayRule
						{
							ruleType = (ItemDisplayRuleType)0,
							followerPrefab = result2,
							childName = "Head",
							localPos = rule2.localPos,
							localAngles = rule2.localAngles,
							localScale = rule2.localScale,
							limbMask = (LimbFlags)0
						});
					}
				}
				list.Add(new KeyAssetRuleGroup
				{
					keyAsset = (Object)(object)result,
					displayRuleGroup = new DisplayRuleGroup
					{
						rules = list2.ToArray()
					}
				});
			}
			ItemDisplayRuleSet val = ScriptableObject.CreateInstance<ItemDisplayRuleSet>();
			((Object)val).name = "idrsBellTower";
			val.keyAssetRuleGroups = list.ToArray();
			model.itemDisplayRuleSet = val;
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("StandaloneBellTower");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "StandaloneBellTower".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Phreel.StandaloneBellTower", "StandaloneBellTower", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<List<string>> <>9__12_0;

			public static CollectContentPackProvidersDelegate <>9__12_1;

			internal void <Awake>b__12_0(List<string> folders)
			{
				folders.Add(Path.Combine(PluginDirectory, "Language"));
			}

			internal void <Awake>b__12_1(AddContentPackProviderDelegate addContentPackProvider)
			{
				addContentPackProvider.Invoke((IContentPackProvider)(object)new BellTowerContent());
			}
		}

		public const string PluginGUID = "Phreel.StandaloneBellTower";

		public const string PluginAuthor = "Phreel";

		public const string PluginName = "StandaloneBellTower";

		public const string PluginVersion = "1.0.0";

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		public void Awake()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			BellTowerConfig.Init(((BaseUnityPlugin)this).Config);
			SoundBanks.Add(File.ReadAllBytes(Path.Combine(PluginDirectory, "BellTower.bnk")));
			Language.collectLanguageRootFolders += delegate(List<string> folders)
			{
				folders.Add(Path.Combine(PluginDirectory, "Language"));
			};
			object obj = <>c.<>9__12_1;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate addContentPackProvider)
				{
					addContentPackProvider.Invoke((IContentPackProvider)(object)new BellTowerContent());
				};
				<>c.<>9__12_1 = val;
				obj = (object)val;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
		}
	}
}
namespace StandaloneBellTower.States
{
	public abstract class BaseSummonState : BaseState
	{
		public static float duration = 10f;

		public static float beamRefreshInterval = 0.5f;

		protected BellTowerMinionTracker tracker;

		private readonly Dictionary<CharacterMaster, GameObject> beams = new Dictionary<CharacterMaster, GameObject>();

		private Transform portal;

		private float beamRefreshTimer;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			Util.PlaySound("BellTowerSummon", ((EntityState)this).gameObject);
			portal = ((BaseState)this).FindModelChild("Portal");
			tracker = ((EntityState)this).GetComponent<BellTowerMinionTracker>();
			if (NetworkServer.active && Object.op_Implicit((Object)(object)tracker))
			{
				Summon();
			}
		}

		protected abstract void Summon();

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			beamRefreshTimer -= Time.fixedDeltaTime;
			if (beamRefreshTimer <= 0f)
			{
				beamRefreshTimer = beamRefreshInterval;
				RefreshBeams();
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		private void RefreshBeams()
		{
			CharacterMaster val = (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) ? ((EntityState)this).characterBody.master : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)portal) || !Object.op_Implicit((Object)(object)BellTowerContent.BeamPrefab))
			{
				return;
			}
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if (!Object.op_Implicit((Object)(object)readOnlyInstances.minionOwnership) || (Object)(object)readOnlyInstances.minionOwnership.ownerMaster != (Object)(object)val || beams.ContainsKey(readOnlyInstances))
				{
					continue;
				}
				CharacterBody body = readOnlyInstances.GetBody();
				if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.mainHurtBox))
				{
					continue;
				}
				GameObject val2 = Object.Instantiate<GameObject>(BellTowerContent.BeamPrefab, ((Component)body.mainHurtBox).transform);
				BeamController componentInChildren = val2.GetComponentInChildren<BeamController>();
				if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.endPoint))
				{
					CopyTransform component = ((Component)componentInChildren.endPoint).GetComponent<CopyTransform>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.target = ((Component)portal).gameObject;
					}
				}
				beams[readOnlyInstances] = val2;
			}
		}

		public override void OnExit()
		{
			foreach (GameObject value in beams.Values)
			{
				if (Object.op_Implicit((Object)(object)value))
				{
					Object.Destroy((Object)(object)value);
				}
			}
			beams.Clear();
			((EntityState)this).OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)2;
		}
	}
	public class DeathState : GenericCharacterDeath
	{
		public override void OnEnter()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			((GenericCharacterDeath)this).OnEnter();
			if (NetworkServer.active)
			{
				BellTowerMinionTracker component = ((EntityState)this).GetComponent<BellTowerMinionTracker>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.KillBells();
				}
			}
			Transform val = (Object.op_Implicit((Object)(object)((EntityState)this).modelLocator) ? ((EntityState)this).modelLocator.modelTransform : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				if (Object.op_Implicit((Object)(object)BellTowerContent.DeathEffectPrefab))
				{
					Object.Instantiate<GameObject>(BellTowerContent.DeathEffectPrefab, val.position, val.rotation);
				}
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
		}
	}
	public class FireBalls : BaseState
	{
		public static float baseDuration = 5f;

		public static float baseFireInterval = 0.3f;

		public static float damageCoefficient = 4.5f;

		public static float force = 450f;

		public static float maxBellRange = 60f;

		public static float bellLaunchHeight = 5f;

		private static readonly string[] muzzles = new string[6] { "MuzzleN", "MuzzleNW", "MuzzleSW", "MuzzleS", "MuzzleSE", "MuzzleNE" };

		private readonly Queue<CharacterMaster> bellQueue = new Queue<CharacterMaster>();

		private float duration;

		private float fireInterval;

		private float fireTimer;

		private int muzzleIndex;

		public override void OnEnter()
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / base.attackSpeedStat;
			fireInterval = baseFireInterval / base.attackSpeedStat;
			fireTimer = fireInterval;
			((EntityState)this).PlayAnimation("Gesture", "FireBalls", "attackspeed", 4.8f / base.attackSpeedStat, 0f);
			if (!NetworkServer.active)
			{
				return;
			}
			BellTowerMinionTracker component = ((EntityState)this).GetComponent<BellTowerMinionTracker>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			float num = maxBellRange * maxBellRange;
			foreach (CharacterMaster bell in component.Bells)
			{
				CharacterBody body = bell.GetBody();
				if (Object.op_Implicit((Object)(object)body))
				{
					Vector3 val = body.corePosition - ((EntityState)this).transform.position;
					if (((Vector3)(ref val)).sqrMagnitude <= num)
					{
						bellQueue.Enqueue(bell);
					}
				}
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (NetworkServer.active)
			{
				fireTimer -= Time.fixedDeltaTime;
				if (fireTimer <= 0f)
				{
					fireTimer += fireInterval;
					FireVolley();
				}
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		private void FireVolley()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			while (bellQueue.Count > 0)
			{
				CharacterMaster val = bellQueue.Dequeue();
				CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetBody() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					Fire(val2.corePosition + Vector3.up * bellLaunchHeight);
					break;
				}
			}
			if (muzzleIndex < muzzles.Length)
			{
				Transform val3 = ((BaseState)this).FindModelChild(muzzles[muzzleIndex++]);
				if (Object.op_Implicit((Object)(object)val3))
				{
					Fire(val3.position);
				}
			}
		}

		private void Fire(Vector3 position)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			if (Object.op_Implicit((Object)(object)BellTowerContent.ProjectilePrefab))
			{
				ProjectileManager instance = ProjectileManager.instance;
				FireProjectileInfo val = new FireProjectileInfo
				{
					projectilePrefab = BellTowerContent.ProjectilePrefab,
					position = position
				};
				Ray aimRay = ((BaseState)this).GetAimRay();
				val.rotation = Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction);
				val.owner = ((EntityState)this).gameObject;
				val.damage = base.damageStat * damageCoefficient;
				val.force = force;
				val.crit = ((BaseState)this).RollCrit();
				instance.FireProjectile(val);
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)2;
		}
	}
	public class MinionDelayedSpawn : BaseState
	{
		public static float bellDuration = 10f;

		public static float monsterDuration = 5f;

		public static float pulverizeDuration = 4f;

		private static BodyIndex bellBodyIndex = (BodyIndex)(-1);

		private bool isBell;

		private float duration;

		public override void OnEnter()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			if ((int)bellBodyIndex == -1)
			{
				bellBodyIndex = BodyCatalog.FindBodyIndex("BellBody");
			}
			isBell = Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && ((EntityState)this).characterBody.bodyIndex == bellBodyIndex;
			duration = (isBell ? bellDuration : monsterDuration);
			if (NetworkServer.active)
			{
				if (Object.op_Implicit((Object)(object)((EntityState)this).healthComponent))
				{
					if (isBell)
					{
						((EntityState)this).healthComponent.health = 1f;
					}
					else
					{
						HealthComponent healthComponent = ((EntityState)this).healthComponent;
						healthComponent.health *= 0.5f;
					}
				}
				if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
				{
					((EntityState)this).characterBody.AddTimedBuff(Buffs.Pulverized, pulverizeDuration);
				}
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				((EntityState)this).characterBody.isSprinting = false;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterDirection))
			{
				((EntityState)this).characterDirection.moveVector = ((EntityState)this).characterDirection.forward;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				((EntityState)this).characterMotor.moveDirection = Vector3.zero;
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).rigidbodyMotor))
			{
				((EntityState)this).rigidbodyMotor.moveVector = Vector3.zero;
			}
		}

		public override void FixedUpdate()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).healthComponent) && ((EntityState)this).healthComponent.alive)
			{
				float num = (isBell ? 1f : 0.5f) / duration;
				((EntityState)this).healthComponent.HealFraction(num * Time.fixedDeltaTime, default(ProcChainMask));
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)8;
		}
	}
	public class SpawnState : BaseState
	{
		public static float duration = 7f;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			((EntityState)this).PlayAnimation("Main", "Spawn");
			Util.PlaySound("BellTowerSpawn", ((EntityState)this).gameObject);
			Transform val = ((BaseState)this).FindModelChild("SpawnDust");
			if (Object.op_Implicit((Object)(object)val))
			{
				ParticleSystem component = ((Component)val).GetComponent<ParticleSystem>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.Play(true);
				}
				ShakeEmitter component2 = ((Component)val).GetComponent<ShakeEmitter>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.StartShake();
				}
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)9;
		}
	}
	public class Stomp : BaseState
	{
		public static float baseDuration = 5f;

		public static float damageCoefficient = 10f;

		public static float radius = 15f;

		public static float force = 1500f;

		public static float procCoefficient = 1.5f;

		private const float clientTimingSlack = 0.5f;

		private float duration;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = baseDuration / base.attackSpeedStat;
			((EntityState)this).PlayAnimation("Gesture", "Stomp", "attackspeed", duration * 1.16f, 0f);
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override void OnExit()
		{
			float num = (((EntityState)this).isAuthority ? duration : (duration - 0.5f));
			if (((EntityState)this).fixedAge >= num && Object.op_Implicit((Object)(object)((EntityState)this).healthComponent) && ((EntityState)this).healthComponent.alive)
			{
				DoStomp();
			}
			((EntityState)this).OnExit();
		}

		private void DoStomp()
		{
			//IL_001f: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((BaseState)this).FindModelChild("Stomp");
			if (Object.op_Implicit((Object)(object)val))
			{
				if (NetworkServer.active)
				{
					new BlastAttack
					{
						attacker = ((EntityState)this).gameObject,
						inflictor = ((EntityState)this).gameObject,
						teamIndex = ((EntityState)this).teamComponent.teamIndex,
						position = val.position,
						radius = radius,
						baseDamage = base.damageStat * damageCoefficient,
						baseForce = force,
						procCoefficient = procCoefficient,
						crit = ((BaseState)this).RollCrit(),
						falloffModel = (FalloffModel)0,
						damageType = DamageTypeCombo.op_Implicit((DamageType)32),
						attackerFiltering = (AttackerFiltering)2,
						losType = (LoSType)0
					}.Fire();
				}
				if (Object.op_Implicit((Object)(object)BellTowerContent.StompEffectPrefab))
				{
					Object.Instantiate<GameObject>(BellTowerContent.StompEffectPrefab, val);
				}
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)2;
		}
	}
	public class SummonBells : BaseSummonState
	{
		private static readonly string[] spawnPoints = new string[2] { "SpawnPointLeft", "SpawnPointRight" };

		protected override void Summon()
		{
			int num = Mathf.Min(spawnPoints.Length, BellTowerConfig.MaxBells.Value - tracker.AliveBellCount);
			for (int i = 0; i < num; i++)
			{
				tracker.Summon(BellTowerContent.BellMinionMasterPrefab, ((BaseState)this).FindModelChild(spawnPoints[i]), isBell: true);
			}
		}
	}
	public class SummonMonsters : BaseSummonState
	{
		public static int maxCreditCost = 400;

		public static int maxRolls = 10;

		private static readonly string[] spawnPoints = new string[2] { "SpawnPointFront", "SpawnPointBack" };

		protected override void Summon()
		{
			if (!BellTowerConfig.SummonMonsters.Value || !Object.op_Implicit((Object)(object)ClassicStageInfo.instance))
			{
				return;
			}
			WeightedSelection<DirectorCard> monsterSelection = ClassicStageInfo.instance.monsterSelection;
			if (monsterSelection == null || monsterSelection.Count == 0)
			{
				return;
			}
			int num = Mathf.Min(spawnPoints.Length, BellTowerConfig.MaxSummonedMonsters.Value - tracker.AliveMonsterCount);
			for (int i = 0; i < num; i++)
			{
				SpawnCard val = RollSpawnCard(monsterSelection);
				if (Object.op_Implicit((Object)(object)val))
				{
					tracker.Summon(val.prefab, ((BaseState)this).FindModelChild(spawnPoints[i]), isBell: false);
				}
			}
		}

		private static SpawnCard RollSpawnCard(WeightedSelection<DirectorCard> selection)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < maxRolls; i++)
			{
				DirectorCard val = selection.Evaluate(Random.value);
				SpawnCard val2 = val?.spawnCard;
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.prefab) && val.IsAvailable() && val2.directorCreditCost < maxCreditCost && (int)val2.hullSize == 0)
				{
					return val2;
				}
			}
			return null;
		}
	}
}
namespace StandaloneBellTower.Components
{
	public class BeamController : MonoBehaviour
	{
		public Transform endPoint;

		public LineRenderer lineRenderer;

		private void LateUpdate()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)lineRenderer) && Object.op_Implicit((Object)(object)endPoint))
			{
				lineRenderer.SetPosition(0, ((Component)this).transform.position);
				lineRenderer.SetPosition(1, endPoint.position);
			}
		}
	}
	public class BellAutomaticAIOwnership : MonoBehaviour
	{
		public CharacterMaster ownerMaster;

		public static float checkInterval = 1f;

		private CharacterMaster master;

		private float checkTimer = 2f;

		private void Awake()
		{
			master = ((Component)this).GetComponent<CharacterMaster>();
		}

		private void FixedUpdate()
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)master))
			{
				return;
			}
			checkTimer -= Time.fixedDeltaTime;
			if (!(checkTimer > 0f))
			{
				checkTimer = checkInterval;
				if (!Object.op_Implicit((Object)(object)ownerMaster) && Object.op_Implicit((Object)(object)master.minionOwnership))
				{
					ownerMaster = master.minionOwnership.ownerMaster;
				}
				if (!Object.op_Implicit((Object)(object)ownerMaster) || ownerMaster.IsDeadAndOutOfLivesServer())
				{
					master.TrueKill();
					((Behaviour)this).enabled = false;
				}
			}
		}
	}
	public class BellTowerMinionTracker : MonoBehaviour
	{
		private readonly List<CharacterMaster> bells = new List<CharacterMaster>();

		private readonly List<CharacterMaster> monsters = new List<CharacterMaster>();

		private CharacterBody body;

		public int AliveBellCount => Prune(bells);

		public int AliveMonsterCount => Prune(monsters);

		public List<CharacterMaster> Bells
		{
			get
			{
				Prune(bells);
				return bells;
			}
		}

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		public CharacterMaster Summon(GameObject masterPrefab, Transform spawnPoint, bool isBell)
		{
			//IL_0019: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)masterPrefab) || !Object.op_Implicit((Object)(object)spawnPoint))
			{
				return null;
			}
			CharacterMaster val = new MasterSummon
			{
				masterPrefab = masterPrefab,
				position = spawnPoint.position,
				rotation = spawnPoint.rotation,
				summonerBodyObject = ((Component)this).gameObject,
				ignoreTeamMemberLimit = true,
				inventoryToCopy = (Object.op_Implicit((Object)(object)body) ? body.inventory : null)
			}.Perform();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.master) && Object.op_Implicit((Object)(object)val.minionOwnership) && (Object)(object)val.minionOwnership.ownerMaster != (Object)(object)body.master)
			{
				val.minionOwnership.SetOwner(body.master);
			}
			(isBell ? bells : monsters).Add(val);
			CharacterBody val2 = val.GetBody();
			if (Object.op_Implicit((Object)(object)val2))
			{
				EntityStateMachine val3 = EntityStateMachine.FindByCustomName(((Component)val2).gameObject, "Body");
				if (Object.op_Implicit((Object)(object)val3))
				{
					val3.SetInterruptState((EntityState)(object)new MinionDelayedSpawn(), (InterruptPriority)8);
				}
			}
			return val;
		}

		public void KillBells()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			foreach (CharacterMaster bell in bells)
			{
				if (Object.op_Implicit((Object)(object)bell))
				{
					bell.TrueKill();
				}
			}
			bells.Clear();
		}

		private static int Prune(List<CharacterMaster> masters)
		{
			masters.RemoveAll(delegate(CharacterMaster m)
			{
				if (!Object.op_Implicit((Object)(object)m))
				{
					return true;
				}
				CharacterBody val = m.GetBody();
				return !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.healthComponent) || !val.healthComponent.alive;
			});
			return masters.Count;
		}
	}
	public class CopyTransform : MonoBehaviour
	{
		public GameObject target;

		private void Update()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)target))
			{
				((Component)this).transform.SetPositionAndRotation(target.transform.position, target.transform.rotation);
			}
		}
	}
	public class DelayedProjectileSimple : ProjectileSimple
	{
		public static float retargetInterval = 0.25f;

		public static float maxTargetDistance = 250f;

		public float fireTimer = 3f;

		public string releaseSound;

		public bool laserMode;

		private Transform cachedTransform;

		private Rigidbody body;

		private TeamFilter teamFilter;

		private HurtBox target;

		private float retargetTimer;

		private float storedSpeed;

		private bool fired;

		public void Awake()
		{
			((ProjectileSimple)this).Awake();
			cachedTransform = ((Component)this).transform;
			body = ((Component)this).GetComponent<Rigidbody>();
			teamFilter = ((Component)this).GetComponent<TeamFilter>();
			storedSpeed = base.desiredForwardSpeed;
			base.desiredForwardSpeed = 0f;
			if (Object.op_Implicit((Object)(object)body))
			{
				body.useGravity = false;
			}
		}

		public void FixedUpdate()
		{
			if (fired)
			{
				((ProjectileSimple)this).FixedUpdate();
				return;
			}
			if (NetworkServer.active)
			{
				AimAtTarget();
			}
			fireTimer -= Time.fixedDeltaTime;
			if (fireTimer <= 0f)
			{
				Release();
			}
		}

		private void AimAtTarget()
		{
			//IL_0085: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			retargetTimer -= Time.fixedDeltaTime;
			if (retargetTimer <= 0f && (!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)target.healthComponent) || !target.healthComponent.alive))
			{
				retargetTimer = retargetInterval;
				target = FindNearestEnemy();
			}
			if (Object.op_Implicit((Object)(object)target))
			{
				cachedTransform.rotation = Util.QuaternionSafeLookRotation(((Component)target).transform.position - cachedTransform.position);
			}
		}

		private HurtBox FindNearestEnemy()
		{
			//IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			TeamIndex val = (TeamIndex)((!Object.op_Implicit((Object)(object)teamFilter)) ? (-1) : ((int)teamFilter.teamIndex));
			Vector3 position = cachedTransform.position;
			float num = maxTargetDistance * maxTargetDistance;
			HurtBox result = null;
			foreach (HurtBox readOnlyBullseyes in HurtBox.readOnlyBullseyesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyBullseyes) && readOnlyBullseyes.teamIndex != val && Object.op_Implicit((Object)(object)readOnlyBullseyes.healthComponent) && readOnlyBullseyes.healthComponent.alive)
				{
					Vector3 val2 = ((Component)readOnlyBullseyes).transform.position - position;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = readOnlyBullseyes;
					}
				}
			}
			return result;
		}

		private void Release()
		{
			fired = true;
			if (!string.IsNullOrEmpty(releaseSound))
			{
				Util.PlaySound(releaseSound, ((Component)this).gameObject);
			}
			base.desiredForwardSpeed = storedSpeed;
			((ProjectileSimple)this).SetForwardSpeed(base.desiredForwardSpeed);
			if (Object.op_Implicit((Object)(object)body))
			{
				body.useGravity = true;
			}
		}
	}
	public class SoundEventProvider : MonoBehaviour
	{
		public AkEvent target;

		public string path;

		private void Awake()
		{
			Resolve();
			Object.Destroy((Object)(object)this);
		}

		internal void Resolve()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)target) && target.data != null && !Object.op_Implicit((Object)(object)target.data.WwiseObjectReference) && !string.IsNullOrEmpty(path))
			{
				target.data.WwiseObjectReference = Addressables.LoadAssetAsync<WwiseEventReference>((object)path).WaitForCompletion();
			}
		}
	}
}