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 CommandChests v0.1.0
plugins\CommandChests.dll
Decompiled 14 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CommandChests")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ac1218504b01ead5c804ffca609e7e8f3c134dce")] [assembly: AssemblyProduct("CommandChests")] [assembly: AssemblyTitle("CommandChests")] [assembly: AssemblyVersion("1.0.0.0")] [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 CommandChests { internal static class CommandChestsArtifact { internal const string NameToken = "COMMANDCHESTS_ARTIFACT_NAME"; internal const string DescToken = "COMMANDCHESTS_ARTIFACT_DESC"; internal static ArtifactDef Def { get; private set; } internal static bool Enabled { get { if ((Object)(object)Def != (Object)null && (Object)(object)RunArtifactManager.instance != (Object)null) { return RunArtifactManager.instance.IsArtifactEnabled(Def); } return false; } } public static void Init() { //IL_002d: 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) LanguageAPI.Add("COMMANDCHESTS_ARTIFACT_NAME", "Artifact of Choice"); LanguageAPI.Add("COMMANDCHESTS_ARTIFACT_DESC", "Chests are replaced with multishop terminals, and each terminal rolls its tier independently."); Sprite val = Textures.SolidSprite(new Color(0.95f, 0.75f, 0.2f)); Sprite smallIconDeselectedSprite = Textures.SolidSprite(new Color(0.3f, 0.3f, 0.32f)); _ = val.texture; Def = ScriptableObject.CreateInstance<ArtifactDef>(); Def.cachedName = "ArtifactOfChoice"; Def.nameToken = "COMMANDCHESTS_ARTIFACT_NAME"; Def.descriptionToken = "COMMANDCHESTS_ARTIFACT_DESC"; Def.smallIconSelectedSprite = val; Def.smallIconDeselectedSprite = smallIconDeselectedSprite; if (!ContentAddition.AddArtifactDef(Def)) { Plugin.Log.LogError((object)"Failed to add ArtifactDef via R2API.ContentAddition."); return; } ArtifactCodeAPI.AddCode(Def, (IEnumerable<int>)new List<int> { 3, 11, 3, 11, 5, 11, 7, 1, 7 }); } } internal static class MultiShopCards { private const string SmallPath = "RoR2/Base/TripleShop/iscTripleShop.asset"; private const string LargePath = "RoR2/Base/TripleShopLarge/iscTripleShopLarge.asset"; private const string EquipmentPath = "RoR2/Base/TripleShopEquipment/iscTripleShopEquipment.asset"; public static InteractableSpawnCard? Small { get; private set; } public static InteractableSpawnCard? Large { get; private set; } public static InteractableSpawnCard? Equipment { get; private set; } public static bool Ready { get { if ((Object)(object)Small != (Object)null && (Object)(object)Large != (Object)null) { return (Object)(object)Equipment != (Object)null; } return false; } } public static void StartLoad() { Load("RoR2/Base/TripleShop/iscTripleShop.asset", delegate(InteractableSpawnCard c) { Small = c; }); Load("RoR2/Base/TripleShopLarge/iscTripleShopLarge.asset", delegate(InteractableSpawnCard c) { Large = c; }); Load("RoR2/Base/TripleShopEquipment/iscTripleShopEquipment.asset", delegate(InteractableSpawnCard c) { Equipment = c; }); } private static void Load(string path, Action<InteractableSpawnCard> assign) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Action<InteractableSpawnCard> assign2 = assign; string path2 = path; AsyncOperationHandle<InteractableSpawnCard> val = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)path2); val.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> handle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)handle.Status == 1 && (Object)(object)handle.Result != (Object)null) { assign2(handle.Result); } else { Plugin.Log.LogError((object)("Failed to load multishop spawn card '" + path2 + "'.")); } }; } } internal static class MultiShopHook { [CompilerGenerated] private static class <>O { public static hook_Start <0>__ShopTerminalBehavior_Start; } public static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ShopTerminalBehavior_Start; if (obj == null) { hook_Start val = ShopTerminalBehavior_Start; <>O.<0>__ShopTerminalBehavior_Start = val; obj = (object)val; } ShopTerminalBehavior.Start += (hook_Start)obj; } private static void ShopTerminalBehavior_Start(orig_Start orig, ShopTerminalBehavior self) { //IL_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (NetworkServer.active && CommandChestsArtifact.Enabled && !((Object)(object)self == (Object)null)) { MultiShopController serverMultiShopController = self.serverMultiShopController; if (!((Object)(object)serverMultiShopController == (Object)null) && !serverMultiShopController.doEquipmentInstead) { ItemTier itemTier = RollPerTerminalTier(serverMultiShopController); self.itemTier = itemTier; self.GenerateNewPickupServer(); } } } private static ItemTier RollPerTerminalTier(MultiShopController controller) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0047: Unknown result type (might be due to invalid IL or missing references) float value = Random.value; ItemTier itemTier = controller.itemTier; if ((int)itemTier != 0) { if ((int)itemTier == 1) { return (ItemTier)((!(value < 0.2f)) ? ((value < 0.9f) ? 1 : 2) : 0); } return controller.itemTier; } return (ItemTier)((!(value < 0.8f)) ? ((value < 0.98f) ? 1 : 2) : 0); } } [BepInPlugin("com.zhait.commandchests", "CommandChests", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.zhait.commandchests"; public const string PluginName = "CommandChests"; public const string PluginVersion = "0.1.0"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; MultiShopCards.StartLoad(); CommandChestsArtifact.Init(); SceneDirectorHook.Init(); MultiShopHook.Init(); Log.LogInfo((object)"CommandChests 0.1.0 loaded."); } } internal static class SceneDirectorHook { public static void Init() { SceneDirector.onGenerateInteractableCardSelection += OnGenerate; } private static void OnGenerate(SceneDirector _, DirectorCardCategorySelection dccs) { if (!NetworkServer.active || !CommandChestsArtifact.Enabled) { return; } if (!MultiShopCards.Ready) { Plugin.Log.LogWarning((object)"Multishop spawn cards not loaded yet; leaving scene director untouched."); return; } for (int i = 0; i < dccs.categories.Length; i++) { ref Category reference = ref dccs.categories[i]; for (int j = 0; j < reference.cards.Length; j++) { DirectorCard val = reference.cards[j]; if (val != null && !((Object)(object)val.spawnCard == (Object)null)) { InteractableSpawnCard val2 = ReplacementFor(((Object)val.spawnCard).name); if ((Object)(object)val2 != (Object)null) { val.spawnCard = (SpawnCard)(object)val2; } } } } } private static InteractableSpawnCard? ReplacementFor(string spawnCardName) { if (spawnCardName != null) { int length = spawnCardName.Length; if (length <= 12) { if (length != 9) { if (length == 12 && spawnCardName == "iscGoldChest") { goto IL_0104; } } else { char c = spawnCardName[8]; if (c != '1') { if (c == '2' && spawnCardName == "iscChest2") { goto IL_0104; } } else if (spawnCardName == "iscChest1") { goto IL_00fc; } } } else if (length != 18) { if (length != 22) { if (length == 23) { char c = spawnCardName[16]; if (c != 'H') { if (c == 'U' && spawnCardName == "iscCategoryChestUtility") { goto IL_0104; } } else if (spawnCardName == "iscCategoryChestHealing") { goto IL_0104; } } } else if (spawnCardName == "iscCategoryChestDamage") { goto IL_0104; } } else { char c = spawnCardName[3]; if (c != 'C') { if (c == 'E' && spawnCardName == "iscEquipmentBarrel") { return MultiShopCards.Equipment; } } else if (spawnCardName == "iscChest1Stealthed") { goto IL_00fc; } } } return null; IL_00fc: return MultiShopCards.Small; IL_0104: return MultiShopCards.Large; } } internal static class Textures { public static Sprite SolidSprite(Color color, int size = 128) { //IL_0004: 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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0063: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < array.Length; i++) { array[i] = color; } val.SetPixels(array); val.Apply(false); return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f)); } } }