Decompiled source of Wetland Downpour v1.0.1

WetlandCool.dll

Decompiled a day 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnemiesReturns.Configuration;
using EnemiesReturns.Configuration.LynxTribe;
using EnemiesReturns.Enemies.LynxTribe.Scout;
using EnemiesReturns.Enemies.LynxTribe.Shaman;
using EnemiesReturns.Enemies.LynxTribe.Totem;
using EnemiesReturns.Enemies.Spitter;
using FSCStage.Content;
using HG;
using HG.Reflection;
using MSU.Config;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using SS2;
using ShaderSwapper;
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")]
public class GravityZone : MonoBehaviour
{
	private List<CharacterBody> characterBodies = new List<CharacterBody>();

	public float gravityCoefficient;

	public void OnTriggerEnter(Collider other)
	{
		CharacterBody component = ((Component)other).GetComponent<CharacterBody>();
		if (Object.op_Implicit((Object)(object)component) && !characterBodies.Contains(component) && (Object)(object)component.characterMotor != (Object)null && component.characterMotor.useGravity && component.characterMotor.hasEffectiveAuthority)
		{
			characterBodies.Add(component);
		}
	}

	public void OnTriggerExit(Collider other)
	{
		CharacterBody component = ((Component)other).GetComponent<CharacterBody>();
		if (characterBodies.Contains(component))
		{
			characterBodies.Remove(component);
		}
	}

	private void FixedUpdate()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		foreach (CharacterBody characterBody in characterBodies)
		{
			if (!characterBody.characterMotor.isGrounded && characterBodies.Contains(characterBody))
			{
				characterBody.characterMotor.velocity.y += (0f - Physics.gravity.y) * gravityCoefficient * Time.fixedDeltaTime;
			}
		}
	}
}
namespace FSCStage
{
	public class InstantiateArtifactFormulaDisplay : MonoBehaviour
	{
		public enum Codes
		{
			Circle,
			Diamond,
			Square,
			Triangle
		}

		public Transform position;

		public Codes[] code;

