Decompiled source of CustomAbilities v1.1.0
BepInEx\plugins\CustomAbilities.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; 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 System.Text; using System.Text.Json; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using CustomAbilities.Commands; using CustomAbilities.Models; using CustomAbilities.Resources; using CustomAbilities.Services; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Network; using ProjectM.Physics; using ProjectM.Scripting; using ProjectM.Shared; using Stunlock.Core; using Stunlock.Network; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using UnityEngine; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CustomAbilities")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+716f81d6837f805c1b4b87aca640b29d39b09da0")] [assembly: AssemblyProduct("CustomAbilities")] [assembly: AssemblyTitle("CustomAbilities")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 CustomAbilities { public static class AbilityAPI { public class SpellPoolEntry { public int PrefabGuid { get; set; } public string Alias { get; set; } public int[] AllowedSlots { get; set; } public int[] RestrictedSlots { get; set; } } private static readonly List<Func<Entity, PrefabGUID, int[], int[]>> _specialCaseHandlers = new List<Func<Entity, PrefabGUID, int[], int[]>>(); private static readonly List<Func<Entity, PrefabGUID, int[]>> _formAbilityOverrideHandlers = new List<Func<Entity, PrefabGUID, int[]>>(); private static readonly List<Func<Entity, List<int>>> _legacySpellPoolProviders = new List<Func<Entity, List<int>>>(); private static readonly List<Func<Entity, List<SpellPoolEntry>>> _spellPoolEntryProviders = new List<Func<Entity, List<SpellPoolEntry>>>(); public static void RegisterSpecialCaseHandler(Func<Entity, PrefabGUID, int[], int[]> handler) { _specialCaseHandlers.Add(handler); } internal static int[] RunSpecialCaseHandlers(Entity playerEntity, PrefabGUID weaponEquipBuff, int[] abilitySlotPrefabGUIDs) { //IL_0014: 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) foreach (Func<Entity, PrefabGUID, int[], int[]> specialCaseHandler in _specialCaseHandlers) { abilitySlotPrefabGUIDs = specialCaseHandler(playerEntity, weaponEquipBuff, abilitySlotPrefabGUIDs); } return abilitySlotPrefabGUIDs; } public static void RegisterFormAbilityOverride(Func<Entity, PrefabGUID, int[]> handler) { _formAbilityOverrideHandlers.Add(handler); } internal static int[] RunFormAbilityOverrides(Entity playerEntity, PrefabGUID formBuffPrefabGUID) { //IL_0014: 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) foreach (Func<Entity, PrefabGUID, int[]> formAbilityOverrideHandler in _formAbilityOverrideHandlers) { int[] array = formAbilityOverrideHandler(playerEntity, formBuffPrefabGUID); if (array != null) { return array; } } return null; } public static void SetAbility(Entity playerEntity, AbilityTypeEnum slot, PrefabGUID ability, string weaponCategory, out string warningMessage) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) AbilityService.SetAbility(playerEntity, slot, ability, weaponCategory, out warningMessage); } public static void SetAbilityForAllCategories(Entity playerEntity, AbilityTypeEnum slot, PrefabGUID ability, out string warningMessage) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) AbilityService.SetAbilityForAllCategories(playerEntity, slot, ability, out warningMessage); } public static void ClearAbilitySlot(Entity playerEntity, AbilityTypeEnum slot, string weaponCategory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) AbilityService.ClearAbilitySlot(playerEntity, slot, weaponCategory); } public static void ClearAbilitySlotForAllCategories(Entity playerEntity, AbilityTypeEnum slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) AbilityService.ClearAbilitySlotForAllCategories(playerEntity, slot); } public static void ClearAllAbilitySlots(Entity playerEntity, string weaponCategory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AbilityService.ClearAllAbilitySlots(playerEntity, weaponCategory); } public static void ClearAllAbilitySlotsForAllCategories(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AbilityService.ClearAllAbilitySlotsForAllCategories(playerEntity); } public static bool SetItemAbility(Entity itemEntity, AbilityTypeEnum slot, PrefabGUID ability, out string reason) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return AbilityService.SetItemAbility(itemEntity, slot, ability, out reason); } public static void ClearItemAbility(Entity itemEntity, AbilityTypeEnum slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) AbilityService.ClearItemAbility(itemEntity, slot); } public static void ClearAllItemAbilities(Entity itemEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AbilityService.ClearAllItemAbilities(itemEntity); } public static int GetItemAbility(Entity itemEntity, AbilityTypeEnum slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return AbilityService.GetItemAbility(itemEntity, slot); } public static int[] GetAllItemAbilities(Entity itemEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return AbilityService.GetAllItemAbilities(itemEntity); } public static CommandResult SavePreset(Entity playerEntity, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PresetService.SavePreset(playerEntity, name); } public static CommandResult LoadPreset(Entity playerEntity, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PresetService.LoadPreset(playerEntity, name); } public static CommandResult DeletePreset(Entity playerEntity, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PresetService.DeletePreset(playerEntity, name); } public static List<AbilityPreset> GetPresets(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PresetService.GetPresets(playerEntity); } public static void ApplyAbilities(Entity playerEntity, Entity buffEntity, int[] abilitySlotPrefabGUIDs, int priority = 1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) AbilityService.ApplyAbilities(playerEntity, buffEntity, abilitySlotPrefabGUIDs, priority); } public static void ApplyAbilityBuff(Entity buffEntity, AbilityTypeEnum abilityType, PrefabGUID abilityGUID, int priority = 0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) AbilityService.ApplyAbilityBuff(buffEntity, abilityType, abilityGUID, priority); } public static void RefreshEquipBuff(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Core.StartCoroutine(AbilityService.RefreshEquipBuff(playerEntity)); } public static void RegisterSpellPoolProvider(Func<Entity, List<int>> provider) { _legacySpellPoolProviders.Add(provider); } public static void RegisterSpellPoolProvider(Func<Entity, List<SpellPoolEntry>> provider) { _spellPoolEntryProviders.Add(provider); } public static List<SpellPoolEntry> GetAvailableSpellEntries(Entity playerEntity) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, SpellPoolEntry> dictionary = new Dictionary<int, SpellPoolEntry>(); foreach (Func<Entity, List<int>> legacySpellPoolProvider in _legacySpellPoolProviders) { List<int> list = legacySpellPoolProvider(playerEntity); if (list == null) { continue; } foreach (int item in list) { if (item != 0 && !dictionary.ContainsKey(item)) { dictionary[item] = new SpellPoolEntry { PrefabGuid = item }; } } } foreach (Func<Entity, List<SpellPoolEntry>> spellPoolEntryProvider in _spellPoolEntryProviders) { List<SpellPoolEntry> list2 = spellPoolEntryProvider(playerEntity); if (list2 == null) { continue; } foreach (SpellPoolEntry item2 in list2) { if (item2.PrefabGuid != 0) { dictionary[item2.PrefabGuid] = item2; } } } return dictionary.Values.ToList(); } public static List<int> GetAvailableSpells(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return (from e in GetAvailableSpellEntries(playerEntity) select e.PrefabGuid).ToList(); } public static bool HasAvailableSpell(Entity playerEntity, int spellPrefabGuid) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (spellPrefabGuid == 0) { return false; } foreach (Func<Entity, List<int>> legacySpellPoolProvider in _legacySpellPoolProviders) { List<int> list = legacySpellPoolProvider(playerEntity); if (list != null && list.Contains(spellPrefabGuid)) { return true; } } foreach (Func<Entity, List<SpellPoolEntry>> spellPoolEntryProvider in _spellPoolEntryProviders) { List<SpellPoolEntry> list2 = spellPoolEntryProvider(playerEntity); if (list2 != null && list2.Any((SpellPoolEntry e) => e.PrefabGuid == spellPrefabGuid)) { return true; } } return false; } public static int? ResolveSpellIdentifier(Entity playerEntity, string identifier) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(identifier)) { return null; } if (int.TryParse(identifier, out var result)) { return result; } string value = identifier.ToLowerInvariant(); List<SpellPoolEntry> availableSpellEntries = GetAvailableSpellEntries(playerEntity); SpellPoolEntry spellPoolEntry = availableSpellEntries.FirstOrDefault((SpellPoolEntry e) => !string.IsNullOrEmpty(e.Alias) && string.Equals(e.Alias, identifier, StringComparison.OrdinalIgnoreCase)); if (spellPoolEntry != null) { return spellPoolEntry.PrefabGuid; } Dictionary<string, PrefabGUID> allPrefabGuidsAsDictionary = PrefabGUIDsExtensions.GetAllPrefabGuidsAsDictionary(); PrefabGUID value2; foreach (KeyValuePair<string, PrefabGUID> item in allPrefabGuidsAsDictionary) { if (string.Equals(item.Key, identifier, StringComparison.OrdinalIgnoreCase)) { value2 = item.Value; return ((PrefabGUID)(ref value2)).GuidHash; } } List<(string, int)> list = new List<(string, int)>(); foreach (SpellPoolEntry item2 in availableSpellEntries) { if (!string.IsNullOrEmpty(item2.Alias) && item2.Alias.ToLowerInvariant().Contains(value)) { list.Add((item2.Alias, item2.PrefabGuid)); } } foreach (KeyValuePair<string, PrefabGUID> item3 in allPrefabGuidsAsDictionary) { if (item3.Key.ToLowerInvariant().Contains(value)) { string key = item3.Key; value2 = item3.Value; list.Add((key, ((PrefabGUID)(ref value2)).GuidHash)); } } if (list.Count == 1) { return list[0].Item2; } return null; } public static bool TryGetStandardizedWeaponCategory(string input, out string standardizedCategory) { return AbilityService.TryGetStandardizedWeaponCategory(input, out standardizedCategory); } public static string GetEquippedWeaponCategory(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PlayerService.GetEquippedWeaponCategory(playerEntity); } public static PrefabGUID GetEquippedAbilityPrefabGuid(Entity playerEntity, AbilityTypeEnum targetSlot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return AbilityService.GetEquippedAbilityPrefabGuid(playerEntity, targetSlot); } public static void CastAbility(Entity casterEntity, PrefabGUID abilityGroupPrefab) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) AbilityService.CastAbility(casterEntity, abilityGroupPrefab); } public static Entity GetHeldWeaponEntity(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ItemService.GetHeldWeaponEntity(playerEntity); } public static bool TryResolvePlacementId(string input, out int placementId) { return AbilityService.TryResolvePlacementId(input, out placementId); } public static string GetValidPlacementIdMessage() { return AbilityService.GetValidPlacementIdMessage(); } } internal static class Core { public static bool _initialized = false; private static DebugEventsSystem _debugEventsSystem; private static ServerScriptMapper _serverScriptMapper; private static MonoBehaviour _monoBehaviour; public static ManualLogSource Log => Plugin.LogInstance; public static World World { get; } = GetServerWorld() ?? throw new Exception("Server world not found. Ensure this plugin is running on a dedicated server."); public static EntityManager EntityManager => World.EntityManager; public static DebugEventsSystem DebugEventsSystem => _debugEventsSystem ?? (_debugEventsSystem = World.GetExistingSystemManaged<DebugEventsSystem>()); public static ServerScriptMapper ServerScriptMapper => _serverScriptMapper ?? (_serverScriptMapper = World.GetExistingSystemManaged<ServerScriptMapper>()); public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager(); public static PlayerService PlayerService { get; private set; } public static void Initialize() { PlayerDataService.Initialize(); ItemDataService.Initialize(); PlayerService = new PlayerService(); _initialized = true; } private static World GetServerWorld() { return ((IEnumerable<World>)World.s_AllWorlds.ToArray()).FirstOrDefault((Func<World, bool>)((World world) => world.Name == "Server")); } public static void StartCoroutine(IEnumerator routine) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_monoBehaviour == (Object)null) { _monoBehaviour = (MonoBehaviour)(object)new GameObject("CustomAbilities").AddComponent<IgnorePhysicsDebugSystem>(); Object.DontDestroyOnLoad((Object)(object)((Component)_monoBehaviour).gameObject); } _monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } } public static class VExtensions { private static EntityManager EntityManager => Core.EntityManager; public static bool TryGetComponent<T>(this Entity entity, out T componentData) where T : struct { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002b: Unknown result type (might be due to invalid IL or missing references) componentData = default(T); EntityManager entityManager = EntityManager; if (((EntityManager)(ref entityManager)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0))) { entityManager = EntityManager; componentData = ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); return true; } return false; } public static T Read<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); } public static User GetUser(this Entity entity) { //IL_0000: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<User>(out User componentData)) { return componentData; } if (entity.TryGetComponent<PlayerCharacter>(out PlayerCharacter componentData2)) { return componentData2.UserEntity.Read<User>(); } return User.Empty; } } [BepInPlugin("io.vrising.CustomAbilities", "CustomAbilities", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BasePlugin { private Harmony _harmony; private static ConfigEntry<bool> _blockJewelableAbilitiesOnItems; private static ConfigEntry<bool> _devMode; private static ConfigEntry<bool> _blockPresetsInCombat; private static ConfigEntry<string> _spellAssignAllowedSlots; internal static Plugin Instance { get; private set; } public static Harmony Harmony => Instance._harmony; public static bool IsServer { get; private set; } public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log; public static bool Initialized { get; internal set; } public static bool BlockJewelableAbilitiesOnItems => _blockJewelableAbilitiesOnItems.Value; public static bool DevMode => _devMode.Value; public static bool BlockPresetsInCombat => _blockPresetsInCombat.Value; internal static HashSet<int> SpellAssignAllowedSlots { get; private set; } = new HashSet<int> { 0, 1, 2, 3, 4, 5, 6 }; public override void Load() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown Instance = this; IsServer = Application.productName == "VRisingServer"; if (!IsServer) { Core.Log.LogWarning((object)"This plugin is intended to run on the server only. It will not function correctly on the client."); return; } _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); InitConfig(); CommandRegistry.RegisterAll(); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CustomAbilities"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded successfully!"); } log.LogInfo(val); } private void InitConfig() { _blockJewelableAbilitiesOnItems = ((BasePlugin)this).Config.Bind<bool>("General", "BlockJewelableAbilitiesOnItems", true, "Prevent jewelable abilities (spell school abilities) from being set on items/weapons."); _devMode = ((BasePlugin)this).Config.Bind<bool>("General", "DevMode", false, "Enable development mode with additional logging/debugging features"); _blockPresetsInCombat = ((BasePlugin)this).Config.Bind<bool>("General", "BlockPresetsInCombat", true, "Block using the .abilities preset save and load commands while the player has the combat (PvE) or PvP combat buff."); _spellAssignAllowedSlots = ((BasePlugin)this).Config.Bind<string>("SpellAssign", "AllowedSlots", "0,1,2,3,4,5,6", "Comma-separated list of slot IDs that players can assign spells to via .abilities spell assign. Valid IDs: 0=Attack, 1=Q, 2=E, 3=Dash, 4=Spell1, 5=Spell2, 6=Ultimate"); SpellAssignAllowedSlots = ParseSlotList(_spellAssignAllowedSlots.Value); } public override bool Unload() { _harmony.UnpatchSelf(); if (IsServer) { PlayerDataService.FlushSaveToDisk(); ItemDataService.FlushSaveToDisk(); } return true; } private static HashSet<int> ParseSlotList(string raw) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (string.IsNullOrWhiteSpace(raw)) { return new HashSet<int> { 0, 1, 2, 3, 4, 5, 6 }; } HashSet<int> hashSet = new HashSet<int>(); string[] array = raw.Split(','); bool flag = default(bool); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (int.TryParse(text, out var result) && result >= 0 && result <= 6) { hashSet.Add(result); continue; } ManualLogSource logInstance = LogInstance; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(76, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SpellAssign AllowedSlots: ignoring invalid entry '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'. Must be an integer 0-6."); } logInstance.LogWarning(val); } if (hashSet.Count == 0) { LogInstance.LogWarning((object)"SpellAssign AllowedSlots: no valid slots configured, defaulting to all slots."); return new HashSet<int> { 0, 1, 2, 3, 4, 5, 6 }; } return hashSet; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "io.vrising.CustomAbilities"; public const string PLUGIN_NAME = "CustomAbilities"; public const string PLUGIN_VERSION = "1.0.2"; } } namespace CustomAbilities.Services { public static class AbilityService { public static PrefabGUID DEFAULT_AXE_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Axe_Base; public static PrefabGUID DEFAULT_CLAWS_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Claws_Base; public static PrefabGUID DEFAULT_CROSSBOW_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Crossbow_Base; public static PrefabGUID DEFAULT_DAGGERS_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Daggers_Base; public static PrefabGUID DEFAULT_FISHING_POLE_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_FishingPole_Base; public static PrefabGUID DEFAULT_GREATSWORD_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_GreatSword_Base; public static PrefabGUID DEFAULT_LONGBOW_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Longbow_Base; public static PrefabGUID DEFAULT_MACE_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Mace_Base; public static PrefabGUID DEFAULT_PISTOLS_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Pistols_Base; public static PrefabGUID DEFAULT_REAPER_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Reaper_Base; public static PrefabGUID DEFAULT_SLASHERS_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Slashers_Base; public static PrefabGUID DEFAULT_SPEAR_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Spear_Base; public static PrefabGUID DEFAULT_SWORD_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Sword_Base; public static PrefabGUID DEFAULT_TWINBLADES_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_TwinBlades_Base; public static PrefabGUID DEFAULT_WHIP_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Whip_Base; public static PrefabGUID DEFAULT_UNARMED_EQUIPBUFF = PrefabGUIDs.EquipBuff_Weapon_Unarmed_Start01; public const string CATEGORY_AXE = "Axe"; public const string CATEGORY_CLAWS = "Claws"; public const string CATEGORY_CROSSBOW = "Crossbow"; public const string CATEGORY_DAGGERS = "Daggers"; public const string CATEGORY_FISHING_POLE = "FishingPole"; public const string CATEGORY_GREATSWORD = "GreatSword"; public const string CATEGORY_LONGBOW = "Longbow"; public const string CATEGORY_MACE = "Mace"; public const string CATEGORY_PISTOLS = "Pistols"; public const string CATEGORY_REAPER = "Reaper"; public const string CATEGORY_SLASHERS = "Slashers"; public const string CATEGORY_SPEAR = "Spear"; public const string CATEGORY_SWORD = "Sword"; public const string CATEGORY_TWINBLADES = "TwinBlades"; public const string CATEGORY_WHIP = "Whip"; public const string CATEGORY_UNARMED = "Unarmed"; public static List<string> weaponCategories = new List<string> { "Unarmed", "Axe", "Claws", "Crossbow", "Daggers", "FishingPole", "GreatSword", "Longbow", "Mace", "Pistols", "Reaper", "Slashers", "Spear", "Sword", "TwinBlades", "Whip" }; public static readonly Dictionary<string, PrefabGUID> WeaponCategoryToDefaultEquipBuff = new Dictionary<string, PrefabGUID> { { "Axe", DEFAULT_AXE_EQUIPBUFF }, { "Claws", DEFAULT_CLAWS_EQUIPBUFF }, { "Crossbow", DEFAULT_CROSSBOW_EQUIPBUFF }, { "Daggers", DEFAULT_DAGGERS_EQUIPBUFF }, { "FishingPole", DEFAULT_FISHING_POLE_EQUIPBUFF }, { "GreatSword", DEFAULT_GREATSWORD_EQUIPBUFF }, { "Longbow", DEFAULT_LONGBOW_EQUIPBUFF }, { "Mace", DEFAULT_MACE_EQUIPBUFF }, { "Pistols", DEFAULT_PISTOLS_EQUIPBUFF }, { "Reaper", DEFAULT_REAPER_EQUIPBUFF }, { "Slashers", DEFAULT_SLASHERS_EQUIPBUFF }, { "Spear", DEFAULT_SPEAR_EQUIPBUFF }, { "Sword", DEFAULT_SWORD_EQUIPBUFF }, { "TwinBlades", DEFAULT_TWINBLADES_EQUIPBUFF }, { "Whip", DEFAULT_WHIP_EQUIPBUFF }, { "Unarmed", DEFAULT_UNARMED_EQUIPBUFF } }; public static readonly Dictionary<int, AbilityTypeEnum> PlacementIdToAbilityType = new Dictionary<int, AbilityTypeEnum> { { 0, (AbilityTypeEnum)0 }, { 1, (AbilityTypeEnum)1 }, { 2, (AbilityTypeEnum)4 }, { 3, (AbilityTypeEnum)2 }, { 4, (AbilityTypeEnum)5 }, { 5, (AbilityTypeEnum)6 }, { 6, (AbilityTypeEnum)7 } }; public static readonly Dictionary<string, int> PlacementIdFriendlyNames = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase) { { "primary", 0 }, { "attack", 0 }, { "q", 1 }, { "secondary", 1 }, { "e", 2 }, { "power", 2 }, { "dash", 3 }, { "travel", 3 }, { "r", 4 }, { "spell1", 4 }, { "offensive", 4 }, { "c", 5 }, { "spell2", 5 }, { "defensive", 5 }, { "t", 6 }, { "ultimate", 6 }, { "ult", 6 } }; public static readonly PrefabGUID[] jewelableAbilityPrefabs = (PrefabGUID[])(object)new PrefabGUID[42] { PrefabGUIDs.AB_Blood_BloodFountain_AbilityGroup, PrefabGUIDs.AB_Blood_BloodRage_AbilityGroup, PrefabGUIDs.AB_Blood_BloodRite_AbilityGroup, PrefabGUIDs.AB_Blood_CarrionSwarm_AbilityGroup, PrefabGUIDs.AB_Blood_SanguineCoil_AbilityGroup, PrefabGUIDs.AB_Blood_Shadowbolt_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfBlood_Group, PrefabGUIDs.AB_Unholy_ChainsOfDeath_AbilityGroup, PrefabGUIDs.AB_Unholy_CorpseExplosion_AbilityGroup, PrefabGUIDs.AB_Unholy_CorruptedSkull_AbilityGroup, PrefabGUIDs.AB_Unholy_DeathKnight_AbilityGroup, PrefabGUIDs.AB_Unholy_Soulburn_AbilityGroup, PrefabGUIDs.AB_Unholy_WardOfTheDamned_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfBones_AbilityGroup, PrefabGUIDs.AB_Storm_BallLightning_AbilityGroup, PrefabGUIDs.AB_Storm_Cyclone_AbilityGroup, PrefabGUIDs.AB_Storm_Discharge_AbilityGroup, PrefabGUIDs.AB_Storm_LightningTendrils_AbilityGroup, PrefabGUIDs.AB_Storm_LightningWall_AbilityGroup, PrefabGUIDs.AB_Storm_PolarityShift_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfStorm_Group, PrefabGUIDs.AB_Chaos_Aftershock_Group, PrefabGUIDs.AB_Chaos_Barrier_AbilityGroup, PrefabGUIDs.AB_Chaos_Volley_AbilityGroup, PrefabGUIDs.AB_Chaos_PowerSurge_AbilityGroup, PrefabGUIDs.AB_Chaos_RainOfChaos_AbilityGroup, PrefabGUIDs.AB_Chaos_Void_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfChaos_Group, PrefabGUIDs.AB_Illusion_Curse_Group, PrefabGUIDs.AB_Illusion_MistTrance_AbilityGroup, PrefabGUIDs.AB_Illusion_Mosquito_AbilityGroup, PrefabGUIDs.AB_Illusion_PhantomAegis_AbilityGroup, PrefabGUIDs.AB_Illusion_SpectralWolf_AbilityGroup, PrefabGUIDs.AB_Illusion_WraithSpear_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfIllusion_AbilityGroup, PrefabGUIDs.AB_Frost_ColdSnap_AbilityGroup, PrefabGUIDs.AB_Frost_CrystalLance_AbilityGroup, PrefabGUIDs.AB_Frost_FrostBat_AbilityGroup, PrefabGUIDs.AB_Frost_IceNova_AbilityGroup, PrefabGUIDs.AB_FrostBarrier_AbilityGroup, PrefabGUIDs.AB_FrostCone_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfFrost_Group }; public static readonly PrefabGUID[] recastableAbilities = (PrefabGUID[])(object)new PrefabGUID[15] { PrefabGUIDs.AB_Blood_BloodFountain_AbilityGroup, PrefabGUIDs.AB_Blood_CarrionSwarm_AbilityGroup, PrefabGUIDs.AB_Chaos_Barrier_AbilityGroup, PrefabGUIDs.AB_Chaos_PowerSurge_AbilityGroup, PrefabGUIDs.AB_Frost_IceNova_AbilityGroup, PrefabGUIDs.AB_FrostBarrier_AbilityGroup, PrefabGUIDs.AB_Illusion_PhantomAegis_AbilityGroup, PrefabGUIDs.AB_Illusion_WispDance_AbilityGroup, PrefabGUIDs.AB_Storm_BallLightning_AbilityGroup, PrefabGUIDs.AB_Storm_Discharge_AbilityGroup, PrefabGUIDs.AB_Storm_EyeOfTheStorm_AbilityGroup, PrefabGUIDs.AB_Unholy_UnstableArachnid_AbilityGroup, PrefabGUIDs.AB_Unholy_WardOfTheDamned_AbilityGroup, PrefabGUIDs.AB_Vampire_VeilOfChaos_Group, PrefabGUIDs.AB_Vampire_VeilOfIllusion_AbilityGroup }; private static EntityManager EntityManager => Core.EntityManager; public static bool TryResolvePlacementId(string input, out int placementId) { if (string.IsNullOrEmpty(input)) { placementId = 0; return false; } if (int.TryParse(input, out placementId)) { return PlacementIdToAbilityType.ContainsKey(placementId); } return PlacementIdFriendlyNames.TryGetValue(input, out placementId); } public static string GetValidPlacementIdMessage() { return "Invalid slot. Valid options: <color=white>primary</color>/<color=white>0</color> (Attack), <color=white>q</color>/<color=white>1</color> (Q), <color=white>e</color>/<color=white>2</color> (E), <color=white>dash</color>/<color=white>3</color> (Dash), <color=white>r</color>/<color=white>4</color> (Spell 1), <color=white>c</color>/<color=white>5</color> (Spell 2), <color=white>ult</color>/<color=white>6</color> (Ultimate)"; } public static bool TryGetStandardizedWeaponCategory(string input, out string standardizedCategory) { if (string.IsNullOrEmpty(input)) { standardizedCategory = null; return false; } string text = input.ToLower(); if (text == "all") { standardizedCategory = "All"; return true; } foreach (string weaponCategory in weaponCategories) { if (weaponCategory.ToLower() == text) { standardizedCategory = weaponCategory; return true; } } standardizedCategory = null; return false; } public static string GetValidWeaponCategories() { return "All, " + string.Join(", ", weaponCategories); } public static void SetAbility(Entity playerEntity, AbilityTypeEnum targetSlot, PrefabGUID abilityPrefab, string currentWeaponCategory, out string warningMessage) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_006c: Unknown result type (might be due to invalid IL or missing references) warningMessage = null; PlayerData playerData = PlayerDataService.GetPlayerData(playerEntity); WeaponCategoryToDefaultEquipBuff.TryGetValue(currentWeaponCategory, out var value); int value2 = value._Value; Dictionary<int, int[]> abilitySlotDefinitions = playerData.AbilitySlotDefinitions; if (!abilitySlotDefinitions.ContainsKey(value2)) { abilitySlotDefinitions[value2] = new int[8]; } if (((PrefabGUID)(ref abilityPrefab)).HasValue() && recastableAbilities.Contains(abilityPrefab)) { warningMessage = $"Using a recastable ability ({abilityPrefab}) on a non-normal slot may cause you to lose your jewel. You have been warned."; } playerData.AbilitySlotDefinitions[value2][targetSlot] = ((PrefabGUID)(ref abilityPrefab)).GuidHash; PlayerDataService.SaveData(); } public static void ClearAbilitySlot(Entity playerEntity, AbilityTypeEnum targetSlot, string currentWeaponCategory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) PlayerData playerData = PlayerDataService.GetPlayerData(playerEntity); WeaponCategoryToDefaultEquipBuff.TryGetValue(currentWeaponCategory, out var value); int value2 = value._Value; Dictionary<int, int[]> abilitySlotDefinitions = playerData.AbilitySlotDefinitions; if (!abilitySlotDefinitions.ContainsKey(value2)) { abilitySlotDefinitions[value2] = new int[8]; } playerData.AbilitySlotDefinitions[value2][targetSlot] = 0; PlayerDataService.SaveData(); } public static void ClearAllAbilitySlots(Entity playerEntity, string currentWeaponCategory) { //IL_0000: 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) PlayerData playerData = PlayerDataService.GetPlayerData(playerEntity); WeaponCategoryToDefaultEquipBuff.TryGetValue(currentWeaponCategory, out var value); int value2 = value._Value; Dictionary<int, int[]> abilitySlotDefinitions = playerData.AbilitySlotDefinitions; if (!abilitySlotDefinitions.ContainsKey(value2)) { abilitySlotDefinitions[value2] = new int[8]; } for (int i = 0; i < 8; i++) { playerData.AbilitySlotDefinitions[value2][i] = 0; } PlayerDataService.SaveData(); } public static void SetAbilityForAllCategories(Entity playerEntity, AbilityTypeEnum targetSlot, PrefabGUID abilityPrefab, out string warningMessage) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) foreach (string weaponCategory in weaponCategories) { SetAbility(playerEntity, targetSlot, abilityPrefab, weaponCategory, out var warningMessage2); if (warningMessage2 != null) { warningMessage = warningMessage2; return; } } warningMessage = null; } public static void ClearAbilitySlotForAllCategories(Entity playerEntity, AbilityTypeEnum targetSlot) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) foreach (string weaponCategory in weaponCategories) { ClearAbilitySlot(playerEntity, targetSlot, weaponCategory); } } public static void ClearAllAbilitySlotsForAllCategories(Entity playerEntity) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) foreach (string weaponCategory in weaponCategories) { ClearAllAbilitySlots(playerEntity, weaponCategory); } } public static bool SetItemAbility(Entity itemEntity, AbilityTypeEnum targetSlot, PrefabGUID abilityPrefab, out string reason) { //IL_006e: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (((PrefabGUID)(ref abilityPrefab)).HasValue() && jewelableAbilityPrefabs.Contains(abilityPrefab) && Plugin.BlockJewelableAbilitiesOnItems) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(99, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[AbilityService] - Attempted to set jewelable ability "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PrefabGUID>(abilityPrefab); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on item "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(itemEntity); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", but this is not allowed by config."); } log.LogInfo(val); reason = "Setting jewelable abilities on items is not allowed."; return false; } ItemDataService.GetItemData(itemEntity).AbilityGUIDs[targetSlot] = ((PrefabGUID)(ref abilityPrefab)).GuidHash; ItemDataService.MarkDirty(); reason = null; return true; } public static void ClearItemAbility(Entity itemEntity, AbilityTypeEnum targetSlot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ItemDataService.GetItemData(itemEntity).AbilityGUIDs[targetSlot] = 0; ItemDataService.MarkDirty(); } public static void ClearAllItemAbilities(Entity itemEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ItemData itemData = ItemDataService.GetItemData(itemEntity); for (int i = 0; i < 8; i++) { itemData.AbilityGUIDs[i] = 0; } ItemDataService.MarkDirty(); } public static int GetItemAbility(Entity itemEntity, AbilityTypeEnum slot) { //IL_0000: 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) ItemData itemData = ItemDataService.GetItemData(itemEntity); if (itemData.AbilityGUIDs == null) { return 0; } return itemData.AbilityGUIDs[slot]; } public static int[] GetAllItemAbilities(Entity itemEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ItemDataService.GetItemData(itemEntity).AbilityGUIDs; } public static void ApplyAbilities(Entity playerEntity, Entity buffEntity, int[] abilitySlotPrefabGUIDs, int groupPriority = 1) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (abilitySlotPrefabGUIDs == null) { return; } EntityManager entityManager = EntityManager; DynamicBuffer<ReplaceAbilityOnSlotBuff> buffer = ((EntityManager)(ref entityManager)).GetBuffer<ReplaceAbilityOnSlotBuff>(buffEntity, false); for (int i = 0; i < buffer.Length; i++) { ReplaceAbilityOnSlotBuff val = buffer[i]; if (val.Priority == 99) { val.Priority = 8; buffer[i] = val; } } PrefabGUID zero = default(PrefabGUID); for (int j = 0; j < abilitySlotPrefabGUIDs.Length; j++) { if (abilitySlotPrefabGUIDs[j] != 0) { ((PrefabGUID)(ref zero))..ctor(abilitySlotPrefabGUIDs[j]); if (abilitySlotPrefabGUIDs[j] == -1) { zero = PrefabGUIDs.Zero; } if (((PrefabGUID)(ref zero)).HasValue()) { ApplyAbilityBuff(buffEntity, (AbilityTypeEnum)j, zero, groupPriority); } } } } public static void ApplyAbilityBuff(Entity buffEntity, AbilityTypeEnum abilityType, PrefabGUID abilityGUID, int priority = 0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected I4, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002e: Expected I4, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; DynamicBuffer<ReplaceAbilityOnSlotBuff> buffer = ((EntityManager)(ref entityManager)).GetBuffer<ReplaceAbilityOnSlotBuff>(buffEntity, false); ReplaceAbilityOnSlotBuff val = ((!((PrefabGUID)(ref abilityGUID)).Equals(PrefabGUIDs.Zero)) ? new ReplaceAbilityOnSlotBuff { Slot = (int)abilityType, NewGroupId = abilityGUID, CopyCooldown = true, Priority = priority } : new ReplaceAbilityOnSlotBuff { Slot = (int)abilityType, CopyCooldown = false, Priority = 99 }); buffer.Add(val); } public static PrefabGUID GetEquippedAbilityPrefabGuid(Entity playerEntity, AbilityTypeEnum targetSlot) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0012: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0077: Unknown result type (might be due to invalid IL or missing references) //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Enumerator<Entity> enumerator = EntityService.GetEntitiesByComponentTypes<Buff, PrefabGUID>().GetEnumerator(); VBloodAbilityReplaceBuff val = default(VBloodAbilityReplaceBuff); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!(current.Read<EntityOwner>().Owner == playerEntity)) { continue; } EntityManager entityManager = EntityManager; if (((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current) == PrefabGUIDs.Buff_VBlood_Ability_Replace) { entityManager = EntityManager; if (((EntityManager)(ref entityManager)).TryGetComponentData<VBloodAbilityReplaceBuff>(current, ref val) && val.AbilityType == targetSlot) { return val.AbilityGUID; } } } return PrefabGUID.Empty; } public static IEnumerator RefreshEquipBuff(Entity playerEntity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) PrefabGUID currentEquipBuff = PlayerService.GetEquipBuffPrefabGUID(playerEntity); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[AbilityService] - Refreshing equip buff "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PrefabGUID>(currentEquipBuff); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(playerEntity); } log.LogInfo(val); if (BuffService.HasBuff(playerEntity, currentEquipBuff)) { BuffService.RemoveBuff(playerEntity, currentEquipBuff); } yield return (object)new WaitForSeconds(0.3f); BuffService.ApplyBuff(playerEntity, currentEquipBuff); yield return null; } public static void CastAbility(Entity casterEntity, PrefabGUID abilityGroupPrefab) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003a: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004f: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) //IL_009a: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) DebugEventsSystem debugEventsSystem = Core.DebugEventsSystem; int num = -1; NetworkId who = default(NetworkId); if (casterEntity.TryGetComponent<NetworkId>(out NetworkId componentData)) { who = componentData; } Nullable_Unboxed<float3> aimPosition = default(Nullable_Unboxed<float3>); FromCharacter val = new FromCharacter { Character = casterEntity }; EntityManager entityManager = EntityManager; ? user; if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(casterEntity)) { entityManager = EntityManager; user = (((EntityManager)(ref entityManager)).HasComponent<User>(casterEntity) ? casterEntity : casterEntity); } else { entityManager = EntityManager; user = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(casterEntity).UserEntity; } val.User = (Entity)user; FromCharacter val2 = val; CastAbilityServerDebugEvent val3 = new CastAbilityServerDebugEvent { Who = who, AimPosition = aimPosition, AbilityGroup = abilityGroupPrefab }; debugEventsSystem.CastAbilityServerDebugEvent(num, ref val3, ref val2); } public static int[] HandleSpecialCases(Entity playerEntity, PrefabGUID weaponEquipBuff, int[] abilitySlotPrefabGUIDs) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return AbilityAPI.RunSpecialCaseHandlers(playerEntity, weaponEquipBuff, abilitySlotPrefabGUIDs); } public static CommandResult SetAbilityCommand(int placementId, int prefabGuid, string playerName = null, string weaponCategory = null) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) PrefabGUID abilityPrefab = default(PrefabGUID); ((PrefabGUID)(ref abilityPrefab))..ctor(prefabGuid); if (!PlacementIdToAbilityType.TryGetValue(placementId, out var value)) { return new CommandResult { Success = false, Message = GetValidPlacementIdMessage() }; } if (!TryGetStandardizedWeaponCategory(weaponCategory, out var standardizedCategory)) { return new CommandResult { Success = false, Message = "'" + weaponCategory + "' is not a valid weapon category.\nAvailable categories: " + GetValidWeaponCategories() }; } if (!EntityService.TryFindPlayer(playerName, out var playerEntity, out var _)) { return new CommandResult { Success = false, Message = "Player '" + playerName + "' not found." }; } if (standardizedCategory == "All") { SetAbilityForAllCategories(playerEntity, value, abilityPrefab, out var warningMessage); return new CommandResult { Success = true, Message = ((warningMessage != null) ? $"{warningMessage} Set ability slot {value} to prefab GUID {prefabGuid} for player '{playerEntity.GetUser().CharacterName}' for ALL weapon categories." : $"Set ability slot {value} to prefab GUID {prefabGuid} for player '{playerEntity.GetUser().CharacterName}' for ALL weapon categories.") }; } string text = standardizedCategory ?? PlayerService.GetEquippedWeaponCategory(playerEntity); SetAbility(playerEntity, value, abilityPrefab, text, out var warningMessage2); return new CommandResult { Success = true, Message = ((warningMessage2 != null) ? $"{warningMessage2} Set ability slot {value} to prefab GUID {prefabGuid} for player '{playerEntity.GetUser().CharacterName}' for {text} category." : $"Set ability slot {value} to prefab GUID {prefabGuid} for player '{playerEntity.GetUser().CharacterName}' for {text} category.") }; } public static CommandResult ClearAbilitySlotCommand(int placementId, string playerName = null, string weaponCategory = null) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if (!PlacementIdToAbilityType.TryGetValue(placementId, out var value)) { return new CommandResult { Success = false, Message = GetValidPlacementIdMessage() }; } if (!TryGetStandardizedWeaponCategory(weaponCategory, out var standardizedCategory)) { return new CommandResult { Success = false, Message = "'" + weaponCategory + "' is not a valid weapon category.\nAvailable categories: " + GetValidWeaponCategories() }; } if (!EntityService.TryFindPlayer(playerName, out var playerEntity, out var _)) { return new CommandResult { Success = false, Message = "Player '" + playerName + "' not found." }; } if (standardizedCategory == "All") { ClearAbilitySlotForAllCategories(playerEntity, value); return new CommandResult { Success = true, Message = $"Cleared ability slot {value} for player '{playerEntity.GetUser().CharacterName}' for ALL weapon categories." }; } string text = standardizedCategory ?? PlayerService.GetEquippedWeaponCategory(playerEntity); ClearAbilitySlot(playerEntity, value, text); return new CommandResult { Success = true, Message = $"Cleared ability slot {value} for player '{playerEntity.GetUser().CharacterName}' for {text} category." }; } public static CommandResult ClearAllAbilitySlotsCommand(string playerName = null, string weaponCategory = null) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (!TryGetStandardizedWeaponCategory(weaponCategory, out var standardizedCategory)) { return new CommandResult { Success = false, Message = "'" + weaponCategory + "' is not a valid weapon category.\nAvailable categories: " + GetValidWeaponCategories() }; } if (!EntityService.TryFindPlayer(playerName, out var playerEntity, out var _)) { return new CommandResult { Success = false, Message = "Player '" + playerName + "' not found." }; } if (standardizedCategory == "All") { ClearAllAbilitySlotsForAllCategories(playerEntity); return new CommandResult { Success = true, Message = $"Cleared ALL ability slots for player '{playerEntity.GetUser().CharacterName}' for ALL weapon categories." }; } string text = standardizedCategory ?? PlayerService.GetEquippedWeaponCategory(playerEntity); ClearAllAbilitySlots(playerEntity, text); return new CommandResult { Success = true, Message = $"Cleared ALL ability slots for player '{playerEntity.GetUser().CharacterName}' for {text} category." }; } private static List<string> GetSpellAssignTargetCategories(int placementId) { if (placementId <= 2) { return new List<string> { "Unarmed" }; } return new List<string>(weaponCategories); } private static string FormatCategoryMessage(List<string> categories) { if (categories.Count == weaponCategories.Count) { return "on all weapon categories"; } if (categories.Count == 1) { return "on " + categories[0]; } return "on categories: " + string.Join(", ", categories); } public unsafe static CommandResult SpellAssignCommand(int placementId, int prefabGuid, Entity playerEntity) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(prefabGuid); if (!AbilityAPI.HasAvailableSpell(playerEntity, prefabGuid)) { return new CommandResult { Success = false, Message = $"You don't have access to spell {prefabGuid}. Check your available spells with .abilities spell list." }; } if (!PlacementIdToAbilityType.TryGetValue(placementId, out var value)) { return new CommandResult { Success = false, Message = GetValidPlacementIdMessage() }; } AbilityAPI.SpellPoolEntry spellPoolEntry = AbilityAPI.GetAvailableSpellEntries(playerEntity).FirstOrDefault((AbilityAPI.SpellPoolEntry e) => e.PrefabGuid == prefabGuid); if (spellPoolEntry != null) { int[] allowedSlots = spellPoolEntry.AllowedSlots; if (allowedSlots != null && allowedSlots.Length > 0) { if (!spellPoolEntry.AllowedSlots.Contains(placementId)) { return new CommandResult { Success = false, Message = "This spell can only be assigned to slots: " + string.Join(", ", spellPoolEntry.AllowedSlots) + "." }; } } else { allowedSlots = spellPoolEntry.RestrictedSlots; if (allowedSlots != null && allowedSlots.Length > 0) { if (spellPoolEntry.RestrictedSlots.Contains(placementId)) { return new CommandResult { Success = false, Message = $"This spell cannot be assigned to slot {placementId}." }; } } else if (!Plugin.SpellAssignAllowedSlots.Contains(placementId)) { string value2 = string.Join(", ", Plugin.SpellAssignAllowedSlots.OrderBy((int x) => x)); return new CommandResult { Success = false, Message = $"Slot {placementId} is not allowed for spell assignment. Allowed slots: {value2}." }; } } } else if (!Plugin.SpellAssignAllowedSlots.Contains(placementId)) { string value3 = string.Join(", ", Plugin.SpellAssignAllowedSlots.OrderBy((int x) => x)); return new CommandResult { Success = false, Message = $"Slot {placementId} is not allowed for spell assignment. Allowed slots: {value3}." }; } List<string> spellAssignTargetCategories = GetSpellAssignTargetCategories(placementId); string text = null; foreach (string item in spellAssignTargetCategories) { SetAbility(playerEntity, value, val, item, out var warningMessage); if (warningMessage != null && text == null) { text = warningMessage; } } string prefabGUIDName = PrefabGUIDsExtensions.GetPrefabGUIDName(val); User user = playerEntity.GetUser(); string value4 = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); string value5 = FormatCategoryMessage(spellAssignTargetCategories); return new CommandResult { Success = true, Message = ((text != null) ? $"{text} Assigned {prefabGUIDName} to slot {value} for {value4} {value5}." : $"Assigned {prefabGUIDName} to slot {value} for {value4} {value5}.") }; } public unsafe static CommandResult SpellUnassignCommand(int placementId, Entity playerEntity) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (!PlacementIdToAbilityType.TryGetValue(placementId, out var value)) { return new CommandResult { Success = false, Message = GetValidPlacementIdMessage() }; } User user = playerEntity.GetUser(); string value2 = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); List<string> spellAssignTargetCategories = GetSpellAssignTargetCategories(placementId); foreach (string item in spellAssignTargetCategories) { ClearAbilitySlot(playerEntity, value, item); } string value3 = FormatCategoryMessage(spellAssignTargetCategories); return new CommandResult { Success = true, Message = $"Cleared ability slot {value} for {value2} {value3}." }; } } internal static class BuffService { private static DebugEventsSystem DebugEventsSystem => Core.DebugEventsSystem; private static ServerGameManager ServerGameManager => Core.ServerGameManager; private static EntityManager EntityManager => Core.EntityManager; public static void ApplyBuff(Entity entity, PrefabGUID buffPrefabGuid) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0051: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_003a: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) ApplyBuffDebugEvent val = new ApplyBuffDebugEvent { BuffPrefabGUID = buffPrefabGuid }; FromCharacter val2 = new FromCharacter { Character = entity }; EntityManager entityManager = EntityManager; ? user; if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(entity)) { entityManager = EntityManager; user = (((EntityManager)(ref entityManager)).HasComponent<User>(entity) ? entity : entity); } else { entityManager = EntityManager; user = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(entity).UserEntity; } val2.User = (Entity)user; FromCharacter val3 = val2; DebugEventsSystem.ApplyBuff(val3, val); } public static bool TryGetBuff(Entity entity, PrefabGUID buffPrefabGUID, out Entity buffEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).TryGetBuff(entity, ((PrefabGUID)(ref buffPrefabGUID)).ToIdentifier(), ref buffEntity)) { return true; } return false; } public static void TryRemoveBuff(Entity entity, PrefabGUID buffPrefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (TryGetBuff(entity, buffPrefabGuid, out var buffEntity)) { DestroyBuff(buffEntity); } } public static void DestroyBuff(Entity buffEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0012: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (buffEntity != Entity.Null) { EntityManager entityManager = EntityManager; if (((EntityManager)(ref entityManager)).Exists(buffEntity)) { DestroyUtility.Destroy(EntityManager, buffEntity, (DestroyDebugReason)13, (string)null, 0); } } } public static bool RemoveBuff(Entity entity, PrefabGUID buffPrefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) TryRemoveBuff(entity, buffPrefabGuid); return true; } public static bool HasBuff(Entity entity, PrefabGUID buffPrefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = ServerGameManager; return ((ServerGameManager)(ref serverGameManager)).HasBuff(entity, ((PrefabGUID)(ref buffPrefabGuid)).ToIdentifier()); } } public static class EntityService { private static EntityManager EntityManager => Core.EntityManager; public unsafe static bool TryFindPlayer(string playerName, out Entity playerEntity, out Entity userEntity) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_007f: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(playerName)) { playerEntity = Entity.Null; userEntity = Entity.Null; return false; } playerEntity = Entity.Null; userEntity = Entity.Null; EntityManager entityManager = EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; entityManager = EntityManager; User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current); if (((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString().Equals(playerName, StringComparison.OrdinalIgnoreCase)) { userEntity = current; playerEntity = componentData.LocalCharacter._Entity; return true; } } return false; } public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0010: 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_0013: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //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_003a: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) //IL_0064: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) EntityQueryOptions val = (EntityQueryOptions)0; if (includeAll) { val = (EntityQueryOptions)(val | 0xC3); } if (includeDisabled) { val = (EntityQueryOptions)(val | 2); } if (includeSpawn) { val = (EntityQueryOptions)(val | 0x40); } if (includePrefab) { val = (EntityQueryOptions)(val | 1); } if (includeDestroyed) { val = (EntityQueryOptions)(val | 0x80); } EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0)); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions(val); EntityManager entityManager = Core.EntityManager; EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3); return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); } } public struct ItemData { public string PrefabGUIDName { get; set; } public int PrefabGUID { get; set; } public int SequenceGuidHash { get; set; } public int[] AbilityGUIDs { get; set; } public ItemData(string prefabGUIDName = "", int itemPrefabGUID = 0, int sequenceGuidHash = 0, int[] abilityGUIDs = null) { PrefabGUIDName = prefabGUIDName; PrefabGUID = itemPrefabGUID; SequenceGuidHash = sequenceGuidHash; AbilityGUIDs = abilityGUIDs; } } public static class ItemDataService { private static readonly string SaveDirectory = Path.Combine(Directory.GetCurrentDirectory(), "BepInEx", "config", "CustomAbilities"); private static readonly string SavePath = Path.Combine(SaveDirectory, "customabilities_item_data.json"); private static List<ItemData> _itemDataList = new List<ItemData>(); private static Dictionary<int, ItemData> _itemDataCache = new Dictionary<int, ItemData>(); private static bool _dataDirty = false; private static bool _periodicSaveCoroutineRunning = false; private const float PERIODIC_SAVE_INTERVAL = 30f; public static void Initialize() { Directory.CreateDirectory(SaveDirectory); LoadData(); } public static bool HasItemData(Entity itemEntity) { //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_000a: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) int num = 0; EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<SequenceGUID>(itemEntity)) { entityManager = Core.EntityManager; num = ((EntityManager)(ref entityManager)).GetComponentData<SequenceGUID>(itemEntity).GuidHash; } if (num != 0) { return _itemDataCache.ContainsKey(num); } return false; } public static ItemData GetItemData(Entity itemEntity) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) int num = 0; EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<SequenceGUID>(itemEntity)) { entityManager = Core.EntityManager; num = ((EntityManager)(ref entityManager)).GetComponentData<SequenceGUID>(itemEntity).GuidHash; } if (num != 0) { ItemData result = (_itemDataCache.ContainsKey(num) ? _itemDataCache[num] : default(ItemData)); if (result.PrefabGUIDName != "" && result.SequenceGuidHash != 0) { return result; } } entityManager = Core.EntityManager; PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(itemEntity); string prefabGUIDName = PrefabGUIDsExtensions.GetPrefabGUIDName(componentData); num = ItemService.GetItemUniqueId(itemEntity); ItemData itemData = new ItemData { PrefabGUIDName = prefabGUIDName, PrefabGUID = componentData._Value, SequenceGuidHash = num, AbilityGUIDs = new int[8] }; _itemDataList.Add(itemData); _itemDataCache[num] = itemData; SaveData(); return itemData; } public static void SaveData() { MarkDirty(); } public static void MarkDirty() { _dataDirty = true; if (!_periodicSaveCoroutineRunning) { Core.StartCoroutine(PeriodicSaveCoroutine()); _periodicSaveCoroutineRunning = true; } } private static IEnumerator PeriodicSaveCoroutine() { while (true) { yield return (object)new WaitForSeconds(30f); if (_dataDirty) { FlushSaveToDisk(); _dataDirty = false; } } } public static void FlushSaveToDisk() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown try { string contents = JsonSerializer.Serialize(_itemDataList); File.WriteAllText(SavePath, contents); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to save item data: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogError(val); } } private static void LoadData() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (!File.Exists(SavePath)) { return; } try { _itemDataList = JsonSerializer.Deserialize<List<ItemData>>(File.ReadAllText(SavePath)) ?? new List<ItemData>(); _itemDataCache = new Dictionary<int, ItemData>(); foreach (ItemData itemData in _itemDataList) { _itemDataCache[itemData.SequenceGuidHash] = itemData; } } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to load item data: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogError(val); _itemDataList = new List<ItemData>(); } } } internal static class ItemService { private static EntityManager EntityManager => Core.EntityManager; public static Entity GetHeldWeaponEntity(Entity playerEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; Equipment val = default(Equipment); if (((EntityManager)(ref entityManager)).TryGetComponentData<Equipment>(playerEntity, ref val)) { Entity entity = val.WeaponSlot.SlotEntity._Entity; entityManager = EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity)) { return entity; } } return Entity.Null; } public static int GetItemUniqueId(Entity itemEntity) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) int num = 0; EntityManager entityManager = EntityManager; SequenceGUID val = default(SequenceGUID); if (((EntityManager)(ref entityManager)).TryGetComponentData<SequenceGUID>(itemEntity, ref val)) { return val.GuidHash; } num = Guid.NewGuid().GetHashCode(); ((SequenceGUID)(ref val))..ctor(num); entityManager = EntityManager; ((EntityManager)(ref entityManager)).AddComponentData<SequenceGUID>(itemEntity, val); return num; } } public static class PlayerDataService { private static readonly string SaveDirectory = Path.Combine(Directory.GetCurrentDirectory(), "BepInEx", "config", "CustomAbilities"); private static readonly string SavePath = Path.Combine(SaveDirectory, "customabilities_player_data.json"); private static List<PlayerData> _playerDataList = new List<PlayerData>(); private static Dictionary<int, PlayerData> _playerDataCache = new Dictionary<int, PlayerData>(); private static bool _dataDirty = false; private static bool _periodicSaveCoroutineRunning = false; private const float PERIODIC_SAVE_INTERVAL = 30f; public static void Initialize() { Directory.CreateDirectory(SaveDirectory); LoadData(); } public unsafe static PlayerData GetPlayerData(Entity characterEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0042: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Entity val = characterEntity; EntityManager entityManager = Core.EntityManager; PrefabGUID val2 = default(PrefabGUID); if (((EntityManager)(ref entityManager)).TryGetComponentData<PrefabGUID>(characterEntity, ref val2) && !((PrefabGUID)(ref val2)).Equals(PrefabGUIDs.CHAR_VampireMale)) { entityManager = Core.EntityManager; ControlledBy val3 = default(ControlledBy); if (((EntityManager)(ref entityManager)).TryGetComponentData<ControlledBy>(characterEntity, ref val3)) { val = val3.Controller.GetUser().LocalCharacter._Entity; } } User user = val.GetUser(); string text = ((object)(*(FixedString64Bytes*)(&user.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text)) { text = "Unknown Player"; } int guidHash = GetGuidHash(val); if (guidHash != 0 && _playerDataCache.TryGetValue(guidHash, out var value)) { return value; } return GetOrCreatePlayerData(guidHash, text, val); } private static PlayerData GetOrCreatePlayerData(int guidHash, string characterName, Entity characterEntity) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) ulong steamId = 0uL; PlayerCharacter componentData2; if (characterEntity.TryGetComponent<User>(out User componentData)) { steamId = componentData.PlatformId; } else if (characterEntity.TryGetComponent<PlayerCharacter>(out componentData2)) { steamId = componentData2.UserEntity.Read<User>().PlatformId; } if (guidHash != 0) { PlayerData playerData = _playerDataList.Find((PlayerData pd) => pd.GuidHash == guidHash); if (playerData != null) { playerData.CharacterName = characterName; _playerDataCache[guidHash] = playerData; return playerData; } } PlayerData obj = new PlayerData { SteamId = steamId, CharacterName = characterName, GuidHash = ((guidHash != 0) ? guidHash : Guid.NewGuid().GetHashCode()) }; PrefabGUID prefabGUID = PrefabGUIDsExtensions.GetPrefabGUID(characterEntity); obj.PrefabGuidHash = ((PrefabGUID)(ref prefabGUID)).GuidHash; PlayerData playerData2 = obj; if (guidHash == 0) { SequenceGUID val = default(SequenceGUID); ((SequenceGUID)(ref val))..ctor(playerData2.GuidHash); EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).AddComponentData<SequenceGUID>(characterEntity, val); guidHash = playerData2.GuidHash; } _playerDataList.Add(playerData2); _playerDataCache[guidHash] = playerData2; SaveData(); return playerData2; } public static void SaveData() { MarkDirty(); } public static void MarkDirty() { _dataDirty = true; if (!_periodicSaveCoroutineRunning) { Core.StartCoroutine(PeriodicSaveCoroutine()); _periodicSaveCoroutineRunning = true; } } private static IEnumerator PeriodicSaveCoroutine() { while (true) { yield return (object)new WaitForSeconds(30f); if (_dataDirty) { FlushSaveToDisk(); _dataDirty = false; } } } public static void FlushSaveToDisk() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown try { string contents = JsonSerializer.Serialize(_playerDataList); File.WriteAllText(SavePath, contents); } catch (Exception