Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ArtifactOfOrder v1.0.2
plugins/ArtifactOfOrder.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 BepInEx.Logging; using HG.Reflection; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArtifactOfOrder")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ArtifactOfOrder")] [assembly: AssemblyTitle("ArtifactOfOrder")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ArtifactOfOrder { public abstract class ArtifactBase { public ArtifactDef ArtifactDef; public abstract string ArtifactName { get; } public abstract string ArtifactLangTokenName { get; } public abstract string ArtifactDescription { get; } public abstract Sprite ArtifactEnabledIcon { get; } public abstract Sprite ArtifactDisabledIcon { get; } public bool ArtifactEnabled => RunArtifactManager.instance.IsArtifactEnabled(ArtifactDef); public abstract void Init(ConfigFile config); protected void CreateLang() { LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_NAME", ArtifactName); LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION", ArtifactDescription); } protected void CreateArtifact() { ArtifactDef = ScriptableObject.CreateInstance<ArtifactDef>(); ArtifactDef.cachedName = "ARTIFACT_" + ArtifactLangTokenName; ArtifactDef.nameToken = "ARTIFACT_" + ArtifactLangTokenName + "_NAME"; ArtifactDef.descriptionToken = "ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION"; ArtifactDef.smallIconSelectedSprite = ArtifactEnabledIcon; ArtifactDef.smallIconDeselectedSprite = ArtifactDisabledIcon; ContentAddition.AddArtifactDef(ArtifactDef); } public abstract void Hooks(); } internal class ArtifactOfOrder : ArtifactBase { public static ConfigEntry<bool> ShouldPearlsBeSeperate; public static ConfigEntry<bool> ShouldLunarEquipBeSeperate; public static ConfigEntry<bool> OverrideCommandArtifact; public static ConfigEntry<bool> DelusionSlotMachine; public Dictionary<ItemTier, PickupIndex> itemList = new Dictionary<ItemTier, PickupIndex>(); public static List<EquipmentDef> ListOfEliteAspects = new List<EquipmentDef>(); public PickupIndex OrderEquipment; public PickupIndex OrderLunarEquipment; public PickupIndex OrderEliteAspect; public override string ArtifactName => "Artifact of Order"; public override string ArtifactLangTokenName => "ARTIFACT_OF_ORDER"; public override string ArtifactDescription => "All items of the same rarity are the same item."; public override Sprite ArtifactEnabledIcon => Main.mainBundle.LoadAsset<Sprite>("order_enabled.png"); public override Sprite ArtifactDisabledIcon => Main.mainBundle.LoadAsset<Sprite>("order_disabled.png"); public override void Init(ConfigFile config) { CreateConfig(config); CreateLang(); CreateArtifact(); Hooks(); } private void CreateConfig(ConfigFile config) { ShouldPearlsBeSeperate = config.Bind<bool>("Artifact: " + ArtifactName, "Should pearls be sperate:", true, "Should pearls be counted as seperate from boss items?"); ShouldLunarEquipBeSeperate = config.Bind<bool>("Artifact: " + ArtifactName, "Should lunar equipment be sperate:", true, "Should lunar equipment be counted as seperate from regular equipment?"); OverrideCommandArtifact = config.Bind<bool>("Artifact: " + ArtifactName, "Override artifact of command:", false, "Should the artifact of order overwrite the artifact of command?"); DelusionSlotMachine = config.Bind<bool>("Artifact: " + ArtifactName, "Make delusion a slot machine:", false, "Should the three choices in the artifact of delusion all be the same item (with only 1 being correct still)?"); } public override void Hooks() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += new hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(CheckArtifactOfOrder); Run.onRunDestroyGlobal += ResetVars; RunArtifactManager.onArtifactEnabledGlobal += new ArtifactStateChangeDelegate(OnArtifactEnabled); RunArtifactManager.onArtifactDisabledGlobal += new ArtifactStateChangeDelegate(OnArtifactDisabled); } [SystemInitializer(new Type[] { typeof(EliteCatalog) })] private static void CreateAspectList() { EliteDef[] eliteDefs = EliteCatalog.eliteDefs; foreach (EliteDef val in eliteDefs) { ListOfEliteAspects.Add(val.eliteEquipmentDef); } } private void OnArtifactEnabled(RunArtifactManager runArtifactManager, ArtifactDef artifactDef) { if (!((Object)(object)artifactDef != (Object)(object)ArtifactDef) && NetworkServer.active) { SceneDirector.onGenerateInteractableCardSelection += RemoveScrapperAndPrinter; } } private void OnArtifactDisabled(RunArtifactManager runArtifactManager, ArtifactDef artifactDef) { if (!((Object)(object)artifactDef != (Object)(object)ArtifactDef)) { SceneDirector.onGenerateInteractableCardSelection += RemoveScrapperAndPrinter; } } private void ResetVars(Run run) { itemList.Clear(); } private void RemoveScrapperAndPrinter(SceneDirector SceneDirector, DirectorCardCategorySelection dccs) { dccs.RemoveCardsThatFailFilter((Predicate<DirectorCard>)ChangesItem); } internal static bool ChangesItem(DirectorCard card) { return !Object.op_Implicit((Object)(object)card.GetSpawnCard().prefab.GetComponent<ShopTerminalBehavior>()) && !Object.op_Implicit((Object)(object)card.GetSpawnCard().prefab.GetComponent<ScrapperController>()); } private void CheckArtifactOfOrder(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_002c: 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_003e: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && base.ArtifactEnabled) { if (pickupInfo.pickerOptions != null) { for (int i = 0; i < pickupInfo.pickerOptions.Length; i++) { PickupIndex pickupIndex = pickupInfo.pickerOptions[i].pickupIndex; PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); AddReplaceItem(ref pickupIndex, ref pickupDef); pickupInfo.pickerOptions[i].pickupIndex = pickupIndex; } } else { PickupIndex pickupIndex2 = ((CreatePickupInfo)(ref pickupInfo)).pickupIndex; PickupDef pickupDef2 = PickupCatalog.GetPickupDef(pickupIndex2); AddReplaceItem(ref pickupIndex2, ref pickupDef2); ((CreatePickupInfo)(ref pickupInfo)).pickupIndex = pickupIndex2; } } orig.Invoke(pickupInfo, position, velocity); } private void AddReplaceItem(ref PickupIndex pickupIndex, ref PickupDef pickupDef) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 //IL_0030: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Invalid comparison between Unknown and I4 //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Invalid comparison between Unknown and I4 //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Invalid comparison between Unknown and I4 //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Invalid comparison between Unknown and I4 //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Invalid comparison between Unknown and I4 //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) PickupIndex val; if (itemList.ContainsKey(pickupDef.itemTier) && (int)pickupDef.itemTier != 5) { val = pickupIndex; string? text = ((object)(PickupIndex)(ref val)).ToString(); val = itemList[pickupDef.itemTier]; Log.Info("Converting " + text + " to " + ((object)(PickupIndex)(ref val)).ToString()); pickupIndex = itemList[pickupDef.itemTier]; } else if ((int)pickupDef.itemTier != 5) { string? text2 = ((object)(ItemTier)(ref pickupDef.itemTier)).ToString(); val = pickupIndex; Log.Info(text2 + " added as " + ((object)(PickupIndex)(ref val)).ToString()); itemList.Add(pickupDef.itemTier, pickupIndex); } else if ((int)pickupDef.itemTier == 5 && (int)pickupDef.equipmentIndex != -1) { if (ListOfEliteAspects.Contains(EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex))) { if ((int)PickupCatalog.GetPickupDef(OrderEliteAspect).equipmentIndex != -1) { val = pickupIndex; string? text3 = ((object)(PickupIndex)(ref val)).ToString(); val = OrderEliteAspect; Log.Info("Converting " + text3 + " to " + ((object)(PickupIndex)(ref val)).ToString()); pickupIndex = OrderEliteAspect; } else { val = pickupIndex; Log.Info("Elite aspect added as " + ((object)(PickupIndex)(ref val)).ToString()); OrderEliteAspect = pickupIndex; } } else if (pickupDef.isLunar) { if ((int)PickupCatalog.GetPickupDef(OrderLunarEquipment).equipmentIndex != -1) { val = pickupIndex; string? text4 = ((object)(PickupIndex)(ref val)).ToString(); val = OrderLunarEquipment; Log.Info("Converting " + text4 + " to " + ((object)(PickupIndex)(ref val)).ToString()); pickupIndex = OrderLunarEquipment; } else { val = pickupIndex; Log.Info("Lunar equipment added as " + ((object)(PickupIndex)(ref val)).ToString()); OrderLunarEquipment = pickupIndex; } } else if ((int)PickupCatalog.GetPickupDef(OrderEquipment).equipmentIndex != -1) { val = pickupIndex; string? text5 = ((object)(PickupIndex)(ref val)).ToString(); val = OrderEquipment; Log.Info("Converting " + text5 + " to " + ((object)(PickupIndex)(ref val)).ToString()); pickupIndex = OrderEquipment; } else { val = pickupIndex; Log.Info("Equipment added as " + ((object)(PickupIndex)(ref val)).ToString()); OrderEquipment = pickupIndex; } } else { val = pickupIndex; Debug.Log((object)("Letting " + ((object)(PickupIndex)(ref val)).ToString() + " pass through")); } } } 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); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Nerdman.ArtifactOfOrder", "ArtifactOfOrder", "1.0.2")] public class Main : BaseUnityPlugin { public static AssetBundle mainBundle; public const string bundleName = "artifact_of_order"; public const string assetBundleFolder = "assetbundles"; public List<ArtifactBase> Artifacts = new List<ArtifactBase>(); public const string PluginGUID = "Nerdman.ArtifactOfOrder"; public const string PluginAuthor = "Nerdman"; public const string PluginName = "ArtifactOfOrder"; public const string PluginVersion = "1.0.2"; public static PluginInfo PInfo { get; private set; } public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(PInfo.Location), "assetbundles", "artifact_of_order"); public bool ValidateArtifact(ArtifactBase artifact, List<ArtifactBase> artifactList) { bool value = ((BaseUnityPlugin)this).Config.Bind<bool>("Artifact: " + artifact.ArtifactName, "Enable Artifact?", true, "Should this artifact appear for selection?").Value; if (value) { artifactList.Add(artifact); } return value; } public void Awake() { PInfo = ((BaseUnityPlugin)this).Info; mainBundle = AssetBundle.LoadFromFile(AssetBundlePath); Log.Init(((BaseUnityPlugin)this).Logger); IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes() where !type.IsAbstract && type.IsSubclassOf(typeof(ArtifactBase)) select type; foreach (Type item in enumerable) { ArtifactBase artifactBase = (ArtifactBase)Activator.CreateInstance(item); if (ValidateArtifact(artifactBase, Artifacts)) { artifactBase.Init(((BaseUnityPlugin)this).Config); } } } private void Update() { } } }