Decompiled source of Hollow Summit v0.1.2

Hollow_Summit.dll

Decompiled 2 days 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.Security.Permissions;
using AncientWisp;
using ArchaicWisp;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ClayMen;
using EnemiesReturns.Configuration;
using EnemiesReturns.Configuration.LynxTribe;
using EnemiesReturns.Enemies.LynxTribe.Totem;
using HG;
using HG.Reflection;
using MapSandbox.Content;
using On.RoR2;
using R2API;
using RecoveredAndReformed;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Navigation;
using Sandswept;
using ShaderSwapper;
using Summit.Content;
using Summit.ModChecks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MapSandbox.Content
{
	public static class Simulacrum
	{
		public static void RegisterSceneToSimulacrum(SceneDef sceneDef, bool canBeStage1 = true, float weight = 1f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_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_004a: 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_009e: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			SceneCollection val = Addressables.LoadAssetAsync<SceneCollection>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/SceneGroups/sgInfiniteTowerStageX.asset").WaitForCompletion();
			SceneCollection val2 = Addressables.LoadAssetAsync<SceneCollection>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/SceneGroups/sgInfiniteTowerStage1.asset").WaitForCompletion();
			List<SceneCollection> list = new List<SceneCollection>();
			Enumerator<SceneEntry> enumerator = val.sceneEntries.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					SceneEntry current = enumerator.Current;
					if (current.sceneDef.hasAnyDestinations)
					{
						list.Add(current.sceneDef.destinationsGroup);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			SceneCollection val3 = ScriptableObject.CreateInstance<SceneCollection>();
			val3._sceneEntries = val._sceneEntries;
			sceneDef.destinationsGroup = val3;
			SceneEntry val4 = default(SceneEntry);
			val4.sceneDef = sceneDef;
			val4.weightMinusOne = weight - 1f;
			SceneEntry val5 = val4;
			ArrayUtils.ArrayAppend<SceneEntry>(ref val._sceneEntries, ref val5);
			if (canBeStage1)
			{
				ArrayUtils.ArrayAppend<SceneEntry>(ref val2._sceneEntries, ref val5);
			}
			foreach (SceneCollection item in list)
			{
				ArrayUtils.ArrayAppend<SceneEntry>(ref item._sceneEntries, ref val5);
			}
		}
	}
}
namespace Summit
{
	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);
		}
	}
	public class AncientWispCompat
	{
		public static void AddEnemies()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			StageSpawnInfo item = new StageSpawnInfo("hollowsummit_wormsworms", 0);
			StageSpawnInfo item2 = new StageSpawnInfo("hollowsummit_wormsworms", 5);
			StageSpawnInfo item3 = new StageSpawnInfo("itsummit_wormsworms", 0);
			StageSpawnInfo item4 = new StageSpawnInfo("itsummit_wormsworms", 5);
			StageSpawnInfo item5 = new StageSpawnInfo("hollowsummitnight_wormsworms", 0);
			StageSpawnInfo item6 = new StageSpawnInfo("hollowsummitnight_wormsworms", 5);
			if (Summit.toggleArchaicWisp.Value && !AncientWispPlugin.StageList.Contains(item) && !AncientWispPlugin.StageList.Contains(item2))
			{
				Helpers.AddNewMonsterToStage(AWContent.AncientWispCard, false, (Stage)1, "hollowsummit_wormsworms");
			}
			if (Summit.toggleArchaicWisp.Value && !AncientWispPlugin.StageList.Contains(item5) && !AncientWispPlugin.StageList.Contains(item6))
			{
				Helpers.AddNewMonsterToStage(AWContent.AncientWispCard, false, (Stage)1, "hollowsummitnight_wormsworms");
			}
			if (Summit.toggleArchaicWisp.Value && !AncientWispPlugin.StageList.Contains(item3) && !AncientWispPlugin.StageList.Contains(item4))
			{
				Helpers.AddNewMonsterToStage(AWContent.AncientWispCard, false, (Stage)1, "itsummit_wormsworms");
			}
		}
	}
	public class ArchaicWispCompat
	{
		public static void AddEnemies()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			StageSpawnInfo item = new StageSpawnInfo("hollowsummit_wormsworms", 0);
			StageSpawnInfo item2 = new StageSpawnInfo("hollowsummit_wormsworms", 5);
			StageSpawnInfo item3 = new StageSpawnInfo("itsummit_wormsworms", 0);
			StageSpawnInfo item4 = new StageSpawnInfo("itsummit_wormsworms", 5);
			StageSpawnInfo item5 = new StageSpawnInfo("hollowsummitnight_wormsworms", 0);
			StageSpawnInfo item6 = new StageSpawnInfo("hollowsummitnight_wormsworms", 5);
			if (Summit.toggleArchaicWisp.Value && !ArchaicWispPlugin.StageList.Contains(item) && !ArchaicWispPlugin.StageList.Contains(item2))
			{
				Helpers.AddNewMonsterToStage(ArchaicWispContent.ArchaicWispCard, false, (Stage)1, "hollowsummit_wormsworms");
				Helpers.RemoveExistingMonsterFromStage(MonsterNames.GreaterWisp, (Stage)1, "hollowsummit_wormsworms");
			}
			if (Summit.toggleArchaicWisp.Value && !ArchaicWispPlugin.StageList.Contains(item5) && !ArchaicWispPlugin.StageList.Contains(item6))
			{
				Helpers.AddNewMonsterToStage(ArchaicWispContent.ArchaicWispCard, false, (Stage)1, "hollowsummitnight_wormsworms");
				Helpers.RemoveExistingMonsterFromStage(MonsterNames.GreaterWisp, (Stage)1, "hollowsummitnight_wormsworms");
			}
			if (Summit.toggleArchaicWisp.Value && !ArchaicWispPlugin.StageList.Contains(item3) && !ArchaicWispPlugin.StageList.Contains(item4))
			{
				Helpers.AddNewMonsterToStage(ArchaicWispContent.ArchaicWispCard, false, (Stage)1, "itsummit_wormsworms");
				Helpers.RemoveExistingMonsterFromStage(MonsterNames.GreaterWisp, (Stage)1, "itsummit_wormsworms");
			}
		}
	}
	public class ClayMenCompat
	{
		public static void AddEnemies()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			StageSpawnInfo item = new StageSpawnInfo("hollowsummit_wormsworms", 0);
			StageSpawnInfo item2 = new StageSpawnInfo("hollowsummit_wormsworms", 5);
			if (Summit.toggleClayMen.Value && !ClayMenPlugin.StageList.Contains(item) && !ClayMenPlugin.StageList.Contains(item2))
			{
				Helpers.AddNewMonsterToStage(ClayMenContent.ClayManCard, false, (Stage)1, "hollowsummit_wormsworms");
				Helpers.RemoveExistingMonsterFromStage(MonsterNames.Imp, (Stage)1, "hollowsummit_wormsworms");
			}
		}
	}
	public class EnemiesReturnsCompat
	{
		public static void AddEnemies()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0033: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			if (Summit.toggleLynxTotems.Value && General.EnableLynxTotem.Value)
			{
				DirectorCard card = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscLynxTotemDefault,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = LynxTotem.SelectionWeight.Value,
					minimumStageCompletions = LynxTotem.MinimumStageCompletion.Value
				};
				DirectorCardHolder val = new DirectorCardHolder
				{
					Card = card,
					MonsterCategory = (MonsterCategory)4
				};
				if (!LynxTotem.DefaultStageList.Value.Contains("hollowsummit_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "hollowsummit_wormsworms");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("itsummit_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itsummit_wormsworms");
				}
			}
		}
	}
	public class RecoveredAndReformedCompat
	{
		public static void AddEnemies()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0030: 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_0037: 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_004f: Expected O, but got Unknown
			//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_005b: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_008b: Expected O, but got Unknown
			if (Summit.toggleIotaConstructs.Value)
			{
				CharacterSpawnCard val = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/MajorAndMinorConstruct/cscMajorConstruct.asset").WaitForCompletion();
				DirectorCard card = new DirectorCard
				{
					spawnCard = (SpawnCard)val,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = 1,
					minimumStageCompletions = Main.MajorConstructMinStage.Value
				};
				DirectorCardHolder val2 = new DirectorCardHolder
				{
					Card = card,
					MonsterCategory = (MonsterCategory)4
				};
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "hollowsummit_wormsworms");
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "hollowsummitnight_wormsworms");
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "itsummit_wormsworms");
			}
		}
	}
	public class SandsweptCompat
	{
		public static CharacterSpawnCard CannonballJellyfishCard;

		public static bool FindEnabledConfig(string configName)
		{
			ConfigEntryBase[] configEntries = Main.config.GetConfigEntries();
			foreach (ConfigEntryBase val in configEntries)
			{
				if (((object)val.Definition).ToString() == configName)
				{
					Log.Debug("Found Config Entry (Enable)");
					return (bool)val.BoxedValue;
				}
			}
			return false;
		}

		public static int FindCreditConfig(string configName)
		{
			ConfigEntryBase[] configEntries = Main.config.GetConfigEntries();
			foreach (ConfigEntryBase val in configEntries)
			{
				if (((object)val.Definition).ToString() == configName)
				{
					return (int)val.DefaultValue;
				}
			}
			return 130;
		}

		public static void AddEnemies()
		{
			//IL_004b: 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_0059: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a4: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00c5: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00e0: Expected O, but got Unknown
			bool flag = FindEnabledConfig("Enemies :: Delta Construct.Enabled");
			if (Summit.toggleDeltaConstructs.Value && flag)
			{
				CharacterSpawnCard val = ScriptableObject.CreateInstance<CharacterSpawnCard>();
				((Object)val).name = "cscMVODeltaConstruct";
				((SpawnCard)val).prefab = Main.assets.LoadAsset<GameObject>("DeltaConstructMaster.prefab");
				((SpawnCard)val).sendOverNetwork = true;
				((SpawnCard)val).hullSize = (HullClassification)0;
				((SpawnCard)val).nodeGraphType = (GraphType)1;
				((SpawnCard)val).requiredFlags = (NodeFlags)0;
				((SpawnCard)val).forbiddenFlags = (NodeFlags)2;
				((SpawnCard)val).directorCreditCost = 45;
				((SpawnCard)val).occupyPosition = false;
				val.loadout = new SerializableLoadout();
				val.noElites = false;
				val.forbiddenAsBoss = false;
				DirectorCardHolder val2 = new DirectorCardHolder
				{
					Card = new DirectorCard
					{
						spawnCard = (SpawnCard)val,
						selectionWeight = 1
					},
					MonsterCategory = (MonsterCategory)3
				};
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "hollowsummit_wormsworms");
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "hollowsummitnight_wormsworms");
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "itsummit_wormsworms");
			}
		}
	}
	[BepInPlugin("wormsworms.Hollow_Summit", "Hollow_Summit", "0.1.2")]
	public class Summit : BaseUnityPlugin
	{
		public const string Author = "wormsworms";

		public const string Name = "Hollow_Summit";

		public const string Version = "0.1.2";

		public const string GUID = "wormsworms.Hollow_Summit";

		public const string RegularSceneName = "hollowsummit_wormsworms";

		public const string SnowySceneName = "hollowsummitnight_wormsworms";

		public const string SimuSceneName = "itsummit_wormsworms";

		public static Summit instance;

		public static ConfigEntry<bool> enableRegular;

		public static ConfigEntry<bool> enableVariant;

		public static ConfigEntry<bool> loopExclusiveVariant;

		public static ConfigEntry<bool> swapVariantPlaces;

		public static ConfigEntry<bool> enableSimulacrum;

		public static ConfigEntry<bool> simulacrumStage1;

		public static ConfigEntry<bool> toggleAncientWisp;

		public static ConfigEntry<bool> toggleArchaicWisp;

		public static ConfigEntry<bool> toggleClayMen;

		public static ConfigEntry<bool> toggleLynxTotems;

		public static ConfigEntry<bool> toggleIotaConstructs;

		public static ConfigEntry<bool> toggleDeltaConstructs;

		private void Awake()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			ConfigSetup();
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(GiveToRoR2OurContentPackProviders);
			Language.collectLanguageRootFolders += CollectLanguageRootFolders;
			RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(AddModdedEnemies));
			SceneManager.sceneLoaded += SceneSetup;
			Run.onRunStartGlobal += InitializeBazaarSeerValues;
			Run.PickNextStageScene += new hook_PickNextStageScene(SwapBazaarFilters);
		}

		public void InitializeBazaarSeerValues(Run run)
		{
			if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && !swapVariantPlaces.Value)
			{
				SceneCatalog.GetSceneDefFromSceneName("hollowsummit_wormsworms").filterOutOfBazaar = false;
				SceneCatalog.GetSceneDefFromSceneName("hollowsummitnight_wormsworms").filterOutOfBazaar = true;
			}
			else if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && swapVariantPlaces.Value)
			{
				SceneCatalog.GetSceneDefFromSceneName("hollowsummit_wormsworms").filterOutOfBazaar = true;
				SceneCatalog.GetSceneDefFromSceneName("hollowsummitnight_wormsworms").filterOutOfBazaar = false;
			}
		}

		public void SwapBazaarFilters(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
		{
			orig.Invoke(self, choices);
			if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && !swapVariantPlaces.Value)
			{
				if (Run.instance.stageClearCount >= 5 && !SceneCatalog.GetSceneDefFromSceneName("hollowsummit_wormsworms").filterOutOfBazaar)
				{
					SceneCatalog.GetSceneDefFromSceneName("hollowsummit_wormsworms").filterOutOfBazaar = true;
					SceneCatalog.GetSceneDefFromSceneName("hollowsummitnight_wormsworms").filterOutOfBazaar = false;
					Log.Debug("Swapped bazaar filter-out values (hollow TRUE, frozen FALSE)");
				}
			}
			else if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && swapVariantPlaces.Value && Run.instance.stageClearCount >= 5 && !SceneCatalog.GetSceneDefFromSceneName("hollowsummitnight_wormsworms").filterOutOfBazaar)
			{
				SceneCatalog.GetSceneDefFromSceneName("hollowsummit_wormsworms").filterOutOfBazaar = false;
				SceneCatalog.GetSceneDefFromSceneName("hollowsummitnight_wormsworms").filterOutOfBazaar = true;
				Log.Debug("Swapped bazaar filter-out values (hollow FALSE, frozen TRUE. my favoritest movie is forozen i love ana and els a)");
			}
		}

		public static void AddModdedEnemies()
		{
			if (IsEnemiesReturns.enabled)
			{
				EnemiesReturnsCompat.AddEnemies();
			}
			if (IsSandswept.enabled)
			{
				SandsweptCompat.AddEnemies();
			}
			if (IsClayMen.IsAncientWisp.enabled)
			{
				AncientWispCompat.AddEnemies();
			}
			if (IsClayMen.IsArchaicWisp.enabled)
			{
				ArchaicWispCompat.AddEnemies();
			}
			if (IsClayMen.enabled)
			{
				ClayMenCompat.AddEnemies();
			}
			if (IsClayMen.IsRecoveredAndReformed.enabled || IsClayMen.IsRecoveredAndReformedStripped.enabled)
			{
				RecoveredAndReformedCompat.AddEnemies();
			}
		}

		private void Destroy()
		{
			Language.collectLanguageRootFolders -= CollectLanguageRootFolders;
		}

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

		public void CollectLanguageRootFolders(List<string> folders)
		{
			folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language"));
			folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Plugins/Language"));
		}

		private void SceneSetup(Scene newScene, LoadSceneMode loadSceneMode)
		{
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref newScene)).name == "hollowsummit_wormsworms" || ((Scene)(ref newScene)).name == "hollowsummitnight_wormsworms" || ((Scene)(ref newScene)).name == "itsummit_wormsworms")
			{
				Transform transform = GameObject.Find("Ruins n Stuff").transform;
				for (int i = 0; i < transform.childCount; i++)
				{
					if (((Object)((Component)transform.GetChild(i)).gameObject).name.Contains("Xi Construct"))
					{
						((Component)transform.GetChild(i).GetChild(0).GetChild(1)).gameObject.SetActive(false);
					}
				}
			}
			if (((Scene)(ref newScene)).name == "hollowsummitnight_wormsworms")
			{
				Transform transform2 = GameObject.Find("Trees").transform;
				for (int j = 0; j < transform2.childCount; j++)
				{
					if (((Object)((Component)transform2.GetChild(j).GetChild(0)).gameObject).name.Contains("NestBranch"))
					{
						((Component)transform2.GetChild(j).GetChild(0).GetChild(0)
							.GetChild(0)).gameObject.layer = 11;
					}
				}
			}
			if (((Scene)(ref newScene)).name == "hollowsummit_wormsworms" || ((Scene)(ref newScene)).name == "hollowsummitnight_wormsworms")
			{
				GameObject.Find("ShatteredMoonMesh").layer = 9;
				GameObject.Find("MoonHolder").transform.localScale = Vector3.one * 1.5f;
				GameObject.Find("AtmosphereDonut").SetActive(false);
			}
		}

		private void ConfigSetup()
		{
			enableRegular = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Hollow Summit", "Enable Hollow Summit", true, "If true, Hollow Summit can appear in runs.");
			enableVariant = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Frozen Summit", "Enable Frozen Summit", true, "If true, Frozen Summit can appear in runs. If Hollow Summit is disabled, the Loop Variant and Swap Places values are ignored and Frozen Summit can appear at any time, effectively replacing it.");
			loopExclusiveVariant = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Frozen Summit", "Loop Variant", true, "If true, Frozen Summit replaces Hollow Summit after looping. If false, it can appear at any time (both variants will have their weight halved to prevent making Summit more common than other stages).");
			swapVariantPlaces = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Frozen Summit", "Swap Places with Hollow Summit", false, "If true, Frozen Summit will appear before looping and Hollow Summit will replace it after looping.");
			enableSimulacrum = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Simulacrum Variant", "Enable Simulacrum Variant", true, "If true, Hollow Summit can appear in the Simulacrum.");
			simulacrumStage1 = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Simulacrum Variant", "Enable Simulacrum Variant on Stage 1", true, "If true, Hollow Summit can appear as the first stage in the Simulacrum. If false, it can only appear on Stage 2 or higher, like Commencement.");
			toggleAncientWisp = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Modded Enemies - Ancient Wisp", "Enable Ancient Wisps", true, "If true, Ancient Wisps can appear in Hollow Summit and Frozen Summit.");
			toggleArchaicWisp = ((BaseUnityPlugin)this).Config.Bind<bool>("04 - Modded Enemies - Archaic Wisp", "Enable Archaic Wisps", true, "If true, Archaic Wisps can appear in Hollow Summit and Frozen Summit (replaces Greater Wisps).");
			toggleClayMen = ((BaseUnityPlugin)this).Config.Bind<bool>("05 - Modded Enemies - Clay Men", "Enable Clay Men", true, "If true, Clay Men can appear in Hollow Summit (replaces Imps).");
			toggleLynxTotems = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Modded Enemies - EnemiesReturns", "Enable Lynx Totems", true, "If true, Lynx Totems can appear in Hollow Summit.");
			toggleIotaConstructs = ((BaseUnityPlugin)this).Config.Bind<bool>("07 - Modded Enemies - RecoveredAndReformed", "Enable Iota Constructs", true, "If true, Iota Constructs can appear in Hollow Summit and Frozen Summit.");
			toggleDeltaConstructs = ((BaseUnityPlugin)this).Config.Bind<bool>("08 - Modded Enemies - Sandswept", "Enable Delta Constructs", true, "If true, Delta Costructs can appear in Hollow Summit.");
		}
	}
}
namespace Summit.ModChecks
{
	public class IsEnemiesReturns
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.Viliger.EnemiesReturns");
				}
				return _enabled.Value;
			}
		}
	}
	public class IsSandswept
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.TeamSandswept.Sandswept");
				}
				return _enabled.Value;
			}
		}
	}
	public class IsClayMen
	{
		public class IsArchaicWisp
		{
			private static bool? _enabled;

			public static bool enabled
			{
				get
				{
					if (!_enabled.HasValue)
					{
						_enabled = Chainloader.PluginInfos.ContainsKey("com.Moffein.ArchaicWisp");
					}
					return _enabled.Value;
				}
			}
		}

		public class IsAncientWisp
		{
			private static bool? _enabled;

			public static bool enabled
			{
				get
				{
					if (!_enabled.HasValue)
					{
						_enabled = Chainloader.PluginInfos.ContainsKey("com.Moffein.AncientWisp");
					}
					return _enabled.Value;
				}
			}
		}

		public class IsRecoveredAndReformed
		{
			private static bool? _enabled;

			public static bool enabled
			{
				get
				{
					if (!_enabled.HasValue)
					{
						_enabled = Chainloader.PluginInfos.ContainsKey("prodzpod.RecoveredAndReformed");
					}
					return _enabled.Value;
				}
			}
		}

		public class IsRecoveredAndReformedStripped
		{
			private static bool? _enabled;

			public static bool enabled
			{
				get
				{
					if (!_enabled.HasValue)
					{
						_enabled = Chainloader.PluginInfos.ContainsKey("Phreel.RecoveredAndReformedStripped");
					}
					return _enabled.Value;
				}
			}
		}

		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.Moffein.ClayMen");
				}
				return _enabled.Value;
			}
		}
	}
}
namespace Summit.Content
{
	public class ContentProvider : IContentPackProvider
	{
		private readonly ContentPack _contentPack = new ContentPack();

