Decompiled source of Sunset Tropics v1.0.3

Tropics.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.ArcherBug;
using EnemiesReturns.Enemies.Colossus;
using EnemiesReturns.Enemies.LynxTribe.Totem;
using EnemiesReturns.Enemies.SandCrab;
using FSCStage;
using HG;
using HG.Reflection;
using MSU.Config;
using MapSandbox.Content;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2BepInExPack.GameAssetPathsBetter;
using SS2;
using ShaderSwapper;
using Tropics;
using Tropics.Content;
using Tropics.ModChecks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
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 DestroyOnDisable : MonoBehaviour
{
	private void OnDisable()
	{
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
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 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 FSCStage
{
	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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//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_0065: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0095: Expected O, but got Unknown
			if (((ConfiguredVariable<bool>)(object)SS2Config.enableBeta).value)
			{
				string text = FindEnemyConfig("Acid Bug");
				if (global::Tropics.Tropics.toggleArcherBug.Value && text == "false")
				{
					DirectorCard card = new DirectorCard
					{
						spawnCard = SS2Assets.LoadAsset<SpawnCard>("cscAcidBug", (SS2Bundle)17),
						spawnDistance = (MonsterSpawnDistance)0,
						selectionWeight = 1
					};
					DirectorCardHolder val = new DirectorCardHolder
					{
						Card = card,
						MonsterCategory = (MonsterCategory)2
					};
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "tropics_wormsworms");
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "tropicsnight_wormsworms");
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "ittropics_wormsworms");
					Log.Info("Archer Bug added to Sunset Tropics' spawn pool.");
				}
			}
		}
	}
}
namespace Tropics
{
	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 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_0041: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_012e: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_01d6: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_02d6: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Expected O, but got Unknown
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			if (Tropics.toggleArcherBugReturns.Value && General.EnableArcherBug.Value)
			{
				DirectorCard card = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscArcherBugJungle,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = 1,
					minimumStageCompletions = 0
				};
				DirectorCardHolder val = new DirectorCardHolder
				{
					Card = card,
					MonsterCategory = (MonsterCategory)2
				};
				if (!LynxTotem.DefaultStageList.Value.Contains("tropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "tropics_wormsworms");
					Log.Info("Archer Bug added to Sunset Tropics' spawn pool.");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("tropicsnight_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "tropicsnight_wormsworms");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("ittropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val, false, (Stage)1, "ittropics_wormsworms");
				}
			}
			if (Tropics.toggleSandCrabs.Value && General.EnableSandCrab.Value)
			{
				DirectorCard card2 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscSandCrabSandy,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = SandCrab.SelectionWeight.Value,
					minimumStageCompletions = SandCrab.MinimumStageCompletion.Value
				};
				DirectorCardHolder val2 = new DirectorCardHolder
				{
					Card = card2,
					MonsterCategory = (MonsterCategory)3
				};
				if (!LynxTotem.DefaultStageList.Value.Contains("tropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "tropics_wormsworms");
					Log.Info("Sand Crab added to Sunset Tropics' spawn pool.");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("tropicsnight_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "tropicsnight_wormsworms");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("ittropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val2, false, (Stage)1, "ittropics_wormsworms");
				}
			}
			if (Tropics.toggleLynxTotems.Value && General.EnableLynxTotem.Value)
			{
				DirectorCard card3 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscLynxTotemDefault,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = LynxTotem.SelectionWeight.Value,
					minimumStageCompletions = LynxTotem.MinimumStageCompletion.Value
				};
				DirectorCardHolder val3 = new DirectorCardHolder
				{
					Card = card3,
					MonsterCategory = (MonsterCategory)4
				};
				if (!LynxTotem.DefaultStageList.Value.Contains("tropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "tropics_wormsworms");
					Log.Info("Lynx Totem added to Sunset Tropics' spawn pool.");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("tropicsnight_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "tropicsnight_wormsworms");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("ittropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val3, false, (Stage)1, "ittropics_wormsworms");
				}
			}
			if (Tropics.toggleColossus.Value && General.EnableColossus.Value)
			{
				DirectorCard card4 = new DirectorCard
				{
					spawnCard = (SpawnCard)SpawnCards.cscColossusSandy,
					spawnDistance = (MonsterSpawnDistance)0,
					selectionWeight = Colossus.SelectionWeight.Value,
					minimumStageCompletions = Colossus.MinimumStageCompletion.Value
				};
				DirectorCardHolder val4 = new DirectorCardHolder
				{
					Card = card4,
					MonsterCategory = (MonsterCategory)4
				};
				if (!LynxTotem.DefaultStageList.Value.Contains("tropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val4, false, (Stage)1, "tropics_wormsworms");
					Log.Info("Colossus added to Sunset Tropics' spawn pool.");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("tropicsnight_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val4, false, (Stage)1, "tropicsnight_wormsworms");
				}
				if (!LynxTotem.DefaultStageList.Value.Contains("ittropics_wormsworms"))
				{
					Helpers.AddNewMonsterToStage(val4, false, (Stage)1, "ittropics_wormsworms");
				}
			}
		}
	}
	[BepInPlugin("wormsworms.Sunset_Tropics", "Sunset_Tropics", "1.0.3")]
	public class Tropics : BaseUnityPlugin
	{
		public const string Author = "wormsworms";

