Decompiled source of Stage Rearrange v0.4.1

StageChanger.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
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 EntityStates.Missions.Goldshores;
using HG;
using Microsoft.CodeAnalysis;
using On.EntityStates.Missions.Goldshores;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StageChanger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+003fd6a07e03ce54268f9814fe877cbaab62ae35")]
[assembly: AssemblyProduct("StageChanger")]
[assembly: AssemblyTitle("StageChanger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 IEye.StageRearrange
{
	public class ChangePathOfCollosus
	{
		private static GameObject basePortal = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/PortalColossus.prefab").WaitForCompletion();

		private static GameObject path2Portal = PrefabAPI.InstantiateClone(basePortal, "path2");

		private static GameObject path3Portal = PrefabAPI.InstantiateClone(basePortal, "path3");

		private static SceneDef templeDef = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lemuriantemple/lemuriantemple.asset").WaitForCompletion();

		private static SceneDef habitatDef = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitat/habitat.asset").WaitForCompletion();

		private static SceneDef meridian = Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/meridian/meridian.asset").WaitForCompletion();

		private static SceneDef habitatNight;

		private static GameObject teleporter = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Teleporters/Teleporter1.prefab").WaitForCompletion();

		private static InteractableSpawnCard iscPortal = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC2/iscColossusPortal.asset").WaitForCompletion();

		private static InteractableSpawnCard iscPortal2;

		public void Init()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Expected O, but got Unknown
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Expected O, but got Unknown
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Expected O, but got Unknown
			SceneExitController component = basePortal.GetComponent<SceneExitController>();
			component.tier2AlternateDestinationScene = null;
			component.tier3AlternateDestinationScene = null;
			component.tier4AlternateDestinationScene = null;
			component.destinationScene = templeDef;
			SceneExitController component2 = path2Portal.GetComponent<SceneExitController>();
			component2.tier2AlternateDestinationScene = null;
			component2.tier3AlternateDestinationScene = null;
			component2.tier4AlternateDestinationScene = null;
			component2.destinationScene = habitatDef;
			SceneExitController component3 = path3Portal.GetComponent<SceneExitController>();
			component3.tier2AlternateDestinationScene = null;
			component3.tier3AlternateDestinationScene = null;
			component3.tier4AlternateDestinationScene = null;
			component3.destinationScene = meridian;
			SceneExitController.onBeginExit += SceneExitController_onBeginExit;
			PortalSpawner val = new PortalSpawner();
			PortalSpawner[] components = teleporter.GetComponents<PortalSpawner>();
			foreach (PortalSpawner val2 in components)
			{
				if (val2.spawnMessageToken == "PORTAL_STORM_OPEN")
				{
					val = val2;
				}
			}
			string[] validStages = new string[1] { "lemuriantemple" };
			val.validStages = validStages;
			val.requiredEventFlag = "colossusStarted";
			iscPortal2 = new InteractableSpawnCard
			{
				prefab = path2Portal,
				sendOverNetwork = ((SpawnCard)iscPortal).sendOverNetwork,
				hullSize = ((SpawnCard)iscPortal).hullSize,
				nodeGraphType = ((SpawnCard)iscPortal).nodeGraphType,
				requiredFlags = ((SpawnCard)iscPortal).requiredFlags,
				forbiddenFlags = ((SpawnCard)iscPortal).forbiddenFlags,
				directorCreditCost = ((SpawnCard)iscPortal).directorCreditCost,
				occupyPosition = ((SpawnCard)iscPortal).occupyPosition,
				eliteRules = ((SpawnCard)iscPortal).eliteRules,
				orientToFloor = iscPortal.orientToFloor,
				slightlyRandomizeOrientation = iscPortal.slightlyRandomizeOrientation,
				skipSpawnWhenSacrificeArtifactEnabled = iscPortal.skipSpawnWhenSacrificeArtifactEnabled,
				skipSpawnWhenDevotionArtifactEnabled = iscPortal.skipSpawnWhenDevotionArtifactEnabled,
				maxSpawnsPerStage = iscPortal.maxSpawnsPerStage,
				prismaticTrialSpawnChance = iscPortal.prismaticTrialSpawnChance
			};
			val.portalSpawnCard = iscPortal2;
			string[] validStages2 = new string[2] { "habitat", "habitatfall" };
			InteractableSpawnCard portalSpawnCard = new InteractableSpawnCard
			{
				prefab = path3Portal,
				sendOverNetwork = ((SpawnCard)iscPortal).sendOverNetwork,
				hullSize = ((SpawnCard)iscPortal).hullSize,
				nodeGraphType = ((SpawnCard)iscPortal).nodeGraphType,
				requiredFlags = ((SpawnCard)iscPortal).requiredFlags,
				forbiddenFlags = ((SpawnCard)iscPortal).forbiddenFlags,
				directorCreditCost = ((SpawnCard)iscPortal).directorCreditCost,
				occupyPosition = ((SpawnCard)iscPortal).occupyPosition,
				eliteRules = ((SpawnCard)iscPortal).eliteRules,
				orientToFloor = iscPortal.orientToFloor,
				slightlyRandomizeOrientation = iscPortal.slightlyRandomizeOrientation,
				skipSpawnWhenSacrificeArtifactEnabled = iscPortal.skipSpawnWhenSacrificeArtifactEnabled,
				skipSpawnWhenDevotionArtifactEnabled = iscPortal.skipSpawnWhenDevotionArtifactEnabled,
				maxSpawnsPerStage = iscPortal.maxSpawnsPerStage,
				prismaticTrialSpawnChance = iscPortal.prismaticTrialSpawnChance
			};
			PortalSpawner val3 = teleporter.AddComponent<PortalSpawner>();
			val3.spawnChance = val.spawnChance;
			val3.minSpawnDistance = val.minSpawnDistance;
			val3.maxSpawnDistance = val.maxSpawnDistance;
			val3.spawnPreviewMessageToken = val.spawnPreviewMessageToken;
			val3.spawnMessageToken = val.spawnMessageToken;
			val3.modelChildLocator = val.modelChildLocator;
			val3.previewChildName = val.previewChildName;
			val3.requiredExpansion = val.requiredExpansion;
			val3.bannedEventFlag = val.bannedEventFlag;
			val3.requiredEventFlag = "colossusStarted";
			val3.validStages = validStages2;
			val3.portalSpawnCard = portalSpawnCard;
			ArrayUtils.ArrayAppend<PortalSpawner>(ref teleporter.GetComponent<TeleporterInteraction>().portalSpawners, ref val3);
			Exit.IsValidStormTier += new hook_IsValidStormTier(Exit_IsValidStormTier);
			Exit.OnEnter += new hook_OnEnter(Exit_OnEnter);
		}

		private void SceneExitController_onBeginExit(SceneExitController obj)
		{
			if (obj.isColossusPortal && !Run.instance.GetEventFlag("colossusStarted"))
			{
				Run.instance.SetEventFlag("colossusStarted");
			}
			else if (!obj.isColossusPortal && Run.instance.GetEventFlag("colossusStarted"))
			{
				Run.instance.ResetEventFlag("colossusStarted");
			}
		}

		private void Exit_OnEnter(orig_OnEnter orig, Exit self)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			if ((string.IsNullOrEmpty("FalseSonBossComplete") || !Run.instance.GetEventFlag("FalseSonBossComplete")) && IsValidStormTierGood() && Object.op_Implicit((Object)(object)DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)iscPortal2, new DirectorPlacementRule
			{
				maxDistance = 30f,
				minDistance = 10f,
				placementMode = (PlacementMode)3,
				position = ((EntityState)self).transform.position
			}, Run.instance.stageRng))))
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "PORTAL_STORM_OPEN"
				});
			}
			orig.Invoke(self);
		}

		private bool Exit_IsValidStormTier(orig_IsValidStormTier orig, Exit self)
		{
			return false;
		}

		private bool IsValidStormTierGood()
		{
			Run instance = Run.instance;
			int stageOrder = instance.nextStageScene.stageOrder;
			ExpansionDef requiredExpansion = GoldshoresMissionController.instance.requiredExpansion;
			if (instance.IsExpansionEnabled(requiredExpansion))
			{
				return true;
			}
			return false;
		}
	}
	public class StageVars
	{
		public SceneDef def { get; set; }

		public SceneEntry sceneEntry { get; set; }

		public StageVars(SceneDef newDef)
		{
			//IL_0013: 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)
			def = newDef;
			SceneEntry val = new SceneEntry
			{
				sceneDef = def
			};
			((SceneEntry)(ref val)).weight = 1f;
			val.weightMinusOne = 0f;
			sceneEntry = val;
		}
	}
	public class ChangeStages
	{
		private static SceneCollection[] sceneCollections = (SceneCollection[])(object)new SceneCollection[5];

		private static SceneCollection[] loopSceneCollections = (SceneCollection[])(object)new SceneCollection[5];

		private static StageVars village = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/village/village.asset").WaitForCompletion());

		private static StageVars villagenight = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/villagenight/villagenight.asset").WaitForCompletion());

		private static StageVars temple = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lemuriantemple/lemuriantemple.asset").WaitForCompletion());

		private static StageVars habitat = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitat/habitat.asset").WaitForCompletion());

		private static StageVars habitatnight = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitatfall/habitatfall.asset").WaitForCompletion());

		private static StageVars lakes = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lakes/lakes.asset").WaitForCompletion());

		private static StageVars lakesnight = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lakesnight/lakesnight.asset").WaitForCompletion());

		private static StageVars helminthroost = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/helminthroost/helminthroost.asset").WaitForCompletion());

		private void AddNightAltsInternal(int stageNum, StageVars dayVar, StageVars nightVar)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			ref SceneEntry[] sceneEntries = ref sceneCollections[stageNum - 1]._sceneEntries;
			SceneEntry sceneEntry = nightVar.sceneEntry;
			ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref sceneEntry);
			ref SceneEntry[] sceneEntries2 = ref loopSceneCollections[stageNum - 1]._sceneEntries;
			sceneEntry = dayVar.sceneEntry;
			ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref sceneEntry);
		}

		private void ChangeStageInternal(int stageNum, StageVars dayVar)
		{
			//IL_001c: 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_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)
			dayVar.def.stageOrder = stageNum;
			ref SceneEntry[] sceneEntries = ref sceneCollections[stageNum - 1]._sceneEntries;
			SceneEntry sceneEntry = dayVar.sceneEntry;
			ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref sceneEntry);
			ref SceneEntry[] sceneEntries2 = ref loopSceneCollections[stageNum - 1]._sceneEntries;
			sceneEntry = dayVar.sceneEntry;
			ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref sceneEntry);
			if (stageNum == 5)
			{
				dayVar.def.destinationsGroup = sceneCollections[0];
				dayVar.def.loopedDestinationsGroup = loopSceneCollections[0];
			}
			else
			{
				dayVar.def.destinationsGroup = sceneCollections[stageNum];
				dayVar.def.loopedDestinationsGroup = loopSceneCollections[stageNum];
			}
		}

		private void ChangeStageInternal(int stageNum, StageVars dayVar, StageVars nightVar)
		{
			//IL_0028: 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_0045: 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)
			dayVar.def.stageOrder = stageNum;
			nightVar.def.stageOrder = stageNum;
			ref SceneEntry[] sceneEntries = ref sceneCollections[stageNum - 1]._sceneEntries;
			SceneEntry sceneEntry = dayVar.sceneEntry;
			ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref sceneEntry);
			ref SceneEntry[] sceneEntries2 = ref loopSceneCollections[stageNum - 1]._sceneEntries;
			sceneEntry = nightVar.sceneEntry;
			ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref sceneEntry);
			if (stageNum == 5)
			{
				dayVar.def.destinationsGroup = loopSceneCollections[0];
				nightVar.def.destinationsGroup = sceneCollections[0];
				dayVar.def.loopedDestinationsGroup = loopSceneCollections[0];
				nightVar.def.loopedDestinationsGroup = sceneCollections[0];
			}
			else
			{
				dayVar.def.destinationsGroup = sceneCollections[stageNum];
				nightVar.def.destinationsGroup = sceneCollections[stageNum];
				dayVar.def.loopedDestinationsGroup = loopSceneCollections[stageNum];
				nightVar.def.loopedDestinationsGroup = loopSceneCollections[stageNum];
			}
		}

		private void ChangeStage(int stageNum, StageVars dayVar)
		{
			if (stageNum >= 0 && stageNum <= 5)
			{
				ChangeStageInternal(stageNum, dayVar);
			}
		}

		private void ChangeStage(int stageNum, StageVars dayVar, StageVars nightVars, bool nightAlt)
		{
			if (stageNum >= 0 && stageNum <= 5)
			{
				ChangeStageInternal(stageNum, dayVar, nightVars);
				if (nightAlt)
				{
					AddNightAltsInternal(stageNum, dayVar, nightVars);
				}
			}
		}

		public void Init()
		{
			//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_0059: 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)
			for (int i = 0; i < 5; i++)
			{
				string text = "RoR2/Base/SceneGroups/sgStage" + (i + 1) + ".asset";
				string text2 = "RoR2/Base/SceneGroups/loopSgStage" + (i + 1) + ".asset";
				sceneCollections[i] = Addressables.LoadAssetAsync<SceneCollection>((object)text).WaitForCompletion();
				loopSceneCollections[i] = Addressables.LoadAssetAsync<SceneCollection>((object)text2).WaitForCompletion();
			}
		}

		private void PurgeStages(StageVars stage)
		{
			//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)
			//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)
			SceneCollection[] array = sceneCollections;
			foreach (SceneCollection val in array)
			{
				for (int j = 0; j < val._sceneEntries.Length; j++)
				{
					if ((Object)(object)((SceneEntry)val.sceneEntries[j]).sceneDef == (Object)(object)stage.def)
					{
						ArrayUtils.ArrayRemoveAtAndResize<SceneEntry>(ref val._sceneEntries, j, 1);
						break;
					}
				}
			}
			SceneCollection[] array2 = loopSceneCollections;
			foreach (SceneCollection val2 in array2)
			{
				for (int l = 0; l < val2._sceneEntries.Length; l++)
				{
					if ((Object)(object)((SceneEntry)val2.sceneEntries[l]).sceneDef == (Object)(object)stage.def)
					{
						ArrayUtils.ArrayRemoveAtAndResize<SceneEntry>(ref val2._sceneEntries, l, 1);
						break;
					}
				}
			}
		}

		public void EditStages()
		{
			PurgeStages(village);
			PurgeStages(villagenight);
			PurgeStages(temple);
			PurgeStages(habitat);
			PurgeStages(habitatnight);
			PurgeStages(lakes);
			PurgeStages(lakesnight);
			ChangeStage(StageChangerPlugin.instance.villageStage.Value, village, villagenight, StageChangerPlugin.instance.nightStageAsAlt.Value);
			ChangeStage(StageChangerPlugin.instance.templeStage.Value, temple);
			ChangeStage(StageChangerPlugin.instance.habitatStage.Value, habitat, habitatnight, StageChangerPlugin.instance.nightStageAsAlt.Value);
			ChangeStage(StageChangerPlugin.instance.lakesStage.Value, lakes, lakesnight, StageChangerPlugin.instance.nightStageAsAlt.Value);
		}
	}
	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("IEye.StageRearrange", "StageRearrange", "0.4.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class StageChangerPlugin : BaseUnityPlugin
	{
		public ConfigEntry<int> villageStage;

		public ConfigEntry<int> templeStage;

		public ConfigEntry<int> habitatStage;

		public ConfigEntry<int> lakesStage;

		public ConfigEntry<int> hatcheryStage;

		public ConfigEntry<bool> nightStageAsAlt;

		public const string PLUGINGUID = "IEye.StageRearrange";

		public const string PluginName = "StageRearrange";

		public const string PluginVersion = "0.4.1";

		public static StageChangerPlugin instance;

		public static ChangeStages changer;

		public void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			instance = this;
			CreateConfigs();
			Log.Init(((BaseUnityPlugin)this).Logger);
			changer = new ChangeStages();
			changer.Init();
			changer.EditStages();
			new ChangePathOfCollosus().Init();
			Run.Start += new hook_Start(Run_Start);
		}

		private void Run_Start(orig_Start orig, Run self)
		{
			changer.EditStages();
			orig.Invoke(self);
		}

		private void CreateConfigs()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			villageStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Shattered Abodes Stage", 2, "Which stage Shattered Abodes/Disturbed Impact should be(1-5)");
			templeStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Reformed Altar Stage", 2, "Which regular stage Reformed Altar should be(1-5 for addition)(0 for no addition)");
			habitatStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Treeborn Colony Stage", 3, "Which regular stage Treeborn Colony/Goldan Dieback should be(1-5 for addition)(0 for no addition)");
			lakesStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Verdant Falls Stage", 1, "Which stage Verdant/Vicious Falls should be(1-5)");
			nightStageAsAlt = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Night stages as alt", false, "Night stages become alternate stages instead of looped stages");
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(villageStage, new IntSliderConfig
			{
				max = 5,
				min = 0
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(templeStage, new IntSliderConfig
			{
				max = 5,
				min = 0
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(habitatStage, new IntSliderConfig
			{
				max = 5,
				min = 0
			}));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(lakesStage, new IntSliderConfig
			{
				max = 5,
				min = 0
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(nightStageAsAlt));
		}
	}
}