Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of Nevermore v1.0.0
Nevermore.dll
Decompiled 10 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 Microsoft.CodeAnalysis; using RoR2; using RoR2.Skills; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.ResourceManagement.ResourceProviders; [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("Nevermore")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Nevermore")] [assembly: AssemblyTitle("Nevermore")] [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 Nevermore { public static class AssetLoader { public static T LoadAssetsBySearchString<T>(string searchString) where T : Object { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, Object> dictionary = new Dictionary<string, Object>(); foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators) { ResourceLocationMap val = (ResourceLocationMap)(object)((resourceLocator is ResourceLocationMap) ? resourceLocator : null); if (val == null) { continue; } foreach (KeyValuePair<object, IList<IResourceLocation>> location in val.Locations) { foreach (IResourceLocation item in location.Value) { if (item.PrimaryKey.Contains(searchString, StringComparison.OrdinalIgnoreCase) && IsLoadableAsset(item)) { Object val2 = Addressables.LoadAssetAsync<Object>(item).WaitForCompletion(); if (val2 != (Object)null) { dictionary[item.PrimaryKey] = val2; } } } } } if (dictionary.Count != 1) { throw new InvalidOperationException($"Expected one asset of type {typeof(T).Name}, but found {dictionary.Count}."); } Object obj = dictionary.Values.First(); return (T)(object)((obj is T) ? obj : null); } private static bool IsLoadableAsset(IResourceLocation location) { return location.ResourceType != typeof(SceneInstance) && location.ResourceType != typeof(IAssetBundleResource) && location.ProviderId != "UnityEngine.ResourceManagement.ResourceProviders.LegacyResourcesProvider" && typeof(Object).IsAssignableFrom(location.ResourceType); } public static T LoadAsset<T>(string path) where T : Object { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 AsyncOperationHandle<T> val = Addressables.LoadAssetAsync<T>((object)path); T result = val.WaitForCompletion(); if ((int)val.Status == 1) { return result; } Debug.LogError((object)$"Failed to load asset of type {typeof(T)} at address: {path}"); return default(T); } } [BepInPlugin("Tully_Vin.Nevermore", "Nevermore", "1.0.0")] public class NevermoreSkill : BaseUnityPlugin { public const string PluginGUID = "Tully_Vin.Nevermore"; public const string PluginAuthor = "Tully_Vin"; public const string PluginName = "Nevermore"; public const string PluginVersion = "1.0.0"; public void Awake() { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LoadNevermore)); } public void OnDestroy() { RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(LoadNevermore)); } public void LoadNevermore() { Debug.Log((object)"Loading Nevermore SkillDef"); SkillDef val = AssetLoader.LoadAssetsBySearchString<SkillDef>("HereticDefaultAbility"); if (!Object.op_Implicit((Object)(object)val)) { Debug.Log((object)"Loading Nevermore SkillDef"); } Debug.Log((object)"Adding Nevermore SkillDef to "); foreach (SkillFamily allSkillFamily in SkillCatalog.allSkillFamilies) { AddSkill(allSkillFamily, val); } } public void AddSkill(SkillFamily family, SkillDef skill, UnlockableDef unlock = null) { //IL_001e: 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_0048: Expected O, but got Unknown //IL_0049: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (family.variants == null) { Debug.LogError((object)"skill family variants array is null."); return; } Variant val = default(Variant); val.skillDef = skill; val.unlockableDef = unlock; ((Variant)(ref val)).viewableNode = new Node(skill.skillNameToken, false, (Node)null); Variant val2 = val; Array.Resize(ref family.variants, family.variants.Length + 1); family.variants[family.variants.Length - 1] = val2; } } }