		private void Awake()
		{
			//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_002f: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			if (code.Length != 9)
			{
				Log.Warning("Slab's code length is not equal to 9, doing nothing...");
				return;
			}
			ArtifactFormulaDisplay component = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_artifactworld.ArtifactFormulaDisplay_prefab).WaitForCompletion(), position.position, position.rotation).GetComponent<ArtifactFormulaDisplay>();
			for (int i = 0; i < code.Length; i++)
			{
				component.artifactCompoundDisplayInfos[i].artifactCompoundDef = GetACD(code[i]);
			}
			ArtifactCompoundDisplayInfo[] artifactCompoundDisplayInfos = component.artifactCompoundDisplayInfos;
			foreach (ArtifactCompoundDisplayInfo val in artifactCompoundDisplayInfos)
			{
				val.decal.Material = val.artifactCompoundDef.decalMaterial;
			}
			static ArtifactCompoundDef GetACD(Codes code)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_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_0056: 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_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				return (ArtifactCompoundDef)(code switch
				{
					Codes.Circle => Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)RoR2_Base_ArtifactCompounds.acdCircle_asset).WaitForCompletion(), 
					Codes.Diamond => Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)RoR2_Base_ArtifactCompounds.acdDiamond_asset).WaitForCompletion(), 
					Codes.Square => Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)RoR2_Base_ArtifactCompounds.acdSquare_asset).WaitForCompletion(), 
					Codes.Triangle => Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)RoR2_Base_ArtifactCompounds.acdTriangle_asset).WaitForCompletion(), 
					_ => Addressables.LoadAssetAsync<ArtifactCompoundDef>((object)RoR2_Base_ArtifactCompounds.acdEmpty_asset).WaitForCompletion(), 
				});
			}
		}

		public void OnDrawGizmos()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)position))
			{
				Gizmos.color = Color.yellow;
				Gizmos.DrawWireMesh(Resources.GetBuiltinResource<Mesh>("Cube.fbx"), position.position, position.rotation, new Vector3(4.0284877f, 6.4461765f, 1.6496983f));
				GUI.color = Color.yellow;
			}
		}

		private void OnValidate()
		{
		}
	}
	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 IsStarstorm2
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.TeamMoonstorm.MSU") && Chainloader.PluginInfos.ContainsKey("com.TeamMoonstorm");
				}
				return _enabled.Value;
			}
		}
	}
	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 EnemiesReturnsCompat
	{
		public static void AddEnemies()
		{
			//IL_0034: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_009f: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00fe: Expected O, but got Unknown
			//IL_00fe: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0154: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_01fd: Expected O, but got Unknown
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			//IL_02a6: Expected O, but got Unknown
			if (FSCStage.toggleLynxTotem.Value && General.EnableLynxTotem.Value && !LynxTotem.DefaultStageList.Value.Contains("foggyswampdownpour"))
			{
				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
				};
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "foggyswampdownpour");
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itfoggyswampdownpour");
				Log.Info("Lynx Totem added to foggyswampdownpour's spawn pool.");
			}
			if (FSCStage.toggleLynxScout.Value && (General.EnableLynxTotem.Value || General.EnableLynxShaman.Value) && !LynxScout.DefaultStageList.Value.Contains("foggyswampdownpour"))
			{
				DirectorCard card2 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscLynxScoutDefault,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = LynxScout.SelectionWeight.Value,
					minimumStageCompletions = LynxScout.MinimumStageCompletion.Value
				};
				DirectorCardHolder val2 = new DirectorCardHolder
				{
					Card = card2,
					MonsterCategory = (MonsterCategory)2
				};
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "foggyswampdownpour");
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "itfoggyswampdownpour");
				Log.Info("Lynx Scout added to foggyswampdownpour's spawn pool.");
			}
			if (FSCStage.toggleLynxShaman.Value && General.EnableLynxShaman.Value && !LynxShaman.DefaultStageList.Value.Contains("foggyswampdownpour"))
			{
				DirectorCard card3 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscLynxShamanDefault,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = LynxShaman.SelectionWeight.Value,
					minimumStageCompletions = LynxShaman.MinimumStageCompletion.Value
				};
				DirectorCardHolder val3 = new DirectorCardHolder
				{
					Card = card3,
					MonsterCategory = (MonsterCategory)2
				};
				Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "foggyswampdownpour");
				Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "itfoggyswampdownpour");
				Log.Info("Lynx Shaman added to foggyswampdownpour's spawn pool.");
			}
			if (FSCStage.toggleSpitter.Value && General.EnableSpitter.Value && !Spitter.DefaultStageList.Value.Contains("foggyswampdownpour"))
			{
				DirectorCard card4 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscSpitterDefault,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = Spitter.SelectionWeight.Value,
					minimumStageCompletions = Spitter.MinimumStageCompletion.Value
				};
				DirectorCardHolder val4 = new DirectorCardHolder
				{
					Card = card4,
					MonsterCategory = (MonsterCategory)3
				};
				Helpers.AddNewMonsterToStage(val4, false, (Stage)1, "foggyswampdownpour");
				Helpers.AddNewMonsterToStage(val4, false, (Stage)1, "itfoggyswampdownpour");
				Log.Info("Spitter added to foggyswampdownpour's spawn pool.");
			}
		}
	}
	public class Starstorm2Compat
	{
		public static string FindEnemyConfig(string monsterName)
		{
			string text = "00 - Enemy Disabling.Disable Enemy: " + monsterName;
			ConfigEntryBase[] configEntries = SS2Config.ConfigMonster.GetConfigEntries();
			foreach (ConfigEntryBase val in configEntries)
			{
				if (((object)val.Definition).ToString() == text)
				{
					return val.GetSerializedValue();
				}
			}
			return "false";
		}

		public static void AddEnemies()
		{
			//IL_0024: 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_003b: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00fa: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_0196: Expected O, but got Unknown
			string text = FindEnemyConfig("Lamp Boss");
			if (FSCStage.toggleWayfarer.Value && text == "false")
			{
				DirectorCard card = new DirectorCard
				{
					spawnCard = SS2Assets.LoadAsset<SpawnCard>("scLampBoss", (SS2Bundle)17),
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = 1
				};
				DirectorCardHolder val = new DirectorCardHolder
				{
					Card = card,
					MonsterCategory = (MonsterCategory)4
				};
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "foggyswampdownpour");
				Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itfoggyswampdownpour");
				Log.Info("Wayfarer added to foggyswampdownpour's spawn pool.");
			}
			string text2 = FindEnemyConfig("Lamp");
			if (FSCStage.toggleFollower.Value && text2 == "false")
			{
				DirectorCard card2 = new DirectorCard
				{
					spawnCard = SS2Assets.LoadAsset<SpawnCard>("scLamp", (SS2Bundle)17),
					spawnDistance = (MonsterSpawnDistance)2,
					selectionWeight = 2
				};
				DirectorCardHolder val2 = new DirectorCardHolder
				{
					Card = card2,
					MonsterCategory = (MonsterCategory)2
				};
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "foggyswampdownpour");
				Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "itfoggyswampdownpour");
				Log.Info("Follower added to foggyswampdownpour's spawn pool.");
			}
			if (((ConfiguredVariable<bool>)(object)SS2Config.enableBeta).value)
			{
				string text3 = FindEnemyConfig("Acid Bug");
				if (FSCStage.toggleAcidBug.Value && text3 == "false")
				{
					DirectorCard card3 = new DirectorCard
					{
						spawnCard = SS2Assets.LoadAsset<SpawnCard>("cscAcidBug", (SS2Bundle)17),
						spawnDistance = (MonsterSpawnDistance)0,
						selectionWeight = 2,
						minimumStageCompletions = 5
					};
					DirectorCardHolder val3 = new DirectorCardHolder
					{
						Card = card3,
						MonsterCategory = (MonsterCategory)2
					};
					Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "foggyswampdownpour");
					Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "itfoggyswampdownpour");
					Log.Info("Archer Wasp added to foggyswampdownpour's spawn pool.");
				}
			}
		}
	}
	[BepInPlugin("wormsworms.WetlandDownpour", "WetlandDownpour", "1.0.1")]
	public class FSCStage : BaseUnityPlugin
	{
		public const string Author = "wormsworms";

		public const string Name = "WetlandDownpour";

		public const string Version = "1.0.1";

		public const string GUID = "wormsworms.WetlandDownpour";

		public static FSCStage instance;

		public static ConfigEntry<bool> loopVariant;

		public static ConfigEntry<bool> replaceFoggyswamp;

		public static ConfigEntry<bool> regularEnabled;

		public static ConfigEntry<bool> waterMuffle;

		public static ConfigEntry<bool> simulacrumEnabled;

		public static ConfigEntry<bool> simulacrumStage1;

		public static ConfigEntry<bool> toggleWayfarer;

		public static ConfigEntry<bool> toggleFollower;

		public static ConfigEntry<bool> toggleAcidBug;

		public static ConfigEntry<bool> toggleLynxTotem;

		public static ConfigEntry<bool> toggleLynxScout;

		public static ConfigEntry<bool> toggleLynxShaman;

		public static ConfigEntry<bool> toggleSpitter;

		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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			ConfigSetup();
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(GiveToRoR2OurContentPackProviders);
			Language.collectLanguageRootFolders += CollectLanguageRootFolders;
			Run.PickNextStageScene += new hook_PickNextStageScene(ReplaceWetlandAspect);
			Run.onRunStartGlobal += InitializeBazaarSeerValues;
			RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(AddModdedEnemies));
			SceneManager.sceneLoaded += SceneSetup;
		}

		public static void AddModdedEnemies()
		{
			if (IsStarstorm2.enabled)
			{
				Starstorm2Compat.AddEnemies();
			}
			if (IsEnemiesReturns.enabled)
			{
				EnemiesReturnsCompat.AddEnemies();
			}
		}

		public void InitializeBazaarSeerValues(Run run)
		{
			if (loopVariant.Value && !replaceFoggyswamp.Value)
			{
				SceneCatalog.GetSceneDefFromSceneName("foggyswamp").filterOutOfBazaar = false;
				SceneCatalog.GetSceneDefFromSceneName("foggyswampdownpour").filterOutOfBazaar = true;
			}
			else if (replaceFoggyswamp.Value)
			{
				SceneCatalog.GetSceneDefFromSceneName("foggyswamp").filterOutOfBazaar = true;
				SceneCatalog.GetSceneDefFromSceneName("foggyswampdownpour").filterOutOfBazaar = false;
			}
		}

		public void ReplaceWetlandAspect(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
		{
			orig.Invoke(self, choices);
			if (loopVariant.Value && !replaceFoggyswamp.Value)
			{
				if (Run.instance.stageClearCount > 3 && !SceneCatalog.GetSceneDefFromSceneName("foggyswamp").filterOutOfBazaar)
				{
					SceneCatalog.GetSceneDefFromSceneName("foggyswamp").filterOutOfBazaar = true;
					SceneCatalog.GetSceneDefFromSceneName("foggyswampdownpour").filterOutOfBazaar = false;
					SceneCatalog.GetSceneDefFromSceneName("foggyswamp").loopedSceneDef = SceneCatalog.GetSceneDefFromSceneName("foggyswampdownpour");
				}
				if (self.nextStageScene.baseSceneName != null && self.nextStageScene.baseSceneName == "foggyswamp" && Run.instance.stageClearCount > 3)
				{
					self.nextStageScene = SceneCatalog.GetSceneDefFromSceneName("foggyswampdownpour");
					Log.Debug("Wetland Aspect annihilated by orbital missile; we did it, (read this in a cool voice)");
				}
			}
			else if (replaceFoggyswamp.Value && self.nextStageScene.baseSceneName != null && self.nextStageScene.baseSceneName == "foggyswamp")
			{
				self.nextStageScene = SceneCatalog.GetSceneDefFromSceneName("foggyswampdownpour");
				Log.Debug("Wetland Aspect annihilated by orbital missile; we did it, (read this in a cool voice)");
			}
		}

		public void SceneSetup(Scene newScene, LoadSceneMode loadSceneMode)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref newScene)).name == "itfoggyswampdownpour")
			{
				MeshRenderer val = default(MeshRenderer);
				GameObject.Find("FSFloor/SubMesh_0").TryGetComponent<MeshRenderer>(ref val);
				Material material = ((Renderer)val).material;
				Material val2 = Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/ITAssets/matInfiniteTowerBooleanEffect1.mat").WaitForCompletion();
				Material[] array = (Material[])(object)new Material[2] { material, val2 };
				RendererSetMaterialsExtension.SetSharedMaterials((Renderer)(object)val, array, 2);
			}
		}

		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 ConfigSetup()
		{
			loopVariant = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Post-Loop Variant", true, "If true, Wetland Downpour behaves like a vanilla loop variant, entirely replacing Wetland Aspect after looping. If false, it does not replace Wetland Aspect and it can appear before or after looping, like a normal stage.");
			replaceFoggyswamp = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Replace Wetland Aspect", false, "If true, Wetland Downpour will always replace Wetland Aspect, before and after looping, regardless of what value Loop Variant is set to.");
			regularEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Wetland Downpour", true, "If true, Wetland Downpour can appear in regular runs.");
			waterMuffle = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Underwater Music Muffling", true, "If true, music will get muffled while the camera is underwater in Wetland Downpour.");
			simulacrumEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - Simulacrum", "Enable Simulacrum Variant", true, "If true, Wetland Downpour can appear in the Simulacrum.");
			simulacrumStage1 = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - Simulacrum", "Enable on Stage 1", true, "If true, Wetland Downpour can appear as the first stage in the Simulacrum. If false, it can only appear on stage 2 or higher, like Commencement.");
			toggleWayfarer = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - Starstorm 2", "Wayfarer", true, "If true, Wayfarers can appear in Wetland Downpour.");
			toggleFollower = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - Starstorm 2", "Follower", true, "If true, Followers can appear in Wetland Downpour.");
			toggleAcidBug = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - Starstorm 2", "Archer Bug", true, "If true, Archer Bugs can appear in Wetland Downpour (after clearing 5 stages).");
			toggleLynxTotem = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - EnemiesReturns", "Lynx Totem", true, "If true, Lynx Totems can appear in Wetland Downpour.");
			toggleLynxScout = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - EnemiesReturns", "Lynx Scout", true, "If true, Lynx Scouts can appear in Wetland Downpour.");
			toggleLynxShaman = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - EnemiesReturns", "Lynx Shaman", false, "If true, Lynx Shamans can appear in Wetland Downpour.");
			toggleSpitter = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings - EnemiesReturns", "Spitter", true, "If true, Spitters can appear in Wetland Downpour.");
		}
	}
}
namespace FSCStage.Content
{
	public class ContentProvider : IContentPackProvider
	{
		private readonly ContentPack _contentPack = new ContentPack();

