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 R2API Stages v1.0.3
plugins/R2API.Stages/R2API.Stages.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HG; using HG.Reflection; using Microsoft.CodeAnalysis; using R2API.AutoVersionGen; using R2API.ContentManagement; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("R2API.Stages")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3+9d1b6706f1d4ea7959a4ff7f93cfa08d8c13ead6")] [assembly: AssemblyProduct("R2API.Stages")] [assembly: AssemblyTitle("R2API.Stages")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } } namespace R2API { [AutoVersion] public static class StageRegistration { public const string PluginGUID = "com.bepis.r2api.stages"; public const string PluginName = "R2API.Stages"; public const float defaultWeight = 1f; private static Dictionary<string, List<SceneDef>> privateStageVariantDictionary = new Dictionary<string, List<SceneDef>>(); public static ReadOnlyDictionary<string, List<SceneDef>> stageVariantDictionary; private static List<SceneCollection> preLoopSceneCollections = new List<SceneCollection>(); private static List<SceneCollection> postLoopSceneCollections = new List<SceneCollection>(); private static int numStageCollections = 5; private static Material baseBazaarSeerMaterial; private static bool _hooksEnabled = false; private static bool _sceneCatalogInitialized = false; public const string PluginVersion = "1.0.3"; [SystemInitializer(new Type[] { typeof(SceneCatalog) })] private static void SystemInit() { //IL_0014: 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_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_0026: Unknown result type (might be due to invalid IL or missing references) //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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) foreach (SceneCollection preLoopSceneCollection in preLoopSceneCollections) { Enumerator<SceneEntry> enumerator2 = preLoopSceneCollection.sceneEntries.GetEnumerator(); try { while (enumerator2.MoveNext()) { SceneDef sceneDef = enumerator2.Current.sceneDef; if (!privateStageVariantDictionary.ContainsKey(sceneDef.baseSceneName) || !privateStageVariantDictionary[sceneDef.baseSceneName].Contains(sceneDef)) { AddSceneOrVariant(sceneDef); } } } finally { ((IDisposable)enumerator2).Dispose(); } } foreach (SceneCollection postLoopSceneCollection in postLoopSceneCollections) { Enumerator<SceneEntry> enumerator2 = postLoopSceneCollection.sceneEntries.GetEnumerator(); try { while (enumerator2.MoveNext()) { SceneDef sceneDef2 = enumerator2.Current.sceneDef; if (!privateStageVariantDictionary.ContainsKey(sceneDef2.baseSceneName) || !privateStageVariantDictionary[sceneDef2.baseSceneName].Contains(sceneDef2)) { AddSceneOrVariant(sceneDef2); } } } finally { ((IDisposable)enumerator2).Dispose(); } } RefreshPublicDictionary(); _sceneCatalogInitialized = true; } internal static void SetHooks() { //IL_0022: 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_0051: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (!_hooksEnabled) { for (int i = 1; i <= numStageCollections; i++) { SceneCollection item = Addressables.LoadAssetAsync<SceneCollection>((object)("RoR2/Base/SceneGroups/sgStage" + i + ".asset")).WaitForCompletion(); preLoopSceneCollections.Add(item); item = Addressables.LoadAssetAsync<SceneCollection>((object)("RoR2/Base/SceneGroups/loopSgStage" + i + ".asset")).WaitForCompletion(); postLoopSceneCollections.Add(item); } baseBazaarSeerMaterial = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/bazaar/matBazaarSeerWispgraveyard.mat").WaitForCompletion(); _hooksEnabled = true; } } internal static void UnsetHooks() { preLoopSceneCollections.Clear(); _hooksEnabled = false; } public static void AddSceneDef(SceneDef sceneDef, PluginInfo plugin) { SetHooks(); AddSceneDefInternal(sceneDef, ((object)plugin.Instance).GetType().Assembly); } internal static void AddSceneDefInternal(SceneDef sceneDef, Assembly addingAssembly) { R2APIContentManager.HandleContentAddition(addingAssembly, (Object)(object)sceneDef); } public static void PrintSceneCollections() { //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_0051: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) SetHooks(); if (!_sceneCatalogInitialized) { StagesPlugin.Logger.LogDebug((object)"This log is printed before the SceneCatalog is initialized. Some results may not be accurate."); } for (int i = 1; i <= numStageCollections; i++) { StagesPlugin.Logger.LogDebug((object)$"Stage {i}"); Enumerator<SceneEntry> enumerator = preLoopSceneCollections[i - 1].sceneEntries.GetEnumerator(); try { while (enumerator.MoveNext()) { SceneEntry current = enumerator.Current; StagesPlugin.Logger.LogDebug((object)$"{current.sceneDef.cachedName}, baseSceneName: {current.sceneDef.baseSceneName}, Weight: {((SceneEntry)(ref current)).weight}"); } } finally { ((IDisposable)enumerator).Dispose(); } } } public static void PrintSceneCollections(int stageNumber) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) SetHooks(); if (!_sceneCatalogInitialized) { StagesPlugin.Logger.LogDebug((object)"This log is printed before the SceneCatalog is initialized. Some results may not be accurate."); } StagesPlugin.Logger.LogDebug((object)$"Stage {stageNumber}"); Enumerator<SceneEntry> enumerator = preLoopSceneCollections[stageNumber - 1].sceneEntries.GetEnumerator(); try { while (enumerator.MoveNext()) { SceneEntry current = enumerator.Current; StagesPlugin.Logger.LogDebug((object)$"{current.sceneDef.cachedName}, baseSceneName: {current.sceneDef.baseSceneName}, Weight: {((SceneEntry)(ref current)).weight}"); } } finally { ((IDisposable)enumerator).Dispose(); } } public static void PrintSceneVariants(string key) { if (!stageVariantDictionary.ContainsKey(key)) { StagesPlugin.Logger.LogError((object)("Entry " + key + " doesn't exist or isn't populated yet in the dictionary.")); return; } if (!_sceneCatalogInitialized) { StagesPlugin.Logger.LogDebug((object)"This log is printed before the SceneCatalog is initialized. Some results may not be accurate."); } SetHooks(); foreach (SceneDef item in stageVariantDictionary[key]) { StagesPlugin.Logger.LogDebug((object)(item.cachedName + ", baseSceneName: " + item.baseSceneName)); } } [Obsolete] public static void RegisterSceneDefToLoop(SceneDef sceneDef) { SetHooks(); if (privateStageVariantDictionary.ContainsKey(sceneDef.baseSceneName) && privateStageVariantDictionary[sceneDef.baseSceneName].Contains(sceneDef)) { StagesPlugin.Logger.LogError((object)("SceneDef " + sceneDef.cachedName + " is already registered into the Scene Pool")); return; } if (sceneDef.stageOrder < 1 || sceneDef.stageOrder > numStageCollections) { StagesPlugin.Logger.LogError((object)$"SceneDef {sceneDef.cachedName} has a stage order not within 1-{numStageCollections}. Please use this method only for stages within the loop."); return; } AddSceneOrVariant(sceneDef); AppendSceneCollections(sceneDef, 1f, preLoop: true, postLoop: true); RefreshPublicDictionary(); } public static void RegisterSceneDefToNormalProgression(SceneDef sceneDef, float weight = 1f, bool preLoop = true, bool postLoop = true) { SetHooks(); if (privateStageVariantDictionary.ContainsKey(sceneDef.baseSceneName) && privateStageVariantDictionary[sceneDef.baseSceneName].Contains(sceneDef)) { StagesPlugin.Logger.LogError((object)("SceneDef " + sceneDef.cachedName + " is already registered into the Scene Pool")); return; } if (sceneDef.stageOrder < 1 || sceneDef.stageOrder > numStageCollections) { StagesPlugin.Logger.LogError((object)$"SceneDef {sceneDef.cachedName} has a stage order not within 1-{numStageCollections}. Please use this method only for stages within the loop."); return; } AddSceneOrVariant(sceneDef); AppendSceneCollections(sceneDef, weight, preLoop, postLoop); RefreshPublicDictionary(); } public static Material MakeBazaarSeerMaterial(Texture2D texture) { SetHooks(); Material obj = Object.Instantiate<Material>(baseBazaarSeerMaterial); obj.mainTexture = (Texture)(object)texture; return obj; } public static Material MakeBazaarSeerMaterial(SceneDef sceneDef) { //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) SetHooks(); if ((Object)(object)sceneDef.previewTexture == (Object)null && sceneDef.previewTextureReference == null) { StagesPlugin.Logger.LogError((object)("SceneDef " + sceneDef.cachedName + " does not have a preview texture.")); return null; } Texture mainTexture = ((!Object.op_Implicit((Object)(object)sceneDef.previewTexture)) ? ((AssetReference)sceneDef.previewTextureReference).LoadAssetAsync<Texture>().WaitForCompletion() : sceneDef.previewTexture); Material obj = Object.Instantiate<Material>(baseBazaarSeerMaterial); obj.mainTexture = mainTexture; return obj; } private static void AddSceneOrVariant(SceneDef sceneDef) { if (privateStageVariantDictionary.ContainsKey(sceneDef.baseSceneName)) { privateStageVariantDictionary[sceneDef.baseSceneName].Add(sceneDef); return; } List<SceneDef> list = new List<SceneDef>(); list.Add(sceneDef); privateStageVariantDictionary.Add(sceneDef.baseSceneName, list); } private static void AppendSceneCollections(SceneDef sceneDef, float weight, bool preLoop, bool postLoop) { //IL_001e: 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) int num = sceneDef.stageOrder - 1; if (preLoop) { ref SceneEntry[] sceneEntries = ref preLoopSceneCollections[num]._sceneEntries; SceneEntry val = new SceneEntry { sceneDef = sceneDef, weightMinusOne = weight - 1f }; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref val); } if (postLoop) { ref SceneEntry[] sceneEntries2 = ref postLoopSceneCollections[num]._sceneEntries; SceneEntry val = new SceneEntry { sceneDef = sceneDef, weightMinusOne = weight - 1f }; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref val); } sceneDef.destinationsGroup = preLoopSceneCollections[(num + 1) % numStageCollections]; sceneDef.loopedDestinationsGroup = postLoopSceneCollections[(num + 1) % numStageCollections]; } private static void RefreshPublicDictionary() { stageVariantDictionary = new ReadOnlyDictionary<string, List<SceneDef>>(privateStageVariantDictionary); } } [BepInPlugin("com.bepis.r2api.stages", "R2API.Stages", "1.0.3")] public sealed class StagesPlugin : BaseUnityPlugin { internal static ManualLogSource Logger { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; StageRegistration.SetHooks(); } private void OnDestroy() { StageRegistration.UnsetHooks(); } } } namespace R2API.AutoVersionGen { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] internal class AutoVersionAttribute : Attribute { } }