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 ShopLoaderAPI v1.2.2
EmpressShopAPI.dll
Decompiled 2 weeks 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("EmpressShopAPI")] [assembly: AssemblyTitle("EmpressShopAPI")] [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_ShopLoaderAPI { [BepInPlugin("com.Empress.ShopAPI", "Empress Shop Loader API", "1.0.0")] public class ShopLoaderPlugin : BaseUnityPlugin { internal class ShopEntry { public GameObject Prefab; public string ResourcePath; public ConfigEntry<bool> EnabledConfig; } internal static ShopLoaderPlugin Instance; internal static List<ShopEntry> RegisteredShops = new List<ShopEntry>(); internal static ConfigEntry<bool> IncludeVanillaShop; private void Awake() { Instance = this; IncludeVanillaShop = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IncludeVanillaShop", true, "Allow the base game shop to be selected."); Harmony.CreateAndPatchAll(typeof(LevelGeneratorPatch), (string)null); } } public static class ShopAPI { public static void RegisterShop(GameObject shopPrefab, string uniqueResourcePath) { if (!((Object)(object)shopPrefab == (Object)null) && !((Object)(object)ShopLoaderPlugin.Instance == (Object)null)) { Object.DontDestroyOnLoad((Object)(object)shopPrefab); ((Object)shopPrefab).hideFlags = (HideFlags)32; ConfigEntry<bool> enabledConfig = ((BaseUnityPlugin)ShopLoaderPlugin.Instance).Config.Bind<bool>("Registered Shops", uniqueResourcePath, true, "Enable the " + uniqueResourcePath + " shop."); ShopLoaderPlugin.RegisteredShops.Add(new ShopLoaderPlugin.ShopEntry { Prefab = shopPrefab, ResourcePath = uniqueResourcePath, EnabledConfig = enabledConfig }); } } } [HarmonyPatch(typeof(LevelGenerator), "Start")] public static class LevelGeneratorPatch { private static bool _captured; private static List<PrefabRef> _startRooms; private static List<PrefabRef> _modulesNormal1; private static List<PrefabRef> _modulesNormal2; private static List<PrefabRef> _modulesNormal3; private static void Postfix(LevelGenerator __instance) { //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown if (!SemiFunc.RunIsShop()) { return; } RunManager instance = RunManager.instance; Level levelCurrent = instance.levelCurrent; if ((Object)(object)levelCurrent == (Object)null) { return; } if (!_captured) { _captured = true; _startRooms = new List<PrefabRef>(levelCurrent.StartRooms); _modulesNormal1 = new List<PrefabRef>(levelCurrent.ModulesNormal1); _modulesNormal2 = new List<PrefabRef>(levelCurrent.ModulesNormal2); _modulesNormal3 = new List<PrefabRef>(levelCurrent.ModulesNormal3); } List<ShopLoaderPlugin.ShopEntry> list = ShopLoaderPlugin.RegisteredShops.Where((ShopLoaderPlugin.ShopEntry x) => x.EnabledConfig.Value).ToList(); bool flag = ShopLoaderPlugin.IncludeVanillaShop != null && ShopLoaderPlugin.IncludeVanillaShop.Value; int num = list.Count + (flag ? 1 : 0); if (num == 0) { return; } int num2 = Random.Range(0, num); if (flag && num2 == 0) { levelCurrent.StartRooms.Clear(); levelCurrent.StartRooms.AddRange(_startRooms); levelCurrent.ModulesNormal1.Clear(); levelCurrent.ModulesNormal1.AddRange(_modulesNormal1); levelCurrent.ModulesNormal2.Clear(); levelCurrent.ModulesNormal2.AddRange(_modulesNormal2); levelCurrent.ModulesNormal3.Clear(); levelCurrent.ModulesNormal3.AddRange(_modulesNormal3); return; } ShopLoaderPlugin.ShopEntry shopEntry = list[num2 - (flag ? 1 : 0)]; if (instance.singleplayerPool != null && !instance.singleplayerPool.ContainsKey(shopEntry.ResourcePath)) { instance.singleplayerPool.Add(shopEntry.ResourcePath, shopEntry.Prefab); } DefaultPool multiplayerPool = instance.multiplayerPool; if (multiplayerPool?.ResourceCache != null && !multiplayerPool.ResourceCache.ContainsKey(shopEntry.ResourcePath)) { multiplayerPool.ResourceCache.Add(shopEntry.ResourcePath, shopEntry.Prefab); } Vector3[] value = (Vector3[])(object)new Vector3[1] { Vector3.zero }; AccessTools.Field(typeof(LevelGenerator), "ModuleRotations").SetValue(__instance, value); PrefabRef val = new PrefabRef(); AccessTools.Field(typeof(PrefabRef), "prefabName").SetValue(val, ((Object)shopEntry.Prefab).name); AccessTools.Field(typeof(PrefabRef), "resourcePath").SetValue(val, shopEntry.ResourcePath); levelCurrent.StartRooms.Clear(); levelCurrent.StartRooms.Add(val); levelCurrent.ModulesNormal1.Clear(); levelCurrent.ModulesNormal2.Clear(); levelCurrent.ModulesNormal3.Clear(); } } }