Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Desolate Coast v1.0.0
Plugins/Desolate_Coast.dll
Decompiled 17 hours agousing 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 DesolateCoast.Content; using EnemiesReturns.Configuration; using EnemiesReturns.Enemies.SandCrab; using HG; using HG.Reflection; using R2API; using RoR2; using RoR2.ContentManagement; 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 ReplaceShaders : MonoBehaviour { } namespace DesolateCoast { [BepInPlugin("wormsworms.Desolate_Coast", "Desolate_Coast", "1.0.0")] public class DesolateCoast : BaseUnityPlugin { public const string Author = "wormsworms"; public const string Name = "Desolate_Coast"; public const string Version = "1.0.0"; public const string GUID = "wormsworms.Desolate_Coast"; public static DesolateCoast instance; public static ConfigEntry<bool> enableRegular; public static ConfigEntry<bool> enableSimulacrum; public static ConfigEntry<bool> stage1Simulacrum; public static ConfigEntry<bool> toggleSandCrab; public static ConfigEntry<bool> toggleWayfarer; public const string mapName = "coast_wormsworms"; public const string simuName = "itcoast_wormsworms"; private static GameObject fanPrefab; private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown instance = this; Log.Init(((BaseUnityPlugin)this).Logger); ConfigSetup(); ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(GiveToRoR2OurContentPackProviders); Language.collectLanguageRootFolders += CollectLanguageRootFolders; SceneManager.sceneLoaded += SceneSetup; RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(AddModdedEnemies)); } 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 CoastAmbienceSetup() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Ambience"); if (Object.op_Implicit((Object)(object)val)) { AkBank component = val.GetComponent<AkBank>(); AkAmbient[] components = val.GetComponents<AkAmbient>(); AkAmbient val2 = components[0]; AkAmbient val3 = components[1]; if (Object.op_Implicit((Object)(object)component)) { WwiseBankReference wwiseObjectReference = Addressables.LoadAssetAsync<WwiseBankReference>((object)"Wwise/8AC8A9CB-604F-43BC-A864-873DC735786F.asset").WaitForCompletion(); WwiseEventReference wwiseObjectReference2 = Addressables.LoadAssetAsync<WwiseEventReference>((object)"Wwise/6C9A5B06-3C87-4DD2-835F-B0F2385B7700.asset").WaitForCompletion(); WwiseEventReference wwiseObjectReference3 = Addressables.LoadAssetAsync<WwiseEventReference>((object)"Wwise/6F2ADD1C-BD55-431F-A62F-80CCD5F9631D.asset").WaitForCompletion(); component.data.WwiseObjectReference = wwiseObjectReference; ((AkEvent)val2).data.WwiseObjectReference = wwiseObjectReference2; ((AkEvent)val3).data.WwiseObjectReference = wwiseObjectReference3; } } else { Log.Error("no ambience :("); } } private void SceneSetup(Scene newScene, LoadSceneMode loadSceneMode) { if (((Scene)(ref newScene)).name == "coast_wormsworms" || ((Scene)(ref newScene)).name == "itcoast_wormsworms") { CoastAmbienceSetup(); Transform transform = GameObject.Find("HOLDER: Geysers").transform; for (int i = 0; i < transform.childCount; i++) { GameObject gameObject = ((Component)transform.GetChild(i).GetChild(0).GetChild(0)).gameObject; GameObject gameObject2 = ((Component)transform.GetChild(i).GetChild(0).GetChild(1)).gameObject; ((Renderer)gameObject.GetComponent<MeshRenderer>()).material = DesolateCoastContent.terrainMaterial; ((Renderer)gameObject2.GetComponent<MeshRenderer>()).material = DesolateCoastContent.terrainMaterial; } Transform transform2 = GameObject.Find("HOLDER: Random/Spires/Geyser").transform; GameObject gameObject3 = ((Component)transform2.GetChild(0).GetChild(0)).gameObject; GameObject gameObject4 = ((Component)transform2.GetChild(0).GetChild(1)).gameObject; ((Renderer)gameObject3.GetComponent<MeshRenderer>()).material = DesolateCoastContent.terrainMaterial; ((Renderer)gameObject4.GetComponent<MeshRenderer>()).material = DesolateCoastContent.terrainMaterial; } } private void ConfigSetup() { enableRegular = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Stages", "Enable Desolate Coast", true, "If true, Desolate Coast can appear in regular runs."); enableSimulacrum = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Stages", "Enable Simulacrum Variant", true, "If true, Desolate Coast can appear in the Simulacrum."); stage1Simulacrum = ((BaseUnityPlugin)this).Config.Bind<bool>("00 - Stages", "Enable Simulacrum Variant on Stage 1", false, "If false, Desolate Coast will only appear after clearing at least one stage in the Simulacrum, like Commencement."); toggleSandCrab = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - Monsters: EnemiesReturns", "Enable Sand Crab", true, "If true, Sand Crabs will appear in Desolate Coast."); toggleWayfarer = ((BaseUnityPlugin)this).Config.Bind<bool>("03 - Monsters: Starstorm 2", "Enable Wayfarer", true, "If true, Wayfarers will appear in Desolate Coast."); } } 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 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 IsForgottenRelics { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("PlasmaCore.ForgottenRelics"); } return _enabled.Value; } } } public class EnemiesReturnsCompat { public static void AddEnemies() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown if (DesolateCoast.toggleSandCrab.Value && General.EnableSandCrab.Value) { DirectorCard card = new DirectorCard { spawnCard = (SpawnCard)SpawnCards.cscSandCrabDefault, spawnDistance = (MonsterSpawnDistance)0, selectionWeight = SandCrab.SelectionWeight.Value, minimumStageCompletions = SandCrab.MinimumStageCompletion.Value }; DirectorCardHolder val = new DirectorCardHolder { Card = card, MonsterCategory = (MonsterCategory)3 }; if (!SandCrab.DefaultStageList.Value.Contains("coast_wormsworms")) { Helpers.AddNewMonsterToStage(val, false, (Stage)1, "coast_wormsworms"); Log.Info("Sand Crab added to Desolate Coast's spawn pool."); } if (!SandCrab.DefaultStageList.Value.Contains("itcoast_wormsworms")) { Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itcoast_wormsworms"); Log.Info("Sand Crab added to Desolate Coast's simulacrum 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 string text = FindEnemyConfig("Lamp Boss"); if (DesolateCoast.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, "coast_wormsworms"); Helpers.AddNewMonsterToStage(val, false, (Stage)1, "itcoast_wormsworms"); Log.Info("Wayfarer added to Desolate Coast's spawn pool."); } } } } namespace DesolateCoast.Content { public static class DesolateCoastContent { internal const string ScenesAssetBundleFileName = "coastscenes"; internal const string AssetsAssetBundleFileName = "coastassets"; private static AssetBundle _scenesAssetBundle; private static AssetBundle _assetsAssetBundle; internal static UnlockableDef[] UnlockableDefs; internal static SceneDef[] SceneDefs; internal static SceneDef coastSceneDef; internal static Sprite coastSceneDefPreviewSprite; internal static Material coastBazaarSeer; internal static SceneDef simuSceneDef; internal static Sprite simuSceneDefPreviewSprite; internal static Material simuBazaarSeer; internal static Material terrainMaterial; internal static Material itTerrainMaterial; 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<Material>(_assetsAssetBundle, progress, (Action<Material[]>)delegate(Material[] assets) { terrainMaterial = assets.First((Material a) => ((Object)a).name == "matCoastTerrain"); itTerrainMaterial = assets.First((Material a) => ((Object)a).name == "matITCoastTerrain"); }); yield return LoadAllAssetsAsync<SceneDef>(_assetsAssetBundle, progress, (Action<SceneDef[]>)delegate(SceneDef[] assets) { SceneDefs = assets; coastSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "coast_wormsworms"); simuSceneDef = SceneDefs.First((SceneDef sd) => sd.baseSceneNameOverride == "itcoast_wormsworms"); Log.Debug(coastSceneDef.nameToken); contentPack.sceneDefs.Add(assets); }); coastSceneDef.portalMaterial = StageRegistration.MakeBazaarSeerMaterial((Texture2D)coastSceneDef.previewTexture); AsyncOperationHandle<MusicTrackDef> mainTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/Base/Common/MusicTrackDefs/muFULLSong07.asset"); while (!mainTrackDefRequest.IsDone) { yield return null; } AsyncOperationHandle<MusicTrackDef> bossTrackDefRequest = Addressables.LoadAssetAsync<MusicTrackDef>((object)"RoR2/DLC2/Common/muSong_Lakes&HabitatBoss.asset"); while (!bossTrackDefRequest.IsDone) { yield return null; } coastSceneDef.mainTrack = mainTrackDefRequest.Result; coastSceneDef.bossTrack = bossTrackDefRequest.Result; simuSceneDef.mainTrack = coastSceneDef.mainTrack; simuSceneDef.bossTrack = coastSceneDef.bossTrack; if (DesolateCoast.enableRegular.Value) { StageRegistration.RegisterSceneDefToNormalProgression(coastSceneDef, 1f, true, true); } if (DesolateCoast.enableSimulacrum.Value && DesolateCoast.stage1Simulacrum.Value) { Simulacrum.RegisterSceneToSimulacrum(simuSceneDef); } else if (DesolateCoast.enableSimulacrum.Value && !DesolateCoast.stage1Simulacrum.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 ContentProvider : IContentPackProvider { private readonly ContentPack _contentPack = new ContentPack(); public static string assetDirectory; public string identifier => "wormsworms.Desolate_Coast.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, "coastscenes"), args.progressReceiver, delegate(AssetBundle assetBundle) { scenesAssetBundle = assetBundle; }); AssetBundle assetsAssetBundle = null; yield return LoadAssetBundle(Path.Combine(assetsFolderFullPath, "coastassets"), args.progressReceiver, delegate(AssetBundle assetBundle) { assetsAssetBundle = assetBundle; }); yield return DesolateCoastContent.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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //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_0087: 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 ((Object)(object)current.sceneDef == (Object)(object)sceneDef) { Log.Error("SceneDef " + sceneDef.cachedName + " is already registered into the Simulacrum"); return; } if (current.sceneDef.hasAnyDestinations) { list.Add(current.sceneDef.destinationsGroup); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } SceneCollection val3 = ScriptableObject.CreateInstance<SceneCollection>(); ((Object)val3).name = "sgInfiniteTowerStageX" + sceneDef.cachedName; val3._sceneEntries = val._sceneEntries; sceneDef.destinationsGroup = val3; SceneEntry val4 = new SceneEntry { sceneDef = sceneDef, weightMinusOne = weight - 1f }; ArrayUtils.ArrayAppend<SceneEntry>(ref val._sceneEntries, ref val4); if (canBeStage1) { ArrayUtils.ArrayAppend<SceneEntry>(ref val2._sceneEntries, ref val4); } foreach (SceneCollection item in list) { ArrayUtils.ArrayAppend<SceneEntry>(ref item._sceneEntries, ref val4); } } } }