Decompiled source of RepurposedCraterBoss v1.0.0

plugins/Risky_Sleeps-RepurposedCraterBoss/RepurposedCraterBoss.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 R2API;
using RepurposedCraterBoss.ModdedEntityStates.AlloyCamera;
using RepurposedCraterBoss.ModdedEntityStates.BossEncounter;
using RoR2;
using RoR2.ContentManagement;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RepurposedCraterBoss")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepurposedCraterBoss")]
[assembly: AssemblyTitle("RepurposedCraterBoss")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RepurposedCraterBoss
{
	public class ContentProvider : IContentPackProvider
	{
		public static GameObject alloyHunterBossEncounterObject;

		private readonly ContentPack _contentPack = new ContentPack();

		public string identifier => "viliger.RepurposedCraterBossPlugin.ContentPack";

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

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

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			_contentPack.identifier = identifier;
			string path = Path.Combine(Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location), "AssetBundles");
			AssetBundle assetbundle = null;
			yield return LoadAssetBundle(Path.Combine(path, "alloyhunterboss"), args.progressReceiver, delegate(AssetBundle resultAssetBundle)
			{
				assetbundle = resultAssetBundle;
			});
			alloyHunterBossEncounterObject = CreateAlloyHunterBossEncounter(assetbundle.LoadAsset<GameObject>("Assets/AlloyHunterCamera/AlloyHunterBossEncounter.prefab"));
			Listening.cameraPrefab = CreateAlloyCamera(assetbundle.LoadAsset<GameObject>("Assets/AlloyHunterCamera/AlloyCamera.prefab"));
			_contentPack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { Listening.cameraPrefab });
			_contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { alloyHunterBossEncounterObject });
			_contentPack.entityStateTypes.Add(new Type[2]
			{
				typeof(Listening),
				typeof(DeathState)
			});
		}

		private IEnumerator LoadAssetBundle(string assetBundleFullPath, IProgress<float> progress, Action<AssetBundle> onAssetBundleLoaded)
		{
			AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundleFullPath);
			while (!((AsyncOperation)assetBundleCreateRequest).isDone)
			{
				progress.Report(((AsyncOperation)assetBundleCreateRequest).progress);
				yield return null;
			}
			onAssetBundleLoaded(assetBundleCreateRequest.assetBundle);
		}

		private GameObject CreateAlloyHunterBossEncounter(GameObject encounterPrefab)
		{
			//IL_0021: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			Transform val = encounterPrefab.transform.Find("ExplicitSpawnPosition");
			val.position = new Vector3(-101.76f, 22.5f, -44.38f);
			Transform val2 = encounterPrefab.transform.Find("ExplicitDropPosition");
			val2.position = new Vector3(-101.76f, 7.3f, -44.38f);
			encounterPrefab.GetOrAddComponent<NetworkIdentity>();
			encounterPrefab.GetOrAddComponent<CombatSquad>().grantBonusHealthInMultiplayer = true;
			CharacterSpawnCard spawnCard = (RepurposedCraterBossPlugin.UseAWU.Value ? Addressables.LoadAssetAsync<CharacterSpawnCard>((object)RoR2_Base_RoboBallBoss.cscSuperRoboBallBoss_asset).WaitForCompletion() : Addressables.LoadAssetAsync<CharacterSpawnCard>((object)RoR2_DLC3_VultureHunter.cscVultureHunter_asset).WaitForCompletion());
			ScriptedCombatEncounter orAddComponent = encounterPrefab.GetOrAddComponent<ScriptedCombatEncounter>();
			orAddComponent.randomizeSeed = false;
			orAddComponent.seed = 111220251533uL;
			orAddComponent.teamIndex = (TeamIndex)2;
			orAddComponent.spawns = (SpawnInfo[])(object)new SpawnInfo[1]
			{
				new SpawnInfo
				{
					spawnCard = (SpawnCard)(object)spawnCard,
					explicitSpawnPosition = ((Component)val).transform,
					cullChance = 0f
				}
			};
			orAddComponent.spawnOnStart = false;
			orAddComponent.grantUniqueBonusScaling = true;
			BossGroup orAddComponent2 = encounterPrefab.GetOrAddComponent<BossGroup>();
			orAddComponent2.bossDropChance = 0f;
			orAddComponent2.dropPosition = ((Component)val2).transform;
			orAddComponent2.dropTable = (PickupDropTable)(object)Addressables.LoadAssetAsync<BasicPickupDropTable>((object)RoR2_Base_Common.dtTier3Item_asset).WaitForCompletion();
			orAddComponent2.scaleRewardsByPlayerCount = true;
			orAddComponent2.shouldDisplayHealthBarOnHud = true;
			orAddComponent2.shouldCreateObjectiveEntry = true;
			EntityStateMachine orAddComponent3 = encounterPrefab.GetOrAddComponent<EntityStateMachine>();
			orAddComponent3.initialStateType = new SerializableEntityStateType(typeof(Listening));
			orAddComponent3.mainStateType = new SerializableEntityStateType(typeof(Listening));
			PrefabAPI.RegisterNetworkPrefab(encounterPrefab);
			return encounterPrefab;
		}

		private GameObject CreateAlloyCamera(GameObject prefab)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			Transform val = prefab.transform.Find("ModelBase/mdlCamera");
			Transform modelBaseTransform = prefab.transform.Find("ModelBase");
			HurtBox val2 = ((Component)prefab.transform.Find("ModelBase/mdlCamera/Hurtbox")).gameObject.AddComponent<HurtBox>();
			val2.isBullseye = true;
			prefab.AddComponent<NetworkIdentity>();
			PseudoCharacterMotor orAddComponent = prefab.GetOrAddComponent<PseudoCharacterMotor>();
			orAddComponent.mass = 100f;
			orAddComponent.needsIncreasedLandingHeight = true;
			prefab.GetOrAddComponent<SkillLocator>();
			prefab.GetOrAddComponent<TeamComponent>().teamIndex = (TeamIndex)0;
			CharacterBody orAddComponent2 = prefab.GetOrAddComponent<CharacterBody>();
			orAddComponent2.baseNameToken = "VILIGER_ALLOY_CAMERA";
			orAddComponent2.bodyFlags = (BodyFlags)260;
			orAddComponent2.baseMaxHealth = 1f;
			HealthComponent orAddComponent3 = prefab.GetOrAddComponent<HealthComponent>();
			orAddComponent3.dontShowHealthbar = true;
			val2.healthComponent = orAddComponent3;
			EntityStateMachine orAddComponent4 = prefab.GetOrAddComponent<EntityStateMachine>();
			orAddComponent4.initialStateType = new SerializableEntityStateType(typeof(Idle));
			orAddComponent4.mainStateType = new SerializableEntityStateType(typeof(Idle));
			CharacterDeathBehavior orAddComponent5 = prefab.GetOrAddComponent<CharacterDeathBehavior>();
			orAddComponent5.deathStateMachine = orAddComponent4;
			orAddComponent5.deathState = new SerializableEntityStateType(typeof(DeathState));
			prefab.GetOrAddComponent<NetworkStateMachine>().stateMachines = (EntityStateMachine[])(object)new EntityStateMachine[1] { orAddComponent4 };
			ModelLocator orAddComponent6 = prefab.GetOrAddComponent<ModelLocator>();
			orAddComponent6.modelTransform = val;
			orAddComponent6.modelBaseTransform = modelBaseTransform;
			orAddComponent6.dontDetatchFromParent = true;
			orAddComponent6.noCorpse = true;
			orAddComponent6.dontReleaseModelOnDeath = true;
			GameObject gameObject = ((Component)val).gameObject;
			HurtBoxGroup orAddComponent7 = gameObject.GetOrAddComponent<HurtBoxGroup>();
			orAddComponent7.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val2 };
			orAddComponent7.mainHurtBox = val2;
			val2.hurtBoxGroup = orAddComponent7;
			gameObject.GetOrAddComponent<CharacterModel>().body = orAddComponent2;
			((Renderer)((Component)prefab.transform.Find("ModelBase/mdlCamera/SolusCamera")).gameObject.GetComponent<MeshRenderer>()).material = Addressables.LoadAssetAsync<Material>((object)RoR2_Base_Common_TrimSheets.matTrimSheetAlien1BossEmission_mat).WaitForCompletion();
			PrefabAPI.RegisterNetworkPrefab(prefab);
			return prefab;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("viliger.RepurposedCraterBossPlugin", "RepurposedCraterBossPlugin", "1.0.0")]
	public class RepurposedCraterBossPlugin : BaseUnityPlugin
	{
		public const string Author = "viliger";

		public const string Name = "RepurposedCraterBossPlugin";

		public const string Version = "1.0.0";

		public const string GUID = "viliger.RepurposedCraterBossPlugin";

		public const string LanguageFolder = "Language";

		public static ConfigEntry<int> CamerasToDestroy;

		public static ConfigEntry<int> CamerasToSpawn;

		public static ConfigEntry<bool> UseAWU;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
			Language.collectLanguageRootFolders += Language_collectLanguageRootFolders;
			Stage.onStageStartGlobal += Stage_onStageStartGlobal;
			CamerasToDestroy = ((BaseUnityPlugin)this).Config.Bind<int>("Repurposed Crater Boss", "Cameras To Destroy", 6, "Number of cameras to destroy to spawn the boss.");
			CamerasToSpawn = ((BaseUnityPlugin)this).Config.Bind<int>("Repurposed Crater Boss", "Cameras To Spawn", 12, "Number of cameras that will be spawned on the stage.");
			UseAWU = ((BaseUnityPlugin)this).Config.Bind<bool>("Repurposed Crater Boss", "Spawn AWU", false, "Spawns AWU instead of Alloy Hunter.");
		}

		private void Language_collectLanguageRootFolders(List<string> folders)
		{
			folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language"));
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentProvider());
		}

		private void Stage_onStageStartGlobal(Stage stage)
		{
			if (!(stage.sceneDef.cachedName == "repurposedcrater"))
			{
				return;
			}
			GameObject val = GameObject.Find("HOLDER: Toggle Groups/GROUP_ GoldChest");
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Warning("Couldn't find \"HOLDER: Toggle Groups/GROUP_ GoldChest\" on repurposedcrater. Not doing anything...");
				return;
			}
			for (int i = 0; i < val.transform.childCount; i++)
			{
				Transform child = val.transform.GetChild(i);
				((Component)child).gameObject.SetActive(true);
				Transform val2 = ((Component)child).transform.Find("GoldChest");
				if (Object.op_Implicit((Object)(object)val2))
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
				}
			}
			if (NetworkServer.active)
			{
				NetworkServer.Spawn(Object.Instantiate<GameObject>(ContentProvider.alloyHunterBossEncounterObject));
			}
		}
	}
	public static class Utils
	{
		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			T result = default(T);
			if (!gameObject.TryGetComponent<T>(ref result))
			{
				return gameObject.AddComponent<T>();
			}
			return result;
		}
	}
}
namespace RepurposedCraterBoss.ModdedEntityStates.BossEncounter
{
	public class Listening : EntityState
	{
		public struct PositionAndRotation
		{
			public Vector3 position;