		public static string assetDirectory;

		public string identifier => "wormsworms.Hollow_Summit.ContentProvider";

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			_contentPack.identifier = identifier;
			string assetsFolderFullPath = (assetDirectory = Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location));
			AssetBundle scenesAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "Scenes"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				scenesAssetBundle = assetBundle;
			});
			AssetBundle assetsAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "Assets"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				assetsAssetBundle = assetBundle;
			});
			yield return SummitContent.LoadAssetBundlesAsync(scenesAssetBundle, assetsAssetBundle, args.progressReceiver, _contentPack);
		}

		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);
		}

		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;
		}
	}
	public static class SummitContent
	{
		internal const string ScenesAssetBundleFileName = "Scenes";

		internal const string AssetsAssetBundleFileName = "Assets";

		private static AssetBundle _scenesAssetBundle;

		private static AssetBundle _assetsAssetBundle;

		internal static UnlockableDef[] UnlockableDefs;

		internal static SceneDef[] SceneDefs;

		internal static SceneDef summitSceneDef;

		internal static Sprite summitSceneDefPreviewSprite;

		internal static Material summitBazaarSeer;

		internal static SceneDef snowySceneDef;

		internal static Sprite snowySceneDefPreviewSprite;

		internal static Material snowyBazaarSeer;

		internal static SceneDef simuSceneDef;

		internal static Sprite simuSceneDefPreviewSprite;

		internal static Material simuBazaarSeer;

		public static List<Material> SwappedMaterials = new List<Material>();

		internal static IEnumerator LoadAssetBundlesAsync(AssetBundle scenesAssetBundle, AssetBundle assetsAssetBundle, IProgress<float> progress, ContentPack contentPack)
		{
			_scenesAssetBundle = scenesAssetBundle;
			_assetsAssetBundle = assetsAssetBundle;
			IEnumerator upgradeStubbedShaders = ShaderSwapper.UpgradeStubbedShadersAsync(_assetsAssetBundle);
			while (upgradeStubbedShaders.MoveNext())
			{
				yield return upgradeStubbedShaders.Current;
			}
			yield return LoadAllAssetsAsync<UnlockableDef>(assetsAssetBundle, progress, (Action<UnlockableDef[]>)delegate(UnlockableDef[] assets)
			{
				contentPack.unlockableDefs.Add(assets);
			});
			yield return LoadAllAssetsAsync<Sprite>(_assetsAssetBundle, progress, (Action<Sprite[]>)delegate(Sprite[] assets)
			{
				summitSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texSUMScenePreview");
				snowySceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texSUMSnowyScenePreview");
				simuSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texSUMScenePreview");
			});
			yield return LoadAllAssetsAsync<SceneDef>(_assetsAssetBundle, progress, (Action<SceneDef[]>)delegate(SceneDef[] assets)
			{
				SceneDefs = assets;
				summitSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "hollowsummit_wormsworms");
				snowySceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "hollowsummitnight_wormsworms");
				simuSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "itsummit_wormsworms");
				Log.Debug(summitSceneDef.nameToken);
				Log.Debug(snowySceneDef.nameToken);
				Log.Debug(simuSceneDef.nameToken);
				contentPack.sceneDefs.Add(assets);
			});
			summitSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)summitSceneDef.previewTexture);
			snowySceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)snowySceneDef.previewTexture);
			simuSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)simuSceneDef.previewTexture);
			AsyncOperationHandle<MusicTrackDef> summitTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muGameplayBase_09.asset");
			while (!summitTrackDefRequest.IsDone)
			{
				yield return null;
			}
			AsyncOperationHandle<MusicTrackDef> summitBossTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muSong16.asset");
			while (!summitBossTrackDefRequest.IsDone)
			{
				yield return null;
			}
			summitSceneDef.mainTrack = summitTrackDefRequest.Result;
			summitSceneDef.bossTrack = summitBossTrackDefRequest.Result;
			snowySceneDef.mainTrack = summitTrackDefRequest.Result;
			snowySceneDef.bossTrack = summitBossTrackDefRequest.Result;
			simuSceneDef.mainTrack = summitTrackDefRequest.Result;
			simuSceneDef.bossTrack = summitBossTrackDefRequest.Result;
			if (Summit.enableRegular.Value && Summit.enableVariant.Value && Summit.loopExclusiveVariant.Value && !Summit.swapVariantPlaces.Value)
			{
				summitSceneDef.loopedSceneDef = snowySceneDef;
				snowySceneDef.loopedSceneDef = null;
				StageRegistration.RegisterSceneDefToNormalProgression(summitSceneDef, 1f, true, false);
				StageRegistration.RegisterSceneDefToNormalProgression(snowySceneDef, 1f, false, true);
				Log.Debug("Hollow Summit and Frozen Summit registered. Hollow pre-loop, Frozen post-loop");
			}
			else if (Summit.enableRegular.Value && Summit.enableVariant.Value && Summit.loopExclusiveVariant.Value && Summit.swapVariantPlaces.Value)
			{
				snowySceneDef.loopedSceneDef = summitSceneDef;
				summitSceneDef.loopedSceneDef = null;
				StageRegistration.RegisterSceneDefToNormalProgression(summitSceneDef, 1f, false, true);
				StageRegistration.RegisterSceneDefToNormalProgression(snowySceneDef, 1f, true, false);
				Log.Debug("Hollow Summit and Frozen Summit registered. Frozen pre-loop, Hollow post-loop");
			}
			else if (Summit.enableRegular.Value && Summit.enableVariant.Value && !Summit.loopExclusiveVariant.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(summitSceneDef, 0.5f, true, true);
				StageRegistration.RegisterSceneDefToNormalProgression(summitSceneDef, 0.5f, true, true);
				Log.Debug("Hollow Summit and Frozen Summit registered. Both stages appear pre & post loop (weight halved)");
			}
			else if (Summit.enableRegular.Value && !Summit.enableVariant.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(summitSceneDef, 1f, true, true);
				Log.Debug("Hollow Summit registered only");
			}
			else if (!Summit.enableRegular.Value && Summit.enableVariant.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(summitSceneDef, 1f, true, true);
				Log.Debug("Frozen Summit registered only");
			}
			if (Summit.enableSimulacrum.Value && Summit.simulacrumStage1.Value)
			{
				Simulacrum.RegisterSceneToSimulacrum(simuSceneDef);
			}
			else if (Summit.enableSimulacrum.Value && !Summit.simulacrumStage1.Value)
			{
				Simulacrum.RegisterSceneToSimulacrum(simuSceneDef, canBeStage1: false);
			}
		}

		internal static void Unload()
		{
			_assetsAssetBundle.Unload(true);
			_scenesAssetBundle.Unload(true);
		}

		private static IEnumerator LoadAllAssetsAsync<T>(AssetBundle assetBundle, IProgress<float> progress, Action<T[]> onAssetsLoaded) where T : Object
		{
			AssetBundleRequest sceneDefsRequest = assetBundle.LoadAllAssetsAsync<T>();
			while (!((AsyncOperation)sceneDefsRequest).isDone)
			{
				progress.Report(((AsyncOperation)sceneDefsRequest).progress);
				yield return null;
			}
			onAssetsLoaded(sceneDefsRequest.allAssets.Cast<T>().ToArray());
		}
	}
}