Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Warrior Glory v1.0.0
plugins/Warrior_Glory.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using AzuEPI; using AzuEPI.Core.Slots; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Distant_Origins.Shared; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using PieceManager; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: AssemblyFileVersion("1.0.0")] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyProduct("Warrior_Glory")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Warrior_Glory")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Dreanegade")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: <6c6ad294-e024-4c1a-a600-3b0ae9889f05>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<c188e3aa-a209-4519-8008-9552740c5754>Embedded] internal sealed class <c188e3aa-a209-4519-8008-9552740c5754>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<c188e3aa-a209-4519-8008-9552740c5754>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <336b9e50-cfc9-4ce2-af50-c6c57e35d432>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <336b9e50-cfc9-4ce2-af50-c6c57e35d432>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <336b9e50-cfc9-4ce2-af50-c6c57e35d432>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<c188e3aa-a209-4519-8008-9552740c5754>Embedded] [CompilerGenerated] internal sealed class <2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContextAttribute : Attribute { public readonly byte Flag; public <2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<c188e3aa-a209-4519-8008-9552740c5754>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <6c6ad294-e024-4c1a-a600-3b0ae9889f05>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <6c6ad294-e024-4c1a-a600-3b0ae9889f05>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] internal static class CraftingStationBaseLevel { [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] private sealed class StationDef { public readonly string PrefabName; public readonly int BaseLevel; public StationDef(string prefabName, int baseLevel) { PrefabName = prefabName; BaseLevel = baseLevel; } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(CraftingStation), "GetLevel")] private static class CraftingStation_GetLevel_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(CraftingStation __instance, ref int __result) { EnsureInitialized(); string prefabName = GetPrefabName(__instance); if (!string.IsNullOrEmpty(prefabName) && BaseLevels.TryGetValue(prefabName, out var value)) { int extentionCount = __instance.GetExtentionCount(false); int val = value + extentionCount; int num = __result; __result = Math.Max(__result, val); if (__result != num) { Log("Level adjusted | prefab=" + prefabName + " | " + $"baseLevel={value} | " + $"extensions={extentionCount} | " + $"before={num} | " + $"after={__result}"); } } } } private const bool LoggingEnabled = false; private static readonly StationDef[] Defs = new StationDef[1] { new StationDef("WarriorForge_DO", 4) }; private static readonly Dictionary<string, int> BaseLevels = new Dictionary<string, int>(StringComparer.Ordinal); private static bool _initialized; private static void EnsureInitialized() { if (_initialized) { return; } _initialized = true; StationDef[] defs = Defs; foreach (StationDef stationDef in defs) { if (stationDef != null && !string.IsNullOrEmpty(stationDef.PrefabName)) { if (stationDef.BaseLevel < 1) { Log("Invalid def ignored | prefab=" + stationDef.PrefabName + " | " + $"baseLevel={stationDef.BaseLevel}"); continue; } BaseLevels[stationDef.PrefabName] = stationDef.BaseLevel; Log("Registered | prefab=" + stationDef.PrefabName + " | " + $"baseLevel={stationDef.BaseLevel}"); } } } private static string GetPrefabName(CraftingStation station) { if ((Object)(object)station == (Object)null || (Object)(object)((Component)station).gameObject == (Object)null) { return null; } string text = ((Object)((Component)station).gameObject).name; if (string.IsNullOrEmpty(text)) { return null; } if (text.EndsWith("(Clone)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - "(Clone)".Length); } return text; } private static void Log(string message) { } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] internal sealed class ConfigurationManagerAttributes { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput); public bool? ShowRangeAsPercent; public Action<ConfigEntryBase> CustomDrawer; public CustomHotkeyDrawerFunc CustomHotkeyDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func<object, string> ObjToStr; public Func<string, object> StrToObj; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] public static class ExtraStats { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class DevLog { public const bool Enabled = false; public const bool AttackSpeed = false; public const bool WetImmune = false; public const bool Tooltips = false; public const bool FoodStats = false; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public enum ExtraStatType { Health, Stamina, Eitr, AttackSpeed, WetImmune } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public enum ExtraSourceType { ItemDrop, StatusEffect } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] public class ExtraStatEntry { public string PrefabName; public ExtraStatType StatType; public float Value; public float? DisplayValue; public ExtraSourceType SourceType; public ExtraStatEntry(string prefab, ExtraStatType stat, float value, ExtraSourceType source) { PrefabName = prefab; StatType = stat; Value = value; DisplayValue = null; SourceType = source; } public ExtraStatEntry(string prefab, ExtraStatType stat, float value, float? displayValue, ExtraSourceType source) { PrefabName = prefab; StatType = stat; Value = value; DisplayValue = displayValue; SourceType = source; } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class Player_GetTotalFoodValue_ExtraStatsPatch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr) { if ((Object)(object)__instance == (Object)null) { return; } float num = 0f; float num2 = 0f; float num3 = 0f; try { Inventory inventory = ((Humanoid)__instance).GetInventory(); if (inventory != null) { foreach (ItemData equippedItem in inventory.GetEquippedItems()) { if (equippedItem != null && !((Object)(object)equippedItem.m_dropPrefab == (Object)null)) { string name = ((Object)equippedItem.m_dropPrefab).name; GetItemDropBonusesForPrefab(name, out var extraHp, out var extraStamina, out var extraEitr, out var _, out var _); if (extraHp != 0f || extraStamina != 0f || extraEitr != 0f) { num += extraHp; num2 += extraStamina; num3 += extraEitr; DLogFood($"ItemDrop matched for food stats: {name} → +HP {extraHp}, +Stamina {extraStamina}, +Eitr {extraEitr}"); } } } } if (((Character)__instance).m_seman != null && ((Character)__instance).m_seman.m_statusEffects != null) { foreach (StatusEffect statusEffect in ((Character)__instance).m_seman.m_statusEffects) { if (!((Object)(object)statusEffect == (Object)null)) { string name2 = ((Object)statusEffect).name; GetStatusEffectBonuses(name2, out var extraHp2, out var extraStamina2, out var extraEitr2, out var _, out var _); if (extraHp2 != 0f || extraStamina2 != 0f || extraEitr2 != 0f) { num += extraHp2; num2 += extraStamina2; num3 += extraEitr2; string prefabName = Utils.GetPrefabName(name2); DLogFood($"StatusEffect matched for food stats: {name2} (clean={prefabName}) → +HP {extraHp2}, +Stamina {extraStamina2}, +Eitr {extraEitr2}"); } } } } } catch (Exception ex) { LogError("Exception in ExtraStats Player.GetTotalFoodValue Postfix: " + ex); } if (num != 0f || num2 != 0f || num3 != 0f) { DLogFood($"Total food bonuses applied to player: +HP {num}, +Stamina {num2}, +Eitr {num3}"); hp += num; stamina += num2; eitr += num3; } } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch] public static class ItemData_StaticGetTooltip_ExtraStatsPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ItemData), "GetTooltip", new Type[6] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) }, (Type[])null); } private static void Postfix(ItemData item, int qualityLevel, bool crafting, float worldLevel, int stackOverride, bool appending, ref string __result) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) try { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return; } string name = ((Object)item.m_dropPrefab).name; DLogTooltip("Static GetTooltip Postfix called for " + name + ", " + $"q={qualityLevel}, crafting={crafting}, worldLevel={worldLevel}, " + $"stackOverride={stackOverride}, appending={appending}"); GetItemDropBonusesForPrefab(name, out var extraHp, out var extraStamina, out var extraEitr, out var _, out var displayAttackSpeedPercent, out var wetImmune); if (extraHp == 0f && extraStamina == 0f && extraEitr == 0f && displayAttackSpeedPercent == 0f && !wetImmune) { return; } string text = BuildExtraStatsTooltipBlock(extraHp, extraStamina, extraEitr, displayAttackSpeedPercent, wetImmune); if (string.IsNullOrEmpty(text)) { return; } float num = 0f; if ((Object)(object)Player.m_localPlayer != (Object)null) { num = ((Character)Player.m_localPlayer).GetSkillLevel(item.m_shared.m_skillType); } string statusEffectTooltip = item.GetStatusEffectTooltip(qualityLevel, num); string chainTooltip = item.GetChainTooltip(qualityLevel, num); string setStatusEffectTooltip = item.GetSetStatusEffectTooltip(qualityLevel, num); int num2 = -1; if (!string.IsNullOrEmpty(statusEffectTooltip)) { int num3 = __result.IndexOf(statusEffectTooltip, StringComparison.Ordinal); if (num3 >= 0) { num2 = ((num3 - 2 >= 0 && __result.Substring(num3 - 2, 2) == "\n\n") ? (num3 - 2) : num3); } } if (num2 < 0 && !string.IsNullOrEmpty(chainTooltip)) { int num4 = __result.IndexOf(chainTooltip, StringComparison.Ordinal); if (num4 >= 0) { num2 = ((num4 - 2 >= 0 && __result.Substring(num4 - 2, 2) == "\n\n") ? (num4 - 2) : num4); } } if (num2 < 0) { int num5 = __result.IndexOf("\n$item_eitrregen_modifier:", StringComparison.Ordinal); if (num5 >= 0) { num2 = num5; } } if (num2 < 0 && !string.IsNullOrEmpty(setStatusEffectTooltip)) { int num6 = __result.IndexOf("\n\n$item_seteffect", StringComparison.Ordinal); if (num6 >= 0) { num2 = num6; } } if (num2 < 0) { int num7 = __result.IndexOf("\n$item_fulladrenaline:", StringComparison.Ordinal); if (num7 >= 0) { num2 = num7; } } if (num2 >= 0) { DLogTooltip("Inserting ItemDrop extras before special/effect section for " + name); __result = __result.Insert(num2, text); } else { DLogTooltip("No special/effect section found, appending ItemDrop extras at end for " + name); __result += text; } } catch (Exception ex) { LogError("Exception in ItemData_StaticGetTooltip_ExtraStatsPatch: " + ex); } } } [HarmonyPatch(typeof(SE_Stats), "GetTooltipString")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class SE_Stats_GetTooltipString_ExtraStatsPatch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(SE_Stats __instance, ref string __result) { try { if ((Object)(object)__instance == (Object)null) { return; } string name = ((Object)__instance).name; string prefabName = Utils.GetPrefabName(name); DLogTooltip("SE GetTooltipString for " + name + " (clean=" + prefabName + ")"); GetStatusEffectBonuses(name, out var extraHp, out var extraStamina, out var extraEitr, out var _, out var displayAttackSpeedPercent, out var wetImmune); if (extraHp == 0f && extraStamina == 0f && extraEitr == 0f && displayAttackSpeedPercent == 0f && !wetImmune) { return; } string text = BuildExtraStatsTooltipBlock(extraHp, extraStamina, extraEitr, displayAttackSpeedPercent, wetImmune); if (!string.IsNullOrEmpty(text)) { if (text.StartsWith("\n")) { text = text.Substring(1); } DLogTooltip($"Appending SE extras for {name} (clean={prefabName}): HP {extraHp}, Stamina {extraStamina}, Eitr {extraEitr}, AttackSpeed(Display)% {displayAttackSpeedPercent}, WetImmune {wetImmune}"); __result += text; } } catch (Exception ex) { LogError("Exception in SE_Stats_GetTooltipString_ExtraStatsPatch: " + ex); } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private sealed class HumanoidState { public float DesiredSpeed = 1f; public float LastAppliedSpeed = 1f; public bool HasDesiredSpeed; public bool WasInAttack; public int ActiveAttackDepth; public float ActiveAttackMul = 1f; } [HarmonyPatch(typeof(Humanoid), "StartAttack", new Type[] { typeof(Character), typeof(bool) })] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class Humanoid_StartAttack_AttackSpeedPatch { [HarmonyPostfix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Humanoid __instance, Character target, bool secondaryAttack, ref bool __result) { EnsureAttackInit(); if (!__result) { return; } HumanoidState attackState = GetAttackState(__instance); float num = ComputeTotalAttackSpeedPercentForHumanoid(__instance); if (num == 0f) { attackState.DesiredSpeed = 1f; attackState.HasDesiredSpeed = false; ApplyAnimSpeed(__instance, attackState, 1f); attackState.ActiveAttackDepth = 0; attackState.ActiveAttackMul = 1f; return; } float num2 = 1f + num / 100f; if (num2 <= 0f || float.IsNaN(num2) || float.IsInfinity(num2)) { attackState.DesiredSpeed = 1f; attackState.HasDesiredSpeed = false; ApplyAnimSpeed(__instance, attackState, 1f); attackState.ActiveAttackDepth = 0; attackState.ActiveAttackMul = 1f; } else { attackState.DesiredSpeed = num2; attackState.HasDesiredSpeed = true; ApplyAnimSpeed(__instance, attackState, num2); attackState.ActiveAttackDepth++; attackState.ActiveAttackMul = num2; DLogAttackSpeed($"StartAttack: total AttackSpeed%={num} → mul={num2} (activeDepth={attackState.ActiveAttackDepth})"); } } } [HarmonyPatch(typeof(Attack), "Stop")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class Attack_Stop_AttackSpeedResetPatch { [HarmonyPostfix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Attack __instance) { try { EnsureAttackInit(); if (__instance != null) { Humanoid character = __instance.m_character; if (!((Object)(object)character == (Object)null)) { ResetForHumanoid(character); DLogAttackSpeed("Attack.Stop: ResetForHumanoid"); } } } catch (Exception) { } } } [HarmonyPatch(typeof(Humanoid), "UpdateAttack")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class Humanoid_UpdateAttack_AttackSpeedDtPatch { [HarmonyPrefix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Prefix(Humanoid __instance, ref float dt) { try { EnsureAttackInit(); if ((Object)(object)__instance == (Object)null) { return; } HumanoidState attackState = GetAttackState(__instance); if (attackState.ActiveAttackDepth > 0) { float activeAttackMul = attackState.ActiveAttackMul; if (!(activeAttackMul <= 0f) && !float.IsNaN(activeAttackMul) && !float.IsInfinity(activeAttackMul)) { dt *= activeAttackMul; } } } catch (Exception ex) { LogError("Exception in Humanoid_UpdateAttack_AttackSpeedDtPatch: " + ex); } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(Humanoid), "CustomFixedUpdate")] public static class Humanoid_CustomFixedUpdate_AttackSpeedPatch { [HarmonyPostfix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Humanoid __instance, float fixedDeltaTime) { EnsureAttackInit(); HumanoidState attackState = GetAttackState(__instance); bool flag = ((Character)__instance).InAttack(); if (flag) { if (attackState.HasDesiredSpeed) { ApplyAnimSpeed(__instance, attackState, attackState.DesiredSpeed); } else { ApplyAnimSpeed(__instance, attackState, 1f); } } else if (attackState.WasInAttack) { ApplyAnimSpeed(__instance, attackState, 1f); attackState.HasDesiredSpeed = false; attackState.DesiredSpeed = 1f; } attackState.WasInAttack = flag; } } [HarmonyPatch(typeof(Character), "RPC_Stagger")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class Character_RPC_Stagger_AttackSpeedResetPatch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] [HarmonyPostfix] private static void Postfix(Character __instance, long sender, Vector3 forceDirection) { try { EnsureAttackInit(); Humanoid val = (Humanoid)(object)((__instance is Humanoid) ? __instance : null); if (!((Object)(object)val == (Object)null)) { ResetForHumanoid(val); } } catch (Exception) { } } } [HarmonyPatch(typeof(Character), "OnDeath")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class Character_OnDeath_AttackSpeedResetPatch { [HarmonyPostfix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Character __instance) { try { EnsureAttackInit(); Humanoid val = (Humanoid)(object)((__instance is Humanoid) ? __instance : null); if (!((Object)(object)val == (Object)null)) { ResetForHumanoid(val); } } catch (Exception) { } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(Character), "FreezeFrame")] public static class Character_FreezeFrame_AttackSpeedScalePatch { [HarmonyPrefix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Prefix(Character __instance, ref float duration) { try { EnsureAttackInit(); if ((Object)(object)__instance == (Object)null || Mathf.Abs(duration - 0.15f) > 0.01f) { return; } Humanoid val = (Humanoid)(object)((__instance is Humanoid) ? __instance : null); if ((Object)(object)val == (Object)null) { return; } HumanoidState attackState = GetAttackState(val); if (!attackState.HasDesiredSpeed) { return; } float desiredSpeed = attackState.DesiredSpeed; if (!(desiredSpeed <= 1.001f) && !float.IsNaN(desiredSpeed) && !float.IsInfinity(desiredSpeed)) { float num = duration / desiredSpeed; if (num < 0.03f) { num = 0.03f; } DLogAttackSpeed($"FreezeFrame scale: {duration:F3} -> {num:F3} (mul={desiredSpeed:F3})"); duration = num; } } catch (Exception ex) { LogError("Exception in Character_FreezeFrame_AttackSpeedScalePatch: " + ex); } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(CharacterAnimEvent), "UpdateFreezeFrame")] public static class CharacterAnimEvent_UpdateFreezeFrame_ReapplySpeedPatch { [HarmonyPostfix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(CharacterAnimEvent __instance, float dt) { try { EnsureAttackInit(); if ((Object)(object)__instance == (Object)null) { return; } Character componentInParent = ((Component)__instance).GetComponentInParent<Character>(); Humanoid val = (Humanoid)(object)((componentInParent is Humanoid) ? componentInParent : null); if (!((Object)(object)val == (Object)null)) { HumanoidState attackState = GetAttackState(val); if (attackState.HasDesiredSpeed && (attackState.ActiveAttackDepth > 0 || ((Character)val).InAttack())) { ApplyAnimSpeed(val, attackState, attackState.DesiredSpeed); } else { ApplyAnimSpeed(val, attackState, 1f); } } } catch (Exception ex) { LogError("Exception in CharacterAnimEvent_UpdateFreezeFrame_ReapplySpeedPatch: " + ex); } } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class SEMan_AddStatusEffect_ByHash_WetImmunePatch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] [HarmonyPrefix] private static bool Prefix(SEMan __instance, int nameHash, bool resetTime, int itemLevel, float skillLevel, short variant) { try { EnsureWetInit(); if (nameHash != SEMan.s_statusEffectWet) { return true; } Character val = null; try { val = _semanCharacterRef.Invoke(__instance); } catch (Exception) { val = null; } if ((Object)(object)val != (Object)null && HasWetImmune(val)) { DLogWet($"Blocked Wet (AddStatusEffect by hash) due to WetImmune | variant={variant}"); return false; } } catch (Exception ex2) { LogError("Exception in SEMan_AddStatusEffect_ByHash_WetImmunePatch: " + ex2); } return true; } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(StatusEffect), typeof(bool), typeof(int), typeof(float), typeof(short) })] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] public static class SEMan_AddStatusEffect_BySE_WetImmunePatch { [HarmonyPrefix] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static bool Prefix(SEMan __instance, StatusEffect statusEffect, bool resetTime, int itemLevel, float skillLevel, short variant, ref StatusEffect __result) { try { if ((Object)(object)statusEffect == (Object)null) { return true; } if (statusEffect.NameHash() != SEMan.s_statusEffectWet) { return true; } Character character = statusEffect.m_character; if ((Object)(object)character != (Object)null && HasWetImmune(character)) { DLogWet($"Blocked Wet (AddStatusEffect by SE) due to WetImmune | variant={variant}"); __result = null; return false; } } catch (Exception ex) { LogError("Exception in SEMan_AddStatusEffect_BySE_WetImmunePatch: " + ex); } return true; } } public static bool DEBUG = false; public static readonly List<ExtraStatEntry> ExtraStatsConfig = new List<ExtraStatEntry> { new ExtraStatEntry("ArmorWukongCape_DO", ExtraStatType.Health, 20f, ExtraSourceType.ItemDrop), new ExtraStatEntry("ArmorCaptainCape_DO", ExtraStatType.Stamina, 15f, ExtraSourceType.ItemDrop), new ExtraStatEntry("ArmorNocturneBladeCape_DO", ExtraStatType.Stamina, 20f, ExtraSourceType.ItemDrop) }; private static readonly ConditionalWeakTable<Humanoid, HumanoidState> _attackState = new ConditionalWeakTable<Humanoid, HumanoidState>(); private static FieldRef<Character, ZSyncAnimation> _zanimRef; private static bool _attackInit; private const float HitFreeze_Default = 0.15f; private const float HitFreeze_Epsilon = 0.01f; private const float HitFreeze_Min = 0.03f; private static FieldRef<SEMan, Character> _semanCharacterRef; private static bool _wetInit; private static void LogInfo(string msg) { } private static void LogError(string msg) { } private static void DLogAttackSpeed(string msg) { } private static void DLogWet(string msg) { } private static void DLogTooltip(string msg) { } private static void DLogFood(string msg) { } private static void GetItemDropBonusesForPrefab(string prefabName, out float extraHp, out float extraStamina, out float extraEitr, out float extraAttackSpeedPercent, out float displayAttackSpeedPercent, out bool wetImmune) { extraHp = 0f; extraStamina = 0f; extraEitr = 0f; extraAttackSpeedPercent = 0f; displayAttackSpeedPercent = 0f; wetImmune = false; if (string.IsNullOrEmpty(prefabName)) { return; } for (int i = 0; i < ExtraStatsConfig.Count; i++) { ExtraStatEntry extraStatEntry = ExtraStatsConfig[i]; if (extraStatEntry.SourceType == ExtraSourceType.ItemDrop && string.Equals(prefabName, extraStatEntry.PrefabName, StringComparison.OrdinalIgnoreCase)) { switch (extraStatEntry.StatType) { case ExtraStatType.Health: extraHp += extraStatEntry.Value; break; case ExtraStatType.Stamina: extraStamina += extraStatEntry.Value; break; case ExtraStatType.Eitr: extraEitr += extraStatEntry.Value; break; case ExtraStatType.AttackSpeed: extraAttackSpeedPercent += extraStatEntry.Value; displayAttackSpeedPercent += (extraStatEntry.DisplayValue.HasValue ? extraStatEntry.DisplayValue.Value : extraStatEntry.Value); break; case ExtraStatType.WetImmune: wetImmune = true; break; } } } } private static void GetItemDropBonusesForPrefab(string prefabName, out float extraHp, out float extraStamina, out float extraEitr, out float extraAttackSpeedPercent, out bool wetImmune) { GetItemDropBonusesForPrefab(prefabName, out extraHp, out extraStamina, out extraEitr, out extraAttackSpeedPercent, out var _, out wetImmune); } private static void GetStatusEffectBonuses(string seRawName, out float extraHp, out float extraStamina, out float extraEitr, out float extraAttackSpeedPercent, out float displayAttackSpeedPercent, out bool wetImmune) { extraHp = 0f; extraStamina = 0f; extraEitr = 0f; extraAttackSpeedPercent = 0f; displayAttackSpeedPercent = 0f; wetImmune = false; if (string.IsNullOrEmpty(seRawName)) { return; } string prefabName = Utils.GetPrefabName(seRawName); for (int i = 0; i < ExtraStatsConfig.Count; i++) { ExtraStatEntry extraStatEntry = ExtraStatsConfig[i]; if (extraStatEntry.SourceType == ExtraSourceType.StatusEffect && string.Equals(prefabName, extraStatEntry.PrefabName, StringComparison.OrdinalIgnoreCase)) { switch (extraStatEntry.StatType) { case ExtraStatType.Health: extraHp += extraStatEntry.Value; break; case ExtraStatType.Stamina: extraStamina += extraStatEntry.Value; break; case ExtraStatType.Eitr: extraEitr += extraStatEntry.Value; break; case ExtraStatType.AttackSpeed: extraAttackSpeedPercent += extraStatEntry.Value; displayAttackSpeedPercent += (extraStatEntry.DisplayValue.HasValue ? extraStatEntry.DisplayValue.Value : extraStatEntry.Value); break; case ExtraStatType.WetImmune: wetImmune = true; break; } } } } private static void GetStatusEffectBonuses(string seRawName, out float extraHp, out float extraStamina, out float extraEitr, out float extraAttackSpeedPercent, out bool wetImmune) { GetStatusEffectBonuses(seRawName, out extraHp, out extraStamina, out extraEitr, out extraAttackSpeedPercent, out var _, out wetImmune); } private static string BuildExtraStatsTooltipBlock(float extraHp, float extraStamina, float extraEitr, float displayAttackSpeedPercent, bool wetImmune) { if (extraHp == 0f && extraStamina == 0f && extraEitr == 0f && displayAttackSpeedPercent == 0f && !wetImmune) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); string text = "$health_DO"; string text2 = "$stamina_DO"; string text3 = "$eitr_DO"; string text4 = "$attackspeed_DO"; string text5 = "$immune_DO"; string text6 = "$wet_DO"; if (Localization.instance != null) { text = Localization.instance.Localize(text); text2 = Localization.instance.Localize(text2); text3 = Localization.instance.Localize(text3); text4 = Localization.instance.Localize(text4); text5 = Localization.instance.Localize(text5); text6 = Localization.instance.Localize(text6); } if (extraHp != 0f) { string arg = ((extraHp >= 0f) ? "+" : ""); stringBuilder.Append($"\n{text}: <color=#f27979>{arg}{extraHp:F0}</color>"); } if (extraStamina != 0f) { string arg2 = ((extraStamina >= 0f) ? "+" : ""); stringBuilder.Append($"\n{text2}: <color=#ffff80>{arg2}{extraStamina:F0}</color>"); } if (extraEitr != 0f) { string arg3 = ((extraEitr >= 0f) ? "+" : ""); stringBuilder.Append($"\n{text3}: <color=#8686ee>{arg3}{extraEitr:F0}</color>"); } if (displayAttackSpeedPercent != 0f) { int num = Mathf.RoundToInt(displayAttackSpeedPercent); string arg4 = ((num >= 0) ? "+" : ""); stringBuilder.Append($"\n{text4}: <color=orange>{arg4}{num}%</color>"); } if (wetImmune) { stringBuilder.Append("\n" + text5 + ": <color=orange>" + text6 + "</color>"); } return stringBuilder.ToString(); } private static bool HasWetImmune(Character c) { if ((Object)(object)c == (Object)null) { return false; } try { Player val = (Player)(object)((c is Player) ? c : null); if ((Object)(object)val != (Object)null) { Inventory inventory = ((Humanoid)val).GetInventory(); if (inventory != null) { List<ItemData> equippedItems = inventory.GetEquippedItems(); for (int i = 0; i < equippedItems.Count; i++) { ItemData val2 = equippedItems[i]; if (val2 != null && !((Object)(object)val2.m_dropPrefab == (Object)null)) { string name = ((Object)val2.m_dropPrefab).name; GetItemDropBonusesForPrefab(name, out var _, out var _, out var _, out var _, out var _, out var wetImmune); if (wetImmune) { DLogWet("WetImmune from ItemDrop: " + name); return true; } } } } } if (c.m_seman != null && c.m_seman.m_statusEffects != null) { List<StatusEffect> statusEffects = c.m_seman.m_statusEffects; for (int j = 0; j < statusEffects.Count; j++) { StatusEffect val3 = statusEffects[j]; if (!((Object)(object)val3 == (Object)null)) { string name2 = ((Object)val3).name; GetStatusEffectBonuses(name2, out var _, out var _, out var _, out var _, out var _, out var wetImmune2); if (wetImmune2) { string prefabName = Utils.GetPrefabName(name2); DLogWet("WetImmune from StatusEffect: " + name2 + " (clean=" + prefabName + ")"); return true; } } } } } catch (Exception ex) { LogError("Exception in HasWetImmune: " + ex); } return false; } private static void EnsureAttackInit() { if (!_attackInit) { _attackInit = true; _zanimRef = AccessTools.FieldRefAccess<Character, ZSyncAnimation>("m_zanim"); } } private static HumanoidState GetAttackState(Humanoid h) { return _attackState.GetValue(h, (Humanoid _) => new HumanoidState()); } private static void ApplyAnimSpeed(Humanoid h, HumanoidState state, float speed) { ZSyncAnimation val = null; try { val = _zanimRef.Invoke((Character)(object)h); } catch (Exception) { return; } if (!((Object)(object)val == (Object)null) && !Mathf.Approximately(state.LastAppliedSpeed, speed)) { val.SetSpeed(speed); state.LastAppliedSpeed = speed; } } private static void ResetForHumanoid(Humanoid h) { if (!((Object)(object)h == (Object)null)) { EnsureAttackInit(); HumanoidState attackState = GetAttackState(h); ApplyAnimSpeed(h, attackState, 1f); attackState.HasDesiredSpeed = false; attackState.DesiredSpeed = 1f; attackState.WasInAttack = false; attackState.ActiveAttackDepth = 0; attackState.ActiveAttackMul = 1f; } } private static float ComputeTotalAttackSpeedPercentForHumanoid(Humanoid h) { float num = 0f; if ((Object)(object)h == (Object)null) { return 0f; } try { Player val = (Player)(object)((h is Player) ? h : null); if ((Object)(object)val != (Object)null) { Inventory inventory = ((Humanoid)val).GetInventory(); if (inventory != null) { List<ItemData> equippedItems = inventory.GetEquippedItems(); for (int i = 0; i < equippedItems.Count; i++) { ItemData val2 = equippedItems[i]; if (val2 != null && !((Object)(object)val2.m_dropPrefab == (Object)null)) { string name = ((Object)val2.m_dropPrefab).name; GetItemDropBonusesForPrefab(name, out var _, out var _, out var _, out var extraAttackSpeedPercent, out var _, out var _); if (extraAttackSpeedPercent != 0f) { num += extraAttackSpeedPercent; DLogAttackSpeed($"AttackSpeed from ItemDrop: {name} → {extraAttackSpeedPercent}%"); } } } } } if (((Character)h).m_seman != null && ((Character)h).m_seman.m_statusEffects != null) { List<StatusEffect> statusEffects = ((Character)h).m_seman.m_statusEffects; for (int j = 0; j < statusEffects.Count; j++) { StatusEffect val3 = statusEffects[j]; if (!((Object)(object)val3 == (Object)null)) { string name2 = ((Object)val3).name; GetStatusEffectBonuses(name2, out var _, out var _, out var _, out var extraAttackSpeedPercent2, out var _, out var _); if (extraAttackSpeedPercent2 != 0f) { num += extraAttackSpeedPercent2; string prefabName = Utils.GetPrefabName(name2); DLogAttackSpeed($"AttackSpeed from StatusEffect: {name2} (clean={prefabName}) → {extraAttackSpeedPercent2}%"); } } } } } catch (Exception ex) { LogError("Exception in ComputeTotalAttackSpeedPercentForHumanoid: " + ex); } return num; } private static void EnsureWetInit() { if (!_wetInit) { _wetInit = true; _semanCharacterRef = AccessTools.FieldRefAccess<SEMan, Character>("m_character"); } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] public static class ItemTypeTooltip { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class DevLog { public const bool Enabled = false; } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] private sealed class ItemTypeDef { public readonly string LocalizationKey; public readonly string Color; public readonly HashSet<string> PrefabNames; public ItemTypeDef(string localizationKey, string color, params string[] prefabNames) { LocalizationKey = localizationKey; Color = color; PrefabNames = new HashSet<string>(prefabNames ?? Array.Empty<string>(), StringComparer.Ordinal); } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class ItemData_GetTooltip_ItemTypeTooltipPatch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(ItemData item, int qualityLevel, bool crafting, float worldLevel, int stackOverride, bool appending, ref string __result) { try { if (appending || item == null || item.m_shared == null) { return; } string itemPrefabName = GetItemPrefabName(item); if (string.IsNullOrEmpty(itemPrefabName)) { return; } ItemTypeDef itemTypeDef = FindDef(itemPrefabName); if (itemTypeDef == null) { return; } string text = Localize(itemTypeDef.LocalizationKey); if (!string.IsNullOrEmpty(text)) { string text2 = "<align=center><color=" + itemTypeDef.Color + ">[ " + text + " ]</color></align>"; if (string.IsNullOrEmpty(__result)) { __result = text2; } else { __result = text2 + "\n" + __result; } DLog("Added item type '" + itemTypeDef.LocalizationKey + "' to '" + itemPrefabName + "'."); } } catch (Exception arg) { DLog($"ERROR while adding item type tooltip: {arg}"); } } } private const string LogPrefix = "[ItemTypeTooltip]"; private static readonly ItemTypeDef[] Defs = new ItemTypeDef[3] { new ItemTypeDef("$armor_heavy_DO", "#C23331", "ArmorCrusaderChest_DO", "ArmorCrusaderHelmet_DO", "ArmorCrusaderLegs_DO", "ArmorShogunChest_DO", "ArmorShogunHelmet_DO", "ArmorShogunLegs_DO", "ArmorWukongChest_DO", "ArmorWukongHelmet_DO", "ArmorWukongLegs_DO"), new ItemTypeDef("$armor_medium_DO", "#D3A359", "ArmorEmirChest_DO", "ArmorEmirHelmet_DO", "ArmorEmirLegs_DO", "ArmorOniChest_DO", "ArmorOniHelmet_DO", "ArmorOniLegs_DO"), new ItemTypeDef("$armor_light_DO", "#429642", "ArmorSilentThornChest_DO", "ArmorSilentThornHelmet_DO", "ArmorSilentThornLegs_DO", "ArmorBogCultistChest_DO", "ArmorBogCultistHelmet_DO", "ArmorBogCultistLegs_DO", "ArmorCaptainChest_DO", "ArmorCaptainHelmet_DO", "ArmorCaptainLegs_DO", "ArmorSnowTalonChest_DO", "ArmorSnowTalonHelmet_DO", "ArmorSnowTalonLegs_DO", "ArmorNocturneBladeChest_DO", "ArmorNocturneBladeHelmet_DO", "ArmorNocturneBladeLegs_DO") }; private static ItemTypeDef FindDef(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return null; } ItemTypeDef[] defs = Defs; foreach (ItemTypeDef itemTypeDef in defs) { if (itemTypeDef != null && itemTypeDef.PrefabNames.Contains(prefabName)) { return itemTypeDef; } } return null; } private static string Localize(string keyOrText) { if (string.IsNullOrEmpty(keyOrText)) { return ""; } if (Localization.instance == null) { return keyOrText; } if (keyOrText.StartsWith("$")) { return Localization.instance.Localize(keyOrText); } return keyOrText; } private static string GetItemPrefabName(ItemData item) { if (item == null) { return ""; } if ((Object)(object)item.m_dropPrefab != (Object)null) { return Utils.GetPrefabName(((Object)item.m_dropPrefab).name); } if (item.m_shared != null && !string.IsNullOrEmpty(item.m_shared.m_name)) { GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(item.m_shared.m_name) : null); if ((Object)(object)val != (Object)null) { return Utils.GetPrefabName(((Object)val).name); } } return ""; } private static void DLog(string message) { } } namespace LocalizationManager { [PublicAPI] [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace Warrior_Glory { [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] public static class WarriorTechniqueSystem { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class DevLog { public const bool Enabled = false; public const bool Init = true; public const bool Definitions = true; public const bool Controller = true; public const bool Sources = true; public const bool Hit = true; public const bool Progress = true; public const bool UI = true; public const bool Tooltip = true; public const bool Assets = true; public const bool Consume = true; public const bool OnProc = true; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private sealed class AttackState { [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(1)] public Player Player; public WarriorTechniqueType Technique; public bool Armed; public bool Consumed; public bool HadValidHit; public float StaminaSpent; public float StaminaRefunded; public int HitEvent; public int LastProgressEvent = -1; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private sealed class ProjectileState { [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(1)] public AttackState Attack; public int EventId; public bool ProgressGranted; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private sealed class UiPresetDef { public float PosX; public float PosY; public float IconScale; public float TextOffsetX; public float TextOffsetY; public int TextFontSize; [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(1)] public string TextColor; } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] private sealed class SlotRefs { public RectTransform Root; public Image Icon; public GameObject CooldownObject; public TMP_Text PrimaryText; public TMP_Text TimeText; } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] public sealed class WarriorTechniqueController : MonoBehaviour { [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] private sealed class TechniqueState { public WarriorTechniqueType TechniqueType; public int CurrentProgress; public int MaxProgress; public bool IsReady; public bool IsActive; public int LastTotalModifier; public string ActiveSourceNames = string.Empty; public string ActiveModifierSourceNames = string.Empty; } private Player _player; private bool _setup; private readonly Dictionary<WarriorTechniqueType, TechniqueState> _states = new Dictionary<WarriorTechniqueType, TechniqueState>(); private float _sourceRefreshTimer; private const float SourceRefreshInterval = 0.5f; public void Setup(Player player) { if (!_setup) { _player = player; EnsureState(WarriorTechniqueType.Execution); EnsureState(WarriorTechniqueType.Discipline); EnsureState(WarriorTechniqueType.Suppression); RefreshActiveSources(forceLog: true); _setup = true; LogController("Controller setup complete."); } } private void Update() { if (_setup && !((Object)(object)_player == (Object)null) && IsSystemEnabled()) { _sourceRefreshTimer += Time.deltaTime; if (_sourceRefreshTimer >= 0.5f) { _sourceRefreshTimer = 0f; RefreshActiveSources(forceLog: false); } } } public void ForceRefresh() { RefreshActiveSources(forceLog: true); } private TechniqueState EnsureState(WarriorTechniqueType techniqueType) { if (!_states.TryGetValue(techniqueType, out var value)) { value = new TechniqueState { TechniqueType = techniqueType, CurrentProgress = 0, MaxProgress = 1, IsReady = false, IsActive = false, LastTotalModifier = 0 }; _states[techniqueType] = value; } return value; } private void RefreshActiveSources(bool forceLog) { if (!((Object)(object)_player == (Object)null)) { RefreshTechniqueState(WarriorTechniqueType.Execution, forceLog); RefreshTechniqueState(WarriorTechniqueType.Discipline, forceLog); RefreshTechniqueState(WarriorTechniqueType.Suppression, forceLog); } } private void RefreshTechniqueState(WarriorTechniqueType techniqueType, bool forceLog) { TechniqueState techniqueState = EnsureState(techniqueType); WarriorTechniqueSystemConfigs.WarriorTechniqueDef techniqueDef = GetTechniqueDef(techniqueType); if (techniqueDef == null) { SetInactive(techniqueState, forceLog, "Missing technique definition."); return; } bool flag = false; List<string> list = new List<string>(); for (int i = 0; i < ActivationSourceDefs.Count; i++) { WarriorTechniqueSystemConfigs.WarriorTechniqueActivationSourceDef warriorTechniqueActivationSourceDef = ActivationSourceDefs[i]; if (warriorTechniqueActivationSourceDef != null && warriorTechniqueActivationSourceDef.TechniqueType == techniqueType && PlayerHasSource(_player, warriorTechniqueActivationSourceDef.SourceType, warriorTechniqueActivationSourceDef.SourceName)) { flag = true; list.Add(warriorTechniqueActivationSourceDef.SourceName); } } int num = 0; List<string> list2 = new List<string>(); for (int j = 0; j < ProgressModifierSourceDefs.Count; j++) { WarriorTechniqueSystemConfigs.WarriorTechniqueProgressModifierSourceDef warriorTechniqueProgressModifierSourceDef = ProgressModifierSourceDefs[j]; if (warriorTechniqueProgressModifierSourceDef != null && warriorTechniqueProgressModifierSourceDef.TechniqueType == techniqueType && PlayerHasSource(_player, warriorTechniqueProgressModifierSourceDef.SourceType, warriorTechniqueProgressModifierSourceDef.SourceName)) { num += warriorTechniqueProgressModifierSourceDef.MaxProgressModifier; list2.Add(warriorTechniqueProgressModifierSourceDef.SourceName + "(" + FormatIntSigned(warriorTechniqueProgressModifierSourceDef.MaxProgressModifier) + ")"); } } int num2 = Mathf.Max(1, techniqueDef.BaseMaxProgress + num); string text = string.Join(", ", list); string text2 = string.Join(", ", list2); bool flag2 = techniqueState.IsActive != flag || techniqueState.MaxProgress != num2 || techniqueState.LastTotalModifier != num || !string.Equals(techniqueState.ActiveSourceNames, text, StringComparison.Ordinal) || !string.Equals(techniqueState.ActiveModifierSourceNames, text2, StringComparison.Ordinal); techniqueState.IsActive = flag; techniqueState.MaxProgress = num2; techniqueState.LastTotalModifier = num; techniqueState.ActiveSourceNames = text; techniqueState.ActiveModifierSourceNames = text2; if (!flag) { techniqueState.CurrentProgress = 0; techniqueState.IsReady = false; if (flag2 || forceLog) { LogSources($"{techniqueType} inactive."); } return; } if (techniqueState.CurrentProgress > techniqueState.MaxProgress) { techniqueState.CurrentProgress = techniqueState.MaxProgress; } if (techniqueState.CurrentProgress >= techniqueState.MaxProgress) { techniqueState.CurrentProgress = techniqueState.MaxProgress; techniqueState.IsReady = true; } if (flag2 || forceLog) { LogSources($"{techniqueType} active | " + "Sources=" + text + " | Modifiers=" + text2 + " | " + $"Base={techniqueDef.BaseMaxProgress} | " + $"Modifier={num} | " + $"FinalMax={techniqueState.MaxProgress}"); } } private void SetInactive(TechniqueState state, bool forceLog, string reason) { if (state != null) { bool num = state.IsActive || state.CurrentProgress != 0 || state.IsReady; state.IsActive = false; state.CurrentProgress = 0; state.IsReady = false; state.MaxProgress = 1; state.LastTotalModifier = 0; state.ActiveSourceNames = string.Empty; state.ActiveModifierSourceNames = string.Empty; if (num || forceLog) { LogSources($"{state.TechniqueType} inactive. Reason={reason}"); } } } public void RegisterSuccessfulHit(WarriorTechniqueType techniqueType, Character target) { if (!_setup || (Object)(object)_player == (Object)null) { return; } RefreshTechniqueState(techniqueType, forceLog: false); TechniqueState techniqueState = EnsureState(techniqueType); if (!techniqueState.IsActive) { LogProgress($"Hit ignored. Technique is not active: {techniqueType}"); return; } if (techniqueState.IsReady) { LogProgress($"{techniqueType} already ready. Progress remains {techniqueState.CurrentProgress}/{techniqueState.MaxProgress}"); return; } techniqueState.CurrentProgress++; if (techniqueState.CurrentProgress >= techniqueState.MaxProgress) { techniqueState.CurrentProgress = techniqueState.MaxProgress; techniqueState.IsReady = true; WarriorTechniqueSystemConfigs.WarriorTechniqueDef techniqueDef = GetTechniqueDef(techniqueType); string arg = ((techniqueDef != null) ? techniqueDef.TechniqueNameKey : techniqueType.ToString()); LogProgress($"{techniqueType} technique ready: {arg}"); } else { LogProgress($"{techniqueType} progress: {techniqueState.CurrentProgress}/{techniqueState.MaxProgress}"); } } public bool IsTechniqueActive(WarriorTechniqueType techniqueType) { return EnsureState(techniqueType).IsActive; } public bool IsTechniqueReady(WarriorTechniqueType techniqueType) { TechniqueState techniqueState = EnsureState(techniqueType); if (techniqueState.IsActive) { return techniqueState.IsReady; } return false; } public int GetCurrentProgress(WarriorTechniqueType techniqueType) { return EnsureState(techniqueType).CurrentProgress; } public int GetMaxProgress(WarriorTechniqueType techniqueType) { return EnsureState(techniqueType).MaxProgress; } public void ResetTechniqueProgress(WarriorTechniqueType techniqueType) { TechniqueState techniqueState = EnsureState(techniqueType); techniqueState.CurrentProgress = 0; techniqueState.IsReady = false; LogProgress($"{techniqueType} progress reset."); } public bool TryConsumeReady(WarriorTechniqueType techniqueType) { TechniqueState techniqueState = EnsureState(techniqueType); if (!techniqueState.IsActive || !techniqueState.IsReady) { return false; } ResetTechniqueProgress(techniqueType); return true; } public bool TryGetPreferredUiTechnique(out WarriorTechniqueType techniqueType) { techniqueType = WarriorTechniqueType.None; if (TryGetCurrentWeaponTechnique(_player, out var techniqueType2) && IsTechniqueActive(techniqueType2)) { techniqueType = techniqueType2; return true; } if (IsTechniqueActive(WarriorTechniqueType.Execution)) { techniqueType = WarriorTechniqueType.Execution; return true; } if (IsTechniqueActive(WarriorTechniqueType.Discipline)) { techniqueType = WarriorTechniqueType.Discipline; return true; } if (IsTechniqueActive(WarriorTechniqueType.Suppression)) { techniqueType = WarriorTechniqueType.Suppression; return true; } return false; } public bool TryGetUiData(out WarriorTechniqueUIData data) { data = default(WarriorTechniqueUIData); if (!TryGetPreferredUiTechnique(out var techniqueType)) { return false; } TechniqueState techniqueState = EnsureState(techniqueType); WarriorTechniqueSystemConfigs.WarriorTechniqueDef techniqueDef = GetTechniqueDef(techniqueType); if (techniqueDef == null) { return false; } data = new WarriorTechniqueUIData { TechniqueType = techniqueType, CurrentProgress = techniqueState.CurrentProgress, MaxProgress = techniqueState.MaxProgress, IsReady = techniqueState.IsReady, OwnerNameKey = techniqueDef.OwnerNameKey, TechniqueNameKey = techniqueDef.TechniqueNameKey, IconAssetName = techniqueDef.IconAssetName, ReadyIconAssetName = techniqueDef.ReadyIconAssetName }; return true; } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] public struct WarriorTechniqueUIData { public WarriorTechniqueType TechniqueType; public int CurrentProgress; public int MaxProgress; public bool IsReady; public string OwnerNameKey; public string TechniqueNameKey; public string IconAssetName; public string ReadyIconAssetName; } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private sealed class SuppressionHitMarker { public bool Apply; } [HarmonyPatch(typeof(Character), "Awake")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class Character_Awake_Suppression_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Character __instance) { ZNetView view = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)view == (Object)null || !view.IsValid()) { return; } view.Register<Vector3>("WG_SuppressionStagger", (Action<long, Vector3>)delegate(long sender, Vector3 direction) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (view.IsOwner() && !__instance.IsDead() && !__instance.IsBoss() && !(__instance.m_staggerDamageFactor <= 0f)) { __instance.Stagger(direction); } }); } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch(typeof(Character), "Damage")] private static class Character_Damage_Patch { private static void Prefix(Character __instance, HitData hit) { RegisterAttackHit(__instance, hit); } private static void Postfix(Character __instance, HitData hit) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (hit == null || !SuppressionHits.TryGetValue(hit, out var value)) { return; } SuppressionHits.Remove(hit); if (value.Apply) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.InvokeRPC("WG_SuppressionStagger", new object[1] { hit.m_dir }); } } } } [HarmonyPatch(typeof(Attack), "Start", new Type[] { typeof(Humanoid), typeof(Rigidbody), typeof(ZSyncAnimation), typeof(CharacterAnimEvent), typeof(VisEquipment), typeof(ItemData), typeof(Attack), typeof(float), typeof(float) })] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class Attack_Start_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Attack __instance, Humanoid character, ItemData weapon, bool __result) { BeginAttack(__instance, character, weapon, __result); } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] private static class Attack_Melee_Patch { private static void Prefix(Attack __instance, out AttackState __state) { AttackStates.TryGetValue(__instance, out __state); _currentMeleeAttack = __state; if (__state != null) { __state.HitEvent++; } } private static void Finalizer(Exception __exception, AttackState __state) { if (_currentMeleeAttack == __state) { _currentMeleeAttack = null; } } } [HarmonyPatch(typeof(Attack), "DoAreaAttack")] [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] private static class Attack_Area_Patch { private static void Prefix(Attack __instance, out AttackState __state) { AttackStates.TryGetValue(__instance, out __state); _currentMeleeAttack = __state; if (__state != null) { __state.HitEvent++; } } private static void Finalizer(Exception __exception, AttackState __state) { if (_currentMeleeAttack == __state) { _currentMeleeAttack = null; } } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch(typeof(Attack), "FireProjectileBurst")] private static class Attack_ProjectileBurst_Patch { private static void Prefix(Attack __instance, out AttackState __state) { AttackStates.TryGetValue(__instance, out __state); _currentProjectileBurst = __state; } private static void Finalizer(Exception __exception, AttackState __state) { if (_currentProjectileBurst == __state) { _currentProjectileBurst = null; } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(Projectile), "Setup", new Type[] { typeof(Character), typeof(Vector3), typeof(float), typeof(HitData), typeof(ItemData), typeof(ItemData) })] private static class Projectile_Setup_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(Projectile __instance) { if (_currentProjectileBurst != null) { ProjectileState value = ProjectileStates.GetValue(__instance, [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] (Projectile _) => new ProjectileState()); value.Attack = _currentProjectileBurst; value.EventId = ++_currentProjectileBurst.HitEvent; } } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch(typeof(Projectile), "OnHit")] private static class Projectile_OnHit_Patch { private static void Prefix(Projectile __instance, out ProjectileState __state) { ProjectileStates.TryGetValue(__instance, out __state); _currentProjectileHit = __state; } private static void Finalizer(Exception __exception, ProjectileState __state) { if (_currentProjectileHit == __state) { _currentProjectileHit = null; } } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch(typeof(Player), "UseStamina")] private static class Player_UseStamina_Patch { private static void Prefix(Player __instance, out float __state) { __state = __instance.GetStamina(); } private static void Postfix(Player __instance, float __state) { TrackStaminaUse(__instance, __state); } } [<336b9e50-cfc9-4ce2-af50-c6c57e35d432>Nullable(0)] [HarmonyPatch(typeof(Attack), "Update", new Type[] { typeof(float) })] private static class Attack_Update_Patch { private static void Prefix(Attack __instance, out AttackState __state) { AttackStates.TryGetValue(__instance, out __state); _staminaAttack = __state; } private static void Finalizer(Exception __exception, AttackState __state) { if (_staminaAttack == __state) { _staminaAttack = null; } } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(Hud), "Update")] private static class Hud_Update_Patch { private static void Postfix() { ManualUpdateUi(); } } [HarmonyPatch(typeof(Hud), "OnDestroy")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class Hud_OnDestroy_Patch { private static void Prefix() { CleanupUi(); LogUI("HUD destroyed. Warrior Technique UI cleaned up."); } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(StatusEffect), "GetTooltipString")] private static class StatusEffect_GetTooltipString_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(StatusEffect __instance, ref string __result) { AppendStatusEffectTooltip(__instance, ref __result); } } [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] [HarmonyPatch(typeof(SE_Stats), "GetTooltipString")] private static class SE_Stats_GetTooltipString_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(SE_Stats __instance, ref string __result) { AppendStatusEffectTooltip((StatusEffect)(object)__instance, ref __result); } } [HarmonyPatch(typeof(SE_Shield), "GetTooltipString")] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class SE_Shield_GetTooltipString_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(SE_Shield __instance, ref string __result) { AppendStatusEffectTooltip((StatusEffect)(object)__instance, ref __result); } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(0)] private static class ItemData_GetTooltip_Patch { [<2b3fbbba-ae27-4e88-8259-124992657c0a>NullableContext(1)] private static void Postfix(ItemData item, int qualityLevel, bool crafting, float worldLevel, int stackOverride, bool appending, ref string __result) { if (!appending) { AppendItemTooltip(item, ref __result); } } } private const string LocReady = "$ready_DO"; private const string LocTooltipActivatesTechnique = "$warrior_tooltip_activates_technique_DO"; private const string LocTooltipMaxProgress = "$warrior_tooltip_max_progress_DO"; private const string LocTooltipWhenAnyTechniqueTriggers = "$warrior_tooltip_when_any_technique_triggers_DO"; private const string LocTooltipWhenTechniqueTriggers = "$warrior_tooltip_when_technique_triggers_DO"; private const string LocTooltipApplies = "$warrior_tooltip_applies_DO"; private const string ExecutionTechniqueColor = "#D3A359"; private const string DisciplineTechniqueColor = "#D57B42"; private const string SuppressionTechniqueColor = "#C23331"; private const string TooltipLabelColor = "#D0D0D0"; private const string TooltipValueColor = "orange"; private const string ExecutionFxPrefabName = ""; private const string DisciplineFxPrefabName = ""; private const string SuppressionFxPrefabName = ""; private static readonly Dictionary<string, WarriorTechniqueType> InternalWeaponWhitelist = new Dictionary<string, WarriorTechniqueType>(StringComparer.Ordinal); private static readonly HashSet<string> InternalWeaponBlacklist = new HashSet<string>(StringComparer.Ordinal); private static bool _initialized; private static AssetBundle _assetBundle; private static readonly FieldInfo AttackCharacterField = AccessTools.Field(typeof(Attack), "m_character"); private static readonly FieldInfo AttackWeaponField = AccessTools.Field(typeof(Attack), "m_weapon"); private static readonly FieldInfo AttackAmmoItemField = AccessTools.Field(typeof(Attack), "m_ammoItem"); private static readonly FieldInfo PlayerActionQueueField = AccessTools.Field(typeof(Player), "m_actionQueue"); private static readonly HashSet<SkillType> SupportedCustomSkills = new HashSet<SkillType> { CustomSkills.GetSkillType("Chakrams"), CustomSkills.GetSkillType("Throwing"), CustomSkills.GetSkillType("Scythes") }; private static readonly ConditionalWeakTable<Attack, AttackState> AttackStates = new ConditionalWeakTable<Attack, AttackState>(); private static readonly ConditionalWeakTable<Projectile, ProjectileState> ProjectileStates = new ConditionalWeakTable<Projectile, ProjectileState>(); private static AttackState _currentMeleeAttack; private static AttackState _currentProjectileBurst; private static ProjectileState _currentProjectileHit; private static AttackState _staminaAttack; private static Attack _lastStartedAttack; private static readonly List<WarriorTechniqueSystemConfigs.WarriorTechniqueDef> TechniqueDefs = new List<WarriorTechniqueSystemConfigs.WarriorTechniqueDef>(); private static readonly List<WarriorTechniqueSystemConfigs.WarriorTechniqueActivationSourceDef> ActivationSourceDefs = new List<WarriorTechniqueSystemConfigs.WarriorTechniqueActivationSourceDef>(); private static readonly List<WarriorTechniqueSystemConfigs.WarriorTechniqueProgressModifierSourceDef> ProgressModifierSourceDefs = new List<WarriorTechniqueSystemConfigs.WarriorTechniqueProgressModifierSourceDef>(); private static readonly List<WarriorTechniqueSystemConfigs.WarriorTechniqueOnProcStatusEffectSourceDef> OnProcStatusEffectSourceDefs = new List<WarriorTechniqueSystemConfigs.WarriorTechniqueOnProcStatusEffectSourceDef>(); private static bool _uiBuilt; private static GameObject _rootObject; private static RectTransform _rootRect; private static Hud _lastHud; private static SlotRefs _techniqueSlot; private static readonly Dictionary<WarriorTechniqueType, Sprite> TechniqueSprites = new Dictionary<WarriorTechniqueType, Sprite>(); private static readonly Dictionary<WarriorTechniqueType, Sprite> TechniqueReadySprites = new Dictionary<WarriorTechniqueType, Sprite>(); private static WarriorTechniqueType _lastUiTechnique = WarriorTechniqueType.None; private static string _lastUiText = string.Empty; private static Sprite _lastUiSprite; private const string SuppressionRpcName = "WG_SuppressionStagger"; private static readonly ConditionalWeakTable<HitData, SuppressionHitMarker> SuppressionHits = new ConditionalWeakTable<HitData, SuppressionHitMarker>(); private static void Log(string category, string msg) { } private static void LogInit(string msg) { } private static void LogDefinitions(string msg) { } private static void LogController(string msg) { } private static void LogSources(string msg) { } private static void LogHit(string msg) { } private static void LogProgress(string msg) { } private static void LogUI(string msg) { } private static void LogTooltip(string msg) { } private static void LogAssets(string msg) { } private static void LogConsume(string msg) { } private static void LogOnProc(string msg) { } public static void Initialize(AssetBundle assetBundle) { if (_initialized) { LogInit("Initialize called more than once. Ignored."); return; } _assetBundle = assetBundle; RebuildDefinitions(); LoadTechniqueSprites(); WarriorTechniqueSystemConfigs.DefinitionsChanged += OnDefinitionsChanged; _initialized = true; LogInit("WarriorTechniqueSystem initialized."); LogInit("Technique definitions: " + TechniqueDefs.Count); LogInit("Activation source definitions: " + ActivationSourceDefs.Count); LogInit("Progress modifier source definitions: " + ProgressModifierSourceDefs.Count); LogInit("On-proc status effect source definitions: " + OnProcStatusEffectSourceDefs.Count); } private static void OnDefinitionsChanged() { RebuildDefinitions(); LoadTechniqueSprites(); WarriorTechniqueController controller = GetController(Player.m_localPlayer); if ((Object)(object)controller != (Object)null) { controller.ForceRefresh(); } LogDefinitions("Definitions changed and rebuilt."); } private static void RebuildDefinitions() { TechniqueDefs.Clear(); ActivationSourceDefs.Clear(); ProgressModifierSourceDefs.Clear(); OnProcStatusEffectSourceDefs.Clear(); IReadOnlyList<WarriorTechniqueSystemConfigs.WarriorTechniqueDef> techniqueDefs = WarriorTechniqueSystemConfigs.GetTechniqueDefs(); if (techniqueDefs != null) { for (int i = 0; i < techniqueDefs.Count; i++) { if (techniqueDefs[i] != null) { TechniqueDefs.Add(techniqueDefs[i]); } } } IReadOnlyList<WarriorTechniqueSystemConfigs.WarriorTechniqueActivationSourceDef> activationSourceDefs = WarriorTechniqueSystemConfigs.GetActivationSourceDefs(); if (activationSourceDefs != null) { for (int j = 0; j < activationSourceDefs.Count; j++) { if (activationSourceDefs[j] != null) { ActivationSourceDefs.Add(activationSourceDefs[j]); } } } IReadOnlyList<WarriorTechniqueSystemConfigs.WarriorTechniqueProgressModifierSourceDef> progressModifierSourceDefs = WarriorTechniqueSystemConfigs.GetProgressModifierSourceDefs(); if (progressModifierSourceDefs != null) { for (int k = 0; k < progressModifierSourceDefs.Count; k++) { if (progressModifierSourceDefs[k] != null) { ProgressModifierSourceDefs.Add(progressModifierSourceDefs[k]); } } } IReadOnlyList<WarriorTechniqueSystemConfigs.WarriorTechniqueOnProcStatusEffectSourceDef> onProcStatusEffectSourceDefs = WarriorTechniqueSystemConfigs.GetOnProcStatusEffectSourceDefs(); if (onProcStatusEffectSourceDefs != null) { for (int l = 0; l < onProcStatusEffectSourceDefs.Count; l++) { if (onProcStatusEffectSourceDefs[l] != null) { OnProcStatusEffectSourceDefs.Add(onProcStatusEffectSourceDefs[l]); } } } LogDefinitions("Rebuilt definitions. " + $"Techniques={TechniqueDefs.Count}, " + $"ActivationSources={ActivationSourceDefs.Count}, " + $"ProgressModifiers={ProgressModifierSourceDefs.Count}, " + $"OnProcSources={OnProcStatusEffectSourceDefs.Count}"); } public static bool IsSystemEnabled() { if (_initialized && WarriorTechniqueSystemConfigs.IsInitialized()) { return WarriorTechniqueSystemConfigs.IsSystemEnabled(); } return false; } public static WarriorTechniqueController GetOrCreateController(Player player) { if ((Object)(object)player == (Object)null) { return null; } WarriorTechniqueController warriorTechniqueController = ((Component)player).GetComponent<WarriorTechniqueController>(); if ((Object)(object)warriorTechniqueController == (Object)null) { warriorTechniqueController = ((Component)player).gameObject.AddComponent<WarriorTechniqueController>(); warriorTechniqueController.Setup(player); LogController("Created WarriorTechniqueController on player."); } return warriorTechniqueController; } public static WarriorTechniqueController GetController(Player player) { if ((Object)(object)player == (Object)null) { return null; } return ((Component)player).GetComponent<WarriorTechniqueController>(); } public static bool TryGetController(Player player, out WarriorTechniqueController controller) { controller = GetController(player); return (Object)(object)controller != (Object)null; } public static WarriorTechniqueSystemConfigs.WarriorTechniqueDef GetTechniqueDef(WarriorTechniqueType techniqueType) { for (int i = 0; i < TechniqueDefs.Count; i++) { WarriorTechniqueSystemConfigs.WarriorTechniqueDef warriorTechniqueDef = TechniqueDefs[i]; if (warriorTechniqueDef != null && warriorTechniqueDef.TechniqueType == techniqueType) { return warriorTechniqueDef; } } return null; } private static bool IsSupportedSkill(SkillType skill) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) switch (skill - 1) { case 0: case 1: case 2: case 3: case 4: case 6: case 10: return true; default: return SupportedCustomSkills.Contains(skill); } } private static bool TryGetTechniqueFromWeapon(ItemData weapon, bool allowInternalWhitelist, out WarriorTechniqueType techniqueType) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) techniqueType = WarriorTechniqueType.None; if (weapon?.m_shared == null) { return false; } string itemPrefabName = GetItemPrefabName(weapon); if (InternalWeaponBlacklist.Contains(itemPrefabName)) { return false; } if (!IsSupportedSkill(weapon.m_shared.m_skillType)) { return false; } WarriorTechniqueController controller = GetController(Player.m_localPlayer); if ((Object)(object)controller == (Object)null) { return false; } if (controller.IsTechniqueActive(WarriorTechniqueType.Execution)) { techniqueType = WarriorTechniqueType.Execution; return true; } if (controller.IsTechniqueActive(WarriorTechniqueType.Discipline)) { techniqueType = WarriorTechniqueType.Discipline; return true; } if (controller.IsTechniqueActive(WarriorTechniqueType.Suppression)) { techniqueType = WarriorTechniqueType.Suppression; return true; } return false; } private static bool TryGetCurrentWeaponTechnique(Player player, out WarriorTechniqueType techniqueType) { techniqueType = WarriorTechniqueType.None; if ((Object)(object)player != (Object)null) { return TryGetTechniqueFromWeapon(((Humanoid)player).GetCurrentWeapon(), allowInternalWhitelist: true, out techniqueType); } return false; } private static bool StatusEffectNameMatchesSource(string seRawName, string seCleanName, string sourceSeName) { if (string.IsNullOrEmpty(sourceSeName)) { return false; } if (!string.IsNullOrEmpty(seRawName) && string.Equals(seRawName, sourceSeName, StringComparison.Ordinal)) { return true; } if (!string.IsNullOrEmpty(seCleanName) && string.Equals(seCleanName, sourceSeName, StringComparison.Ordinal)) { return true; } if (!string.IsNullOrEmpty(seCleanName) && StringExtensionMethods.GetStableHashCode(seCleanName) == StringExtensionMethods.GetStableHashCode(sourceSeName)) { return true; } return false; } private static bool PlayerHasSource(Player player, WarriorTechniqueSourceType sourceType, string sourceName) { if ((Object)(object)player == (Object)null || string.IsNullOrWhiteSpace(sourceName)) { return false; } return sourceType switch { WarriorTechniqueSourceType.StatusEffect => PlayerHasSourceStatusEffect(player, sourceName), WarriorTechniqueSourceType.Item => PlayerHasSourceItem(player, sourceName), _ => false, }; } private static bool PlayerHasSourceStatusEffect(Player player, string sourceName) { if ((Object)(object)player == (Object)null || string.IsNullOrWhiteSpace(sourceName)) { return false; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return false; } List<StatusEffect> statusEffects = sEMan.GetStatusEffects(); for (int i = 0; i < statusEffects.Count; i++) { StatusEffect val = statusEffects[i]; if (!((Object)(object)val == (Object)null)) { string name = ((Object)val).name; string prefabName = Utils.GetPrefabName(name); if (StatusEffectNameMatchesSource(name, prefabName, sourceName)) { return true; } } } return false; } private static bool PlayerHasSourceItem(Player player, string sourceName) { if ((Object)(object)player == (Object)null || string.IsNullOrWhiteSpace(sourceName)) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } List<ItemData> allItems = inventory.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val = allItems[i]; if (val != null && val.m_equipped && string.Equals(GetItemPrefabName(val), sourceName, StringComparison.Ordinal)) { return true; } } return false; } private static string GetItemPrefabName(ItemData item) { if (item == null) { return string.Empty; } if ((Object)(object)item.m_dropPrefab != (Object)null) { return Utils.GetPrefabName(((Object)item.m_dropPrefab).name); } return string.Empty; } private static void BeginAttack(Attack attack, Humanoid character, ItemData weapon, bool started) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 if (!started || !IsSystemEnabled() || attack == null || weapon?.m_shared == null) { return; } Player val = (Player)(object)((character is Player) ? character : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer || !IsSupportedSkill(weapon.m_shared.m_skillType) || ((int)attack.m_attackType != 0 && (int)attack.m_attackType != 1 && (int)attack.m_attackType != 4 && (int)attack.m_attackType != 2)) { return; } WarriorTechniqueController orCreateController = GetOrCreateController(val); if ((Object)(object)orCreateController == (Object)null) { return; } WarriorTechniqueType warriorTechniqueType = (orCreateController.IsTechniqueActive(WarriorTechniqueType.Execution) ? WarriorTechniqueType.Execution : (orCreateController.IsTechniqueActive(WarriorTechniqueType.Discipline) ? WarriorTechniqueType.Discipline : (orCreateController.IsTechniqueActive(WarriorTechniqueType.Suppression) ? WarriorTechniqueType.Suppression : WarriorTechniqueType.None))); if (warriorTechniqueType != WarriorTechniqueType.None) { AttackState value = AttackStates.GetValue(attack, (Attack _) => new AttackState()); value.Player = val; value.Technique = warriorTechniqueType; value.Armed = orCreateController.IsTechniqueReady(warriorTechniqueType); value.Consumed = false; value.HadValidHit = false; value.StaminaSpent = 0f; value.StaminaRefunded = 0f; value.HitEvent = 0; value.LastProgressEvent = -1; _lastStartedAttack = attack; } } private static bool IsValidTarget(Character target, HitData hit, AttackState state) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (state == null || (Object)(object)target == (Object)null || hit == null || (Object)(object)state.Player == (Object)null) { return false; } if ((Object)(object)target == (Object)(object)state.Player || target.IsDead() || ((DamageTypes)(ref hit.m_damage)).GetTotalDamage() <= 0f) { return false; } if ((Object)(object)hit.GetAttacker() != (Object)(object)state.Player || !IsSupportedSkill(hit.m_skill)) { return false; } Player val = (Player)(object)((target is Player) ? target : null); if (val != null && !((Character)state.Player).IsPVPEnabled() && !((Character)val).IsPVPEnabled()) { return false; } return true; } private static void RegisterAttackHit(Character target, HitData hit) { //IL_008b: 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) AttackState attackState = _currentProjectileHit?.Attack ?? _currentMeleeAttack; if (!IsSystemEnabled() || !IsValidTarget(target, hit, attackState) || (Object)(object)attackState.Player != (Object)(object)Player.m_localPlayer) { return; } WarriorTechniqueController orCreateController = GetOrCreateController(attackState.Player); if ((Object)(object)orCreateController == (Object)null) { return; } if (attackState.Armed) { if (!attackState.Consumed) { if (!orCreateController.TryConsumeReady(attackState.Technique)) { return; } attackState.Consumed = true; SpawnTechniqueFx(attackState.Technique, ((Character)attackState.Player).GetCenterPoint(), ((Component)attackState.Player).transform.rotation); ApplyOnProcStatusEffects(attackState.Player, attackState.Technique); } if (attackState.Technique == WarriorTechniqueType.Execution) { ((DamageTypes)(ref hit.m_damage)).Modify(2f); } else if (attackState.Technique == WarriorTechniqueType.Discipline) { RefundDiscipline(attackState); } else if (attackState.Technique == WarriorTechniqueType.Suppression && !target.IsBoss() && target.m_staggerDamageFactor > 0f) { SuppressionHits.GetValue(hit, (HitData _) => new SuppressionHitMarker()).Apply = true; } } else if (!attackState.Consumed) { if (_currentProjectileHit != null) { if (!_currentProjectileHit.ProgressGranted) { _currentProjectileHit.ProgressGranted = true; orCreateController.RegisterSuccessfulHit(attackState.Technique, target); } } else if (attackState.LastProgressEvent != attackState.HitEvent) { attackState.LastProgressEvent = attackState.HitEvent; orCreateController.RegisterSuccessfulHit(attackState.Technique, target); } } attackState.HadValidHit = true; } private static void RefundDiscipline(AttackState state) { float num = Mathf.Max(0f, state.StaminaSpent - state.StaminaRefunded); if (!(num <= 0f)) { ((Character)state.Player).AddStamina(num); state.StaminaRefunded += num; } } private static void TrackStaminaUse(Player player, float before) { if (_staminaAttack != null && !((Object)(object)_staminaAttack.Player != (Object)(object)player)) { float num = Mathf.Max(0f, before - player.GetStamina()); _staminaAttack.StaminaSpent += num; if (_staminaAttack.Consumed && _staminaAttack.Technique == WarriorTechniqueType.Discipline) { RefundDiscipline(_staminaAttack); } } } private static void SpawnTechniqueFx(WarriorTechniqueType type, Vector3 position, Quaternion rotation) { //IL_004a: 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) if (!WarriorTechniqueSystemConfigs.IsTechniqueFxEnabled()) { return; } string text = type switch { WarriorTechniqueType.Discipline => "", WarriorTechniqueType.Execution => "", _ => "", }; if (!string.IsNullOrWhiteSpace(text)) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(text) : null); if ((Object)(object)val != (Object)null) { Object.Instantiate<GameObject>(val, position, rotation); } } } private static void ApplyOnProcStatusEffects(Player player, WarriorTechniqueType triggerTechnique) { if (!_initialized || !IsSystemEnabled() || (Object)(object)player == (Object)null || OnProcStatusEffectSourceDefs.Count == 0) { return; } for (int i = 0; i < OnProcStatusEffectSourceDefs.Count; i++) { WarriorTechniqueSystemConfigs.WarriorTechniqueOnProcStatusEffectSourceDef warriorTechniqueOnProcStatusEffectSourceDef = OnProcStatusEffectSourceDefs[i]; if (warriorTechniqueOnProcStatusEffectSourceDef != null && (warriorTechniqueOnProcStatusEffectSourceDef.TriggerTechnique == WarriorTechniqueType.Any || warriorTechniqueOnProcStatusEffectSourceDef.TriggerTechnique == triggerTechnique) && PlayerHasSource(player, warriorTechniqueOnProcStatusEffectSourceDef.SourceType, warriorTechniqueOnProcStatusEffectSourceDef.SourceName)) { ApplyConfiguredStatusEffect(player, warriorTechniqueOnProcStatusEffectSourceDef.StatusEffectName); } } } private static void ApplyConfiguredStatusEffect(Player player, string statusEffectName) { if ((Object)(object)player == (Object)null || string.IsNullOrWhiteSpace(statusEffectName)) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return; } int stableHashCode = StringExtensionMethods.GetStableHashCode(statusEffectName); StatusEffect statusEffect = sEMan.GetStatusEffect(stableHashCode); if ((Object)(object)statusEffect != (Object)null) { statusEffect.ResetTime(); LogOnProc("Reset on-proc SE '" + statusEffectName + "'."); return; } if ((Object)(object)sEMan.AddStatusEffect(stableHashCode, true, 0, 0f, (short)(-1)) != (Object)null) { LogOnProc("Applied registered on-proc SE '" + statusEffectName + "'."); return; } StatusEffect val = null; if ((Object)(object)_assetBundle != (Object)null) { try { val = _assetBundle.LoadAsset<StatusEffect>(statusEffectName); } catch (Exception arg) { LogOnProc($"Exception while loading on-proc SE '{statusEffectName}' from asset bundle: {arg}"); } } if ((Object)(object)val == (Object)null) { LogOnProc("Failed to apply on-proc SE '" + statusEffectName + "'. Not found in registered status effects or Warrior asset bundle."); } else if ((Object)(object)sEMan.AddStatusEffect(val, true, 0, 0f, (short)(-1)) != (Object)null) { LogOnProc("Applied bundle on-proc SE '" + statusEffectName + "'."); } else { LogOnProc("Failed to apply bundle on-proc SE '" + statusEffectName + "'."); } } private static void LoadTechniqueSprites() { TechniqueSprites.Clear(); TechniqueReadySprites.Clear(); if ((Object)(object)_assetBundle == (Object)null) { LogAssets("AssetBundle is null. Technique sprites cannot be loaded."); return; } for (int i = 0; i < TechniqueDefs.Count; i++) { WarriorTechniqueSystemConfigs.WarriorTechniqueDef warriorTechniqueDef = TechniqueDefs[i]; if (warriorTechniqueDef != null) { TryLoadSprite(warriorTechniqueDef.TechniqueType, warriorTechniqueDef.IconAssetName, TechniqueSprites, ready: false); TryLoadSprite(warriorTechniqueDef.TechniqueType, warriorTechniqueDef.ReadyIconAssetName, TechniqueReadySprites, ready: true); } } } private static void TryLoadSprite(WarriorTechniqueType techniqueType, string assetName, Dictionary<WarriorTechniqueType, Sprite> target, bool ready) { if (string.IsNullOrWhiteSpace(assetName) || target == null) { return; } try { Sprite val = _assetBundle.LoadAsset<Sprite>(assetName); if ((Object)(object)val == (Object)null) { LogAssets("Sprite not found: " + assetName); return; } target[techniqueType] = val; LogAssets(string.Format("Loaded {0} sprite '{1}' for {2}.", ready ? "ready" : "normal", assetName, techniqueType)); } catch (Exception arg) { LogAssets($"Exception while loading sprite '{assetName}': {arg}"); } } private static Sprite GetTechniqueSprite(WarriorTechniqueType techniqueType, bool ready) { if (ready && TechniqueReadySprites.TryGetValue(techniqueType, out var value)) { return value; } if (TechniqueSprites.TryGetValue(techniqueType, out var value2)) { return value2; } return null; } private static UiPresetDef BuildUiPreset() { return new UiPresetDef { PosX = WarriorTechniqueSystemConfigs.GetUiPosX(), PosY = WarriorTechniqueSystemConfigs.GetUiPosY(), IconScale = WarriorTechniqueSystemConfigs.GetUiIconScale(), TextOffsetX = WarriorTechniqueSystemConfigs.GetUiTextOffsetX(), TextOffsetY = WarriorTechniqueSystemConfigs.GetUiTextOffsetY(), TextFontSize = WarriorTechniqueSystemConfigs.GetUiTextFontSize(), TextColor = WarriorTechniqueSystemConfigs.GetUiTextColor() }; } private static void EnsureUiBuilt() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_009a: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (_initialized) { Hud instance = Hud.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_rootObject == (Object)null) && !((Object)(object)instance.m_statusEffectTemplate == (Object)null) && (!_uiBuilt || !((Object)(object)_lastHud == (Object)(object)instance) || !((Object)(object)_rootObject != (Object)null))) { CleanupUi(); _lastHud = instance; _rootObject = new GameObject("Warrior_Glory_WarriorTechniqueSystemUI"); _rootRect = _rootObject.AddComponent<RectTransform>(); ((Transform)_rootRect).SetParent(instance.m_rootObject.transform, false); _rootRect.anchorMin = Vector2.zero; _rootRect.anchorMax = Vector2.one; _rootRect.offsetMin = Vector2.zero; _rootRect.offsetMax = Vector2.zero; ((Transform)_rootRect).SetAsLastSibling(); _techniqueSlot = CreateSlot("WarriorTechniqueSlot"); _uiBuilt = true; LogUI("Warrior Technique UI built."); } } } private static SlotRefs CreateSlot(string objectName) { RectTransform val = Object.Instantiate<RectTransform>(Hud.instance.m_statusEffectTemplate, (Transform)(object)_rootRect); ((Object)((Component)val).gameObject).name = objectName; ((Component)val).gameObject.SetActive(true); Image val2 = FindChildComponent<Image>(val, "Icon"); Transform val3 = ((Transform)val).Find("Cooldown"); TMP_Text timeText = FindChildComponent<TMP_Text>(val, "TimeText"); TMP_Text val4 = FindPrimaryText(val); if ((Object)(object)val2 != (Object)null) { ((Object)((Component)val2).gameObject).name = "TechniqueIcon"; ((Component)val2).gameObject.SetActive(true); } if ((Object)(object)val4 != (Object)null) { val4.transform.SetAsLastSibling(); } SlotRefs slotRefs = new SlotRefs { Root = val, Icon = val2, CooldownObject = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : null), PrimaryText = val4, TimeText = timeText }; if ((Object)(object)slotRefs.TimeText != (Object)null) { ((Component)slotRefs.TimeText).gameObject.SetActive(false); } if ((Object)(object)slotRefs.CooldownObject != (Object)null) { slotRefs.CooldownObject.SetActive(false); } return slotRefs; } private static void CleanupUi() { if ((Object)(object)_rootObject != (Object)null) { Object.Destroy((Object)(object)_rootObject); } _rootObject = null; _rootRect = null; _techniqueSlot = null; _uiBuilt = false; _lastHud = null; _lastUiTechnique = WarriorTechniqueType.None; _lastUiText = string.Empty; _lastUiSprite = null; } private static void ManualUpdateUi() { if (!_initialized || !IsSystemEnabled()) { return; } EnsureUiBuilt(); if (!_uiBuilt || (Object)(object)_rootObject == (Object)null || (Object)(object)_rootRect == (Object)null) { return; } Hud instance = Hud.instance; if ((Object)(object)instance == (Object)null || !instance.IsVisible() || Minimap.IsOpen()) { if (_rootObject.activeSelf) { _rootObject.SetActive(false); } return; } if (!_rootObject.activeSelf) { _rootObject.SetActive(true); } if (!WarriorTechniqueSystemConfigs.IsCustomUiEnabled()) { SetSlotVisible(_techniqueSlot, visible: false); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer =