Decompiled source of Beelzebub v0.137.7
BepInEx/plugins/Beelzebub.dll
Decompiled 21 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; using System.Text.RegularExpressions; using System.Threading; using Beelzebub.Config; using Beelzebub.Logic; using Beelzebub.Patches; using Beelzebub.Services; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppSystem.Text; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Behaviours; using ProjectM.Gameplay.Scripting; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Scripting; using ProjectM.Shared; using ProjectM.Shared.Systems; using Stunlock.Core; using Stunlock.Network; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; 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("kdpen")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Server-side V Rising mod: defeat a unit, acquire its ability. Configurable assignment to spell slots and admin-defined extra hotkeys.")] [assembly: AssemblyFileVersion("0.137.7.0")] [assembly: AssemblyInformationalVersion("0.137.7+bb8c7a50b73f386122227d4ef9620036ed338c37")] [assembly: AssemblyProduct("Beelzebub")] [assembly: AssemblyTitle("Beelzebub")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.137.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [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 Beelzebub { internal static class Core { private static bool _initInProgress; private static int _initAttempts; public static World Server { get; private set; } public static EntityManager EntityManager { get; private set; } public static PrefabCollectionSystem PrefabCollectionSystem { get; private set; } public static ServerScriptMapper ServerScriptMapper { get; private set; } public static DebugEventsSystem DebugEventsSystem { get; private set; } public static ReplaceAbilityOnSlotSystem ReplaceAbilityOnSlotSystem { get; private set; } public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager(); public static AbilityRegistry AbilityRegistry { get; private set; } public static AbilityFilter AbilityFilter { get; private set; } public static AbilityRules AbilityRules { get; private set; } public static AbilityMetadataService AbilityMetadata { get; private set; } public static ChatNotifier Chat { get; private set; } public static TransformService Transforms { get; private set; } public static PersistenceService Persistence { get; private set; } public static Dictionary<int, string> PrefabNames { get; } = new Dictionary<int, string>(); public static ManualLogSource Log => Plugin.PluginLog; public static bool IsReady { get; private set; } internal static void InitializeAfterLoaded() { TryInitialize("InitializeAfterLoaded"); } internal static void TryInitialize(string trigger) { //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Expected O, but got Unknown //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Expected O, but got Unknown //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Expected O, but got Unknown //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Expected O, but got Unknown //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ce: 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_0189: Expected O, but got Unknown //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) if (IsReady || _initInProgress) { return; } _initInProgress = true; _initAttempts++; bool flag = default(bool); try { World val = FindServerWorld(); BepInExInfoLogInterpolatedStringHandler val2; if (val == null) { if (_initAttempts == 1) { ManualLogSource log = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Beelzebub init ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): Server world not yet present; will retry."); } log.LogInfo(val2); } return; } PrefabCollectionSystem existingSystemManaged = val.GetExistingSystemManaged<PrefabCollectionSystem>(); if (existingSystemManaged == null || existingSystemManaged.SpawnableNameToPrefabGuidDictionary.Count == 0) { if (_initAttempts == 1) { ManualLogSource log2 = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(72, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Beelzebub init ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): PrefabCollectionSystem not yet populated; will retry."); } log2.LogInfo(val2); } return; } Server = val; EntityManager = val.EntityManager; PrefabCollectionSystem = existingSystemManaged; ServerScriptMapper = val.GetExistingSystemManaged<ServerScriptMapper>(); DebugEventsSystem = val.GetExistingSystemManaged<DebugEventsSystem>(); ReplaceAbilityOnSlotSystem = val.GetExistingSystemManaged<ReplaceAbilityOnSlotSystem>(); Persistence = new PersistenceService(); AbilityRules = new AbilityRules(); AbilityRules.Load(); AbilityMetadata = new AbilityMetadataService(); AbilityMetadata.Load(); AbilityRegistry = new AbilityRegistry(); AbilityFilter = new AbilityFilter(); Chat = new ChatNotifier(); Transforms = new TransformService(); Persistence.LoadInto(AbilityRegistry); BuildPrefabNameMap(); try { int num = SummonRegistry.BackfillAll(); if (num > 0) { ManualLogSource log3 = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(82, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Beelz] backfilled "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" signature-summon ability(ies) into existing transform unlocks."); } log3.LogInfo(val2); } } catch (Exception ex) { ManualLogSource log4 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] signature-summon backfill failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log4.LogWarning(val3); } try { int num2 = 0; int num3 = 0; int num4 = 0; PrefabGUID unit = default(PrefabGUID); foreach (var (steamId, readOnlyList2) in AbilityRegistry.TransformSnapshot()) { foreach (UnlockedTransform item in readOnlyList2) { if (!BossFormRegistry.Has(item.UnitPrefabGuid)) { ((PrefabGUID)(ref unit))..ctor(item.UnitPrefabGuid); if (!DevourService.CanResolveKit(unit)) { num4++; continue; } num3 += DevourService.Devour(steamId, unit, item.Source); AbilityRegistry.ForgetTransform(steamId, item.UnitPrefabGuid); num2++; } } } if (num4 > 0) { ManualLogSource log5 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(122, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] v0.44.0 migration: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num4); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" legacy unlock(s) left unconverted (unit prefab not resolvable this run); will retry next load."); } log5.LogWarning(val3); } if (num2 > 0) { Persistence.RequestSave(); ManualLogSource log6 = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(134, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Beelz] v0.44.0 migration: converted "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" legacy transform unlock(s) into Devour (granted "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ability(ies)); kept Dracula/Morgana transforms."); } log6.LogInfo(val2); } } catch (Exception ex2) { ManualLogSource log7 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] transform→Devour migration failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } log7.LogWarning(val3); } try { AbilityChainGraph.Build(); } catch (Exception ex3) { ManualLogSource log8 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] ability chain graph build failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex3.Message); } log8.LogWarning(val3); } try { AbilityTuningService.ApplyAll(); } catch (Exception ex4) { ManualLogSource log9 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] ability-tuning apply failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex4.Message); } log9.LogWarning(val3); } try { MountRecovery.NeutralizeMountDisruptingCasts(); } catch (Exception ex5) { ManualLogSource log10 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] mount-disrupt neutralize failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex5.Message); } log10.LogWarning(val3); } IsReady = true; ModLeakService.MarkDue("boot"); DealDamageSystemPatch.LogCoPatchers("kdpen.Beelzebub"); try { Heartbeat.StartTimer(); } catch (Exception ex6) { ManualLogSource log11 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz] heartbeat StartTimer failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex6.Message); } log11.LogWarning(val3); } ManualLogSource log12 = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(129, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Beelzebub initialized via "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (attempt #"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_initAttempts); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("). Registry size: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(AbilityRegistry.PlayerCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" player(s). Prefab map has "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(existingSystemManaged.SpawnableNameToPrefabGuidDictionary.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" entries. Built reverse name map with "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(PrefabNames.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" entries."); } log12.LogInfo(val2); } catch (Exception ex7) { ManualLogSource log13 = Log; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(39, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Beelzebub init ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") FAILED on attempt #"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(_initAttempts); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex7); } log13.LogError(val4); } finally { _initInProgress = false; } } private static World FindServerWorld() { Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } private static void BuildPrefabNameMap() { //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown PrefabNames.Clear(); int num = LoadEmbeddedPrefabNames(); int num2 = 0; int num3 = 0; int num4 = 0; bool flag = default(bool); try { foreach (KeyValuePair<int, string> prefabName in PrefabNames) { if (prefabName.Value.StartsWith("AB_")) { num3++; } } Enumerator<string, PrefabGUID> enumerator2 = PrefabCollectionSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator2.MoveNext()) { KeyValuePair<string, PrefabGUID> current = enumerator2.Current; string text = current.Key.ToString(); int value = current.Value._Value; if (PrefabNames.TryAdd(value, text)) { num2++; if (text.StartsWith("AB_")) { num4++; } } } ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(80, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Beelzebub: name map built. Embedded="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (AB_="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), added from runtime="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (AB_="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("). Total="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(PrefabNames.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Beelzebub: failed building name map (runtime merge): "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); } } private static int LoadEmbeddedPrefabNames() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown bool flag = default(bool); try { using Stream stream = typeof(Core).Assembly.GetManifestResourceStream("Beelzebub.Resources.prefab_names.tsv"); if (stream == null) { ManualLogSource log = Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Beelzebub: embedded resource '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Beelzebub.Resources.prefab_names.tsv"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found."); } log.LogWarning(val); return 0; } using StreamReader streamReader = new StreamReader(stream); int num = 0; string text; while ((text = streamReader.ReadLine()) != null) { int num2 = text.IndexOf('\t'); if (num2 > 0 && int.TryParse(text.AsSpan(0, num2), out var result)) { PrefabNames[result] = text.Substring(num2 + 1); num++; } } return num; } catch (Exception ex) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(49, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Beelzebub: failed loading embedded prefab names: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); return 0; } } } internal static class EntityExtensions { public delegate void RefAction<T>(ref T value) where T : unmanaged; public static bool Exists(this Entity entity) { //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) if (entity != Entity.Null) { EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(entity); } return false; } public static bool TryGetComponent<T>(this Entity entity, out T component) where T : unmanaged { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<T>(entity)) { entityManager = Core.EntityManager; component = ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); return true; } } component = default(T); return false; } public static bool Has<T>(this Entity entity) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).HasComponent<T>(entity); } return false; } public static void With<T>(this Entity entity, RefAction<T> mutator) where T : unmanaged { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_006b: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!entity.Has<T>()) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz] Entity.With<"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeof(T).Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(">: component missing on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(entity); } log.LogWarning(val); } else { EntityManager entityManager = Core.EntityManager; T value = ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); mutator(ref value); entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, value); } } public static bool IsPlayer(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return entity.Has<PlayerCharacter>(); } public static bool TryGetPlayer(this Entity entity, out Entity playerCharacter) { //IL_0000: 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_0009: 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) if (entity.IsPlayer()) { playerCharacter = entity; return true; } playerCharacter = Entity.Null; return false; } public static ulong GetSteamId(this Entity playerCharacter) { //IL_0000: 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_0019: Unknown result type (might be due to invalid IL or missing references) if (playerCharacter.TryGetComponent<PlayerCharacter>(out PlayerCharacter component) && component.UserEntity.TryGetComponent<User>(out User component2)) { return component2.PlatformId; } return 0uL; } public static PrefabGUID GetPrefabGuid(this Entity entity) { //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_000c: 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) if (!entity.TryGetComponent<PrefabGUID>(out PrefabGUID component)) { return default(PrefabGUID); } return component; } public static string GetPrefabName(this PrefabGUID guid) { //IL_0005: 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) if (!Core.PrefabNames.TryGetValue(guid._Value, out var value)) { return $"PrefabGuid({guid._Value})"; } return value; } public static string Humanize(this string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return ""; } string text = prefabName; string[] array = new string[6] { "AB_", "CHAR_", "Buff_", "Item_", "TM_", "SpellMod_" }; foreach (string text2 in array) { if (text.StartsWith(text2, StringComparison.OrdinalIgnoreCase)) { text = text.Substring(text2.Length); break; } } array = new string[5] { "_AbilityGroup", "_Group", "_Cast", "_Throw", "_VBlood" }; foreach (string text3 in array) { if (text.EndsWith(text3, StringComparison.OrdinalIgnoreCase)) { text = text.Substring(0, text.Length - text3.Length); break; } } text = text.Replace('_', ' '); StringBuilder stringBuilder = new StringBuilder(text.Length + 8); for (int j = 0; j < text.Length; j++) { char c = text[j]; if (j > 0 && char.IsUpper(c) && (char.IsLower(text[j - 1]) || char.IsDigit(text[j - 1]))) { stringBuilder.Append(' '); } stringBuilder.Append(c); } StringBuilder stringBuilder2 = new StringBuilder(stringBuilder.Length); char c2 = ' '; string text4 = stringBuilder.ToString(); foreach (char c3 in text4) { if (c3 != ' ' || c2 != ' ') { stringBuilder2.Append(c3); c2 = c3; } } return stringBuilder2.ToString().Trim(); } public static List<Entity> FindPlayersNear(float3 position, float radius) { //IL_0006: 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_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_0027: 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_0033: 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_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_005f: 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_0074: 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_0088: 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) List<Entity> list = new List<Entity>(); EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).World == null) { return list; } entityManager = Core.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadOnly<PlayerCharacter>(), ComponentType.ReadOnly<LocalToWorld>() }); NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { float num = radius * radius; for (int i = 0; i < val2.Length; i++) { if (val2[i].TryGetComponent<LocalToWorld>(out LocalToWorld component)) { float3 position2 = ((LocalToWorld)(ref component)).Position; float num2 = position2.x - position.x; float num3 = position2.z - position.z; if (num2 * num2 + num3 * num3 <= num) { list.Add(val2[i]); } } } return list; } finally { val2.Dispose(); } } public unsafe static Entity FindCharacterByName(string nameFragment, out ulong steamId, out string fullName) { //IL_001f: 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_0014: 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_002a: 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_0040: 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_0049: 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_0054: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) steamId = 0uL; fullName = null; if (!string.IsNullOrWhiteSpace(nameFragment)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).World != null) { entityManager = Core.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Entity result = Entity.Null; int num = 0; try { for (int i = 0; i < val2.Length; i++) { if (!val2[i].TryGetComponent<User>(out User component)) { continue; } string text = ((object)(*(FixedString64Bytes*)(&component.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrEmpty(text) && text.Contains(nameFragment, StringComparison.OrdinalIgnoreCase)) { Entity entity = component.LocalCharacter._Entity; if (entity.Exists()) { result = entity; steamId = component.PlatformId; fullName = text; num++; } } } } finally { val2.Dispose(); } if (num != 1) { return Entity.Null; } return result; } } return Entity.Null; } public unsafe static List<(ulong steamId, string name, bool isAdmin)> AllUsers() { //IL_0006: 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_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_0027: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0094: Unknown result type (might be due to invalid IL or missing references) List<(ulong, string, bool)> list = new List<(ulong, string, bool)>(); EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).World == null) { return list; } entityManager = Core.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val2.Length; i++) { if (val2[i].TryGetComponent<User>(out User component)) { ulong platformId = component.PlatformId; if (platformId != 0L) { string text = ((object)(*(FixedString64Bytes*)(&component.CharacterName))/*cast due to .constrained prefix*/).ToString(); list.Add((platformId, string.IsNullOrEmpty(text) ? platformId.ToString() : text, component.IsAdmin)); } } } return list; } finally { val2.Dispose(); } } public static float ResolveTierMultiplier(this Entity died) { //IL_0000: 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) if (!died.TryGetComponent<UnitLevel>(out UnitLevel component)) { return 1f; } int value = component.Level._Value; if (value >= Settings.Capture_TierHighThreshold.Value) { return Settings.Capture_TierMultiplier_High.Value; } if (value >= Settings.Capture_TierMidThreshold.Value) { return Settings.Capture_TierMultiplier_Mid.Value; } return Settings.Capture_TierMultiplier_Low.Value; } public static bool IsVBloodUnit(this PrefabGUID unitGuid) { //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_0016: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (Core.PrefabCollectionSystem == null) { return false; } PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; Entity entity = default(Entity); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(unitGuid, ref entity)) { return false; } if (!entity.Has<VBloodUnit>()) { return entity.Has<VBloodConsumeSource>(); } return true; } public static Entity FindCharacterBySteamId(ulong steamId) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_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_0028: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0040: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007e: Unknown result type (might be due to invalid IL or missing references) if (steamId != 0L) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).World != null) { entityManager = Core.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val2.Length; i++) { if (val2[i].TryGetComponent<User>(out User component) && component.PlatformId == steamId) { Entity entity = component.LocalCharacter._Entity; if (entity.Exists()) { return entity; } } } return Entity.Null; } finally { val2.Dispose(); } } } return Entity.Null; } } [BepInPlugin("kdpen.Beelzebub", "Beelzebub", "0.137.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { internal static Harmony Harmony; internal static ManualLogSource PluginLog; internal static Plugin Instance { get; private set; } public override void Load() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown if (!(Application.productName != "VRisingServer")) { Instance = this; PluginLog = ((BasePlugin)this).Log; ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("kdpen.Beelzebub"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.137.7"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loading..."); } log.LogInfo(val); Settings.Initialize(((BasePlugin)this).Config); Harmony = new Harmony("kdpen.Beelzebub"); Harmony.PatchAll(Assembly.GetExecutingAssembly()); int num = Harmony.GetPatchedMethods().Count(); ManualLogSource log2 = ((BasePlugin)this).Log; val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches applied: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" method(s) patched."); } log2.LogInfo(val); CommandRegistry.RegisterAll(); ManualLogSource log3 = ((BasePlugin)this).Log; val = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("kdpen.Beelzebub"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.137.7"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Awaiting game data init."); } log3.LogInfo(val); } } public override bool Unload() { CommandRegistry.UnregisterAssembly(); Core.Persistence?.SaveSync(); Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } public void OnGameInitialized() { if (Core.Server == null && !HasGameDataLoaded()) { ((BasePlugin)this).Log.LogDebug((object)"OnGameInitialized fired but PrefabCollectionSystem is empty; deferring to InitializationPatch."); } else { Core.InitializeAfterLoaded(); } } private static bool HasGameDataLoaded() { Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (!(current.Name != "Server")) { PrefabCollectionSystem existingSystemManaged = current.GetExistingSystemManaged<PrefabCollectionSystem>(); if (existingSystemManaged == null) { return false; } return existingSystemManaged.SpawnableNameToPrefabGuidDictionary.Count > 0; } } return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "kdpen.Beelzebub"; public const string PLUGIN_NAME = "Beelzebub"; public const string PLUGIN_VERSION = "0.137.7"; } } namespace Beelzebub.Services { internal static class AbilityChainGraph { public enum EdgeKind { Root, StartAbility, SpawnOnCast, SpawnOnStartCast, SpawnOnEvent, SpawnOnDestroy, ApplyBuff, KnockbackBuff, ProjectileFan, MultiShot, Cluster, MinionDeathBuff, Script } public sealed class Node { public int Guid; public int Depth; public int Parent; public EdgeKind Via; public bool IsUnit; } public sealed class Chain { public int Root; public readonly List<Node> Nodes = new List<Node>(); public readonly HashSet<int> NodeSet = new HashSet<int>(); public bool Complete = true; public readonly List<string> IncompleteReasons = new List<string>(); public bool HasMinionSpawn; } public const int MaxDepth = 8; private static readonly Dictionary<int, Chain> _groups = new Dictionary<int, Chain>(); private static readonly Dictionary<int, HashSet<int>> _owners = new Dictionary<int, HashSet<int>>(); private static readonly HashSet<int> _persistentKinds = new HashSet<int>(); private static Dictionary<int, List<(int tgt, string kind)>> _scriptEdges; private static readonly Dictionary<string, int> _decodeFailures = new Dictionary<string, int>(); private static readonly HashSet<string> _failedKinds = new HashSet<string>(); private static bool _scriptTableFailed; public static readonly HashSet<string> UnsafeClasses = new HashSet<string>(); public static readonly List<string> UnsafeReasons = new List<string>(); public static bool Built { get; private set; } public static int Generation { get; private set; } public static int GroupCount => _groups.Count; public static int IncompleteCount { get; private set; } public static int ScriptEdgeDrift { get; private set; } public static IReadOnlyDictionary<string, int> DecodeFailures => _decodeFailures; private static string ProducedClass(string what) { switch (what) { case "ApplyBuff": case "KnockbackBuff": case "SpawnMinion": return "Buff"; case "ProjectileFan": case "MultiShot": return "Projectile"; default: return "Any"; } } public static bool IsInUnsafeClass(Entity prefab, out string reason) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) reason = null; if (UnsafeClasses.Count == 0) { return false; } if (UnsafeClasses.Contains("Any")) { reason = "graph has unresolved edges (" + string.Join("; ", UnsafeReasons) + ")"; return true; } if (UnsafeClasses.Contains("Buff") && prefab.Has<Buff>()) { reason = "unresolved buff edges (" + string.Join("; ", UnsafeReasons) + ")"; return true; } if (UnsafeClasses.Contains("Projectile") && prefab.Has<Projectile>()) { reason = "unresolved projectile edges (" + string.Join("; ", UnsafeReasons) + ")"; return true; } return false; } public static void Build() { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Expected O, but got Unknown //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Expected O, but got Unknown DateTime utcNow = DateTime.UtcNow; Built = false; _decodeFailures.Clear(); _failedKinds.Clear(); Dictionary<int, Chain> dictionary = new Dictionary<int, Chain>(); Dictionary<int, HashSet<int>> dictionary2 = new Dictionary<int, HashSet<int>>(); HashSet<int> hashSet = new HashSet<int>(); int num = 0; bool flag = default(bool); try { LoadScriptEdges(); EntityManager entityManager = Core.EntityManager; foreach (KeyValuePair<int, string> prefabName in Core.PrefabNames) { if (!TryPrefab(prefabName.Key, out var e) || !((EntityManager)(ref entityManager)).HasBuffer<AbilityGroupStartAbilitiesBuffer>(e)) { continue; } Chain chain = Walk(prefabName.Key); dictionary[prefabName.Key] = chain; if (!chain.Complete) { num++; } foreach (Node node in chain.Nodes) { if (!dictionary2.TryGetValue(node.Guid, out var value)) { value = (dictionary2[node.Guid] = new HashSet<int>()); } value.Add(prefabName.Key); EdgeKind via = node.Via; flag = (uint)via <= 1u; if (flag) { hashSet.Add(node.Guid); } } } } catch (Exception ex) { Built = false; ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(88, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz GRAPH] build FAILED — baked ability tuning is disabled until a successful build: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogError(val); return; } _groups.Clear(); foreach (KeyValuePair<int, Chain> item in dictionary) { _groups[item.Key] = item.Value; } _owners.Clear(); foreach (KeyValuePair<int, HashSet<int>> item2 in dictionary2) { _owners[item2.Key] = item2.Value; } _persistentKinds.Clear(); _persistentKinds.UnionWith(hashSet); IncompleteCount = num; UnsafeClasses.Clear(); UnsafeReasons.Clear(); foreach (string failedKind in _failedKinds) { UnsafeClasses.Add(ProducedClass(failedKind)); UnsafeReasons.Add("decode " + failedKind + " failed"); } if (_scriptTableFailed) { UnsafeClasses.Add("Any"); UnsafeReasons.Add("script-edge table missing/unreadable"); } if (ScriptEdgeDrift > 0) { UnsafeClasses.Add("Any"); UnsafeReasons.Add($"script-edge table stale ({ScriptEdgeDrift} source prefab(s) gone — game update? re-run tools/build_script_edges.py)"); } Built = true; Generation++; ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(106, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Beelz GRAPH] built: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_groups.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ability groups, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_owners.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" chain prefabs, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(IncompleteCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" incomplete group(s), script-edge drift "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(ScriptEdgeDrift); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>((DateTime.UtcNow - utcNow).TotalMilliseconds, "F0"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ms (gen "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(Generation); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log2.LogInfo(val2); if (_decodeFailures.Count > 0) { Core.Log.LogWarning((object)("[Beelz GRAPH] decode failures: " + string.Join(", ", DescribeFailures()))); } if (UnsafeClasses.Count > 0) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(51, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Beelz GRAPH] baked edits DISABLED for class(es) "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(string.Join(",", UnsafeClasses)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(string.Join("; ", UnsafeReasons)); } log3.LogWarning(val3); } } public static IEnumerable<string> DescribeFailures() { foreach (KeyValuePair<string, int> decodeFailure in _decodeFailures) { yield return $"{decodeFailure.Key}×{decodeFailure.Value}"; } } public static List<int> AllGroups() { List<int> list = new List<int>(_groups.Keys); list.Sort(); return list; } public static Chain GetGroup(int groupGuid) { if (!_groups.TryGetValue(groupGuid, out var value)) { return null; } return value; } public static Chain GetOrWalk(int rootGuid) { return GetGroup(rootGuid) ?? Walk(rootGuid); } public static bool IsNode(int prefabGuid) { return _owners.ContainsKey(prefabGuid); } public static bool IsPersistentKind(int prefabGuid) { return _persistentKinds.Contains(prefabGuid); } public static IReadOnlyCollection<int> Owners(int prefabGuid) { if (!_owners.TryGetValue(prefabGuid, out var value)) { return (IReadOnlyCollection<int>)(object)Array.Empty<int>(); } return value; } public static bool IsOwner(int prefabGuid, int group) { if (_owners.TryGetValue(prefabGuid, out var value)) { return value.Contains(group); } return false; } public static bool IsOwnershipComplete(int prefabGuid) { foreach (int item in Owners(prefabGuid)) { if (_groups.TryGetValue(item, out var value) && !value.Complete) { return false; } } return true; } public static bool IsShared(int prefabGuid) { if (Owners(prefabGuid).Count <= 1) { return !IsOwnershipComplete(prefabGuid); } return true; } public static List<int> OtherOwners(int prefabGuid, int self) { List<int> list = new List<int>(); foreach (int item in Owners(prefabGuid)) { if (item != self) { list.Add(item); } } list.Sort(); return list; } public static Chain Walk(int rootGuid) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) Chain chain = new Chain { Root = rootGuid }; Queue<Node> queue = new Queue<Node>(); Node item = new Node { Guid = rootGuid, Depth = 0, Parent = 0, Via = EdgeKind.Root, IsUnit = IsUnitGuid(rootGuid) }; chain.Nodes.Add(item); chain.NodeSet.Add(rootGuid); queue.Enqueue(item); List<(int, EdgeKind)> list = new List<(int, EdgeKind)>(); while (queue.Count > 0) { Node node = queue.Dequeue(); if (node.IsUnit || !TryPrefab(node.Guid, out var e)) { continue; } list.Clear(); CollectEdges(e, node.Guid, list, chain); foreach (var (num, via) in list) { if (num == 0 || chain.NodeSet.Contains(num)) { continue; } if (node.Depth + 1 > 8) { if (chain.Complete) { chain.IncompleteReasons.Add($"depth>{8} at {Name(node.Guid)}"); } chain.Complete = false; } else { Node item2 = new Node { Guid = num, Depth = node.Depth + 1, Parent = node.Guid, Via = via, IsUnit = IsUnitGuid(num) }; chain.Nodes.Add(item2); chain.NodeSet.Add(num); queue.Enqueue(item2); } } } return chain; } private static void CollectEdges(Entity e, int guid, List<(int, EdgeKind)> edges, Chain chain) { //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) //IL_001c: 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) EntityManager em = Core.EntityManager; Try("StartAbilities", chain, delegate { //IL_0007: 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_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_0034: 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) if (((EntityManager)(ref em)).HasBuffer<AbilityGroupStartAbilitiesBuffer>(e)) { DynamicBuffer<AbilityGroupStartAbilitiesBuffer> buffer = ((EntityManager)(ref em)).GetBuffer<AbilityGroupStartAbilitiesBuffer>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].PrefabGUID._Value, EdgeKind.StartAbility)); } } }); Try("SpawnOnCast", chain, delegate { //IL_0007: 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_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_0034: 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) if (((EntityManager)(ref em)).HasBuffer<AbilitySpawnPrefabOnCast>(e)) { DynamicBuffer<AbilitySpawnPrefabOnCast> buffer = ((EntityManager)(ref em)).GetBuffer<AbilitySpawnPrefabOnCast>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].SpawnPrefab._Value, EdgeKind.SpawnOnCast)); } } }); Try("SpawnOnStartCast", chain, delegate { //IL_0007: 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_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_0034: 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) if (((EntityManager)(ref em)).HasBuffer<AbilitySpawnPrefabOnStartCast>(e)) { DynamicBuffer<AbilitySpawnPrefabOnStartCast> buffer = ((EntityManager)(ref em)).GetBuffer<AbilitySpawnPrefabOnStartCast>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].SpawnPrefab._Value, EdgeKind.SpawnOnStartCast)); } } }); Try("SpawnOnEvent", chain, delegate { //IL_0007: 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_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_0034: 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) if (((EntityManager)(ref em)).HasBuffer<SpawnPrefabOnGameplayEvent>(e)) { DynamicBuffer<SpawnPrefabOnGameplayEvent> buffer = ((EntityManager)(ref em)).GetBuffer<SpawnPrefabOnGameplayEvent>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].SpawnPrefab._Value, EdgeKind.SpawnOnEvent)); } } }); Try("SpawnOnDestroy", chain, delegate { //IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (e.TryGetComponent<SpawnPrefabOnDestroy>(out SpawnPrefabOnDestroy component)) { edges.Add((component.SpawnPrefab._Value, EdgeKind.SpawnOnDestroy)); } }); Try("ApplyBuff", chain, delegate { //IL_0007: 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_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (((EntityManager)(ref em)).HasBuffer<ApplyBuffOnGameplayEvent>(e)) { DynamicBuffer<ApplyBuffOnGameplayEvent> buffer = ((EntityManager)(ref em)).GetBuffer<ApplyBuffOnGameplayEvent>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].Buff0._Value, EdgeKind.ApplyBuff)); edges.Add((buffer[i].Buff1._Value, EdgeKind.ApplyBuff)); edges.Add((buffer[i].Buff2._Value, EdgeKind.ApplyBuff)); edges.Add((buffer[i].Buff3._Value, EdgeKind.ApplyBuff)); } } }); Try("KnockbackBuff", chain, delegate { //IL_0007: 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_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_0034: 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) if (((EntityManager)(ref em)).HasBuffer<ApplyKnockbackOnGameplayEvent>(e)) { DynamicBuffer<ApplyKnockbackOnGameplayEvent> buffer = ((EntityManager)(ref em)).GetBuffer<ApplyKnockbackOnGameplayEvent>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].CustomKnockbackBuff._Value, EdgeKind.KnockbackBuff)); } } }); Try("SpawnMinion", chain, delegate { //IL_0007: 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_0032: 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_0045: Unknown result type (might be due to invalid IL or missing references) if (((EntityManager)(ref em)).HasBuffer<SpawnMinionOnGameplayEvent>(e)) { chain.HasMinionSpawn = true; DynamicBuffer<SpawnMinionOnGameplayEvent> buffer = ((EntityManager)(ref em)).GetBuffer<SpawnMinionOnGameplayEvent>(e, false); for (int i = 0; i < buffer.Length; i++) { edges.Add((buffer[i].MasterDeathBuffPrefabGuid._Value, EdgeKind.MinionDeathBuff)); } } }); Try("ProjectileFan", chain, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_0019: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (e.TryGetComponent<AbilityProjectileFanOnGameplayEvent_DataServer>(out AbilityProjectileFanOnGameplayEvent_DataServer component)) { edges.Add((component.NewProjectileEntity._Value, EdgeKind.ProjectileFan)); edges.Add((component.NewProjectileEntityAlternate._Value, EdgeKind.ProjectileFan)); edges.Add((component.BoostBuffType._Value, EdgeKind.ProjectileFan)); edges.Add((component.BoostPerStackPrefab1._Value, EdgeKind.ProjectileFan)); edges.Add((component.BoostPerStackPrefab2._Value, EdgeKind.ProjectileFan)); edges.Add((component.BoostPerStackPrefab3._Value, EdgeKind.ProjectileFan)); } if (e.TryGetComponent<AbilityProjectileFanOnTick_DataServer>(out AbilityProjectileFanOnTick_DataServer component2)) { edges.Add((component2.NewProjectileEntity._Value, EdgeKind.ProjectileFan)); edges.Add((component2.NewProjectileEntityAlternate._Value, EdgeKind.ProjectileFan)); } }); Try("MultiShot", chain, delegate { //IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (e.TryGetComponent<Script_MultiShot_Cast_DataServer>(out Script_MultiShot_Cast_DataServer component)) { edges.Add((component.NewProjectile._Value, EdgeKind.MultiShot)); } }); Try("Cluster", chain, delegate { //IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (e.TryGetComponent<EvenSpreadCluster_DataServer>(out EvenSpreadCluster_DataServer component)) { edges.Add((component.NewThrowEntity._Value, EdgeKind.Cluster)); } }); if (_scriptEdges == null || !_scriptEdges.TryGetValue(guid, out List<(int, string)> value)) { return; } foreach (var item2 in value) { int item = item2.Item1; edges.Add((item, EdgeKind.Script)); } } private static void Try(string what, Chain chain, Action a) { try { a(); } catch (Exception) { _decodeFailures[what] = ((!_decodeFailures.TryGetValue(what, out var value)) ? 1 : (value + 1)); _failedKinds.Add(what); if (chain.Complete || chain.IncompleteReasons.Count < 4) { chain.IncompleteReasons.Add("decode " + what + " failed"); } chain.Complete = false; } } public static IEnumerable<(int tgt, string kind)> ScriptEdgesFrom(int guid) { if (_scriptEdges == null || !_scriptEdges.TryGetValue(guid, out List<(int, string)> value)) { yield break; } foreach (var item in value) { yield return item; } } private static void LoadScriptEdges() { //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown if (_scriptEdges != null && !_scriptTableFailed) { ScriptEdgeDrift = CountDrift(); return; } _scriptTableFailed = false; _scriptEdges = new Dictionary<int, List<(int, string)>>(); bool flag = default(bool); try { using Stream stream = typeof(AbilityChainGraph).Assembly.GetManifestResourceStream("Beelzebub.Resources.script_edges.tsv"); if (stream == null) { _scriptTableFailed = true; ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz GRAPH] embedded '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Beelzebub.Resources.script_edges.tsv"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' missing — scripted edges not decoded."); } log.LogWarning(val); return; } using StreamReader streamReader = new StreamReader(stream); int num = 0; int result = -1; int num2 = 0; string text; while ((text = streamReader.ReadLine()) != null) { num2++; if (text.Length == 0) { continue; } if (text[0] == '#') { if (text.StartsWith("# edges=", StringComparison.Ordinal)) { int.TryParse(text.Substring(8), out result); } continue; } string[] array = text.Split('\t'); if (array.Length < 3 || !int.TryParse(array[0], out var result2) || !int.TryParse(array[1], out var result3) || array[2].Length == 0) { _scriptTableFailed = true; ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(80, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz GRAPH] script-edge table corrupt at line "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" — treating the table as failed."); } log2.LogWarning(val); return; } if (!_scriptEdges.TryGetValue(result2, out List<(int, string)> value)) { value = (_scriptEdges[result2] = new List<(int, string)>()); } value.Add((result3, array[2])); num++; } if (result < 0 || num != result || num == 0) { _scriptTableFailed = true; ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(109, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz GRAPH] script-edge table integrity check failed (rows "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", header edges="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(result); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") — treating the table as failed."); } log3.LogWarning(val); return; } } catch (Exception ex) { _scriptTableFailed = true; ManualLogSource log4 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz GRAPH] script-edge table load failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log4.LogWarning(val); } ScriptEdgeDrift = CountDrift(); } private static int CountDrift() { int num = 0; foreach (int key in _scriptEdges.Keys) { if (!TryPrefab(key, out var _)) { num++; } } return num; } public static bool IsUnitGuid(int guid) { return Name(guid).StartsWith("CHAR_", StringComparison.Ordinal); } public static string Name(int guid) { if (!Core.PrefabNames.TryGetValue(guid, out var value) || string.IsNullOrEmpty(value)) { return guid.ToString(); } return value; } private static bool TryPrefab(int guid, out Entity e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_002a: Unknown result type (might be due to invalid IL or missing references) e = Entity.Null; if (guid != 0) { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(new PrefabGUID(guid), ref e)) { return e.Exists(); } } return false; } } internal static class AbilityCooldownEnforcer { private sealed class Pending { public long CastId; public Entity Character; public Entity GroupEntity; public int AbilityGuid; public float? Absolute; public float Scale; public float Floor; public double[] PreEnd; public DateTime ExpireUtc; } private static readonly Dictionary<(ulong, int, Entity), Queue<Pending>> _pending = new Dictionary<(ulong, int, Entity), Queue<Pending>>(); private static readonly HashSet<int> _chargeWarned = new HashSet<int>(); private const float EnforceWindowSeconds = 6f; private const float GuardSeconds = 12f; private static readonly Dictionary<Entity, (double End, float Seconds, DateTime Until)> _guards = new Dictionary<Entity, (double, float, DateTime)>(); private static readonly Dictionary<int, bool> _zeroNative = new Dictionary<int, bool>(); public static long Applied { get; private set; } public static long Expired { get; private set; } public static long Created { get; private set; } public static void OnCast(Entity caster, PrefabGUID abilityGroup, CastHistoryService.CastRecord rec) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Expected O, but got Unknown //IL_0008: 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_003f: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown bool flag2 = default(bool); try { if (!caster.Exists() || !caster.IsPlayer()) { return; } ulong steamId = caster.GetSteamId(); if (steamId == 0L || Core.AbilityRegistry.GetActiveTransform(steamId) != null || rec == null || rec.Group != abilityGroup._Value || !rec.Captured || !rec.FromSlot) { return; } string prefabName = abilityGroup.GetPrefabName(); float? cooldownOverride = Core.AbilityRules.GetCooldownOverride(prefabName); float cooldownScale = Core.AbilityRules.GetCooldownScale(prefabName); float num = Math.Max(0f, Settings.Grant_MinimumCooldownSeconds.Value); bool flag = !float.IsFinite(cooldownScale) || cooldownScale <= 0f || Math.Abs(cooldownScale - 1f) < 0.0001f; if (!cooldownOverride.HasValue && flag && num <= 0f) { return; } if (HasCharges(abilityGroup._Value)) { if (_chargeWarned.Add(abilityGroup._Value)) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(120, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz CD] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prefabName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" uses charges — cooldown/cooldownscale/floor are not applied to charge abilities (tune 'chargetime' instead)."); } log.LogWarning(val); } return; } double[] array = ReadEndTimes(rec.GroupEntity); if (array == null) { return; } if (cooldownOverride.HasValue) { float valueOrDefault = cooldownOverride.GetValueOrDefault(); if (valueOrDefault > 0.01f && NativeCooldownIsZero(abilityGroup._Value)) { float num2 = Math.Max(valueOrDefault, num); if (StartCooldown(rec.GroupEntity, num2) && Settings.VerboseLogging.Value) { ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(51, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Beelz CD] cast #"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<long>(rec.CastId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(prefabName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": no native cooldown — started "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num2, "F2"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("s."); } log2.LogInfo(val2); } return; } } (ulong, int, Entity) key = (steamId, abilityGroup._Value, rec.GroupEntity); if (!_pending.TryGetValue(key, out var value)) { value = (_pending[key] = new Queue<Pending>()); } value.Enqueue(new Pending { CastId = rec.CastId, Character = caster, GroupEntity = rec.GroupEntity, AbilityGuid = abilityGroup._Value, Absolute = cooldownOverride, Scale = (flag ? 1f : cooldownScale), Floor = num, PreEnd = array, ExpireUtc = DateTime.UtcNow.AddSeconds(6.0) }); if (Settings.VerboseLogging.Value) { ManualLogSource log3 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(44, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Beelz CD] queued cast #"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<long>(rec.CastId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(prefabName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" abs="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(cooldownOverride?.ToString("0.##") ?? "-"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" scale="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(cooldownScale, "0.##"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" floor="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(num, "0.##"); } log3.LogInfo(val2); } } catch (Exception ex) { ManualLogSource log4 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz CD] OnCast failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log4.LogWarning(val); } } private static bool NativeCooldownIsZero(int groupGuid) { //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_005d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) if (_zeroNative.TryGetValue(groupGuid, out var value)) { return value; } value = true; try { Entity entity = default(Entity); foreach (AbilityChainGraph.Node node in AbilityChainGraph.GetOrWalk(groupGuid).Nodes) { if (node.Guid == groupGuid || (node.Via == AbilityChainGraph.EdgeKind.StartAbility && node.Parent == groupGuid)) { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(new PrefabGUID(node.Guid), ref entity) && entity.Exists() && entity.TryGetComponent<AbilityCooldownData>(out AbilityCooldownData component) && component.Cooldown._Value > 0.01f) { value = false; break; } } } } catch { value = false; } _zeroNative[groupGuid] = value; return value; } private static bool StartCooldown(Entity groupEntity, float seconds) { //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_0012: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_005e: 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) //IL_008c: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00bc: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasBuffer<AbilityStateBuffer>(groupEntity)) { return false; } double serverTime = Core.ServerGameManager.ServerTime; List<Entity> list = new List<Entity>(); entityManager = Core.EntityManager; DynamicBuffer<AbilityStateBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AbilityStateBuffer>(groupEntity, false); for (int i = 0; i < buffer.Length; i++) { Entity entity = buffer[i].StateEntity._Entity; if (entity.Exists()) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<AbilityCooldownState>(entity)) { list.Add(entity); } } } foreach (Entity item in list) { entityManager = Core.EntityManager; AbilityCooldownState componentData = ((EntityManager)(ref entityManager)).GetComponentData<AbilityCooldownState>(item); componentData.CurrentCooldown = seconds; componentData.CooldownEndTime = serverTime + (double)seconds; entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<AbilityCooldownState>(item, componentData); _guards[item] = (serverTime + (double)seconds, seconds, DateTime.UtcNow.AddSeconds(Math.Min(12f, seconds))); } if (list.Count > 0) { Created++; } return list.Count > 0; } private static void TickGuards() { //IL_0039: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_005c: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008b: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (_guards.Count == 0) { return; } DateTime utcNow = DateTime.UtcNow; List<Entity> list = null; foreach (var (val2, tuple2) in _guards) { if (!(utcNow > tuple2.Item3) && val2.Exists()) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<AbilityCooldownState>(val2)) { entityManager = Core.EntityManager; AbilityCooldownState componentData = ((EntityManager)(ref entityManager)).GetComponentData<AbilityCooldownState>(val2); if (componentData.CooldownEndTime < tuple2.Item1 - 0.05) { componentData.CooldownEndTime = tuple2.Item1; componentData.CurrentCooldown = tuple2.Item2; entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<AbilityCooldownState>(val2, componentData); } continue; } } (list ?? (list = new List<Entity>())).Add(val2); } if (list == null) { return; } foreach (Entity item in list) { _guards.Remove(item); } } public static bool HasCharges(int groupGuid) { //IL_0041: 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_004f: 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_0065: Unknown result type (might be due to invalid IL or missing references) if (groupGuid == 0) { return false; } try { Entity entity = default(Entity); foreach (AbilityChainGraph.Node node in AbilityChainGraph.GetOrWalk(groupGuid).Nodes) { if (node.Guid == groupGuid || (node.Via == AbilityChainGraph.EdgeKind.StartAbility && node.Parent == groupGuid)) { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(new PrefabGUID(node.Guid), ref entity) && entity.Exists() && entity.Has<AbilityChargesData>()) { return true; } } } } catch { } return false; } private static double[] ReadEndTimes(Entity stateEnt) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_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) //IL_0051: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_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_0078: 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 (stateEnt.Exists()) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasBuffer<AbilityStateBuffer>(stateEnt)) { entityManager = Core.EntityManager; DynamicBuffer<AbilityStateBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AbilityStateBuffer>(stateEnt, false); double[] array = new double[buffer.Length]; bool flag = false; for (int i = 0; i < buffer.Length; i++) { Entity entity = buffer[i].StateEntity._Entity; if (entity.Exists()) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<AbilityCooldownState>(entity)) { int num = i; entityManager = Core.EntityManager; array[num] = ((EntityManager)(ref entityManager)).GetComponentData<AbilityCooldownState>(entity).CooldownEndTime; flag = true; continue; } } array[i] = double.NaN; } if (!flag) { return null; } return array; } } return null; } public static void Tick() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { TickGuards(); } catch (Exception ex) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Beelz CD] guard tick failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); _guards.Clear(); } if (_pending.Count == 0) { return; } DateTime utcNow = DateTime.UtcNow; List<(ulong, int, Entity)> list = null; foreach (KeyValuePair<(ulong, int, Entity), Queue<Pending>> item in _pending) { Queue<Pending> value = item.Value; while (value.Count > 0) { Pending pending = value.Peek(); if (!pending.Character.Exists() || !pending.GroupEntity.Exists() || utcNow > pending.ExpireUtc) { value.Dequeue(); Expired++; if (Settings.VerboseLogging.Value) { ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(65, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Beelz CD] cast #"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<long>(pending.CastId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(EntityExtensions.GetPrefabName(new PrefabGUID(pending.AbilityGuid))); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": no new cooldown seen within "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(6f, "0"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("s — left vanilla."); } log2.LogInfo(val2); } continue; } if (!TryEnforce(pending, out var writtenEnd, out var index)) { break; } value.Dequeue(); foreach (Pending item2 in value) { if (index < item2.PreEnd.Length) { item2.PreEnd[index] = writtenEnd; } } } if (value.Count == 0) { (list ?? (list = new List<(ulong, int, Entity)>())).Add(item.Key); } } if (list == null) { return; } foreach (var item3 in list) { _pending.Remove(item3); } } private static bool TryEnforce(Pending p, out double writtenEnd, out int index) { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0033: 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_0049: 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_0058: 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_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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to