			public Vector3 rotation;
		}

		public static float delayBeforeBeginningEncounter = 2f;

		public static GameObject cameraPrefab;

		public static PositionAndRotation[] cameraPositions = new PositionAndRotation[45]
		{
			new PositionAndRotation
			{
				position = new Vector3(-106.46f, 6.25f, -5.44f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(-87.36f, 9.57f, 28.02f),
				rotation = new Vector3(0f, 185.24216f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-96.49f, 5.8151374f, -82.76f),
				rotation = new Vector3(0f, 180f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-115.86f, 9.851197f, -115.9504f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(-53.01f, 64.36f, -192f),
				rotation = new Vector3(0f, 264.00134f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-49.95f, 86.05f, -123.11f),
				rotation = new Vector3(0f, 137.27098f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-37.82f, 87.25f, 59.89f),
				rotation = new Vector3(0f, 298.39673f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-182.07f, 95.12f, 60.48f),
				rotation = new Vector3(0f, 272.16983f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-237.61f, 89.82f, -49.07f),
				rotation = new Vector3(0f, 114.82716f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-127.91f, 66.54f, -66.94f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(-96.551895f, 67f, 11.643568f),
				rotation = new Vector3(0f, 170.95744f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-236.27f, 7.48f, -3.804f),
				rotation = new Vector3(0f, 338.59607f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-125.24f, 39.02f, -183.1f),
				rotation = new Vector3(0f, 246.22888f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-74.37372f, 52.052517f, 111.492805f),
				rotation = new Vector3(6.673094f, 36.21268f, 9.284662f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-140.23f, 101.30812f, 156.19176f),
				rotation = new Vector3(0f, 171.87086f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-250.7f, 111.75009f, 45.16f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(-257.36f, 117.85f, 10.92f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(-237.956f, 119.46f, 55.151f),
				rotation = new Vector3(0f, 175.3847f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-234.352f, 51.577f, -134.994f),
				rotation = new Vector3(0f, 119.49031f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-192.08f, 12.153609f, 90.15f),
				rotation = new Vector3(0f, 176.98672f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(6.92f, 63.69187f, -38.62f),
				rotation = new Vector3(0f, 275.84613f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-13.716f, 63.535294f, -83.08f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(3.89f, 59.7472f, 28.1f),
				rotation = new Vector3(0f, 309.36496f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-92.83f, 65.43f, 108.99f),
				rotation = new Vector3(0f, 261.87573f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-3.87f, 8.485565f, -172f),
				rotation = new Vector3(0f, 316.88406f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-87.31f, 70.56766f, -78.63f),
				rotation = new Vector3(0f, 189.66772f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(10.12f, 102.46655f, -90.48f),
				rotation = Vector3.zero
			},
			new PositionAndRotation
			{
				position = new Vector3(-6.23f, 95.072975f, -25.87f),
				rotation = new Vector3(0f, 268.7272f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-13.34f, 18.412636f, -21.65403f),
				rotation = new Vector3(7.182824f, 231.34401f, 8.884359f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-27.65675f, 13.214622f, 29.467016f),
				rotation = new Vector3(341.29306f, 20.368748f, 350.32663f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-34.1f, 70.69f, 60.19f),
				rotation = new Vector3(0f, 89.62731f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-234.63f, 21.7f, 69.87f),
				rotation = new Vector3(0f, 173.97859f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-131.55351f, 51.340866f, -100.06823f),
				rotation = new Vector3(4.6581645f, 314.04672f, 4.795306f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-180.89798f, 54.333588f, -176.28987f),
				rotation = new Vector3(5.781952f, 231.71936f, 8.65082f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-28.333122f, 9.564346f, -83.79394f),
				rotation = new Vector3(0f, 357.31638f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-89.81f, 8.387001f, -121.62f),
				rotation = new Vector3(0f, 269.84332f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-100.91f, 13.0732f, 54.88f),
				rotation = new Vector3(0f, 257.05292f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-30.607563f, 5.882291f, -140.95206f),
				rotation = new Vector3(0f, 346.7502f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-213.69f, 75.20826f, 87.35f),
				rotation = new Vector3(0f, 125.6665f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-116.74f, 20.44f, 101.57f),
				rotation = new Vector3(0f, 290.6012f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-104.58812f, 24.43f, -144.85408f),
				rotation = new Vector3(0f, 312.26245f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-218.36f, 51.145203f, -105.57f),
				rotation = new Vector3(0f, 114.34585f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-15.02f, 72.120285f, 152.6f),
				rotation = new Vector3(0f, 293.23914f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-255.45f, 126.01523f, 143.16f),
				rotation = new Vector3(0f, 227.52072f, 0f)
			},
			new PositionAndRotation
			{
				position = new Vector3(-245.28f, 56.32366f, -149.4f),
				rotation = new Vector3(0f, 339.61462f, 0f)
			}
		};

		private List<GameObject> cameraList = new List<GameObject>();

		private ScriptedCombatEncounter scriptedCombatEncounter;

		private bool hasRegisteredCameras;

		private int camerasToDestroy;

		private int previousDestroyedCameras;

		private bool beginEncounterCountdown;

		private float encounterCountdown;

		public static int camerasDestroyedToTriggerEncounter => RepurposedCraterBossPlugin.CamerasToDestroy.Value;

		public static int camerasCountToSpawn => RepurposedCraterBossPlugin.CamerasToSpawn.Value;

		public override void OnEnter()
		{
			//IL_005d: 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)
			((EntityState)this).OnEnter();
			scriptedCombatEncounter = ((EntityState)this).GetComponent<ScriptedCombatEncounter>();
			camerasToDestroy = Mathf.Min(camerasDestroyedToTriggerEncounter, cameraPositions.Length);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)cameraPrefab))
			{
				Util.ShuffleArray<PositionAndRotation>(cameraPositions);
				for (int i = 0; i < Mathf.Min(camerasCountToSpawn, cameraPositions.Length); i++)
				{
					PositionAndRotation positionAndRotation = cameraPositions[i];
					GameObject val = Object.Instantiate<GameObject>(cameraPrefab, positionAndRotation.position, Quaternion.Euler(positionAndRotation.rotation));
					NetworkServer.Spawn(val);
					cameraList.Add(val);
				}
				hasRegisteredCameras = true;
			}
		}

		public override void FixedUpdate()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//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_00af: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			((EntityState)this).FixedUpdate();
			if (!NetworkServer.active || !hasRegisteredCameras)
			{
				return;
			}
			int num = 0;
			for (int i = 0; i < cameraList.Count; i++)
			{
				if ((Object)(object)cameraList[i] == (Object)null)
				{
					num++;
				}
			}
			if (previousDestroyedCameras < camerasToDestroy - 1 && num >= camerasToDestroy - 1)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "VILIGER_ALLOY_CAMERA_CLOSE"
				});
			}
			if (num >= camerasToDestroy && !beginEncounterCountdown)
			{
				encounterCountdown = delayBeforeBeginningEncounter;
				beginEncounterCountdown = true;
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "VILIGER_ALLOY_CAMERA_BEGIN"
				});
			}
			if (beginEncounterCountdown)
			{
				encounterCountdown -= ((EntityState)this).GetDeltaTime();
				if (encounterCountdown <= 0f)
				{
					scriptedCombatEncounter.BeginEncounter();
					base.outer.SetNextState((EntityState)new Idle());
				}
			}
			previousDestroyedCameras = num;
		}
	}
}
namespace RepurposedCraterBoss.ModdedEntityStates.AlloyCamera
{
	public class DeathState : BaseState
	{
		public static GameObject shockEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Captain.CaptainTazerSupplyDropNova_prefab).WaitForCompletion();