		public static string assetDirectory;

		public string identifier => "wormsworms.WetlandDownpour.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, "WetlandCoolScene"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				scenesAssetBundle = assetBundle;
			});
			AssetBundle assetsAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "WetlandCoolAssets"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				assetsAssetBundle = assetBundle;
			});
			yield return FSCContent.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 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);
			}
		}
	}
	public class AudioMuffleZone : MonoBehaviour
	{
		private void OnEnable()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (FSCStage.waterMuffle.Value)
			{
				MusicController.RecalculateHealth += new hook_RecalculateHealth(MusicController_RecalculateHealth);
			}
		}

		private void OnDisable()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (FSCStage.waterMuffle.Value)
			{
				MusicController.RecalculateHealth -= new hook_RecalculateHealth(MusicController_RecalculateHealth);
			}
		}

		public static bool IsInsideCollider(Collider collider, Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = collider.bounds;
			return ((Bounds)(ref bounds)).Contains(position);
		}

		private void MusicController_RecalculateHealth(orig_RecalculateHealth orig, MusicController self, GameObject playerObject)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, playerObject);
			if (Object.op_Implicit((Object)(object)self.targetCamera) && IsInsideCollider((Collider)(object)((Component)this).gameObject.GetComponent<BoxCollider>(), ((Component)self.targetCamera).transform.localPosition))
			{
				self.rtpcPlayerHealthValue.value -= 100f;
				self.rtpcPlayerHealthValue.value = Mathf.Max(self.rtpcEnemyValue.value, -100f);
			}
		}
	}
	public static class FSCContent
	{
		internal const string ScenesAssetBundleFileName = "WetlandCoolScene";

		internal const string AssetsAssetBundleFileName = "WetlandCoolAssets";

		private static AssetBundle _scenesAssetBundle;

		private static AssetBundle _assetsAssetBundle;

		internal static UnlockableDef[] UnlockableDefs;

		internal static SceneDef[] SceneDefs;

		internal static SceneDef FSCSceneDef;

		internal static Sprite FSCSceneDefPreviewSprite;

		internal static Material FSCBazaarSeer;

		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)
			{
				FSCSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texFSCScenePreview");
				SimuSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texFSCScenePreview");
			});
			yield return LoadAllAssetsAsync<SceneDef>(_assetsAssetBundle, progress, (Action<SceneDef[]>)delegate(SceneDef[] assets)
			{
				SceneDefs = assets;
				FSCSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "foggyswampdownpour");
				SimuSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "itfoggyswampdownpour");
				Log.Debug(FSCSceneDef.nameToken);
				Log.Debug(SimuSceneDef.nameToken);
				contentPack.sceneDefs.Add(assets);
			});
			FSCSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)FSCSceneDef.previewTexture);
			SimuSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)FSCSceneDef.previewTexture);
			AsyncOperationHandle<MusicTrackDef> mainTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muFULLSong06.asset");
			while (!mainTrackDefRequest.IsDone)
			{
				yield return null;
			}
			AsyncOperationHandle<MusicTrackDef> bossTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muSong22.asset");
			while (!bossTrackDefRequest.IsDone)
			{
				yield return null;
			}
			FSCSceneDef.mainTrack = mainTrackDefRequest.Result;
			FSCSceneDef.bossTrack = bossTrackDefRequest.Result;
			SimuSceneDef.mainTrack = mainTrackDefRequest.Result;
			SimuSceneDef.bossTrack = bossTrackDefRequest.Result;
			if (FSCStage.regularEnabled.Value)
			{
				if (FSCStage.loopVariant.Value)
				{
					StageRegistration.RegisterSceneDefToNormalProgression(FSCSceneDef, 0f, false, true);
				}
				else if (FSCStage.replaceFoggyswamp.Value)
				{
					StageRegistration.RegisterSceneDefToNormalProgression(FSCSceneDef, 0f, true, true);
				}
				else
				{
					StageRegistration.RegisterSceneDefToNormalProgression(FSCSceneDef, 1f, true, true);
				}
			}
			if (FSCStage.simulacrumEnabled.Value && FSCStage.simulacrumStage1.Value)
			{
				Simulacrum.RegisterSceneToSimulacrum(SimuSceneDef);
			}
			else if (FSCStage.simulacrumEnabled.Value && !FSCStage.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());
		}
	}
}