		public const string Name = "Sunset_Tropics";

		public const string Version = "1.0.3";

		public const string GUID = "wormsworms.Sunset_Tropics";

		public const string RegularSceneName = "tropics_wormsworms";

		public const string LoopSceneName = "tropicsnight_wormsworms";

		public const string SimuSceneName = "ittropics_wormsworms";

		private static GameObject scalingChestPrefab;

		public static Tropics instance;

		public static ConfigEntry<bool> enableRegular;

		public static ConfigEntry<bool> waterMuffle;

		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> toggleSandCrabs;

		public static ConfigEntry<bool> toggleLynxTotems;

		public static ConfigEntry<bool> toggleColossus;

		public static ConfigEntry<bool> toggleArcherBugReturns;

		public static ConfigEntry<bool> toggleArcherBug;

		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)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && !swapVariantPlaces.Value)
			{
				SceneCatalog.GetSceneDefFromSceneName("tropics_wormsworms").filterOutOfBazaar = false;
				SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").filterOutOfBazaar = true;
			}
			else if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && swapVariantPlaces.Value)
			{
				SceneCatalog.GetSceneDefFromSceneName("tropics_wormsworms").filterOutOfBazaar = true;
				SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").filterOutOfBazaar = false;
			}
			ExpansionDef val = Addressables.LoadAssetAsync<ExpansionDef>((object)RoR2_DLC3.DLC3_asset).WaitForCompletion();
			if (Run.instance.IsExpansionEnabled(val))
			{
				MusicTrackDef mainTrack = Addressables.LoadAssetAsync<MusicTrackDef>((object)RoR2_DLC3.muGameplayDLC3_02_P_Map_asset).WaitForCompletion();
				SceneCatalog.GetSceneDefFromSceneName("tropics_wormsworms").mainTrack = mainTrack;
				SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").mainTrack = mainTrack;
				SceneCatalog.GetSceneDefFromSceneName("ittropics_wormsworms").mainTrack = mainTrack;
			}
			else
			{
				MusicTrackDef mainTrack2 = Addressables.LoadAssetAsync<MusicTrackDef>((object)RoR2_Base_Common_MusicTrackDefs.muFULLSong02_asset).WaitForCompletion();
				SceneCatalog.GetSceneDefFromSceneName("tropics_wormsworms").mainTrack = mainTrack2;
				SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").mainTrack = mainTrack2;
				SceneCatalog.GetSceneDefFromSceneName("ittropics_wormsworms").mainTrack = mainTrack2;
			}
		}

		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("tropics_wormsworms").filterOutOfBazaar)
				{
					SceneCatalog.GetSceneDefFromSceneName("tropics_wormsworms").filterOutOfBazaar = true;
					SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").filterOutOfBazaar = false;
					Log.Debug("Swapped bazaar filter-out values (Regular TRUE, Loop FALSE)");
				}
			}
			else if (enableRegular.Value && enableVariant.Value && loopExclusiveVariant.Value && swapVariantPlaces.Value && Run.instance.stageClearCount >= 5 && !SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").filterOutOfBazaar)
			{
				SceneCatalog.GetSceneDefFromSceneName("tropics_wormsworms").filterOutOfBazaar = false;
				SceneCatalog.GetSceneDefFromSceneName("tropicsnight_wormsworms").filterOutOfBazaar = true;
				Log.Debug("Swapped bazaar filter-out values (Regular FALSE, Loop TRUE)");
			}
		}

		public static void AddModdedEnemies()
		{
			if (IsEnemiesReturns.enabled)
			{
				EnemiesReturnsCompat.AddEnemies();
			}
			if (IsStarstorm2.enabled)
			{
				Starstorm2Compat.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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Scene)(ref newScene)).name == "tropics_wormsworms") && !(((Scene)(ref newScene)).name == "tropicsnight_wormsworms") && !(((Scene)(ref newScene)).name == "ittropics_wormsworms"))
			{
				return;
			}
			GameObject[] array = (GameObject[])(object)new GameObject[5]
			{
				GameObject.Find("Gold Chest 1/GoldChest(Clone)"),
				GameObject.Find("Gold Chest 2/GoldChest(Clone)"),
				GameObject.Find("Gold Chest 3/GoldChest(Clone)"),
				GameObject.Find("Gold Chest 4/GoldChest(Clone)"),
				GameObject.Find("Gold Chest 5/GoldChest(Clone)")
			};
			GameObject[] array2 = (GameObject[])(object)new GameObject[5]
			{
				GameObject.Find("Gold Chests/Under Planks"),
				GameObject.Find("Gold Chests/Beach Nautilus"),
				GameObject.Find("Gold Chests/Ruins Staircase"),
				GameObject.Find("Gold Chests/Cliff Hole"),
				GameObject.Find("Gold Chests/Trench")
			};
			for (int i = 0; i < array.Length; i++)
			{
				GameObject val = array[i];
				GameObject val2 = array2[i];
				if ((Object)(object)val != (Object)null)
				{
					GameObject obj = Object.Instantiate<GameObject>(scalingChestPrefab, val.transform.position, val.transform.rotation, val2.transform);
					obj.AddComponent<DestroyOnDisable>();
					NetworkServer.Spawn(obj);
					Object.Destroy((Object)(object)val);
				}
			}
		}

		public static void CreateScalingChestPrefab(ContentPack contentPack)
		{
			//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)
			scalingChestPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_GoldChest.GoldChest_prefab).WaitForCompletion(), "TropicsScalingGoldChest", true);
			PurchaseInteraction val = default(PurchaseInteraction);
			scalingChestPrefab.TryGetComponent<PurchaseInteraction>(ref val);
			val.automaticallyScaleCostWithDifficulty = true;
			contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { scalingChestPrefab });
		}

		private void ConfigSetup()
		{
			enableRegular = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Sunset Tropics", "Enable Sunset Tropics", true, "If true, Sunset Tropics can appear in runs.");
			waterMuffle = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Sunset Tropics", "Underwater Music Muffling", true, "If true, music gets muffled while the camera is underwater in Sunset Tropics and its variants.");
			enableVariant = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Midnight Tropics", "Enable Midnight Tropics", true, "If true, Midnight Tropics can appear in runs. If Sunset Tropics is disabled, the Loop Variant and Swap Places values are ignored and Midnight Tropics can appear at any time, effectively replacing it.");
			loopExclusiveVariant = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Midnight Tropics", "Loop Variant", true, "If true, Midnight Tropics replaces Sunset Tropics after looping. If false, it can appear at any time (both variants will have their weight halved to prevent making Tropics more common than other stages).");
			swapVariantPlaces = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Midnight Tropics", "Swap Places with Sunset Tropics", false, "If true, Midnight Tropics will appear before looping and Sunset Tropics will replace it after looping.");
			enableSimulacrum = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Simulacrum Variant", "Enable Simulacrum Variant", true, "If true, Sunset Tropics can appear in the Simulacrum.");
			simulacrumStage1 = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Simulacrum Variant", "Enable Simulacrum Variant on Stage 1", true, "If true, Sunset Tropics can appear as the first stage in the Simulacrum. If false, it can only appear on Stage 2 or higher, like Commencement.");
			toggleSandCrabs = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Modded Enemies - EnemiesReturns", "Enable Sand Crabs", true, "If true, Sand Crabs can appear in Sunset Tropics and Midnight Tropics.");
			toggleLynxTotems = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Modded Enemies - EnemiesReturns", "Enable Lynx Totems", true, "If true, Lynx Totems can appear in Sunset Tropics and Midnight Tropics.");
			toggleColossus = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Modded Enemies - EnemiesReturns", "Enable Colossus", true, "If true, Colossi can appear in Sunset Tropics and Midnight Tropics.");
			toggleArcherBugReturns = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Modded Enemies - EnemiesReturns", "Enable Archer Bugs", false, "If true, Archer Bugs can appear in Sunset Tropics and Midnight Tropics.");
			toggleArcherBug = ((BaseUnityPlugin)this).Config.Bind<bool>("04 - Modded Enemies - Starstorm 2", "Enable Archer Bugs", true, "If true, Archer Bugs can appear in Sunset Tropics and Midnight Tropics.");
		}
	}
}
namespace Tropics.ModChecks
{
	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 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 Tropics.Content
{
	public class ContentProvider : IContentPackProvider
	{
		private readonly ContentPack _contentPack = new ContentPack();

		public static string assetDirectory;

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

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			_contentPack.identifier = identifier;
			string assetsFolderFullPath = (assetDirectory = Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location));
			Tropics.CreateScalingChestPrefab(_contentPack);
			AssetBundle scenesAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "TropicsScenes"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				scenesAssetBundle = assetBundle;
			});
			AssetBundle assetsAssetBundle = null;
			yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "TropicsAssets"), args.progressReceiver, delegate(AssetBundle assetBundle)
			{
				assetsAssetBundle = assetBundle;
			});
			yield return TropicsContent.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 TropicsContent
	{
		internal const string ScenesAssetBundleFileName = "TropicsScenes";

		internal const string AssetsAssetBundleFileName = "TropicsAssets";

		private static AssetBundle _scenesAssetBundle;

		private static AssetBundle _assetsAssetBundle;

		internal static UnlockableDef[] UnlockableDefs;

		internal static SceneDef[] SceneDefs;

		internal static SceneDef TropicsSceneDef;

		internal static Sprite TropicsSceneDefPreviewSprite;

		internal static Material TropicsBazaarSeer;

		internal static SceneDef LoopSceneDef;

		internal static Sprite LoopSceneDefPreviewSprite;

		internal static Material LoopBazaarSeer;

		internal static SceneDef simuSceneDef;

		internal static Sprite simuSceneDefPreviewSprite;

		internal static Material simuBazaarSeer;

		internal static ExplicitPickupDropTable tricornDropTable;

		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)
			{
				TropicsSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texTropicsScenePreview");
				LoopSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texTropicsNightScenePreview");
				simuSceneDefPreviewSprite = assets.First((Sprite a) => ((Object)a).name == "texTropicsScenePreview");
			});
			yield return LoadAllAssetsAsync<SceneDef>(_assetsAssetBundle, progress, (Action<SceneDef[]>)delegate(SceneDef[] assets)
			{
				SceneDefs = assets;
				TropicsSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "tropics_wormsworms");
				LoopSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "tropicsnight_wormsworms");
				simuSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "ittropics_wormsworms");
				Log.Debug(TropicsSceneDef.nameToken + " + " + LoopSceneDef.nameToken + " + " + simuSceneDef.nameToken);
				contentPack.sceneDefs.Add(assets);
			});
			TropicsSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)TropicsSceneDef.previewTexture);
			LoopSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)LoopSceneDef.previewTexture);
			simuSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)simuSceneDef.previewTexture);
			AsyncOperationHandle<MusicTrackDef> tropicsTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muFULLSong02.asset");
			while (!tropicsTrackDefRequest.IsDone)
			{
				yield return null;
			}
			AsyncOperationHandle<MusicTrackDef> tropicsBossTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/DLC2/Common/muSong_Lakes&HabitatBoss.asset");
			while (!tropicsBossTrackDefRequest.IsDone)
			{
				yield return null;
			}
			TropicsSceneDef.mainTrack = tropicsTrackDefRequest.Result;
			TropicsSceneDef.bossTrack = tropicsBossTrackDefRequest.Result;
			LoopSceneDef.mainTrack = tropicsTrackDefRequest.Result;
			LoopSceneDef.bossTrack = tropicsBossTrackDefRequest.Result;
			simuSceneDef.mainTrack = tropicsTrackDefRequest.Result;
			simuSceneDef.bossTrack = tropicsBossTrackDefRequest.Result;
			if (Tropics.enableRegular.Value && Tropics.enableVariant.Value && Tropics.loopExclusiveVariant.Value && !Tropics.swapVariantPlaces.Value)
			{
				TropicsSceneDef.loopedSceneDef = LoopSceneDef;
				LoopSceneDef.loopedSceneDef = null;
				StageRegistration.RegisterSceneDefToNormalProgression(TropicsSceneDef, 1f, true, false);
				StageRegistration.RegisterSceneDefToNormalProgression(LoopSceneDef, 1f, false, true);
				Log.Debug("Sunset Tropics and Midnight Tropics registered. Sunset pre-loop, Midnight post-loop");
			}
			else if (Tropics.enableRegular.Value && Tropics.enableVariant.Value && Tropics.loopExclusiveVariant.Value && Tropics.swapVariantPlaces.Value)
			{
				LoopSceneDef.loopedSceneDef = TropicsSceneDef;
				TropicsSceneDef.loopedSceneDef = null;
				StageRegistration.RegisterSceneDefToNormalProgression(TropicsSceneDef, 1f, false, true);
				StageRegistration.RegisterSceneDefToNormalProgression(LoopSceneDef, 1f, true, false);
				Log.Debug("Sunset Tropics and Midnight Tropics registered. Midnight pre-loop, Sunset post-loop");
			}
			else if (Tropics.enableRegular.Value && Tropics.enableVariant.Value && !Tropics.loopExclusiveVariant.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(TropicsSceneDef, 0.5f, true, true);
				StageRegistration.RegisterSceneDefToNormalProgression(LoopSceneDef, 0.5f, true, true);
				Log.Debug("Sunset Tropics and Midnight Tropics registered. Both stages appear pre & post loop (weight halved)");
			}
			else if (Tropics.enableRegular.Value && !Tropics.enableVariant.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(TropicsSceneDef, 1f, true, true);
				Log.Debug("Sunset Tropics registered only");
			}
			else if (!Tropics.enableRegular.Value && Tropics.enableVariant.Value)
			{
				StageRegistration.RegisterSceneDefToNormalProgression(LoopSceneDef, 1f, true, true);
				Log.Debug("Midnight Tropics registered only");
			}
			if (Tropics.enableSimulacrum.Value && Tropics.simulacrumStage1.Value)
			{
				Simulacrum.RegisterSceneToSimulacrum(simuSceneDef);
			}
			else if (Tropics.enableSimulacrum.Value && !Tropics.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());
		}
	}
	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 (Tropics.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 (Tropics.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);
			}
		}
	}
}