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 Empress ArenaLoaderAPI v1.0.1
EmpressArenaAPI.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7caf00520587bc4705fdf22c05a4ce546279ff19")] [assembly: AssemblyProduct("EmpressArenaAPI")] [assembly: AssemblyTitle("EmpressArenaAPI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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 Empress_ArenaLoaderAPI { [BepInPlugin("com.Empress.ArenaAPI", "Empress Arena Loader API", "1.0.2")] public class ArenaLoaderPlugin : BaseUnityPlugin { internal class ArenaEntry { public GameObject Prefab; public string ResourcePath; public ConfigEntry<bool> EnabledConfig; } internal static ArenaLoaderPlugin Instance; internal static List<ArenaEntry> RegisteredArenas = new List<ArenaEntry>(); private void Awake() { Instance = this; Harmony.CreateAndPatchAll(typeof(LevelGeneratorPatch), (string)null); Harmony.CreateAndPatchAll(typeof(ArenaPatch), (string)null); } } public static class ArenaAPI { public static void RegisterArena(GameObject arenaPrefab, string uniqueResourcePath) { if ((Object)(object)arenaPrefab == (Object)null || (Object)(object)ArenaLoaderPlugin.Instance == (Object)null) { return; } ItemVolume[] componentsInChildren = arenaPrefab.GetComponentsInChildren<ItemVolume>(true); ItemVolume[] array = componentsInChildren; foreach (ItemVolume val in array) { if ((Object)(object)((Component)val).GetComponentInParent<ItemAttributes>() == (Object)null) { Object.DestroyImmediate((Object)(object)val, true); } } Object.DontDestroyOnLoad((Object)(object)arenaPrefab); ((Object)arenaPrefab).hideFlags = (HideFlags)32; ConfigEntry<bool> enabledConfig = ((BaseUnityPlugin)ArenaLoaderPlugin.Instance).Config.Bind<bool>("Registered Arenas", uniqueResourcePath, true, "Enable the " + uniqueResourcePath + " arena."); ArenaLoaderPlugin.RegisteredArenas.Add(new ArenaLoaderPlugin.ArenaEntry { Prefab = arenaPrefab, ResourcePath = uniqueResourcePath, EnabledConfig = enabledConfig }); } } [HarmonyPatch(typeof(LevelGenerator), "Start")] public static class LevelGeneratorPatch { private static void Postfix(LevelGenerator __instance) { //IL_0103: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown if (!SemiFunc.RunIsArena()) { return; } List<ArenaLoaderPlugin.ArenaEntry> list = ArenaLoaderPlugin.RegisteredArenas.Where((ArenaLoaderPlugin.ArenaEntry x) => x.EnabledConfig.Value).ToList(); if (list.Count != 0) { ArenaLoaderPlugin.ArenaEntry arenaEntry = list[Random.Range(0, list.Count)]; RunManager instance = RunManager.instance; if (instance.singleplayerPool != null && !instance.singleplayerPool.ContainsKey(arenaEntry.ResourcePath)) { instance.singleplayerPool.Add(arenaEntry.ResourcePath, arenaEntry.Prefab); } DefaultPool multiplayerPool = instance.multiplayerPool; if (multiplayerPool?.ResourceCache != null && !multiplayerPool.ResourceCache.ContainsKey(arenaEntry.ResourcePath)) { multiplayerPool.ResourceCache.Add(arenaEntry.ResourcePath, arenaEntry.Prefab); } Vector3[] value = (Vector3[])(object)new Vector3[1] { Vector3.zero }; AccessTools.Field(typeof(LevelGenerator), "ModuleRotations").SetValue(__instance, value); Level levelCurrent = instance.levelCurrent; if ((Object)(object)levelCurrent != (Object)null) { PrefabRef val = new PrefabRef(); AccessTools.Field(typeof(PrefabRef), "prefabName").SetValue(val, ((Object)arenaEntry.Prefab).name); AccessTools.Field(typeof(PrefabRef), "resourcePath").SetValue(val, arenaEntry.ResourcePath); levelCurrent.StartRooms.Clear(); levelCurrent.StartRooms.Add(val); levelCurrent.ModulesNormal1.Clear(); levelCurrent.ModulesNormal2.Clear(); levelCurrent.ModulesNormal3.Clear(); } } } } [HarmonyPatch(typeof(Arena))] public static class ArenaPatch { [HarmonyPatch("MusicLogic")] [HarmonyPrefix] private static bool Prefix() { return false; } } }