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 ForsakenPowers v1.4.0
plugins/ForsakenPowers.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ForsakenPowers")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0")] [assembly: AssemblyProduct("ForsakenPowers")] [assembly: AssemblyTitle("ForsakenPowers")] [assembly: AssemblyVersion("1.4.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ForsakenPowers { public enum UiLanguage { Auto, Russian, English } internal static class L { internal static ConfigEntry<UiLanguage> Setting; private static readonly MethodInfo GetSelectedLanguage = AccessTools.Method(typeof(Localization), "GetSelectedLanguage", (Type[])null, (Type[])null); public static bool Ru { get { switch (Setting?.Value ?? UiLanguage.Auto) { case UiLanguage.Russian: return true; case UiLanguage.English: return false; default: try { if (Localization.instance != null && GetSelectedLanguage != null) { return string.Equals(GetSelectedLanguage.Invoke(Localization.instance, null) as string, "Russian", StringComparison.OrdinalIgnoreCase); } } catch { } return false; } } } public static void Bind(ConfigFile cfg) { Setting = cfg.Bind<UiLanguage>("General", "Language", UiLanguage.Auto, "Interface language / Язык интерфейса: Auto (как в игре), Russian, English."); } public static string T(string ru, string en) { return Ru ? ru : en; } } internal static class ModHubBridge { public const string ModHubGuid = "kaefchik.modhub"; private static Texture2D _iconTex; private static Sprite _iconSprite; public static string IconPath { get { try { return Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location) ?? "", "icon.png"); } catch { return ""; } } } private static void LoadIcon() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_iconTex != (Object)null) { return; } try { byte[] array = null; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ForsakenPowers.icon.png")) { if (stream != null) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } } if (array == null && File.Exists(IconPath)) { array = File.ReadAllBytes(IconPath); } if (array != null) { _iconTex = new Texture2D(2, 2, (TextureFormat)4, false) { name = "ForsakenPowers_icon", hideFlags = (HideFlags)61 }; ImageConversion.LoadImage(_iconTex, array); _iconSprite = Sprite.Create(_iconTex, new Rect(0f, 0f, (float)((Texture)_iconTex).width, (float)((Texture)_iconTex).height), new Vector2(0.5f, 0.5f), 100f); ((Object)_iconSprite).name = "ForsakenPowers_icon"; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Не удалось загрузить иконку: " + ex.Message)); } } private static bool IsIconType(Type t) { return t == typeof(Sprite) || typeof(Texture).IsAssignableFrom(t); } public static bool TryRegister(string guid, string title, string description, Action open) { try { if (!Chainloader.PluginInfos.TryGetValue("kaefchik.modhub", out var value) || (Object)(object)value.Instance == (Object)null) { Plugin.Log.LogWarning((object)"ModHub не найден — включена резервная клавиша."); return false; } LoadIcon(); Assembly assembly = ((object)value.Instance).GetType().Assembly; Type[] array; try { array = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = ex.Types.Where((Type t) => t != null).ToArray(); } List<MethodInfo> list = (from m in array.SelectMany((Type t) => t.GetMethods(BindingFlags.Static | BindingFlags.Public)) where m.Name.IndexOf("Register", StringComparison.OrdinalIgnoreCase) >= 0 where m.GetParameters().Any((ParameterInfo p) => p.ParameterType == typeof(Action)) orderby m.GetParameters().Any((ParameterInfo p) => IsIconType(p.ParameterType) || IsIconName(p)) descending, m.GetParameters().Count((ParameterInfo p) => p.ParameterType == typeof(string)) descending select m).ToList(); foreach (MethodInfo item in list) { object[] array2 = BuildArgs(item.GetParameters(), guid, title, description, open); if (array2 == null) { continue; } item.Invoke(null, array2); Plugin.Log.LogInfo((object)("Встроился в ModHub через " + Describe(item))); TrySetIconSeparately(array, guid, title); return true; } Plugin.Log.LogWarning((object)"В ModHub не найден подходящий метод регистрации. Доступные публичные статические методы:"); LogAll(array); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Ошибка встраивания в ModHub: " + (ex2.InnerException ?? ex2).Message)); } return false; } private static void TrySetIconSeparately(Type[] types, string guid, string title) { if ((Object)(object)_iconSprite == (Object)null) { return; } IEnumerable<MethodInfo> enumerable = from m in types.SelectMany((Type t) => t.GetMethods(BindingFlags.Static | BindingFlags.Public)) where m.Name.IndexOf("Icon", StringComparison.OrdinalIgnoreCase) >= 0 where m.GetParameters().Any((ParameterInfo p) => IsIconType(p.ParameterType)) select m; foreach (MethodInfo item in enumerable) { object[] array = BuildArgs(item.GetParameters(), guid, title, "", null); if (array != null) { try { item.Invoke(null, array); Plugin.Log.LogInfo((object)("Иконка передана в ModHub через " + Describe(item))); return; } catch (Exception ex) { Plugin.Log.LogWarning((object)(Describe(item) + ": " + (ex.InnerException ?? ex).Message)); } } } Plugin.Log.LogInfo((object)("Отдельного метода для иконки в ModHub нет; icon.png лежит рядом с DLL: " + IconPath)); } private static bool IsIconName(ParameterInfo p) { string text = (p.Name ?? "").ToLowerInvariant(); return p.ParameterType == typeof(string) && (text.Contains("icon") || text.Contains("image") || text.Contains("png")); } private static object[] BuildArgs(ParameterInfo[] ps, string guid, string title, string desc, Action open) { object[] array = new object[ps.Length]; int num = 0; string[] array2 = new string[3] { guid, title, desc }; for (int i = 0; i < ps.Length; i++) { ParameterInfo parameterInfo = ps[i]; Type parameterType = parameterInfo.ParameterType; string text = (parameterInfo.Name ?? "").ToLowerInvariant(); if (parameterType == typeof(Action)) { array[i] = open; } else if (parameterType == typeof(Sprite)) { array[i] = _iconSprite; } else if (typeof(Texture).IsAssignableFrom(parameterType) && parameterType.IsAssignableFrom(typeof(Texture2D))) { array[i] = _iconTex; } else if (parameterType.IsAssignableFrom(typeof(Plugin)) && typeof(BaseUnityPlugin).IsAssignableFrom(parameterType)) { array[i] = Plugin.Instance; } else if (parameterType == typeof(PluginInfo)) { array[i] = ((BaseUnityPlugin)Plugin.Instance).Info; } else if (parameterType == typeof(string)) { if (IsIconName(parameterInfo)) { array[i] = IconPath; } else if (text.Contains("guid") || text == "id" || text.EndsWith("id")) { array[i] = guid; } else if (text.Contains("desc") || text.Contains("tooltip")) { array[i] = desc; } else if (text.Contains("name") || text.Contains("title") || text.Contains("label") || text.Contains("display")) { array[i] = title; } else if (text.Contains("version")) { array[i] = "1.4.0"; } else { array[i] = ((num < array2.Length) ? array2[num] : ""); } num++; } else if (parameterInfo.IsOptional) { array[i] = ((parameterInfo.DefaultValue is DBNull) ? null : parameterInfo.DefaultValue); } else { if (parameterType.IsValueType) { return null; } array[i] = null; } } return array; } private static string Describe(MethodInfo m) { return m.DeclaringType?.FullName + "." + m.Name + "(" + string.Join(", ", from p in m.GetParameters() select p.ParameterType.Name + " " + p.Name) + ")"; } private static void LogAll(Type[] types) { foreach (Type type in types) { MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo m in methods) { Plugin.Log.LogWarning((object)(" " + Describe(m))); } } } } internal static class Patches { [HarmonyPatch(typeof(ObjectDB), "Awake")] private static class ObjectDB_Awake { private static void Postfix() { Settings.Discover(); Settings.Apply(); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] private static class ObjectDB_CopyOtherDB { private static void Postfix() { Settings.Discover(); Settings.Apply(); } } [HarmonyPatch(typeof(Game), "Start")] private static class Game_Start { private static void Postfix() { Settings.LoadFromConfig(); Settings.Apply(); Settings.RegisterRpcs(); } } [HarmonyPatch(typeof(Player), "OnSpawned")] private static class Player_OnSpawned { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Settings.Apply(); if (Settings.IsClientOnServer) { Settings.RequestFromHost(); } } } } [HarmonyPatch(typeof(Player), "StartGuardianPower")] private static class Player_StartGuardianPower_Toggle { private static bool Prefix(Player __instance, ref bool __result) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Plugin.ToggleOff.Value) { return true; } StatusEffect val = Settings.GuardianSeRef.Invoke(__instance); if ((Object)(object)val == (Object)null) { return true; } SEMan sEMan = ((Character)__instance).GetSEMan(); StatusEffect val2 = null; foreach (StatusEffect statusEffect in sEMan.GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && statusEffect.NameHash() == val.NameHash()) { val2 = statusEffect; break; } } if ((Object)(object)val2 == (Object)null) { return true; } sEMan.RemoveStatusEffect(val.NameHash(), false); PowerCfg powerCfg = Settings.Find(((Object)val).name); ((Character)__instance).Message((MessageType)1, L.T("Сила снята: ", "Power removed: ") + ((powerCfg != null) ? powerCfg.DisplayName : ((Object)val).name), 0, (Sprite)null, false); __result = true; return false; } } [HarmonyPatch(typeof(Player), "ActivateGuardianPower")] private static class Player_ActivateGuardianPower { private static bool Prefix(Player __instance, ref bool __result) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) StatusEffect val = Settings.GuardianSeRef.Invoke(__instance); if ((Object)(object)val == (Object)null) { return true; } ref float reference = ref Settings.GuardianCooldown(__instance); if (reference > 0f) { __result = false; return false; } List<StatusEffect> list = Settings.CollectPowers(val); List<Player> list2 = new List<Player>(); if (Settings.Share) { Player.GetPlayersInRange(((Component)__instance).transform.position, Mathf.Max(1f, Settings.Radius), list2); } if (!list2.Contains(__instance)) { list2.Add(__instance); } foreach (Player item in list2) { foreach (StatusEffect item2 in list) { ((Character)item).GetSEMan().AddStatusEffect(item2.NameHash(), true, 0, 0f, (short)(-1)); } } reference = Settings.CooldownFor(list); __result = true; return false; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] private static class PlayerController_TakeInput { private static void Postfix(ref bool __result) { if (PowerMenu.Mode == MenuMode.Settings) { __result = false; } else if (PowerMenu.QuickOpen && PowerMenu.RingMouseDown) { __result = false; } else if ((PowerMenu.QuickOpen || PowerMenu.SuppressCombat) && PowerMenu.MouseHeld) { __result = false; } } } [HarmonyPatch(typeof(ZInput), "GetButton", new Type[] { typeof(string) })] private static class ZInput_GetButton { private static bool Prefix(string __0, ref bool __result) { if (!BlockCombat(__0)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ZInput), "GetButtonDown", new Type[] { typeof(string) })] private static class ZInput_GetButtonDown { private static bool Prefix(string __0, ref bool __result) { if (!BlockCombat(__0)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ZInput), "GetButtonUp", new Type[] { typeof(string) })] private static class ZInput_GetButtonUp { private static bool Prefix(string __0, ref bool __result) { if (!BlockCombat(__0)) { return true; } __result = false; return false; } } [HarmonyPatch] private static class Humanoid_StartAttack { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo h = AccessTools.DeclaredMethod(typeof(Humanoid), "StartAttack", (Type[])null, (Type[])null); if (h != null) { yield return h; } MethodInfo p = AccessTools.DeclaredMethod(typeof(Player), "StartAttack", (Type[])null, (Type[])null); if (p != null) { yield return p; } } private static bool Prefix(Humanoid __instance, ref bool __result) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (!PowerMenu.IsOpen && !PowerMenu.SuppressCombat) { return true; } __result = false; return false; } } [HarmonyPatch] private static class SEMan_AddStatusEffect_Cap { private static readonly FieldRef<StatusEffect, float> TimeRef = AccessTools.FieldRefAccess<StatusEffect, float>("m_time"); private static readonly List<StatusEffect> Gp = new List<StatusEffect>(); private static MethodBase TargetMethod() { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(SEMan))) { if (!(declaredMethod.Name != "AddStatusEffect")) { ParameterInfo[] parameters = declaredMethod.GetParameters(); if (parameters.Length != 0 && parameters[0].ParameterType == typeof(StatusEffect)) { return declaredMethod; } } } return null; } private static void Postfix(SEMan __instance, StatusEffect __result) { if ((Object)(object)__result == (Object)null || !((Object)__result).name.StartsWith("GP_")) { return; } int num = Mathf.Max(1, Settings.EffectiveCap); Gp.Clear(); foreach (StatusEffect statusEffect in __instance.GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && (Object)(object)statusEffect != (Object)(object)__result && ((Object)statusEffect).name.StartsWith("GP_")) { Gp.Add(statusEffect); } } int num2 = Gp.Count + 1 - num; if (num2 > 0) { Gp.Sort((StatusEffect x, StatusEffect y) => TimeRef.Invoke(y).CompareTo(TimeRef.Invoke(x))); for (int num3 = 0; num3 < num2 && num3 < Gp.Count; num3++) { __instance.RemoveStatusEffect(Gp[num3].NameHash(), true); } } } } [HarmonyPatch(typeof(ZInput), "GetMouseDelta")] private static class ZInput_GetMouseDelta { private static void Postfix(ref Vector2 __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (PowerMenu.QuickOpen) { __result = Vector2.zero; } } } [HarmonyPatch(typeof(Player), "TakeInput")] private static class Player_TakeInput { private static void Postfix(ref bool __result) { if (PowerMenu.IsOpen) { __result = false; } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] private static class GameCamera_UpdateMouseCapture { private static bool Prefix() { if (!PowerMenu.IsOpen) { return true; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return false; } } [HarmonyPatch(typeof(Menu), "Update")] private static class Menu_Update { private static bool Prefix() { return !PowerMenu.IsOpen && Time.frameCount - PowerMenu.ClosedFrame > 1; } } private static bool IsCombat(string name) { int result; switch (name) { default: result = ((name == "JoyBlock") ? 1 : 0); break; case "Attack": case "SecondaryAttack": case "Block": case "JoyAttack": case "JoySecondaryAttack": result = 1; break; } return (byte)result != 0; } private static bool BlockCombat(string name) { return (PowerMenu.IsOpen || PowerMenu.SuppressCombat) && name != null && IsCombat(name); } } [BepInPlugin("kaefchik.forsakenpowers", "ForsakenPowers", "1.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "kaefchik.forsakenpowers"; public const string ModName = "ForsakenPowers"; public const string Version = "1.4.0"; internal static Plugin Instance; internal static ManualLogSource Log; internal static ConfigFile Cfg; internal static ConfigEntry<KeyboardShortcut> FallbackKey; internal static ConfigEntry<KeyboardShortcut> RingKey; internal static ConfigEntry<bool> ToggleOff; private Harmony _harmony; private bool _hubRegistered; private void Awake() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Cfg = ((BaseUnityPlugin)this).Config; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; FallbackKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "FallbackKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Резервная клавиша меню настроек. Работает ТОЛЬКО если не удалось встроиться в ModHub."); ToggleOff = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ReactivateRemoves", true, "Повторная активация уже действующей силы снимает её (без отката). Личная настройка."); RingKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "QuickRingKey", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Клавиша быстрого кольца сил: зажать, навести на силу, отпустить — сила активируется. Личная настройка."); L.Bind(((BaseUnityPlugin)this).Config); Settings.BindGlobal(); Settings.BindKnownPowers(); Settings.LoadFromConfig(); ((BaseUnityPlugin)this).Config.Save(); ((Component)this).gameObject.AddComponent<PowerMenu>(); _harmony = new Harmony("kaefchik.forsakenpowers"); Type[] nestedTypes = typeof(Patches).GetNestedTypes(AccessTools.all); foreach (Type type in nestedTypes) { try { _harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogWarning((object)("Патч " + type.Name + " не применён: " + ex.Message)); } } Log.LogInfo((object)"ForsakenPowers 1.4.0 загружен"); _hubRegistered = ModHubBridge.TryRegister("kaefchik.forsakenpowers", "Forsaken Powers", "Duration, cooldown and combo of boss powers", delegate { PowerMenu.Instance.Open(); }); } private void Update() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Settings.Tick(); if (!_hubRegistered && !PowerMenu.IsOpen) { KeyboardShortcut value = FallbackKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && (Object)(object)Player.m_localPlayer != (Object)null) { PowerMenu.Instance.Open(); } } } private void OnDestroy() { Settings.SaveNow(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public enum MenuMode { None, Settings, Quick } public class PowerMenu : MonoBehaviour { public static PowerMenu Instance; public static MenuMode Mode = MenuMode.None; public static int ClosedFrame = -10; public static bool SuppressCombat; public static bool RingMouseDown; private static float _closeTime; private const float VH = 1080f; private const float Side = 400f; private const float Gap = 36f; private const float HoldThreshold = 0.25f; private int _selected; private int _pendingSelect = -1; private int _hovered = -1; private readonly Dictionary<string, string> _buf = new Dictionary<string, string>(); private Vector2 _leftScroll; private Vector2 _rightScroll; private bool _holding; private float _openTime; private PowerCfg _pendingActivate; private float _pendingSince; private bool _waitingKey; private static readonly MethodInfo SetGuardianPowerM = AccessTools.Method(typeof(Player), "SetGuardianPower", new Type[1] { typeof(string) }, (Type[])null); private static readonly MethodInfo StartGuardianPowerM = AccessTools.Method(typeof(Player), "StartGuardianPower", (Type[])null, (Type[])null); public static bool IsOpen => Mode != MenuMode.None; public static bool QuickOpen => Mode == MenuMode.Quick; public static bool MouseHeld { get { try { return UnityInput.Current.GetMouseButton(0) || UnityInput.Current.GetMouseButton(1); } catch { return false; } } } private void Awake() { Instance = this; } public void Open() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { Settings.Discover(); _waitingKey = false; Mode = MenuMode.Settings; } } private void OpenQuick() { Settings.Discover(); _hovered = -1; _holding = true; _openTime = Time.unscaledTime; Mode = MenuMode.Quick; SuppressCombat = true; } public void Close() { Mode = MenuMode.None; RingMouseDown = false; ClosedFrame = Time.frameCount; SuppressCombat = true; _closeTime = Time.unscaledTime; GUIUtility.keyboardControl = 0; _waitingKey = false; _buf.Clear(); Settings.SaveNow(); } private void Update() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (IsOpen && (Object)(object)localPlayer == (Object)null) { Close(); return; } if (_pendingActivate != null) { TryPendingActivate(localPlayer); } if (SuppressCombat && !IsOpen) { bool flag = UnityInput.Current.GetMouseButton(0) || UnityInput.Current.GetMouseButton(1); float num = Time.unscaledTime - _closeTime; if ((num > 0.35f && !flag) || num > 2f) { SuppressCombat = false; } } KeyboardShortcut value = Plugin.RingKey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; if ((int)mainKey == 0) { return; } bool keyDown = UnityInput.Current.GetKeyDown(mainKey); bool key = UnityInput.Current.GetKey(mainKey); if (Mode == MenuMode.None) { if (keyDown && CanOpenQuick()) { OpenQuick(); } } else { if (Mode != MenuMode.Quick) { return; } if (_holding && !key) { _holding = false; if (Time.unscaledTime - _openTime > 0.25f) { if (_hovered >= 0 && _hovered < Settings.Powers.Count) { _pendingActivate = Settings.Powers[_hovered]; _pendingSince = Time.unscaledTime; } Close(); } } else if (!_holding && keyDown) { Close(); } } } private static bool CanOpenQuick() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return false; } try { if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if (Console.IsVisible() || TextInput.IsVisible() || Menu.IsVisible()) { return false; } if (InventoryGui.IsVisible() || Minimap.IsOpen() || StoreGui.IsVisible()) { return false; } } catch { } return true; } private void TryPendingActivate(Player lp) { if ((Object)(object)lp == (Object)null) { _pendingActivate = null; return; } float num = Time.unscaledTime - _pendingSince; if (num > 2f) { _pendingActivate = null; } else if (!MouseHeld || !(num < 1f)) { PowerCfg pendingActivate = _pendingActivate; if (!(Settings.GuardianCooldown(lp) <= 0f)) { _pendingActivate = null; Activate(pendingActivate); } else if (!((Character)lp).InAttack() && Activate(pendingActivate)) { _pendingActivate = null; } } } private static bool Activate(PowerCfg p) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)p.Template == (Object)null) { return true; } if (Settings.RequireDefeat && !Settings.IsDefeated(p)) { ((Character)localPlayer).Message((MessageType)2, L.T("Сначала победи этого босса", "Defeat this boss first"), 0, (Sprite)null, false); return true; } StatusEffect val = Settings.GuardianSeRef.Invoke(localPlayer); if ((Object)(object)val == (Object)null || ((Object)val).name != p.Se) { SetGuardianPowerM?.Invoke(localPlayer, new object[1] { p.Se }); } if (StartGuardianPowerM == null) { return true; } object obj = StartGuardianPowerM.Invoke(localPlayer, null); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = ((1 == 0) ? 1 : 0); } else { num = 1; } return (byte)((uint)num | (flag ? 1u : 0u)) != 0; } private void OnGUI() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Invalid comparison between Unknown and I4 //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Invalid comparison between Unknown and I4 //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Invalid comparison between Unknown and I4 //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } UiStyle.Ensure(); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; float num = (float)Screen.height / 1080f; float vw = (float)Screen.width / num; Matrix4x4 val = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f)); Matrix4x4 matrix = GUI.matrix; GUI.matrix = val; GUI.depth = -1000; Event current = Event.current; if (_waitingKey && (int)current.type == 4 && (int)current.keyCode > 0) { if ((int)current.keyCode != 27) { Plugin.RingKey.Value = new KeyboardShortcut(current.keyCode, Array.Empty<KeyCode>()); Plugin.Cfg.Save(); } _waitingKey = false; current.Use(); } else if ((int)current.type == 4 && (int)current.keyCode == 27) { current.Use(); Close(); GUI.matrix = matrix; return; } if (Mode == MenuMode.Quick) { DrawQuick(current, vw, val); } else { DrawSettings(current, vw, val); } GUI.matrix = matrix; } private void DrawQuick(Event e, float vw, Matrix4x4 baseM) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) List<PowerCfg> powers = Settings.Powers; int count = powers.Count; if (count == 0) { return; } float num = 135f; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(vw * 0.5f, 540f); _hovered = SectorAt(e.mousePosition, val, num, 300f, count); if ((int)e.type == 0 && (e.button == 0 || e.button == 1)) { RingMouseDown = true; e.Use(); return; } if ((int)e.type == 1 && (e.button == 0 || e.button == 1)) { RingMouseDown = false; if (e.button == 0 && _hovered >= 0) { _pendingActivate = powers[_hovered]; _pendingSince = Time.unscaledTime; } e.Use(); Close(); return; } GUI.DrawTexture(new Rect(0f, 0f, vw, 1080f), (Texture)(object)UiStyle.DimLight); DrawWheel(val, num, 300f, -1, baseM, (PowerCfg p) => Settings.RequireDefeat && !Settings.IsDefeated(p), (PowerCfg p) => (Settings.RequireDefeat && !Settings.IsDefeated(p)) ? L.T("не побеждён", "not defeated") : (p.Infinite ? L.T("бесконечно", "infinite") : Fmt(p.Duration))); float num2 = num - 10f; GUI.DrawTexture(new Rect(val.x - num2, val.y - num2, num2 * 2f, num2 * 2f), (Texture)(object)UiStyle.Disc); Player localPlayer = Player.m_localPlayer; PowerCfg powerCfg = ((_hovered >= 0) ? powers[_hovered] : null); if (powerCfg == null && (Object)(object)localPlayer != (Object)null) { StatusEffect val2 = Settings.GuardianSeRef.Invoke(localPlayer); if ((Object)(object)val2 != (Object)null) { powerCfg = Settings.Find(((Object)val2).name); } } if (powerCfg != null) { StatusEffect template = powerCfg.Template; float num3 = num2 * 0.62f; UiStyle.DrawSprite(new Rect(val.x - num3 * 0.5f, val.y - num2 * 0.78f, num3, num3), ((Object)(object)template != (Object)null) ? template.m_icon : null, Color.white); GUI.Label(new Rect(val.x - num2 * 0.85f, val.y - num2 * 0.12f, num2 * 1.7f, 30f), powerCfg.DisplayName.ToUpperInvariant(), UiStyle.CenterName); } if ((Object)(object)localPlayer != (Object)null) { float num4 = Settings.GuardianCooldown(localPlayer); string text = ((num4 > 0f) ? (L.T("Откат: ", "Cooldown: ") + Fmt(num4)) : L.T("<color=#99d173>Готово</color>", "<color=#99d173>Ready</color>")); if (powerCfg != null && Plugin.ToggleOff.Value && Settings.IsActiveOnLocal(powerCfg.Se)) { text = L.T("<color=#e6c172>Активна — выбери, чтобы снять</color>", "<color=#e6c172>Active — select to remove</color>"); } GUI.Label(new Rect(val.x - num2 * 0.85f, val.y + num2 * 0.25f, num2 * 1.7f, 22f), text, UiStyle.CenterInfo); if (Settings.Multi) { GUI.Label(new Rect(val.x - num2 * 0.85f, val.y + num2 * 0.25f + 22f, num2 * 1.7f, 22f), L.T("+ силы из комбо", "+ combo powers"), UiStyle.CenterInfo); } } GUI.Label(new Rect(0f, val.y + 300f + 24f, vw, 24f), L.T("Отпусти клавишу на силе или кликни по ней · ПКМ / Esc — отмена", "Release the key over a power or click it · RMB / Esc — cancel"), UiStyle.CenterInfo); } private void DrawSettings(Event e, float vw, Matrix4x4 baseM) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) if ((int)e.type == 8 && _pendingSelect >= 0) { _selected = _pendingSelect; _pendingSelect = -1; } List<PowerCfg> powers = Settings.Powers; int count = powers.Count; if (count == 0) { return; } _selected = Mathf.Clamp(_selected, 0, count - 1); float num = Mathf.Clamp((vw - 872f - 40f) * 0.5f, 210f, 300f); float rIn = num * 0.45f; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(vw * 0.5f, 570f); GUI.DrawTexture(new Rect(0f, 0f, vw, 1080f), (Texture)(object)UiStyle.Dim); GUI.Label(new Rect(0f, val.y - num - 90f, vw, 50f), L.T("СИЛЫ ПАВШИХ", "FORSAKEN POWERS"), UiStyle.Title); GUI.DrawTexture(new Rect(vw * 0.5f - 160f, val.y - num - 38f, 320f, 2f), (Texture)(object)UiStyle.Line); _hovered = SectorAt(e.mousePosition, val, rIn, num, count); if ((int)e.type == 0 && e.button == 0 && _hovered >= 0) { _pendingSelect = _hovered; GUIUtility.keyboardControl = 0; _buf.Clear(); e.Use(); } DrawWheel(val, rIn, num, _selected, baseM, (PowerCfg p) => Settings.RequireDefeat && !Settings.IsDefeated(p), delegate(PowerCfg p) { string text = (p.Infinite ? L.T("бесконечно", "infinite") : Fmt(p.Duration)); if (Settings.Multi && p.InCombo) { text += L.T(" · комбо", " · combo"); } return text; }); DrawCenter(powers[(_hovered >= 0) ? _hovered : _selected], val, rIn); float num2 = Mathf.Min(680f, num * 2f + 80f); float num3 = val.y - num2 * 0.5f; DrawGlobalPanel(new Rect(val.x - num - 36f - 400f, num3, 400f, num2)); DrawPowerPanel(new Rect(val.x + num + 36f, num3, 400f, num2), powers[_selected]); GUI.Label(new Rect(0f, val.y + num + 30f, vw, 24f), L.T("ЛКМ по сектору — выбрать босса · Esc — закрыть", "LMB on a sector — select boss · Esc — close"), UiStyle.CenterInfo); } private void DrawWheel(Vector2 c, float rIn, float rOut, int selected, Matrix4x4 baseM, Func<PowerCfg, bool> isLocked, Func<PowerCfg, string> subLabel) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) List<PowerCfg> powers = Settings.Powers; int count = powers.Count; float num = 360f / (float)count; Texture2D[] wedges = UiStyle.GetWedges(count); Rect val = default(Rect); ((Rect)(ref val))..ctor(c.x - rOut, c.y - rOut, rOut * 2f, rOut * 2f); for (int i = 0; i < count; i++) { Texture2D val2 = ((i == selected) ? wedges[2] : ((i == _hovered) ? wedges[1] : wedges[0])); GUI.matrix = baseM * Matrix4x4.TRS(Vector2.op_Implicit(c), Quaternion.Euler(0f, 0f, (float)i * num), Vector3.one) * Matrix4x4.TRS(Vector2.op_Implicit(-c), Quaternion.identity, Vector3.one); GUI.DrawTexture(val, (Texture)(object)val2); } GUI.matrix = baseM; float num2 = (rIn + rOut) * 0.5f; float num3 = Mathf.Clamp((rOut - rIn) * 0.42f, 48f, 76f); for (int j = 0; j < count; j++) { PowerCfg powerCfg = powers[j]; StatusEffect template = powerCfg.Template; float num4 = (float)j * num * (MathF.PI / 180f); Vector2 val3 = c + new Vector2(Mathf.Sin(num4), 0f - Mathf.Cos(num4)) * num2; bool flag = j == _hovered || j == selected; bool flag2 = isLocked(powerCfg); Color tint = (Color)(((Object)(object)template == (Object)null) ? new Color(0.4f, 0.4f, 0.4f, 0.6f) : (flag ? Color.white : (flag2 ? new Color(0.75f, 0.65f, 0.5f, 0.45f) : new Color(1f, 0.9f, 0.7f, 0.95f)))); UiStyle.DrawSprite(new Rect(val3.x - num3 * 0.5f, val3.y - num3 * 0.5f - 14f, num3, num3), ((Object)(object)template != (Object)null) ? template.m_icon : null, tint); GUI.Label(new Rect(val3.x - 80f, val3.y + num3 * 0.5f - 14f, 160f, 20f), powerCfg.DisplayName, UiStyle.SectorName); GUI.Label(new Rect(val3.x - 80f, val3.y + num3 * 0.5f + 4f, 160f, 20f), subLabel(powerCfg), UiStyle.SectorTime); } } private static int SectorAt(Vector2 m, Vector2 c, float rIn, float rOut, int n) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector2 val = m - c; float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < rIn || magnitude > rOut) { return -1; } float num = Mathf.Atan2(val.x, 0f - val.y) * 57.29578f; if (num < 0f) { num += 360f; } float num2 = 360f / (float)n; return Mathf.FloorToInt((num + num2 * 0.5f) / num2) % n; } private void DrawCenter(PowerCfg p, Vector2 c, float rIn) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) float num = rIn - 10f; GUI.DrawTexture(new Rect(c.x - num, c.y - num, num * 2f, num * 2f), (Texture)(object)UiStyle.Disc); StatusEffect template = p.Template; float num2 = num * 0.62f; UiStyle.DrawSprite(new Rect(c.x - num2 * 0.5f, c.y - num * 0.78f, num2, num2), ((Object)(object)template != (Object)null) ? template.m_icon : null, Color.white); GUI.Label(new Rect(c.x - num * 0.85f, c.y - num * 0.12f, num * 1.7f, 30f), p.DisplayName.ToUpperInvariant(), UiStyle.CenterName); string text = (p.Infinite ? L.T("бесконечно", "infinite") : Fmt(p.Duration)); GUI.Label(new Rect(c.x - num * 0.85f, c.y + num * 0.2f, num * 1.7f, 22f), L.T("Длительность: ", "Duration: ") + text, UiStyle.CenterInfo); GUI.Label(new Rect(c.x - num * 0.85f, c.y + num * 0.2f + 22f, num * 1.7f, 22f), L.T("Откат: ", "Cooldown: ") + Fmt(p.Cooldown), UiStyle.CenterInfo); if ((Object)(object)template == (Object)null) { GUI.Label(new Rect(c.x - num * 0.85f, c.y + num * 0.2f + 46f, num * 1.7f, 22f), L.T("<color=#d96b52>нет в игре</color>", "<color=#d96b52>not in game</color>"), UiStyle.CenterInfo); } } private unsafe void DrawGlobalPanel(Rect r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginArea(r, UiStyle.PanelStyle); _leftScroll = GUILayout.BeginScrollView(_leftScroll, GUIStyle.none, GUIStyle.none, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("ОБЩИЕ НАСТРОЙКИ", "GENERAL SETTINGS"), UiStyle.Header, Array.Empty<GUILayoutOption>()); Separator(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Язык", "Language"), UiStyle.Label, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); LangButton("Авто/Auto", UiLanguage.Auto, 96f); LangButton("RU", UiLanguage.Russian, 50f); LangButton("EN", UiLanguage.English, 50f); GUILayout.EndHorizontal(); GUILayout.Space(6f); if (Settings.FromHost) { GUILayout.Label(L.T("Загружены настройки хоста. Всё, что поменяешь, действует только для тебя.", "Host settings loaded. Anything you change applies only to you."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); } else if (Settings.IsClientOnServer) { GUILayout.Label(L.T("Твои настройки. Можно подтянуть настройки хоста кнопкой ниже.", "Your own settings. You can pull the host settings with the button below."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); } else { GUILayout.Label(L.T("Ты хост: эти настройки получат все, кто зайдёт с модом.", "You are the host: everyone joining with the mod gets these settings."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); } if (Settings.IsClientOnServer && GUILayout.Button(L.T("Подтянуть настройки хоста", "Pull host settings"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { _buf.Clear(); Settings.RequestFromHost(); } GUILayout.Space(10f); bool flag = false; GUILayout.Label(L.T("БЫСТРОЕ КОЛЬЦО", "QUICK RING"), UiStyle.Header, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Клавиша", "Key"), UiStyle.Label, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); KeyboardShortcut value = Plugin.RingKey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; string text = (_waitingKey ? L.T("нажми клавишу…", "press a key…") : (((int)mainKey == 0) ? L.T("не назначена", "not set") : ((object)(*(KeyCode*)(&mainKey))/*cast due to .constrained prefix*/).ToString())); if (GUILayout.Button(text, UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(170f), GUILayout.Height(30f) })) { _waitingKey = !_waitingKey; } GUILayout.EndHorizontal(); if (GUILayout.Button(L.T("Убрать клавишу", "Clear key"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { _waitingKey = false; Plugin.RingKey.Value = new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()); Plugin.Cfg.Save(); } GUILayout.Label(L.T("Зажми клавишу, наведи на силу и отпусти — сила активируется. Это твоя личная настройка, с хостом не синхронизируется.", "Hold the key, hover a power and release — it activates. Personal setting, not synced with the host."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label(L.T("АКТИВАЦИЯ", "ACTIVATION"), UiStyle.Header, Array.Empty<GUILayoutOption>()); if (Toggle(L.T("Несколько сил одновременно", "Several powers at once"), ref Settings.Multi)) { flag = true; } GUILayout.Label(L.T("Активация силы включает выбранную силу и все силы, отмеченные «В комбо». Откат — по самой долгой из них.", "Activating a power also turns on every power marked \"In combo\". Cooldown is the longest of them."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); GUI.enabled = Settings.Multi; float value2 = Settings.MaxActive; if (SliderRow("maxactive", L.T("Максимум сил на игроке", "Max powers per player"), ref value2, 0f, 10f, 20f)) { Settings.MaxActive = Mathf.RoundToInt(value2); flag = true; } GUI.enabled = true; string text2 = L.T("0 — без ограничения. Если сил больше — самая старая снимается, даже если новую дал сосед.", "0 — unlimited. If there are more, the oldest is removed, even if a neighbour gave you the new one."); if (Settings.IsClientOnServer && Settings.HostCap > 0) { text2 = text2 + L.T(" Сервер: не больше ", " Server limit: ") + Settings.HostCap + "."; } GUILayout.Label(text2, UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); bool value3 = Plugin.ToggleOff.Value; if (Toggle(L.T("Повторная активация снимает силу", "Activating again removes the power"), ref value3)) { Plugin.ToggleOff.Value = value3; Plugin.Cfg.Save(); } GUILayout.Label(L.T("Выбери уже действующую силу ещё раз (кольцом или F) — она снимется без отката. Личная настройка.", "Pick an already active power again (ring or F) to remove it, no cooldown. Personal setting."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); if (Toggle(L.T("Только побеждённые боссы", "Defeated bosses only"), ref Settings.RequireDefeat)) { flag = true; } GUILayout.Label(L.T("Касается и быстрого кольца, и комбо.", "Applies to both the quick ring and combo."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); if (Toggle(L.T("Делиться силами с союзниками", "Share powers with allies"), ref Settings.Share)) { flag = true; } GUI.enabled = Settings.Share; if (SliderRow("radius", L.T("Радиус на союзников", "Radius for allies"), ref Settings.Radius, 1f, 50f, 100f, L.T(" м", " m"))) { flag = true; } GUI.enabled = true; GUILayout.Label(L.T("Включено — твоя сила достаётся всем рядом (ваниль: 10 м). Выключено — только тебе.", "On — your power is given to everyone nearby (vanilla: 10 m). Off — only to you."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); if (flag) { Settings.CommitGlobal(); } GUILayout.Space(12f); GUILayout.Label(L.T("БЫСТРО ДЛЯ ВСЕХ", "QUICK ACTIONS"), UiStyle.Header, Array.Empty<GUILayoutOption>()); Separator(); if (GUILayout.Button(L.T("Все силы — бесконечные", "All powers — infinite"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { ForAll(delegate(PowerCfg p) { p.Infinite = true; }); } if (GUILayout.Button(L.T("Все силы — без отката", "All powers — no cooldown"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { ForAll(delegate(PowerCfg p) { p.Cooldown = 0f; }); } if (GUILayout.Button(L.T("Все в комбо", "All in combo"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { ForAll(delegate(PowerCfg p) { p.InCombo = true; }); } if (GUILayout.Button(L.T("Всё по-ванильному", "Reset to vanilla"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { ForAll(Vanilla); Settings.Multi = false; Settings.Radius = 10f; Settings.Share = true; Settings.CommitGlobal(); } GUILayout.Space(14f); if (GUILayout.Button(L.T("Закрыть", "Close"), UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { Close(); } GUILayout.EndScrollView(); GUILayout.EndArea(); } private void ForAll(Action<PowerCfg> act) { _buf.Clear(); GUIUtility.keyboardControl = 0; foreach (PowerCfg power in Settings.Powers) { act(power); Settings.Commit(power); } } private static void Vanilla(PowerCfg p) { p.Duration = ((p.VanillaDuration > 0f) ? p.VanillaDuration : 300f); p.Infinite = false; p.Cooldown = p.VanillaCooldown; p.InCombo = true; } private void DrawPowerPanel(Rect r, PowerCfg p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginArea(r, UiStyle.PanelStyle); _rightScroll = GUILayout.BeginScrollView(_rightScroll, GUIStyle.none, GUIStyle.none, Array.Empty<GUILayoutOption>()); GUILayout.Label(p.DisplayName.ToUpperInvariant(), UiStyle.Header, Array.Empty<GUILayoutOption>()); Separator(); StatusEffect template = p.Template; if ((Object)(object)template == (Object)null) { GUILayout.Label(L.T("Этой силы нет в текущей версии игры.", "This power is not in the current game version."), UiStyle.Small, Array.Empty<GUILayoutOption>()); } else { string text = (string.IsNullOrEmpty(template.m_tooltip) ? "" : Localization.instance.Localize(template.m_tooltip)); if (!string.IsNullOrEmpty(text)) { GUILayout.Label(text, UiStyle.Small, Array.Empty<GUILayoutOption>()); } GUILayout.Label(Settings.IsDefeated(p) ? L.T("<color=#99d173>Босс побеждён</color>", "<color=#99d173>Boss defeated</color>") : L.T("<color=#d96b52>Босс ещё не побеждён</color>", "<color=#d96b52>Boss not defeated yet</color>"), UiStyle.Small, Array.Empty<GUILayoutOption>()); } GUILayout.Space(10f); bool flag = false; GUILayout.Label(L.T("ДЛИТЕЛЬНОСТЬ", "DURATION"), UiStyle.Header, Array.Empty<GUILayoutOption>()); if (Toggle(L.T("Бесконечно", "Infinite"), ref p.Infinite)) { flag = true; } GUI.enabled = !p.Infinite; if (SliderRow(p.Se + "_dur", L.T("Секунд", "Seconds"), ref p.Duration, 10f, 3600f, 86400f, null, asTime: true)) { flag = true; } GUI.enabled = true; GUILayout.Label(p.Infinite ? L.T("Сила не спадает, пока не выйдешь из игры или не умрёшь.", "The power lasts until you log out or die.") : L.T("Ваниль: 300 с (5 минут).", "Vanilla: 300 s (5 minutes)."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label(L.T("ОТКАТ", "COOLDOWN"), UiStyle.Header, Array.Empty<GUILayoutOption>()); if (SliderRow(p.Se + "_cd", L.T("Секунд", "Seconds"), ref p.Cooldown, 0f, 3600f, 86400f, null, asTime: true)) { flag = true; } GUILayout.Label(L.T("0 — можно активировать сразу снова.", "0 — can be activated again right away."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label(L.T("КОМБО", "COMBO"), UiStyle.Header, Array.Empty<GUILayoutOption>()); GUI.enabled = Settings.Multi; if (Toggle(L.T("В комбо (вместе с выбранной силой)", "In combo (with the selected power)"), ref p.InCombo)) { flag = true; } GUI.enabled = true; GUILayout.Label(Settings.Multi ? L.T("Сила включится вместе с той, что выбрана у камня.", "Turns on together with the power selected at the stone.") : L.T("Включи «Несколько сил одновременно» слева.", "Enable \"Several powers at once\" on the left."), UiStyle.Hint, Array.Empty<GUILayoutOption>()); if (flag) { Settings.Commit(p); } GUILayout.Space(14f); string text2 = L.T("Ваниль", "Vanilla") + " (" + Fmt(p.VanillaDuration) + " / " + Fmt(p.VanillaCooldown) + ")"; if (GUILayout.Button(text2, UiStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { _buf.Clear(); GUIUtility.keyboardControl = 0; Vanilla(p); Settings.Commit(p); } GUILayout.EndScrollView(); GUILayout.EndArea(); } private static void LangButton(string text, UiLanguage lang, float width) { bool flag = L.Setting.Value == lang; GUIStyle val = (flag ? UiStyle.ButtonOn : UiStyle.Button); if (GUILayout.Button(text, val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(width), GUILayout.Height(28f) }) && !flag) { L.Setting.Value = lang; Plugin.Cfg.Save(); } } private static void Separator() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(10f, 8f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width, 1f), (Texture)(object)UiStyle.Line); } private static bool Toggle(string text, ref bool value) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(10f, 30f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 4f, 22f, 22f); Color color = GUI.color; if (!GUI.enabled) { GUI.color = new Color(1f, 1f, 1f, 0.4f); } GUI.DrawTexture(val, (Texture)(object)(value ? UiStyle.BoxOn : UiStyle.Box)); GUI.Label(new Rect(((Rect)(ref rect)).x + 32f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 32f, ((Rect)(ref rect)).height), text, UiStyle.Label); GUI.color = color; if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) { value = !value; return true; } return false; } private bool SliderRow(string id, string label, ref float value, float min, float sliderMax, float max, string unit = null, bool asTime = false) { float num = value; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(label, UiStyle.Label, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label(asTime ? Fmt(value) : (Mathf.RoundToInt(value) + unit), UiStyle.Value, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); float num2 = GUILayout.HorizontalSlider(Mathf.Min(value, sliderMax), min, sliderMax, UiStyle.Slider, UiStyle.SliderThumb, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (Mathf.Abs(num2 - Mathf.Min(value, sliderMax)) > 0.001f) { value = Mathf.Round(num2); _buf.Remove(id); } GUILayout.Space(8f); GUI.SetNextControlName(id); bool flag = GUI.GetNameOfFocusedControl() == id; string value2; string text = ((flag && _buf.TryGetValue(id, out value2)) ? value2 : Mathf.RoundToInt(value).ToString()); string text2 = GUILayout.TextField(text, 6, UiStyle.FieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(76f), GUILayout.Height(28f) }); if (flag && text2 != text) { _buf[id] = text2; if (float.TryParse(text2, out var result)) { value = Mathf.Clamp(result, min, max); } } GUILayout.EndHorizontal(); return Mathf.Abs(num - value) > 0.0001f; } public static string Fmt(float sec) { int num = Mathf.Max(0, Mathf.RoundToInt(sec)); if (num < 60) { return num + L.T(" с", " s"); } if (num < 3600) { return $"{num / 60}:{num % 60:00}"; } return $"{num / 3600}:{num % 3600 / 60:00}:{num % 60:00}"; } } public class PowerCfg { public string Se; public string DefeatKey; public string Fallback; public string NameRu; public string NameEn; public float Duration = 300f; public bool Infinite; public float Cooldown = 1200f; public bool InCombo = true; public float VanillaDuration = 300f; public float VanillaCooldown = 1200f; public bool VanillaRecorded; internal ConfigEntry<float> EDuration; internal ConfigEntry<float> ECooldown; internal ConfigEntry<bool> EInfinite; internal ConfigEntry<bool> ECombo; public StatusEffect Template => ((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(Se)) : null; public string DisplayName { get { if (NameRu != null) { return L.Ru ? NameRu : NameEn; } StatusEffect template = Template; if ((Object)(object)template != (Object)null && Localization.instance != null && !string.IsNullOrEmpty(template.m_name)) { string text = Localization.instance.Localize(template.m_name); if (!string.IsNullOrEmpty(text) && !text.StartsWith("[") && !text.StartsWith("$")) { return text; } } return Fallback ?? Se; } } } internal static class Settings { public static bool Multi; public static bool RequireDefeat = true; public static float Radius = 10f; public static bool Share = true; public static int MaxActive = 3; public static int HostCap; public static readonly List<PowerCfg> Powers = new List<PowerCfg>(); public static bool FromHost; private static ConfigEntry<bool> _eMulti; private static ConfigEntry<bool> _eRequire; private static ConfigEntry<float> _eRadius; private static ConfigEntry<bool> _eShare; private static ConfigEntry<int> _eMax; private static bool _dirty; private static float _dirtyTime; private static readonly string[,] Known = new string[7, 4] { { "GP_Eikthyr", "defeated_eikthyr", "Эйктюр", "Eikthyr" }, { "GP_TheElder", "defeated_gdking", "Древний", "The Elder" }, { "GP_Bonemass", "defeated_bonemass", "Масса костей", "Bonemass" }, { "GP_Moder", "defeated_dragon", "Модер", "Moder" }, { "GP_Yagluth", "defeated_goblinking", "Яглут", "Yagluth" }, { "GP_Queen", "defeated_queen", "Королева", "The Queen" }, { "GP_Fader", "defeated_fader", "Фейдер", "Fader" } }; private static readonly FieldRef<Player, float> CooldownRef = AccessTools.FieldRefAccess<Player, float>("m_guardianPowerCooldown"); internal static readonly FieldRef<Player, StatusEffect> GuardianSeRef = AccessTools.FieldRefAccess<Player, StatusEffect>("m_guardianSE"); private static readonly MethodInfo HaveUniqueKey = AccessTools.Method(typeof(Player), "HaveUniqueKey", new Type[1] { typeof(string) }, (Type[])null); private const string RpcRequest = "ForsakenPowers_Request"; private const string RpcConfig = "ForsakenPowers_Config"; private const int PackageVersion = 2; public static int OwnCap => (!Multi) ? 1 : ((MaxActive <= 0) ? int.MaxValue : MaxActive); public static int EffectiveCap { get { int num = OwnCap; if (IsClientOnServer && HostCap > 0) { num = Mathf.Min(num, HostCap); } return num; } } public static bool IsClientOnServer => (Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer(); public static void BindGlobal() { _eMulti = Plugin.Cfg.Bind<bool>("Global", "MultiActivation", false, "Активация силы включает выбранную силу + все силы, отмеченные InCombo."); _eRequire = Plugin.Cfg.Bind<bool>("Global", "RequireDefeatedBoss", true, "Быстрое кольцо и комбо дают только силы боссов, которых уже победили."); _eShare = Plugin.Cfg.Bind<bool>("Global", "ShareWithAllies", true, "Сила достаётся и союзникам в радиусе (как в ванили). false — только себе."); _eMax = Plugin.Cfg.Bind<int>("Global", "MaxActivePowers", 3, "Максимум сил на одном игроке в режиме MultiActivation (0 — без ограничения). Лишняя самая старая снимается. Лимит хоста обязателен для всех на его сервере."); _eRadius = Plugin.Cfg.Bind<float>("Global", "Radius", 10f, "Радиус, в котором сила достаётся союзникам (ваниль: 10)."); } public static void BindKnownPowers() { for (int i = 0; i < Known.GetLength(0); i++) { PowerCfg orCreate = GetOrCreate(Known[i, 0], Known[i, 1], Known[i, 2]); orCreate.NameRu = Known[i, 2]; orCreate.NameEn = Known[i, 3]; } } public static PowerCfg Find(string se) { foreach (PowerCfg power in Powers) { if (power.Se == se) { return power; } } return null; } private static PowerCfg GetOrCreate(string se, string defeatKey = null, string fallback = null) { PowerCfg powerCfg = Find(se); if (powerCfg != null) { return powerCfg; } powerCfg = new PowerCfg { Se = se, DefeatKey = defeatKey, Fallback = (fallback ?? se.Replace("GP_", "")) }; powerCfg.EDuration = Plugin.Cfg.Bind<float>(se, "Duration", 300f, "Длительность в секундах (ваниль: 300)."); powerCfg.EInfinite = Plugin.Cfg.Bind<bool>(se, "Infinite", false, "Сила длится бесконечно."); powerCfg.ECooldown = Plugin.Cfg.Bind<float>(se, "Cooldown", 1200f, "Откат в секундах (ваниль: 1200)."); powerCfg.ECombo = Plugin.Cfg.Bind<bool>(se, "InCombo", true, "Участвует в мульти-активации."); powerCfg.Duration = powerCfg.EDuration.Value; powerCfg.Infinite = powerCfg.EInfinite.Value; powerCfg.Cooldown = powerCfg.ECooldown.Value; powerCfg.InCombo = powerCfg.ECombo.Value; Powers.Add(powerCfg); return powerCfg; } public static void LoadFromConfig() { Multi = _eMulti.Value; RequireDefeat = _eRequire.Value; Radius = _eRadius.Value; Share = _eShare.Value; MaxActive = Mathf.Max(0, _eMax.Value); HostCap = 0; foreach (PowerCfg power in Powers) { power.Duration = power.EDuration.Value; power.Infinite = power.EInfinite.Value; power.Cooldown = power.ECooldown.Value; power.InCombo = power.ECombo.Value; } FromHost = false; } public static void Commit(PowerCfg p) { if (p != null) { p.EDuration.Value = p.Duration; p.EInfinite.Value = p.Infinite; p.ECooldown.Value = p.Cooldown; p.ECombo.Value = p.InCombo; } Apply(); MarkDirty(); } public static void CommitGlobal() { _eMulti.Value = Multi; _eRequire.Value = RequireDefeat; _eRadius.Value = Radius; _eShare.Value = Share; _eMax.Value = MaxActive; Apply(); MarkDirty(); } private static void MarkDirty() { _dirty = true; _dirtyTime = Time.unscaledTime; } public static void SaveNow() { if (!_dirty) { return; } _dirty = false; try { Plugin.Cfg.Save(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Не удалось сохранить cfg: " + ex.Message)); } } public static void Tick() { if (_dirty && Time.unscaledTime - _dirtyTime > 1f) { SaveNow(); } ClampLocalCooldown(); } public static void Discover() { ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null || instance.m_StatusEffects == null) { return; } foreach (StatusEffect statusEffect in instance.m_StatusEffects) { if (!((Object)(object)statusEffect == (Object)null) && ((Object)statusEffect).name.StartsWith("GP_")) { PowerCfg orCreate = GetOrCreate(((Object)statusEffect).name); if (!orCreate.VanillaRecorded) { orCreate.VanillaDuration = statusEffect.m_ttl; orCreate.VanillaCooldown = statusEffect.m_cooldown; orCreate.VanillaRecorded = true; } } } } public static void Apply() { if ((Object)(object)ObjectDB.instance == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; List<StatusEffect> list = (((Object)(object)localPlayer != (Object)null) ? ((Character)localPlayer).GetSEMan().GetStatusEffects() : null); foreach (PowerCfg power in Powers) { StatusEffect template = power.Template; if ((Object)(object)template == (Object)null) { continue; } if (!power.VanillaRecorded) { power.VanillaDuration = template.m_ttl; power.VanillaCooldown = template.m_cooldown; power.VanillaRecorded = true; } template.m_ttl = (power.Infinite ? 0f : Mathf.Max(1f, power.Duration)); template.m_cooldown = Mathf.Max(0f, power.Cooldown); if (list == null) { continue; } int num = template.NameHash(); foreach (StatusEffect item in list) { if ((Object)(object)item != (Object)null && item.NameHash() == num) { item.m_ttl = template.m_ttl; } } } } public static ref float GuardianCooldown(Player p) { return ref CooldownRef.Invoke(p); } public static bool IsActiveOnLocal(string se) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || string.IsNullOrEmpty(se)) { return false; } foreach (StatusEffect statusEffect in ((Character)localPlayer).GetSEMan().GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && ((Object)statusEffect).name.StartsWith(se)) { return true; } } return false; } public static bool IsDefeated(PowerCfg p) { if (string.IsNullOrEmpty(p.DefeatKey)) { return true; } ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance != (Object)null && instance.GetGlobalKey(p.DefeatKey)) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && HaveUniqueKey != null) { try { return (bool)HaveUniqueKey.Invoke(localPlayer, new object[1] { p.DefeatKey }); } catch { } } return false; } public static List<StatusEffect> CollectPowers(StatusEffect selected) { List<StatusEffect> list = new List<StatusEffect>(); if (Multi) { foreach (PowerCfg power in Powers) { if (power.InCombo && !(power.Se == ((Object)selected).name) && (!RequireDefeat || IsDefeated(power))) { StatusEffect template = power.Template; if ((Object)(object)template != (Object)null && !list.Contains(template)) { list.Add(template); } } } } list.Add(selected); return list; } public static float CooldownFor(List<StatusEffect> list) { float num = 0f; foreach (StatusEffect item in list) { num = Mathf.Max(num, item.m_cooldown); } return num; } private static void ClampLocalCooldown() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } StatusEffect val = GuardianSeRef.Invoke(localPlayer); if ((Object)(object)val == (Object)null) { return; } ref float reference = ref GuardianCooldown(localPlayer); if (!(reference <= 0f)) { float num = CooldownFor(CollectPowers(val)); if (reference > num) { reference = num; } } } public static void RegisterRpcs() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.Register("ForsakenPowers_Request", (Action<long>)OnRequest); instance.Register<ZPackage>("ForsakenPowers_Config", (Action<long, ZPackage>)OnConfig); } } public static void RequestFromHost() { if (!((Object)(object)ZNet.instance == (Object)null) && !ZNet.instance.IsServer() && ZRoutedRpc.instance != null) { ZNetPeer serverPeer = ZNet.instance.GetServerPeer(); if (serverPeer != null) { ZRoutedRpc.instance.InvokeRoutedRPC(serverPeer.m_uid, "ForsakenPowers_Request", Array.Empty<object>()); } } } private static void OnRequest(long sender) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { ZRoutedRpc.instance.InvokeRoutedRPC(sender, "ForsakenPowers_Config", new object[1] { Write() }); } } private static void OnConfig(long sender, ZPackage pkg) { if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer()) { return; } try { Read(pkg); FromHost = true; Apply(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, L.T("Forsaken Powers: настройки хоста загружены (можно поменять для себя в ModHub)", "Forsaken Powers: host settings loaded (you can change them for yourself in ModHub)"), 0, (Sprite)null, false); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Не удалось прочитать настройки хоста: " + ex.Message)); } } private static ZPackage Write() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(2); val.Write(Multi); val.Write(RequireDefeat); val.Write(Radius); val.Write(Share); val.Write(MaxActive); val.Write((OwnCap != int.MaxValue) ? OwnCap : 0); val.Write(Powers.Count); foreach (PowerCfg power in Powers) { val.Write(power.Se); val.Write(power.Duration); val.Write(power.Infinite); val.Write(power.Cooldown); val.Write(power.InCombo); } return val; } private static void Read(ZPackage pkg) { int num = pkg.ReadInt(); if (num != 2) { throw new Exception("другая версия пакета: " + num); } Multi = pkg.ReadBool(); RequireDefeat = pkg.ReadBool(); Radius = pkg.ReadSingle(); Share = pkg.ReadBool(); MaxActive = pkg.ReadInt(); HostCap = pkg.ReadInt(); int num2 = pkg.ReadInt(); for (int i = 0; i < num2; i++) { PowerCfg orCreate = GetOrCreate(pkg.ReadString()); orCreate.Duration = pkg.ReadSingle(); orCreate.Infinite = pkg.ReadBool(); orCreate.Cooldown = pkg.ReadSingle(); orCreate.InCombo = pkg.ReadBool(); } } } internal static class UiStyle { public static readonly Color Gold = new Color(0.86f, 0.69f, 0.36f, 1f); public static readonly Color GoldBright = new Color(1f, 0.85f, 0.5f, 1f); public static readonly Color TextCol = new Color(0.94f, 0.87f, 0.72f, 1f); public static readonly Color Muted = new Color(0.62f, 0.57f, 0.48f, 1f); public static readonly Color Bad = new Color(0.85f, 0.42f, 0.32f, 1f); public static readonly Color Good = new Color(0.6f, 0.82f, 0.45f, 1f); private static readonly Color Black = new Color(0.03f, 0.025f, 0.02f, 0.9f); public static Texture2D Dim; public static Texture2D DimLight; public static Texture2D Panel; public static Texture2D Btn; public static Texture2D BtnHover; public static Texture2D BtnActive; public static Texture2D Field; public static Texture2D Track; public static Texture2D Thumb; public static Texture2D Box; public static Texture2D BoxOn; public static Texture2D Disc; public static Texture2D Line; public static GUIStyle PanelStyle; public static GUIStyle Title; public static GUIStyle Header; public static GUIStyle Label; public static GUIStyle Small; public static GUIStyle Hint; public static GUIStyle CenterName; public static GUIStyle CenterInfo; public static GUIStyle SectorName; public static GUIStyle SectorTime; public static GUIStyle Button; public static GUIStyle ButtonOn; public static GUIStyle FieldStyle; public static GUIStyle Slider; public static GUIStyle SliderThumb; public static GUIStyle Value; private static bool _ready; private static Font _font; private static readonly Dictionary<int, Texture2D[]> Wedges = new Dictionary<int, Texture2D[]>(); public const float InnerRatio = 0.45f; public static void Ensure() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_028c: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Expected O, but got Unknown //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Expected O, but got Unknown //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Expected O, but got Unknown //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Expected O, but got Unknown //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Expected O, but got Unknown //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Expected O, but got Unknown //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Expected O, but got Unknown //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Expected O, but got Unknown //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Expected O, but got Unknown //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Expected O, but got Unknown //IL_05d9: Expected O, but got Unknown //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Expected O, but got Unknown //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Expected O, but got Unknown //IL_0658: Expected O, but got Unknown if (!_ready || !((Object)(object)Panel != (Object)null)) { _ready = true; _font = FindFont(); Dim = Solid(new Color(0f, 0f, 0f, 0.45f)); DimLight = Solid(new Color(0f, 0f, 0f, 0.22f)); Line = Solid(new Color(Gold.r, Gold.g, Gold.b, 0.55f)); Panel = Frame(16, Black, Gold, 2); Btn = Frame(12, new Color(0.07f, 0.06f, 0.045f, 0.95f), new Color(0.6f, 0.48f, 0.26f, 1f), 1); BtnHover = Frame(12, new Color(0.2f, 0.15f, 0.07f, 0.97f), GoldBright, 1); BtnActive = Frame(12, new Color(0.32f, 0.23f, 0.09f, 1f), GoldBright, 2); Field = Frame(12, new Color(0f, 0f, 0f, 0.95f), new Color(0.6f, 0.48f, 0.26f, 1f), 1); Track = Frame(8, new Color(0.12f, 0.1f, 0.07f, 1f), new Color(0.45f, 0.36f, 0.2f, 1f), 1); Thumb = Frame(8, Gold, GoldBright, 1); Box = Frame(12, new Color(0f, 0f, 0f, 0.95f), Gold, 2); BoxOn = CheckBox(); Disc = MakeDisc(256, new Color(0.02f, 0.015f, 0.01f, 0.93f), Gold, 3f); GUIStyle val = new GUIStyle(); val.normal.background = Panel; val.border = new RectOffset(4, 4, 4, 4); val.padding = new RectOffset(18, 18, 16, 16); PanelStyle = val; Title = Text(34, GoldBright, (TextAnchor)4, (FontStyle)1); Header = Text(22, GoldBright, (TextAnchor)3, (FontStyle)1); Label = Text(17, TextCol, (TextAnchor)3, (FontStyle)0); Small = Text(14, Muted, (TextAnchor)0, (FontStyle)0); Small.wordWrap = true; Hint = Text(13, Muted, (TextAnchor)0, (FontStyle)0); Hint.wordWrap = true; Value = Text(17, GoldBright, (TextAnchor)5, (FontStyle)1); CenterName = Text(22, GoldBright, (TextAnchor)4, (FontStyle)1); CenterName.wordWrap = true; CenterInfo = Text(15, TextCol, (TextAnchor)4, (FontStyle)0); CenterInfo.wordWrap = true; SectorName = Text(14, TextCol, (TextAnchor)4, (FontStyle)1); SectorTime = Text(14, GoldBright, (TextAnchor)4, (FontStyle)0); GUIStyle val2 = new GUIStyle(GUI.skin.button); val2.normal.background = Btn; val2.normal.textColor = TextCol; val2.hover.background = BtnHover; val2.hover.textColor = GoldBright; val2.active.background = BtnActive; val2.active.textColor = GoldBright; val2.focused.background = Btn; val2.focused.textColor = TextCol; val2.border = new RectOffset(3, 3, 3, 3); val2.padding = new RectOffset(10, 10, 6, 6); val2.fontSize = 16; val2.font = _font; val2.alignment = (TextAnchor)4; Button = val2; GUIStyle val3 = new GUIStyle(Button); val3.normal.background = BtnActive; val3.normal.textColor = GoldBright; val3.hover.background = BtnActive; val3.hover.textColor = GoldBright; val3.fontStyle = (FontStyle)1; ButtonOn = val3; GUIStyle val4 = new GUIStyle(GUI.skin.textField); val4.normal.background = Field; val4.normal.textColor = GoldBright; val4.hover.background = Field; val4.hover.textColor = GoldBright; val4.focused.background = BtnHover; val4.focused.textColor = GoldBright; val4.border = new RectOffset(3, 3, 3, 3); val4.padding = new RectOffset(6, 6, 4, 4); val4.fontSize = 16; val4.font = _font; val4.alignment = (TextAnchor)4; FieldStyle = val4; GUIStyle val5 = new GUIStyle(GUI.skin.horizontalSlider); val5.normal.background = Track; val5.border = new RectOffset(2, 2, 2, 2); val5.fixedHeight = 8f; val5.margin = new RectOffset(4, 4, 12, 8); val5.padding = new RectOffset(0, 0, 0, 0); val5.overflow = new RectOffset(0, 0, 0, 0); Slider = val5; GUIStyle val6 = new GUIStyle(GUI.skin.horizontalSliderThumb); val6.normal.background = Thumb; val6.hover.background = Thumb; val6.active.background = Thumb; val6.border = new RectOffset(2, 2, 2, 2); val6.fixedWidth = 14f; val6.fixedHeight = 22f; val6.overflow = new RectOffset(0, 0, 7, 7); SliderThumb = val6; } } private static GUIStyle Text(int size, Color c, TextAnchor a, FontStyle fs = (FontStyle)0) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = size, font = _font, alignment = a, fontStyle = fs }; val.normal.textColor = c; val.wordWrap = false; val.richText = true; return val; } private static Font FindFont() { Font val = null; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val2 in array) { if (!((Object)(object)val2 == (Object)null)) { if (((Object)val2).name.Contains("AveriaSerifLibre-Bold")) { return val2; } if ((Object)(object)val == (Object)null && ((Object)val2).name.Contains("Averia")) { val = val2; } } } return val; } public static Texture2D Solid(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; val.SetPixel(0, 0, c); val.Apply(); return val; } public static Texture2D Frame(int size, Color fill, Color border, int bw) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { hideFlags = (HideFlags)61, filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { bool flag = j < bw || i < bw || j >= size - bw || i >= size - bw; array[i * size + j] = (flag ? border : fill); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D CheckBox() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Frame(12, new Color(0f, 0f, 0f, 0.95f), Gold, 2); for (int i = 4; i < 8; i++) { for (int j = 4; j < 8; j++) { val.SetPixel(j, i, GoldBright); } } val.Apply(); return val; } private static float SmoothCover(float sd) { return Mathf.Clamp01(sd + 0.5f); } public static Texture2D MakeDisc(int size, Color fill, Color border, float bw) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references)