		public static float shockRadius = 10f;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			Shock();
			if (Object.op_Implicit((Object)(object)((EntityState)this).modelLocator))
			{
				if (Object.op_Implicit((Object)(object)((EntityState)this).modelLocator.modelBaseTransform))
				{
					EntityState.Destroy((Object)(object)((Component)((EntityState)this).modelLocator.modelBaseTransform).gameObject);
				}
				if (Object.op_Implicit((Object)(object)((EntityState)this).modelLocator.modelTransform))
				{
					EntityState.Destroy((Object)(object)((Component)((EntityState)this).modelLocator.modelTransform).gameObject);
				}
			}
			EntityState.Destroy((Object)(object)((EntityState)this).gameObject);
		}

		private void Shock()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			new BlastAttack
			{
				radius = shockRadius,
				baseDamage = 0f,
				damageType = DamageTypeCombo.op_Implicit((DamageType)16779264),
				falloffModel = (FalloffModel)0,
				attacker = null,
				teamIndex = (TeamIndex)1,
				position = ((EntityState)this).transform.position
			}.Fire();
			if (Object.op_Implicit((Object)(object)shockEffectPrefab))
			{
				EffectManager.SpawnEffect(shockEffectPrefab, new EffectData
				{
					origin = ((EntityState)this).transform.position,
					scale = shockRadius
				}, false);
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)9;
		}
	}
}