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 Encore v1.0.3
Encore.dll
Decompiled a week 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GlobalSettings; using Gods_Of_Pharloom; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Newtonsoft.Json; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] namespace Encore; internal sealed class AttackKind { internal string Ru; internal string En; internal string[] Events; internal string Name { get { if (!L.IsRu) { return En; } return Ru; } } } internal sealed class AttackSpec { internal string Boss; internal string Object; internal string Fsm; internal AttackKind[] Kinds; } internal sealed class ChoicePlan { internal bool[] Off; internal int Keep = -1; } internal static class AttackMath { internal const int Never = 99999; internal const int Unlimited = 99; internal static ChoicePlan Plan(string[] events, float[] weights, ICollection<string> off) { if (events == null || weights == null || off == null || off.Count == 0) { return null; } int num = ((events.Length < weights.Length) ? events.Length : weights.Length); ChoicePlan choicePlan = new ChoicePlan { Off = new bool[num] }; int num2 = 0; int num3 = 0; int num4 = -1; for (int i = 0; i < num; i++) { if (events[i] != null && off.Contains(events[i])) { choicePlan.Off[i] = true; num2++; } else if (weights[i] > 0f) { num3++; num4 = i; } } if (num2 == 0 || num3 == 0) { return null; } choicePlan.Keep = ((num3 == 1) ? num4 : (-1)); return choicePlan; } } internal static class AttackData { internal const int Max = 20; private static readonly AttackKind[] None = new AttackKind[0]; private static readonly Dictionary<string, AttackSpec> specs = Build(); internal static IEnumerable<AttackSpec> All => specs.Values; private static AttackKind A(string ru, string en, params string[] events) { return new AttackKind { Ru = ru, En = en, Events = events }; } private static void Add(Dictionary<string, AttackSpec> map, string boss, string obj, params AttackKind[] kinds) { map[boss] = new AttackSpec { Boss = boss, Object = obj, Fsm = "Control", Kinds = kinds }; } private static Dictionary<string, AttackSpec> Build() { Dictionary<string, AttackSpec> dictionary = new Dictionary<string, AttackSpec>(); Add(dictionary, "Bell Beast", "Bone Beast", A("Прыжок", "Leap", "LEAP"), A("Рывок", "Charge", "CHARGE"), A("Взрыв колокола", "Bell burst", "BURST")); Add(dictionary, "Lace in Deep Docks", "Lace Boss1", A("Серия", "Combo", "COMBO"), A("Рывок", "Charge", "CHARGE"), A("Удар J", "J slash", "J SLASH")); Add(dictionary, "Fourth Chorus", "song_golem", A("Прицельный удар", "Aim slam", "AIM SLAM"), A("Взмах", "Swipe", "ANY SWIPE"), A("Случайный удар", "Random slam", "RANDOM SLAM"), A("Угольный залп", "Coal barrage", "COAL BARRAGE")); Add(dictionary, "Moorwing", "Vampire Gnat", A("Серпы", "Flap sickle", "FLAP SICKLE"), A("Взмах", "Flap", "FLAP"), A("Рывок", "Charge", "CHARGE"), A("Удар", "Slash", "SLASH"), A("Ярость", "Rage", "RAGE")); Add(dictionary, "Sister Splinter", "Splinter Queen", A("Удар", "Slam", "SLAM"), A("Рёв", "Roar", "ROAR"), A("Шипы", "Spikes", "SPIKES")); Add(dictionary, "Widow", "Spinner Boss", A("Удар в погоне", "Chase slam", "CHASE SLAM"), A("Рывок с ударом", "Dash slash", "DASH SLASH"), A("Перебежка", "Scuttle", "SCUTTLE"), A("Выстрел нитью", "Strum shot", "STRUM SHOT"), A("Крик", "Scream", "SCREAM")); Add(dictionary, "The Last Judge", "Last Judge", A("Удар", "Slam", "SLAM"), A("Прыжок", "Jump", "JUMP"), A("Рывок", "Dash", "DASH"), A("Топот", "Stomp", "STOMP"), A("Вращение", "Spin", "SPIN"), A("Разбег", "Charge", "CHARGE")); Add(dictionary, "Broodmother", "Slab Fly Broodmother", A("Прыжок", "Leap", "LEAP"), A("Плевок", "Spit", "SPIT"), A("Вылупление", "Hatch", "HATCH"), A("Удар", "Slam", "SLAM")); Add(dictionary, "Nyleth", "Flower Queen Boss", A("Прыжок", "Leap", "LEAP"), A("Шипы", "Spikes", "SPIKE SUMMON"), A("Выстрел", "Shoot", "SHOOT"), A("Пыльца", "Pollen blast", "POLLEN BLAST")); Add(dictionary, "Trobbio", "Trobbio", A("Торнадо", "Tornado", "TORNADO"), A("Бомбы", "Bombs", "BOMB THROW"), A("Прыжок", "Jump", "JUMP"), A("Вспышка", "Flash", "DAZZLE FLASH"), A("Столбы", "Columns", "BURST COLUMNS")); Add(dictionary, "Raging Conchfly", "Coral Conch Driller Giant Solo", A("Горизонтальный", "Horizontal", "ATTACK H"), A("Вертикальный", "Vertical", "ATTACK V"), A("Рёв", "Roar", "ROAR"), A("Выстрел", "Shoot", "SHOOT"), A("Рывок миньонов", "Minion charge", "MINION CHARGE")); Add(dictionary, "Groal the Great", "Swamp Shaman", A("Плевок", "Spit", "SPIT"), A("Засасывание", "Suck", "SUCK"), A("Пике", "Dive", "DIVE"), A("Огненный шар", "Fireball", "FIREBALL")); Add(dictionary, "Crust King Khann", "Coral King", A("Тычок", "Jab", "JAB"), A("Тычок сверху", "Air jab", "AIR JAB"), A("Апперкот", "Uppercut", "UPPERCUT"), A("Рёв", "Roar", "ROAR"), A("Крестовый удар", "Cross chop", "CROSS CHOP"), A("Шипы", "Spikes", "SHOOT SPIKES")); Add(dictionary, "Phantom", "Phantom", A("Серия уколов", "Stab combo", "STAB COMBO"), A("Бросок в воздухе", "Air throw", "A THROW"), A("Бросок с земли", "Ground throw", "G THROW"), A("Драгун", "Dragoon", "DRAGOON")); Add(dictionary, "Second Sentiel", "Song Knight", A("Рывок", "Dash attack", "DASH ATTACK"), A("Пике", "Dive slash", "DIVE SLASH"), A("Ветровой удар", "Wind slash", "WIND SLASH"), A("Крестовый удар", "Cross slash", "CROSS SLASH"), A("Удар вверх", "Rising slash", "RISING SLASH")); Add(dictionary, "The Unravelled", "Conductor Boss", A("Выстрел", "Shoot", "SHOOT"), A("Рывок", "Charge", "CHARGE"), A("Град копий", "Barrage", "BARRAGE"), A("Рёв", "Roar", "ROAR")); Add(dictionary, "First Sinner", "First Weaver", A("Иглы", "Pins", "PINS"), A("Удар", "Slash", "SLASH"), A("Рывок с разрезом", "Slice charge", "SLICE CHARGE"), A("Бомба", "Bomb", "BOMB")); Add(dictionary, "Lace in the Cradle", "Lace Boss2 New", A("Серия", "Combo", "COMBO"), A("Рывок", "Charge", "CHARGE"), A("Удар J", "J slash", "J SLASH")); Add(dictionary, "Gurr the Outcast", "Bone Hunter Trapper", A("Рывок", "Charge", "CHARGE"), A("Зарыться", "Dig in", "DIG IN"), A("Прыжок", "Hop", "HOP"), A("Шипы", "Spikes", "SPIKES")); Add(dictionary, "Tormented Trobbio", "Tormented Trobbio", A("Торнадо", "Tornado", "TORNADO"), A("Бомбы", "Bombs", "BOMB THROW"), A("Прыжок", "Jump", "JUMP"), A("Вспышка", "Flash", "DAZZLE FLASH"), A("Столбы", "Columns", "BURST COLUMNS")); Add(dictionary, "Shrine Guardian Seth", "Seth", A("Серия", "Slash combo", "SLASH COMBO"), A("Пике", "Jump dive", "JUMP DIVE"), A("Бросок с земли", "Ground throw", "G THROW"), A("Бросок в прыжке", "Jump throw", "JUMP THROW"), A("Телепорт", "Tele out", "TELE OUT"), A("Удар из тени", "Fade slash", "FADE SLASH")); Add(dictionary, "Pinstress", "Pinstress Boss", A("Рывок", "Dash", "DASH"), A("Бросок", "Throw", "THROW"), A("Таран", "Charge", "CHARGE"), A("Бросок вниз", "Down throw", "DOWN THROW")); Add(dictionary, "Skarrsinger Karmelita", "Hunter Queen Boss", A("Прыжок с вращением", "Jump spin", "JUMP SPIN"), A("Серия", "Slash combo", "SLASH COMBO"), A("Циклон", "Cyclone spin", "CYCLONE SPIN"), A("Бросок", "Throw", "THROW"), A("Бросок в воздухе", "Air throw", "AIR THROW"), A("Скользящий рывок", "Dash grind", "DASH GRIND")); Add(dictionary, "Lost Lace", "Lost Lace Boss", A("Серия", "Combo", "COMBO"), A("Рывок", "Charge", "CHARGE"), A("Удар J", "J slash", "J SLASH"), A("Щупальца", "Tendril", "TENDRIL"), A("Рвота", "Vomit", "VOMIT"), A("Пули", "Bullets", "BULLET SUMMON"), A("Призыв щупалец", "Tendril summon", "TENDRIL SUMMON"), A("Крестовый удар", "Cross slash", "CROSS SLASH")); return dictionary; } internal static AttackSpec Spec(string boss) { if (boss == null || !specs.TryGetValue(boss, out var value)) { return null; } return value; } internal static bool Has(string boss) { return Spec(boss) != null; } internal static AttackKind[] Kinds(string boss) { AttackSpec attackSpec = Spec(boss); if (attackSpec != null) { return attackSpec.Kinds; } return None; } internal static int Count(string boss) { return Kinds(boss).Length; } private static int Full(int count) { if (count < 31) { return (1 << count) - 1; } return int.MaxValue; } internal static int Clean(string boss, int mask) { int num = Count(boss); if (num == 0 || mask < 0) { return 0; } int num2 = Full(num); mask &= num2; if (mask != num2) { return mask; } return 0; } internal static int Mask(Entry e) { if (e == null || e.IsRest) { return 0; } return Clean(e.Boss, e.At); } internal static bool IsOff(Entry e, int index) { if (index >= 0 && index < Count(e?.Boss)) { return (Mask(e) & (1 << index)) != 0; } return false; } internal static int Enabled(string boss, int mask) { int num = Count(boss); int num2 = 0; for (int i = 0; i < num; i++) { if ((mask & (1 << i)) == 0) { num2++; } } return num2; } internal static bool Set(Entry e, int index, bool off) { if (e == null || e.IsRest || index < 0 || index >= Count(e.Boss)) { return false; } int num = Mask(e); int num2 = 1 << index; int num3 = (off ? (num | num2) : (num & ~num2)); if (off && Enabled(e.Boss, num3) == 0) { return false; } e.At = num3; return true; } internal static bool Only(Entry e, int index) { if (e == null || e.IsRest || index < 0 || index >= Count(e.Boss)) { return false; } e.At = Full(Count(e.Boss)) & ~(1 << index); if (Count(e.Boss) == 1) { e.At = 0; } return true; } internal static void Reset(Entry e) { if (e != null) { e.At = 0; } } internal static void Normalize(Entry e) { if (e != null) { e.At = ((!e.IsRest) ? Clean(e.Boss, e.At) : 0); } } internal static HashSet<string> OffEvents(string boss, int mask) { HashSet<string> hashSet = new HashSet<string>(); AttackKind[] array = Kinds(boss); mask = Clean(boss, mask); for (int i = 0; i < array.Length; i++) { if ((mask & (1 << i)) != 0) { string[] events = array[i].Events; foreach (string item in events) { hashSet.Add(item); } } } return hashSet; } internal static string DescribeOff(string boss, int mask) { AttackKind[] array = Kinds(boss); mask = Clean(boss, mask); List<string> list = new List<string>(); for (int i = 0; i < array.Length; i++) { if ((mask & (1 << i)) != 0) { list.Add(array[i].Name); } } return string.Join(", ", list.ToArray()); } internal static string OnlyName(string boss, int mask) { AttackKind[] array = Kinds(boss); mask = Clean(boss, mask); if (mask == 0 || Enabled(boss, mask) != 1) { return null; } for (int i = 0; i < array.Length; i++) { if ((mask & (1 << i)) == 0) { return array[i].Name; } } return null; } } internal static class Attacks { private const float FindEvery = 0.2f; private const float SlowFindEvery = 1.5f; private const float WindowSec = 300f; private static bool armed; private static string boss; private static string scene; private static AttackSpec spec; private static HashSet<string> off; private static int mask; private static int found; private static int changed; private static float nextFind; private static float until; private static readonly HashSet<int> patched = new HashSet<int>(); private const float WatchWarnSec = 10f; private static int waiting; private static Fsm watchFsm; private static string watchState; private static float watchSince; private static bool watchWarned; internal static void Arm(string bossName, string sceneName, int disabledMask) { Disarm(); AttackSpec attackSpec = AttackData.Spec(bossName); int num = AttackData.Clean(bossName, disabledMask); if (attackSpec != null && num != 0) { armed = true; boss = bossName; scene = sceneName; spec = attackSpec; mask = num; off = AttackData.OffEvents(bossName, num); found = 0; changed = 0; waiting = 0; watchFsm = null; watchState = null; watchWarned = false; nextFind = 0f; until = Time.unscaledTime + 300f; Runner.MarkPractice(); Plugin.Log.LogInfo((object)("Босс " + bossName + ": выключены атаки — " + AttackData.DescribeOff(bossName, num) + " (бой не идёт в статистику).")); } } internal static void Disarm() { armed = false; boss = null; scene = null; spec = null; off = null; mask = 0; found = 0; changed = 0; waiting = 0; watchFsm = null; watchState = null; watchWarned = false; patched.Clear(); } internal static void LeaveScene(string newScene) { if (armed && !Rooms.Same(newScene, scene)) { Disarm(); } } internal static void Tick() { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) if (!armed) { return; } if (!Runner.Active) { Disarm(); return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < nextFind) { return; } nextFind = unscaledTime + ((found >= 1) ? 1.5f : 0.2f); if (unscaledTime > until) { if (found == 0 && waiting > 0) { Plugin.Log.LogWarning((object)("Босс " + boss + ": выключенные атаки не применены — FSM «" + spec.Fsm + "» объекта «" + spec.Object + "» нашёлся, но игра так и не запустила его.")); } else if (found == 0) { Plugin.Log.LogWarning((object)("Босс " + boss + ": выключенные атаки не применены — FSM «" + spec.Fsm + "» объекта «" + spec.Object + "» не нашёлся.")); } Disarm(); return; } try { Watch(unscaledTime); PlayMakerFSM[] array = Object.FindObjectsByType<PlayMakerFSM>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (PlayMakerFSM val in array) { if ((Object)(object)val == (Object)null || ((Object)((Component)val).gameObject).name != spec.Object) { continue; } Fsm fsm = val.Fsm; if (fsm == null || val.FsmName != spec.Fsm) { continue; } Scene val2 = ((Component)val).gameObject.scene; if (!Rooms.Same(((Scene)(ref val2)).name, scene)) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (patched.Contains(instanceID)) { continue; } if (!fsm.Started) { waiting++; continue; } patched.Add(instanceID); found++; string activeStateName = fsm.ActiveStateName; int num = Patch(val); changed += num; Plugin.Log.LogInfo((object)("Босс " + boss + ": выбор атаки изменён в " + num + " действиях FSM «" + val.FsmName + "» (FSM был в состоянии «" + activeStateName + "»).")); if (num == 0) { Plugin.Log.LogWarning((object)("Босс " + boss + ": в FSM нет случайного выбора с выключенными атаками — ничего не изменилось.")); } if (watchFsm == null) { watchFsm = fsm; watchState = activeStateName; watchSince = unscaledTime; watchWarned = false; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Босс " + boss + ": выключенные атаки не применены: " + ex.Message)); Disarm(); } } private static void Watch(float now) { if (watchFsm != null) { string activeStateName = watchFsm.ActiveStateName; if (activeStateName != watchState) { Plugin.Log.LogInfo((object)("Босс " + boss + ": FSM вышел из состояния «" + watchState + "» в «" + activeStateName + "» через " + (now - watchSince).ToString("0.0") + " с после правки.")); watchFsm = null; } else if (!watchWarned && now - watchSince > 10f) { watchWarned = true; Plugin.Log.LogWarning((object)("Босс " + boss + ": FSM уже " + 10f.ToString("0") + " с стоит в состоянии «" + activeStateName + "» после правки атак. Если бой не начался, пришли этот журнал.")); } } } private static bool Parts(FsmStateAction a, out FsmEvent[] events, out FsmFloat[] weights, out FsmInt[] eventMax, out FsmInt[] missedMax) { events = null; weights = null; eventMax = null; missedMax = null; SendRandomEventV4 val = (SendRandomEventV4)(object)((a is SendRandomEventV4) ? a : null); if (val != null) { events = val.events; weights = val.weights; eventMax = val.eventMax; missedMax = val.missedMax; return true; } SendRandomEventV3ActiveBool val2 = (SendRandomEventV3ActiveBool)(object)((a is SendRandomEventV3ActiveBool) ? a : null); if (val2 != null) { events = val2.events; weights = val2.weights; eventMax = val2.eventMax; missedMax = val2.missedMax; return true; } SendRandomEventV3 val3 = (SendRandomEventV3)(object)((a is SendRandomEventV3) ? a : null); if (val3 != null) { events = val3.events; weights = val3.weights; eventMax = val3.eventMax; missedMax = val3.missedMax; return true; } SendRandomEventV2 val4 = (SendRandomEventV2)(object)((a is SendRandomEventV2) ? a : null); if (val4 != null) { events = val4.events; weights = val4.weights; eventMax = val4.eventMax; return true; } SendRandomEvent val5 = (SendRandomEvent)(object)((a is SendRandomEvent) ? a : null); if (val5 != null) { events = val5.events; weights = val5.weights; return true; } return false; } private static int Patch(PlayMakerFSM f) { int num = 0; FsmState[] fsmStates = f.FsmStates; foreach (FsmState val in fsmStates) { if (val == null || val.Actions == null) { continue; } FsmStateAction[] actions = val.Actions; foreach (FsmStateAction val2 in actions) { if (val2 != null && Parts(val2, out var events, out var weights, out var eventMax, out var missedMax) && events != null && weights != null && Apply(events, weights, eventMax, missedMax)) { num++; } } } return num; } private static bool Apply(FsmEvent[] events, FsmFloat[] weights, FsmInt[] eventMax, FsmInt[] missedMax) { int num = ((events.Length < weights.Length) ? events.Length : weights.Length); string[] array = new string[num]; float[] array2 = new float[num]; for (int i = 0; i < num; i++) { array[i] = ((events[i] == null) ? null : events[i].Name); array2[i] = ((weights[i] == null) ? 0f : weights[i].Value); } ChoicePlan choicePlan = AttackMath.Plan(array, array2, off); if (choicePlan == null) { return false; } for (int j = 0; j < choicePlan.Off.Length; j++) { if (choicePlan.Off[j]) { if (weights[j] != null) { weights[j].Value = 0f; } if (missedMax != null && j < missedMax.Length && missedMax[j] != null) { missedMax[j].Value = 99999; } } } if (choicePlan.Keep >= 0 && eventMax != null && choicePlan.Keep < eventMax.Length && eventMax[choicePlan.Keep] != null) { eventMax[choicePlan.Keep].Value = 99; } return true; } } internal static class BossFx { private sealed class Saved { internal EnemyHp info; internal string[] diffs; internal int[][] oldPhases; internal int[] oldFull; internal int[][] newPhases; internal int[] newFull; } private const float PollEvery = 0.15f; private const float GiveUpAfter = 60f; private const float GiveUpAfterVanilla = 300f; private static string boss; private static BossDef pollDef; private static string scene; private static int mode; private static bool full; private static int custom; private static float nextTry; private static float giveUpAt; private static FieldInfo initHpField; private static readonly string[] SecondPhaseOn = new string[3] { "Phase 2", "Doing First Burst Column", "Will Burst Column" }; private static readonly string[] SecondPhaseOff = new string[1] { "Doing First Attack" }; private static readonly List<Saved> saved = new List<Saved>(); private static string tableScene; private static readonly Dictionary<string, int[]> vanillaHp = new Dictionary<string, int[]>(); internal static void Arm(string bossName, string sceneName, int phase, bool challenge, int ownHp) { boss = null; BossDef bossDef = PhaseLock.Find(bossName); bool flag = bossDef != null && phase >= 1 && phase <= bossDef.Phases; BossDef bossDef2 = ((bossDef != null) ? bossDef : PhaseLock.FindHp(bossName)); int num = ((bossDef2 != null) ? PhaseLock.NormalizeHp(bossName, ownHp) : 0); if (!flag) { PhaseSkip.Disarm(); PhaseKick.Disarm(); PhaseEnd.Disarm(); PhaseDancers.Disarm(); PhaseFather.Disarm(); PhaseUnravel.Disarm(); if (num <= 0) { LeaveScene(sceneName); return; } PhaseUnravel.Arm(bossName, sceneName, 0); } else { PhaseFather.Disarm(); PhaseKick.Arm(bossName, sceneName, phase); PhaseEnd.Arm(bossName, sceneName, phase); PhaseDancers.Arm(bossName, phase); PhaseUnravel.Arm(bossName, sceneName, phase); PhaseSkip.Arm(bossName, sceneName, phase); } if (num > 0) { challenge = false; } if (bossDef2.Rule == PhaseRule.Trobbio || bossDef2.Rule == PhaseRule.Vanilla) { LeaveScene(sceneName); if (flag || num > 0) { boss = bossName; pollDef = bossDef2; scene = sceneName; mode = (flag ? phase : 0); full = challenge; custom = num; nextTry = 0f; giveUpAt = Time.unscaledTime + ((bossDef2.Rule == PhaseRule.Vanilla) ? 300f : 60f); } } else { ApplyTable(bossDef2, sceneName, flag ? phase : 0, challenge, num); } } internal static void LeaveScene(string newScene) { if (saved.Count > 0 && !Rooms.Same(newScene, tableScene)) { Restore(); } } internal static void Restore() { if (saved.Count == 0) { return; } try { foreach (Saved item in saved) { for (int i = 0; i < item.diffs.Length; i++) { for (int j = 0; j < item.oldPhases[i].Length; j++) { item.info.phases[j].hpDict[item.diffs[i]] = item.oldPhases[i][j]; } item.info.hpFullDict[item.diffs[i]] = item.oldFull[i]; } } Plugin.Log.LogInfo((object)"Таблица здоровья фаз GoP возвращена."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Таблица здоровья фаз GoP не возвращена: " + ex.Message)); } saved.Clear(); tableScene = null; } internal static int VanillaHp(string bossName, string difficulty) { int num = Array.IndexOf(Tokens.Difficulties, difficulty); if (num < 0 || bossName == null) { return 0; } if (!vanillaHp.TryGetValue(bossName, out var value)) { if (saved.Count > 0) { return 0; } value = new int[Tokens.Difficulties.Length]; try { BossDef bossDef = PhaseLock.FindHp(bossName); if (bossDef != null && bossDef.Keys.Length == 1 && bossDef.Rule != PhaseRule.Vanilla && EnemyHp.enemies.TryGetValue(bossDef.Keys[0], out var value2) && value2.phases != null && value2.phases.Length == TableLen(bossDef)) { for (int i = 0; i < value.Length; i++) { int[] array = new int[value2.phases.Length]; for (int j = 0; j < array.Length; j++) { array[j] = value2.phases[j].hpDict[Tokens.Difficulties[i]]; } value[i] = PhaseLock.VanillaTotal(bossDef.Rule, array); } } } catch (Exception) { value = new int[Tokens.Difficulties.Length]; } vanillaHp[bossName] = value; } return value[num]; } private static int TableLen(BossDef def) { if (def.TableLen <= 0) { return def.Phases; } return def.TableLen; } private static void ApplyTable(BossDef def, string sceneName, int phase, bool challenge, int ownHp) { Restore(); try { List<Saved> list = new List<Saved>(); string[] keys = def.Keys; foreach (string text in keys) { if (!EnemyHp.enemies.TryGetValue(text, out var value) || value.phases == null || value.phases.Length != TableLen(def)) { Plugin.Log.LogWarning((object)("Босс " + def.Boss + ": GoP не знает здоровья его фаз (" + text + ") — настройку не применяю.")); return; } Saved saved = new Saved(); saved.info = value; saved.diffs = new List<string>(value.hpFullDict.Keys).ToArray(); saved.oldPhases = new int[saved.diffs.Length][]; saved.newPhases = new int[saved.diffs.Length][]; saved.oldFull = new int[saved.diffs.Length]; saved.newFull = new int[saved.diffs.Length]; for (int j = 0; j < saved.diffs.Length; j++) { int[] array = new int[TableLen(def)]; for (int k = 0; k < array.Length; k++) { array[k] = value.phases[k].hpDict[saved.diffs[j]]; } if (!PhaseLock.TablePlan(def.Rule, phase, challenge, ownHp, array, out var phases, out var total)) { Plugin.Log.LogWarning((object)("Босс " + def.Boss + ": здоровье фаз в GoP не подходит для настройки" + ((ownHp > 0) ? (" (своё здоровье " + ownHp + ", слишком мало для стольких фаз?)") : "") + " — не применяю.")); return; } saved.oldPhases[j] = array; saved.newPhases[j] = phases; saved.oldFull[j] = value.hpFullDict[saved.diffs[j]]; saved.newFull[j] = total; } list.Add(saved); } foreach (Saved item in list) { for (int l = 0; l < item.diffs.Length; l++) { for (int m = 0; m < item.newPhases[l].Length; m++) { item.info.phases[m].hpDict[item.diffs[l]] = item.newPhases[l][m]; } item.info.hpFullDict[item.diffs[l]] = item.newFull[l]; } BossFx.saved.Add(item); } tableScene = sceneName; int num = 0; string currentDifficultMode = BossSequence.currentDifficultMode; Saved saved2 = list[0]; for (int n = 0; n < saved2.diffs.Length; n++) { if (saved2.diffs[n] == currentDifficultMode) { num = saved2.newFull[n]; } } if (def.Rule == PhaseRule.Lanterns) { int num2 = Array.IndexOf(saved2.diffs, currentDifficultMode); if (num2 >= 0) { PhaseFather.Arm(def.Boss, sceneName, phase, saved2.oldPhases[num2], saved2.newPhases[num2]); } } if (!challenge) { Runner.MarkPractice(); } string text2 = PhaseLock.DescribeHp(phase, challenge, ownHp); Plugin.Log.LogInfo((object)("Босс " + def.Boss + ": " + text2 + " (здоровье " + num + ", таблица фаз GoP подменена) — " + (challenge ? "челлендж, считается в статистике" : "тренировка, статистика не меняется"))); Plugin.Toast(Runner.Display(def.Boss) + ": " + text2 + (challenge ? L.T(" · челлендж", " · challenge") : L.T(" · тренировка", " · practice")), 4f); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Босс " + def.Boss + ": настройка не применена: " + ex.Message)); Restore(); } } internal static void Tick() { if (saved.Count > 0 && !Runner.Active) { Restore(); } PhaseSkip.Tick(); PhaseFather.Tick(); Summons.Tick(); Attacks.Tick(); PhaseKick.Tick(); PhaseEnd.Tick(); PhaseDancers.Tick(); PhaseUnravel.Tick(); if (boss == null) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < nextTry) { return; } nextTry = unscaledTime + 0.15f; if (!Runner.Active) { boss = null; return; } if (unscaledTime > giveUpAt) { Plugin.Log.LogWarning((object)("Босс " + boss + ": настройка (" + PhaseLock.DescribeHp(mode, full, custom) + ") не применена — босс не появился или не поставил здоровье вовремя.")); boss = null; return; } try { if ((pollDef != null && pollDef.Rule == PhaseRule.Vanilla) ? TryApplyVanilla() : TryApply()) { boss = null; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Босс " + boss + ": настройка не применена: " + ex.Message)); boss = null; } } private static bool TryApply() { HealthManager val = FindBoss(boss, scene); if ((Object)(object)val == (Object)null) { return false; } PlayMakerFSM val2 = null; PlayMakerFSM[] components = ((Component)val).GetComponents<PlayMakerFSM>(); foreach (PlayMakerFSM val3 in components) { if (val3.FsmName == "Control") { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return false; } FsmInt val4 = val2.FsmVariables.FindFsmInt("P2 HP"); if (val4 == null) { Plugin.Log.LogWarning((object)("Босс " + boss + ": в FSM нет переменной «P2 HP» — настройку не применяю.")); return true; } if (!EnemyHp.enemies.TryGetValue(boss, out var value) || value.phases == null || value.phases.Length < 2) { Plugin.Log.LogWarning((object)("Босс " + boss + ": GoP не знает здоровья его фаз — настройку не применяю.")); return true; } int[] array = new int[value.phases.Length]; for (int j = 0; j < array.Length; j++) { array[j] = value.phases[j].hp; } int num = value.hpFullDict[BossSequence.currentDifficultMode]; if (val.hp != num || val4.Value != num - array[0]) { return false; } if (!PhaseLock.Plan(mode, full, custom, array, out var hp, out var secondPhaseAt)) { return true; } val.hp = hp; if (initHpField == null) { initHpField = typeof(HealthManager).GetField("initHp", BindingFlags.Instance | BindingFlags.NonPublic); } if (initHpField != null) { initHpField.SetValue(val, hp); } val4.Value = secondPhaseAt; bool flag = mode == 2 && SkipRoar(val2); if (!full) { Runner.MarkPractice(); } string text = PhaseLock.DescribeHp(mode, full, custom); Plugin.Log.LogInfo((object)("Босс " + boss + ": " + text + " (здоровье " + hp + ", порог второй фазы " + secondPhaseAt + ((mode != 2) ? "" : (flag ? ", рёв пропущен" : ", рёв остался")) + ") — " + (full ? "челлендж, считается в статистике" : "тренировка, статистика не меняется"))); Plugin.Toast(Runner.Display(boss) + ": " + text + (full ? L.T(" · челлендж", " · challenge") : L.T(" · тренировка", " · practice")), 4f); return true; } private static bool TryApplyVanilla() { HealthManager val = FindBoss(pollDef.Object, scene); if ((Object)(object)val == (Object)null) { return false; } PlayMakerFSM val2 = null; PlayMakerFSM[] components = ((Component)val).GetComponents<PlayMakerFSM>(); foreach (PlayMakerFSM val3 in components) { if (val3.FsmName == "Control") { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return false; } FsmInt val4 = val2.FsmVariables.FindFsmInt("P2 HP"); if (val4 == null) { Plugin.Log.LogWarning((object)("Босс " + boss + ": в FSM нет переменной «P2 HP» — настройку не применяю.")); return true; } string activeStateName = val2.Fsm.ActiveStateName; if (string.IsNullOrEmpty(activeStateName) || activeStateName == "Init") { return false; } int hp = val.hp; int value = val4.Value; if (value <= 0 || hp <= value) { Plugin.Log.LogWarning((object)("Босс " + boss + ": здоровье " + hp + " и порог второй фазы " + value + " не подходят — настройку не применяю.")); return true; } int[] phaseHp = new int[2] { hp - value, value }; if (!PhaseLock.Plan(mode, full, custom, phaseHp, out var hp2, out var secondPhaseAt)) { return true; } val.hp = hp2; if (initHpField == null) { initHpField = typeof(HealthManager).GetField("initHp", BindingFlags.Instance | BindingFlags.NonPublic); } if (initHpField != null) { initHpField.SetValue(val, hp2); } val4.Value = secondPhaseAt; if (!full) { Runner.MarkPractice(); } string text = PhaseLock.DescribeHp(mode, full, custom); Plugin.Log.LogInfo((object)("Босс " + boss + ": " + text + " (здоровье " + hp2 + " из " + hp + ", порог второй фазы " + secondPhaseAt + ") — " + (full ? "челлендж, считается в статистике" : "тренировка, статистика не меняется"))); Plugin.Toast(Runner.Display(boss) + ": " + text + (full ? L.T(" · челлендж", " · challenge") : L.T(" · тренировка", " · practice")), 4f); return true; } private static bool SkipRoar(PlayMakerFSM control) { FsmBool[] array = (FsmBool[])(object)new FsmBool[SecondPhaseOn.Length]; FsmBool[] array2 = (FsmBool[])(object)new FsmBool[SecondPhaseOff.Length]; for (int i = 0; i < array.Length; i++) { array[i] = control.FsmVariables.FindFsmBool(SecondPhaseOn[i]); if (array[i] == null) { return false; } } for (int j = 0; j < array2.Length; j++) { array2[j] = control.FsmVariables.FindFsmBool(SecondPhaseOff[j]); if (array2[j] == null) { return false; } } FsmBool[] array3 = array; for (int k = 0; k < array3.Length; k++) { array3[k].Value = true; } array3 = array2; for (int k = 0; k < array3.Length; k++) { array3[k].Value = false; } return true; } private static HealthManager FindBoss(string name, string sceneName) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) HealthManager[] array = Object.FindObjectsByType<HealthManager>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (HealthManager val in array) { if (!(((Object)((Component)val).gameObject).name != name)) { Scene val2 = ((Component)val).gameObject.scene; if (Rooms.Same(((Scene)(ref val2)).name, sceneName)) { return val; } } } return null; } } internal static class Build { internal sealed class Skill { internal string Code; internal string Ru; internal string En; internal Func<PlayerData, bool> Get; internal Action<PlayerData, bool> Set; } internal sealed class SlotView { internal int Index; internal ToolItemType Type; internal string Tool = ""; internal bool Open; internal bool Allowed; } internal static readonly Skill[] Skills = new Skill[9] { new Skill { Code = "dash", Ru = "Рывок (Swift Step)", En = "Swift Step", Get = (PlayerData p) => p.hasDash, Set = delegate(PlayerData p, bool v) { p.hasDash = v; } }, new Skill { Code = "claw", Ru = "Гарпун (Clawline)", En = "Clawline", Get = (PlayerData p) => p.hasHarpoonDash, Set = delegate(PlayerData p, bool v) { p.hasHarpoonDash = v; } }, new Skill { Code = "eva", Ru = "Лечение Евы (Eva Heal)", En = "Eva Heal", Get = (PlayerData p) => p.HasBoundCrestUpgrader, Set = delegate(PlayerData p, bool v) { p.HasBoundCrestUpgrader = v; } }, new Skill { Code = "soar", Ru = "Суперпрыжок (Silk Soar)", En = "Silk Soar", Get = (PlayerData p) => p.hasSuperJump, Set = delegate(PlayerData p, bool v) { p.hasSuperJump = v; } }, new Skill { Code = "grip", Ru = "Стенопрыжок (Cling Grip)", En = "Cling Grip", Get = (PlayerData p) => p.hasWalljump, Set = delegate(PlayerData p, bool v) { p.hasWalljump = v; } }, new Skill { Code = "needolin", Ru = "Нидолин (Needolin)", En = "Needolin", Get = (PlayerData p) => p.hasNeedolin, Set = delegate(PlayerData p, bool v) { p.hasNeedolin = v; } }, new Skill { Code = "strike", Ru = "Ударная игла (Needle Strike)", En = "Needle Strike", Get = (PlayerData p) => p.hasChargeSlash, Set = delegate(PlayerData p, bool v) { p.hasChargeSlash = v; } }, new Skill { Code = "drift", Ru = "Плащ странника (Drifter's Cloak)", En = "Drifter's Cloak", Get = (PlayerData p) => p.hasBrolly, Set = delegate(PlayerData p, bool v) { p.hasBrolly = v; } }, new Skill { Code = "fay", Ru = "Плащ Фейдаун (Faydown Cloak)", En = "Faydown Cloak", Get = (PlayerData p) => p.hasDoubleJump, Set = delegate(PlayerData p, bool v) { p.hasDoubleJump = v; } } }; private static readonly string[] BindingKeys = new string[4] { "Needle Binding", "Silk Binding", "Tools Binding", "Mask Binding" }; private static string crestBefore = ""; private static List<ToolCrest> crestCache = new List<ToolCrest>(); private static float crestCacheAt = -10f; private static List<List<ToolCrest>> crestFamilies = new List<List<ToolCrest>>(); private static Dictionary<string, int> crestLevel = new Dictionary<string, int>(); private static Dictionary<string, int> crestLevels = new Dictionary<string, int>(); private static Dictionary<string, string> crestPicked = new Dictionary<string, string>(); private static FieldInfo previousField; private static bool previousTried; private static int cachedMask = -1; private static string cachedOff; private static string cachedVariant = ""; internal static string BindingName(int i) { return i switch { 2 => "Tools", 1 => "Silk", 0 => "Needle", _ => "Mask", }; } internal static string BindingInfo(int i) { return i switch { 0 => L.T("Игла слабее: урон иглы урезан.", "Weaker needle: needle damage is capped."), 1 => L.T("Шёлка меньше: катушка урезана.", "Less silk: the spool is cut down."), 2 => L.T("Инструменты отключены, остаются только шёлковые навыки.", "Tools are disabled, only silk skills stay."), _ => L.T("Масок меньше: здоровье урезано.", "Fewer masks: health is cut down."), }; } internal static string SkillName(Skill s) { if (!L.IsRu) { return s.En; } return s.Ru; } internal static bool Check() { if (Skills.Length != BuildMath.SkillCodes.Length) { return false; } for (int i = 0; i < Skills.Length; i++) { if (Skills[i].Code != BuildMath.SkillCodes[i]) { return false; } } return true; } internal static bool Binding(int i) { PlayerDataMod instance = PlayerDataMod.instance; if (instance == null || instance.bindings == null || i < 0 || i >= BindingKeys.Length) { return false; } bool value; return instance.bindings.TryGetValue(BindingKeys[i], out value) && value; } internal static bool CanChange(out string reason) { reason = ""; if (PlayerDataMod.instance == null || PlayerData.instance == null) { reason = L.T("Сначала загрузи сохранение.", "Load a save first."); return false; } if (Runner.Active || BossSequence.isInSequence) { reason = L.T("Во время сегмента менять нельзя.", "Cannot be changed during a segment."); return false; } return true; } internal static bool ToggleBinding(int i, out string message) { return SetBinding(i, !Binding(i), out message); } internal static bool SetBinding(int i, bool on, out string message) { message = ""; if (i < 0 || i >= BindingKeys.Length) { return false; } if (!CanChange(out message)) { return false; } if (Binding(i) != on) { PlayerDataMod.instance.bindings[BindingKeys[i]] = on; Persist(); } message = BindingName(i) + ": " + (on ? L.T("включена", "on") : L.T("выключена", "off")); return true; } internal static bool SetAllBindings(bool on, out string message) { message = ""; if (!CanChange(out message)) { return false; } bool flag = false; for (int i = 0; i < BindingKeys.Length; i++) { if (Binding(i) != on) { PlayerDataMod.instance.bindings[BindingKeys[i]] = on; flag = true; } } if (flag) { Persist(); } message = (on ? L.T("Все привязки включены.", "All bindings on.") : L.T("Все привязки сняты.", "All bindings off.")); return true; } private static void Persist() { try { if ((Object)(object)GodsOfPharloomMod.instance != (Object)null) { GodsOfPharloomMod.instance.SaveModData(); } } catch (Exception ex) { Plugin.Caught("Build/SaveModData", ex); } try { if (BindingsMenu.menuBindingsFsm != null) { BindingsMenu.UpdateMenuBindingsDisplay(); } } catch (Exception ex2) { Plugin.Caught("Build/UpdateMenuBindingsDisplay", ex2); } } internal static bool IsOff(Skill s) { return BuildMath.HasSkill(Plugin.SkillsOff, s.Code); } internal static bool Has(Skill s) { PlayerData instance = PlayerData.instance; if (instance != null) { return s.Get(instance); } return false; } internal static bool SetSkill(Skill s, bool off, out string message) { message = ""; if (!CanChange(out message)) { return false; } PlayerData instance = PlayerData.instance; if (off) { if (!s.Get(instance) && !IsOff(s)) { message = SkillName(s) + L.T(": такого навыка нет в сохранении.", ": the save does not have this skill."); return false; } Plugin.SkillsOff = BuildMath.WithSkill(Plugin.SkillsOff, s.Code, off: true); s.Set(instance, arg2: false); } else { if (!IsOff(s)) { message = SkillName(s) + L.T(": Encore его не отключал.", ": Encore did not turn it off."); return false; } Plugin.SkillsOff = BuildMath.WithSkill(Plugin.SkillsOff, s.Code, off: false); s.Set(instance, arg2: true); } message = SkillName(s) + ": " + (off ? L.T("отключён", "off") : L.T("включён", "on")); return true; } internal static bool ReturnSkills(out string message) { message = ""; if (!CanChange(out message)) { return false; } PlayerData instance = PlayerData.instance; int num = 0; Skill[] skills = Skills; foreach (Skill skill in skills) { if (IsOff(skill)) { skill.Set(instance, arg2: true); num++; } } Plugin.SkillsOff = ""; message = L.T("Навыки возвращены: ", "Skills returned: ") + num; return true; } internal static int ApplySkills() { PlayerData instance = PlayerData.instance; string skillsOff = Plugin.SkillsOff; if (instance == null || skillsOff.Length == 0) { return 0; } int num = 0; Skill[] skills = Skills; foreach (Skill skill in skills) { if (BuildMath.HasSkill(skillsOff, skill.Code) && skill.Get(instance)) { skill.Set(instance, arg2: false); num++; } } return num; } internal static string GearName(int gear) { return gear switch { 0 => L.T("Игла (уровень)", "Needle (level)"), 1 => L.T("Маски", "Masks"), 2 => L.T("Катушка шёлка", "Silk spool"), 3 => L.T("Сердца шёлка", "Silk hearts"), 4 => L.T("Сумка для инструментов", "Tool pouch"), _ => L.T("Набор для ремонта", "Crafting kit"), }; } internal static int Gear(int gear) { PlayerData instance = PlayerData.instance; if (instance == null) { return 0; } return gear switch { 0 => instance.nailUpgrades, 1 => instance.maxHealth, 2 => instance.silkMax, 3 => instance.silkRegenMax, 4 => instance.ToolPouchUpgrades, _ => instance.ToolKitUpgrades, }; } internal static int GearTop(int gear) { return BuildMath.GearMax(gear, Binding(3), BindingsMenu.maskBindingCount, Binding(1)); } internal static bool StepGear(int gear, int dir, out string message) { message = ""; if (gear < 0 || gear >= 6) { return false; } if (!CanChange(out message)) { return false; } PlayerData instance = PlayerData.instance; int num = Gear(gear); int num2 = BuildMath.Step(num, dir, BuildMath.GearMin(gear), GearTop(gear)); if (num2 != num) { switch (gear) { case 0: instance.nailUpgrades = num2; break; case 1: if (BindingsMenu.isHealthIncreasing) { message = L.T("Маски ещё меняются — подожди секунду.", "The masks are still changing — wait a second."); return false; } SetMasks(num2); break; case 2: instance.silkMax = num2; break; case 3: instance.silkRegenMax = num2; break; case 4: instance.ToolPouchUpgrades = num2; break; default: instance.ToolKitUpgrades = num2; break; } Persist(); } message = GearName(gear) + ": " + num2; return true; } private static void SetMasks(int n) { PlayerData instance = PlayerData.instance; PlayerDataMod instance2 = PlayerDataMod.instance; if (Binding(3) && instance2 != null) { instance2.previousHealthCount = n; } bool flag = false; try { GameCameras instance3 = GameCameras.instance; flag = (Object)(object)instance3 != (Object)null && (Object)(object)instance3.hudCanvasSlideOut != (Object)null && (Object)(object)GodsOfPharloomMod.instance != (Object)null && BindingsMenu.menuBindingsFsm != null; } catch (Exception ex) { Plugin.Caught("Build/MasksHud", ex); } if (flag) { try { ((MonoBehaviour)GodsOfPharloomMod.instance).StartCoroutine(BindingsMenu.TrySetHeroHealth(n)); return; } catch (Exception ex2) { Plugin.Caught("Build/TrySetHeroHealth", ex2); } } instance.maxHealth = n; instance.maxHealthBase = n; instance.health = n; } internal static int Cloak() { PlayerData instance = PlayerData.instance; if (instance != null) { return BuildMath.CloakState(instance.hasBrolly, instance.hasDoubleJump); } return 0; } internal static bool StepCloak(int dir, out string message) { message = ""; if (!CanChange(out message)) { return false; } int num = BuildMath.Step(Cloak(), dir, 0, 3); SetCloakFlag(Skills[7], (num & 1) != 0); SetCloakFlag(Skills[8], (num & 2) != 0); Persist(); message = L.T("Плащи: ", "Cloaks: ") + num switch { 2 => SkillName(Skills[8]), 1 => SkillName(Skills[7]), 0 => L.T("нет", "none"), _ => L.T("оба", "both"), }; return true; } private static void SetCloakFlag(Skill s, bool want) { PlayerData instance = PlayerData.instance; bool flag = s.Get(instance); if (want) { if (!flag) { s.Set(instance, arg2: true); } Plugin.SkillsOff = BuildMath.WithSkill(Plugin.SkillsOff, s.Code, off: false); } else if (flag) { s.Set(instance, arg2: false); Plugin.SkillsOff = BuildMath.WithSkill(Plugin.SkillsOff, s.Code, off: true); } } internal static bool SpecialCrestOn(bool cursed) { try { ToolCrest val = (cursed ? Gameplay.CursedCrest : Gameplay.CloaklessCrest); return (Object)(object)val != (Object)null && ((ToolBase)val).IsEquipped; } catch (Exception ex) { Plugin.Caught("Build/SpecialCrestOn", ex); return false; } } private static bool IsSpecialCrest(string name) { if (string.IsNullOrEmpty(name)) { return false; } try { return name == Gameplay.CloaklessCrest.name || name == Gameplay.CursedCrest.name; } catch (Exception) { return false; } } internal static bool ToggleSpecialCrest(bool cursed, out string message) { message = ""; if (!CanChange(out message)) { return false; } try { ToolCrest val = (cursed ? Gameplay.CursedCrest : Gameplay.CloaklessCrest); if ((Object)(object)val == (Object)null) { message = L.T("Такого креста в игре нет.", "The game has no such crest."); return false; } if (((ToolBase)val).IsEquipped) { ToolCrest val2 = null; if (crestBefore.Length > 0) { val2 = ToolItemManager.GetCrestByName(crestBefore); if ((Object)(object)val2 != (Object)null && !val2.IsUnlocked) { val2 = null; } } if ((Object)(object)val2 == (Object)null) { val2 = Gameplay.HunterCrest3; if (!val2.IsUnlocked) { val2 = Gameplay.HunterCrest2; } if (!val2.IsUnlocked) { val2 = Gameplay.HunterCrest; } } ToolItemManager.AutoEquip(val2, false, false); } else { string currentCrestID = PlayerData.instance.CurrentCrestID; if (!string.IsNullOrEmpty(currentCrestID) && !IsSpecialCrest(currentCrestID)) { crestBefore = currentCrestID; } ToolItemManager.AutoEquip(val, false, false); } Persist(); message = (cursed ? L.T("Проклятая Хорнет: ", "Cursed Hornet: ") : L.T("Хорнет без креста: ", "Crestless Hornet: ")) + (((ToolBase)val).IsEquipped ? L.T("надета", "on") : L.T("снята", "off")); return true; } catch (Exception ex) { Plugin.Caught("Build/ToggleSpecialCrest", ex); message = L.T("Не вышло: ", "Failed: ") + ex.Message; return false; } } private static ToolCrest PreviousOf(ToolCrest c) { if ((Object)(object)c == (Object)null) { return null; } try { if (!previousTried) { previousTried = true; previousField = typeof(ToolCrest).GetField("previousVersion", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (previousField == null) { return null; } object? value = previousField.GetValue(c); return (ToolCrest)((value is ToolCrest) ? value : null); } catch (Exception) { return null; } } internal static List<ToolCrest> Crests() { float unscaledTime = Time.unscaledTime; if (unscaledTime - crestCacheAt < 0.5f && crestCache.Count > 0) { return crestCache; } crestCacheAt = unscaledTime; List<ToolCrest> list = new List<ToolCrest>(); List<List<ToolCrest>> list2 = new List<List<ToolCrest>>(); Dictionary<string, int> level = new Dictionary<string, int>(); Dictionary<string, int> levels = new Dictionary<string, int>(); try { List<ToolCrest> allCrests = ToolItemManager.GetAllCrests(); bool flag = false; int num = 0; while (allCrests != null && num < allCrests.Count && !flag) { flag = (Object)(object)PreviousOf(allCrests[num]) != (Object)null; num++; } Dictionary<string, ToolCrest> dictionary = new Dictionary<string, ToolCrest>(); List<CrestMath.Entry> list3 = new List<CrestMath.Entry>(); int num2 = 0; while (allCrests != null && num2 < allCrests.Count) { ToolCrest val = allCrests[num2]; if (!((Object)(object)val == (Object)null) && !IsSpecialCrest(val.name) && !dictionary.ContainsKey(val.name)) { bool unlocked = val.IsUnlocked && (flag || !val.IsUpgradedVersionUnlocked); ToolCrest val2 = (flag ? PreviousOf(val) : null); dictionary[val.name] = val; list3.Add(new CrestMath.Entry(val.name, ((Object)(object)val2 != (Object)null) ? val2.name : "", unlocked)); } num2++; } PlayerData instance = PlayerData.instance; string current = ((instance != null) ? instance.CurrentCrestID : ""); List<List<string>> list4 = CrestMath.Families(list3, level, levels); for (int i = 0; i < list4.Count; i++) { List<ToolCrest> list5 = new List<ToolCrest>(); for (int j = 0; j < list4[i].Count; j++) { list5.Add(dictionary[list4[i][j]]); } crestPicked.TryGetValue(list4[i][0], out var value); string key = CrestMath.Representative(list4[i], current, value); list2.Add(list5); list.Add(dictionary[key]); } } catch (Exception ex) { Plugin.Caught("Build/Crests", ex); } crestCache = list; crestFamilies = list2; crestLevel = level; crestLevels = levels; return list; } internal static int CrestLevel(ToolCrest c, out int of) { of = 0; if ((Object)(object)c == (Object)null) { return 0; } if (!crestLevel.TryGetValue(c.name, out var value)) { return 0; } crestLevels.TryGetValue(c.name, out of); return value; } private static List<ToolCrest> FamilyOf(ToolCrest c) { if ((Object)(object)c == (Object)null) { return null; } for (int i = 0; i < crestFamilies.Count; i++) { for (int j = 0; j < crestFamilies[i].Count; j++) { if (crestFamilies[i][j].name == c.name) { return crestFamilies[i]; } } } return null; } private static void RememberCrest(ToolCrest c) { List<ToolCrest> list = FamilyOf(c); if (list != null && list.Count > 0) { crestPicked[list[0].name] = c.name; } crestCacheAt = -10f; } internal static bool StepCrest(ToolCrest c, int dir, out string message) { message = ""; List<ToolCrest> list = FamilyOf(c); if (list == null || list.Count < 2) { return false; } List<string> list2 = new List<string>(); for (int i = 0; i < list.Count; i++) { list2.Add(list[i].name); } string text = CrestMath.Step(list2, c.name, dir); for (int j = 0; j < list.Count; j++) { if (list[j].name == text) { return EquipCrest(list[j], out message); } } return false; } internal static ToolCrest CurrentCrest() { PlayerData instance = PlayerData.instance; if (instance == null || string.IsNullOrEmpty(instance.CurrentCrestID)) { return null; } try { return ToolItemManager.GetCrestByName(instance.CurrentCrestID); } catch (Exception) { return null; } } internal static bool CrestIsOn(ToolCrest c) { PlayerData instance = PlayerData.instance; if ((Object)(object)c != (Object)null && instance != null) { return c.name == instance.CurrentCrestID; } return false; } internal static bool EquipCrest(ToolCrest c, out string message) { message = ""; if (!CanChange(out message)) { return false; } if ((Object)(object)c == (Object)null) { return false; } try { ToolItemManager.AutoEquip(c, false, false); Persist(); RememberCrest(c); int of; int num = CrestLevel(c, out of); message = L.T("Крест надет: ", "Crest on: ") + Label(c) + ((num > 0) ? (L.T(" (уровень ", " (level ") + num + ")") : ""); return true; } catch (Exception ex) { Plugin.Caught("Build/EquipCrest", ex); message = L.T("Не вышло: ", "Failed: ") + ex.Message; return false; } } internal static List<SlotView> Slots(ToolCrest crest) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Invalid comparison between Unknown and I4 List<SlotView> list = new List<SlotView>(); PlayerData instance = PlayerData.instance; if ((Object)(object)crest == (Object)null || instance == null) { return list; } try { SlotInfo[] slots = crest.Slots; List<SlotData> slots2 = ((SerializableNamedList<Data, NamedData>)(object)instance.ToolEquips).GetData(crest.name).Slots; if (slots == null || slots2 == null) { return list; } bool flag = Binding(2); for (int i = 0; i < slots.Length && i < slots2.Count; i++) { SlotView slotView = new SlotView(); slotView.Index = i; slotView.Type = slots[i].Type; slotView.Tool = slots2[i].EquippedTool ?? ""; slotView.Open = !slots[i].IsLocked || slots2[i].IsUnlocked; slotView.Allowed = slotView.Open && (!flag || (int)slotView.Type == 3); list.Add(slotView); } } catch (Exception ex) { Plugin.Caught("Build/Slots", ex); } return list; } internal static List<ToolItem> ToolsOf(ToolItemType type) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) List<ToolItem> list = new List<ToolItem>(); try { foreach (ToolItem unlockedTool in ToolItemManager.GetUnlockedTools()) { if ((Object)(object)unlockedTool != (Object)null && unlockedTool.Type == type) { list.Add(unlockedTool); } } } catch (Exception ex) { Plugin.Caught("Build/ToolsOf", ex); } return list; } internal static bool SetSlot(ToolCrest crest, int slot, string toolName, out string message) { message = ""; if (!CanChange(out message)) { return false; } if ((Object)(object)crest == (Object)null) { return false; } try { List<SlotView> list = Slots(crest); if (slot < 0 || slot >= list.Count) { return false; } if (!list[slot].Allowed) { message = (list[slot].Open ? L.T("Привязка Tools: инструменты отключены.", "Tools binding: tools are disabled.") : L.T("Этот слот ещё закрыт.", "This slot is still locked.")); return false; } List<string> list2 = new List<string>(); for (int i = 0; i < list.Count; i++) { list2.Add(list[i].Tool); } if (!string.IsNullOrEmpty(toolName)) { for (int j = 0; j < list2.Count; j++) { if (j != slot && list2[j] == toolName) { list2[j] = ""; } } } list2[slot] = toolName ?? ""; ToolItemManager.SetEquippedTools(crest.name, list2); ToolItemManager.SendEquippedChangedEvent(false); message = (string.IsNullOrEmpty(toolName) ? L.T("Слот очищен.", "Slot cleared.") : (L.T("Инструмент надет: ", "Tool on: ") + ToolLabel(toolName))); return true; } catch (Exception ex) { Plugin.Caught("Build/SetSlot", ex); message = L.T("Не вышло: ", "Failed: ") + ex.Message; return false; } } internal static string Label(ToolCrest c) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null) { return ""; } try { string text = ((object)c.DisplayName/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrEmpty(text)) { return text; } } catch (Exception) { } return c.name; } internal static string ToolLabel(string toolName) { //IL_0020: 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) if (string.IsNullOrEmpty(toolName)) { return ""; } try { ToolItem toolByName = ToolItemManager.GetToolByName(toolName); if ((Object)(object)toolByName != (Object)null) { string text = ((object)toolByName.DisplayName/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrEmpty(text)) { return text; } } } catch (Exception) { } return toolName; } internal static string Variant() { int num = 0; for (int i = 0; i < BindingKeys.Length; i++) { if (Binding(i)) { num |= 1 << i; } } string skillsOff = Plugin.SkillsOff; if (num == cachedMask && string.Equals(skillsOff, cachedOff, StringComparison.Ordinal)) { return cachedVariant; } bool[] array = new bool[BindingKeys.Length]; for (int j = 0; j < array.Length; j++) { array[j] = (num & (1 << j)) != 0; } cachedMask = num; cachedOff = skillsOff; cachedVariant = BuildMath.Variant(array, skillsOff); return cachedVariant; } internal static bool SkillsApplied() { PlayerData instance = PlayerData.instance; string skillsOff = Plugin.SkillsOff; if (skillsOff.Length == 0) { return true; } if (instance == null) { return false; } Skill[] skills = Skills; foreach (Skill skill in skills) { if (BuildMath.HasSkill(skillsOff, skill.Code) && skill.Get(instance)) { return false; } } return true; } } internal static class GameSpeed { private const float CheckEvery = 0.1f; private const int LogLimit = 6; private static int percent = 100; private static float factor = 1f; private static bool failed; private static int calls; private static int direct; private static float written; private static float nextCheck; private static int reapplied; internal static int Percent => percent; internal static bool Broken => failed; internal static void Set(int newPercent) { int num = SpeedMath.Clamp(newPercent); if (num != percent) { percent = num; if (failed) { factor = 1f; return; } factor = SpeedMath.Factor(num); int num2 = calls; Refresh(); Plugin.Log.LogInfo((object)("Скорость игры: " + num + "% (Time.timeScale сейчас " + Time.timeScale + ", перехват сработал " + (calls - num2) + " раз, ScaleTime до этого " + direct + " раз)")); } } internal static void Tick() { if (factor == 1f || failed) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < nextCheck) { return; } nextCheck = unscaledTime + 0.1f; float timeScale = Time.timeScale; if (!(timeScale <= 0f) && !Mathf.Approximately(timeScale, written)) { int num = calls; Refresh(); reapplied++; if (reapplied <= 6) { Plugin.Log.LogInfo((object)("Скорость игры: время было сбито (" + timeScale + " вместо " + written + "), пересчитано заново: теперь " + Time.timeScale + ", перехват сработал " + (calls - num) + " раз, ScaleTime всего " + direct + " раз.")); } if (calls == num) { Fail(new InvalidOperationException("пересчёт времени не дошёл до перехвата (патч TimeManager.UpdateTimeScale не применился)")); } } } private static void Refresh() { if (failed) { return; } try { TimeManager.TimeScale = TimeManager.TimeScale; } catch (Exception ex) { Fail(ex); } } internal static void Fail(Exception ex) { if (failed) { return; } failed = true; factor = 1f; Plugin.Log.LogError((object)("Скорость игры: перехват сломался, скорость выключена: " + ex)); Plugin.Toast(L.T("Скорость игры сломалась и выключена (подробности в журнале)", "Game speed broke and is switched off (see the log)"), 8f); try { TimeManager.TimeScale = TimeManager.TimeScale; } catch (Exception) { } } internal static void Scale() { calls++; Apply(); } internal static void ScaleByAction() { direct++; Apply(); } private static void Apply() { if (failed || factor == 1f) { written = 0f; return; } float timeScale = Time.timeScale; if (timeScale <= 0f) { written = 0f; return; } Time.timeScale = timeScale * factor; written = Time.timeScale; } } internal static class GameSpeedPatches { [HarmonyPostfix] [HarmonyPatch(typeof(TimeManager), "UpdateTimeScale")] private static void AfterUpdateTimeScale() { try { GameSpeed.Scale(); } catch (Exception ex) { GameSpeed.Fail(ex); } } } internal static class GameSpeedActionPatches { [HarmonyPostfix] [HarmonyPatch(typeof(ScaleTime), "DoTimeScale")] private static void AfterScaleTime() { try { GameSpeed.ScaleByAction(); } catch (Exception ex) { GameSpeed.Fail(ex); } } } internal static class Icons { private static readonly Dictionary<string, Texture2D> baked = new Dictionary<string, Texture2D>(); private static readonly Dictionary<string, float> nextTry = new Dictionary<string, float>(); private static readonly List<string> wanted = new List<string>(); private static readonly HashSet<string> reported = new HashSet<string>(); private static Transform[] scan; private static Sprite[] spriteScan; private static int emptyDiag; private const float RetrySec = 3f; private const float ArtRetrySec = 8f; private const int PerPump = 6; private static readonly string[] BindingArt = new string[4] { "nail", "soul", "charm", "shell" }; private static Type tkDataType; private static Texture bakeSrc; private static RenderTexture bakeRt; internal static string BindingKey(int i, bool on) { return "bind" + i + (on ? "" : "off"); } internal static string NeedleKey(int level) { return "needle:" + (Mathf.Clamp(level, 0, 4) + 1); } internal static string GearKey(string name) { return "gear:" + name; } internal static string CloakKey(int state) { return "gear:cloak" + Mathf.Clamp(state, 0, 3); } internal static string CrestKey(string name) { return "crest:" + name; } internal static string ToolKey(string name) { return "tool:" + name; } internal static string ArtKey(string spriteName) { return "art:" + spriteName; } internal static string TkKey(string spriteName) { return "tk2d:" + spriteName; } internal static string SkillKey(string code) { return "skill:" + code; } internal static Texture2D Get(string key) { if (baked.TryGetValue(key, out var value)) { return value; } if (!wanted.Contains(key)) { wanted.Add(key); } return null; } internal static void Pump() { if (wanted.Count == 0) { return; } float unscaledTime = Time.unscaledTime; int num = 0; bool flag = false; scan = null; spriteScan = null; int num2 = wanted.Count - 1; while (num2 >= 0 && num < 6) { string text = wanted[num2]; if (!nextTry.TryGetValue(text, out var value) || !(unscaledTime < value)) { num++; Texture2D val = null; try { val = Make(text); } catch (Exception ex) { Plugin.Caught("Icons/" + text, ex); } if ((Object)(object)val != (Object)null) { baked[text] = val; wanted.RemoveAt(num2); } else { nextTry[text] = unscaledTime + ((text.StartsWith("art:") || text.StartsWith("tk2d:")) ? 8f : 3f); if (text.StartsWith("skill:") && text != SkillKey("strike")) { flag = true; } if (reported.Add("miss " + text)) { Plugin.Log.LogInfo((object)("Encore: значок «" + text + "» пока не найден (будет повтор)")); } } } num2--; } ReleaseBake(); spriteScan = null; if (flag && scan != null && !reported.Contains("diag")) { Diagnose(); } scan = null; } private static void Diagnose() { int num = 0; for (int i = 0; i < scan.Length; i++) { if (num >= 60) { break; } Transform val = scan[i]; if ((Object)(object)val == (Object)null || (Object)(object)val.parent == (Object)null) { continue; } string name = ((Object)val.parent).name; if (name != "Radial Layout" && name != "Cloak States") { continue; } SpriteRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<SpriteRenderer>(true); int num2 = 0; for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j].sprite != (Object)null) { num2++; } } Plugin.Log.LogInfo((object)("Encore: значки навыков — " + Path(val) + ": SpriteRenderer " + componentsInChildren.Length + ", со спрайтом " + num2)); num++; } if (num > 0) { reported.Add("diag"); return; } HashSet<string> hashSet = reported; int num3 = ++emptyDiag; if (hashSet.Add("diag-empty" + num3) && emptyDiag <= 2) { Plugin.Log.LogInfo((object)"Encore: значки навыков — в сцене нет предметов инвентаря (Radial Layout / Cloak States); откройте инвентарь в игре"); } } private static Texture2D Make(string key) { string note; if (key.StartsWith("tk2d:")) { Texture2D obj = MakeTk(key.Substring(5), out note); if ((Object)(object)obj != (Object)null && reported.Add("found " + key)) { Plugin.Log.LogInfo((object)("Encore: значок «" + key + "» ← " + note)); } return obj; } Sprite val = Find(key, out note); if ((Object)(object)val == (Object)null) { return null; } Texture2D obj2 = Bake(val, !key.StartsWith("art:") && !NoStrip(key)); if ((Object)(object)obj2 != (Object)null && reported.Add("found " + key)) { Plugin.Log.LogInfo((object)("Encore: значок «" + key + "» ← " + note)); } return obj2; } private static bool NoStrip(string key) { switch (key) { default: return key == "gear:pearl"; case "skill:strike": case "gear:orb": case "gear:ring": case "gear:wide": case "gear:slim": return true; } } private static Sprite Find(string key, out string note) { note = ""; if (key.StartsWith("bind")) { bool flag = key.EndsWith("off"); int num = key[4] - 48; if (num < 0 || num >= BindingArt.Length) { return null; } string text = "GG_UI_pieces_" + BindingArt[num] + (flag ? "_off" : ""); note = "GoP: " + text; return Bundle(text); } if (key.StartsWith("art:")) { return Art(key.Substring(4), out note); } if (key.StartsWith("needle:")) { return Inventory("Nail" + key.Substring(7), "Needle", out note); } if (key.StartsWith("gear:")) { return Gear(key.Substring(5), out note); } if (key.StartsWith("crest:")) { ToolCrest crestByName = ToolItemManager.GetCrestByName(key.Substring(6)); if ((Object)(object)crestByName == (Object)null) { return null; } note = "крест " + crestByName.name; return crestByName.CrestSprite; } if (key.StartsWith("tool:")) { ToolItem toolByName = ToolItemManager.GetToolByName(key.Substring(5)); if ((Object)(object)toolByName == (Object)null) { return null; } note = "инструмент " + toolByName.name; return toolByName.GetInventorySprite((IconVariants)0); } switch (key.StartsWith("skill:") ? key.Substring(6) : key) { case "dash": return Inventory("Sprint", out note); case "claw": return Inventory("Harpoon Dash", out note); case "eva": return Inventory("Eva Heal", out note); case "soar": return Inventory("Super Jump", out note); case "grip": return Inventory("Wall Jump", out note); case "needolin": return Inventory("Needolin", out note); case "drift": return Inventory("CloakState_1", out note); case "fay": return Inventory("CloakState_2", out note); case "strike": { note = "GoP: needle_charge_prompt"; Sprite val = Bundle("needle_charge_prompt"); if (!((Object)(object)val != (Object)null)) { return Inventory("Needle Art", out note); } return val; } default: return null; } } private static Sprite Gear(string name, out string note) { note = ""; switch (name) { case "heart": return Inventory("Pieces 4", "Heart Pieces", out note); case "silk": return Inventory("Full", "Spool Pieces", out note); case "regen": return Inventory("Spool", "Spool Group", out note); case "orb": return Direct("New Item Orb", "Needle", out note); case "ring": return Direct("Icon Ring", "Spool Group", out note); case "wide": return Direct("Wide", "Spool", out note); case "slim": return Direct("Slim", "Spool", out note); case "pearl": return Direct("Left", "Heart", out note); case "pouch": note = "GoP: tools_bug_upgrade"; return Bundle("tools_bug_upgrade"); case "kit": note = "GoP: tools_upgrade_sack"; return Bundle("tools_upgrade_sack"); case "crestless": note = "GoP: cloakless_hornet_attack"; return Bundle("cloakless_hornet_attack"); case "cursed": note = "GoP: CurseWitch"; return Bundle("CurseWitch"); case "cloak0": case "cloak1": case "cloak2": case "cloak3": note = "GoP: CloakState_" + name[5]; return Bundle("CloakState_" + name[5]); default: return null; } } private static Sprite Art(string name, out string note) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) note = ""; if (spriteScan == null) { spriteScan = Resources.FindObjectsOfTypeAll<Sprite>(); } string text = name + "(Clone)"; Sprite val = null; Rect rect; for (int i = 0; i < spriteScan.Length; i++) { Sprite val2 = spriteScan[i]; if ((Object)(object)val2 == (Object)null) { continue; } string name2 = ((Object)val2).name; if (name2 != name && name2 != text) { continue; } if (!((Object)(object)val == (Object)null)) { rect = val2.rect; float width = ((Rect)(ref rect)).width; rect = val2.rect; float num = width * ((Rect)(ref rect)).height; rect = val.rect; float width2 = ((Rect)(ref rect)).width; rect = val.rect; if (!(num > width2 * ((Rect)(ref rect)).height)) { continue; } } val = val2; } if ((Object)(object)val != (Object)null) { string[] obj = new string[6] { "спрайт ", ((Object)val).name, " ", null, null, null }; rect = val.rect; obj[3] = ((int)((Rect)(ref rect)).width).ToString(); obj[4] = "x"; rect = val.rect; obj[5] = ((int)((Rect)(ref rect)).height).ToString(); note = string.Concat(obj); } return val; } private static Sprite Direct(string objectName, string parentName, out string note) { note = ""; if (scan == null) { scan = Resources.FindObjectsOfTypeAll<Transform>(); } for (int i = 0; i < scan.Length; i++) { Transform val = scan[i]; if (!((Object)(object)val == (Object)null) && !(((Object)val).name != objectName) && !((Object)(object)val.parent == (Object)null) && !(((Object)val.parent).name != parentName)) { SpriteRenderer component = ((Component)val).GetComponent<SpriteRenderer>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sprite == (Object)null)) { note = "инвентарь: " + Path(val) + " (спрайт " + ((Object)component.sprite).name + ")"; return component.sprite; } } } return null; } private static Texture2D MakeTk(string name, out string note) { //IL_0247: Unknown result type (might be due to invalid IL or missing references) note = ""; if (tkDataType == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { if (!(tkDataType == null)) { break; } try { tkDataType = assemblies[i].GetType("tk2dSpriteCollectionData"); } catch (Exception) { } } if (tkDataType == null) { return null; } } Object[] array = Resources.FindObjectsOfTypeAll(tkDataType); FieldInfo field = tkDataType.GetField("spriteDefinitions"); if (field == null) { return null; } Rect r = default(Rect); for (int j = 0; j < array.Length; j++) { if (array[j] == (Object)null || !(field.GetValue(array[j]) is Array array2)) { continue; } for (int k = 0; k < array2.Length; k++) { object value = array2.GetValue(k); if (value == null) { continue; } Type type = value.GetType(); string text = type.GetField("name").GetValue(value) as string; if (text != name) { continue; } Vector2[] array3 = type.GetField("uvs").GetValue(value) as Vector2[]; object? value2 = type.GetField("material").GetValue(value); Material val = (Material)((value2 is Material) ? value2 : null); if (array3 != null && array3.Length >= 3 && !((Object)(object)val == (Object)null) && !((Object)(object)val.mainTexture == (Object)null)) { Texture mainTexture = val.mainTexture; float num = 1f; float num2 = 0f; float num3 = 1f; float num4 = 0f; for (int l = 0; l < array3.Length; l++) { num = Mathf.Min(num, array3[l].x); num2 = Mathf.Max(num2, array3[l].x); num3 = Mathf.Min(num3, array3[l].y); num4 = Mathf.Max(num4, array3[l].y); } ((Rect)(ref r))..ctor(Mathf.Round(num * (float)mainTexture.width), Mathf.Round(num3 * (float)mainTexture.height), Mathf.Round((num2 - num) * (float)mainTexture.width), Mathf.Round((num4 - num3) * (float)mainTexture.height)); Texture2D val2 = BakeRegion(mainTexture, r); if ((Object)(object)val2 == (Object)null) { return null; } int num5 = Convert.ToInt32(type.GetField("flipped").GetValue(value)); if (num5 == 1) { val2 = TurnLeft(val2); } note = "tk2d " + text + " " + ((Texture)val2).width + "x" + ((Texture)val2).height + ((num5 == 1) ? " (повёрнут)" : ""); return val2; } } } return null; } private static Texture2D TurnLeft(Texture2D tex) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) int width = ((Texture)tex).width; int height = ((Texture)tex).height; Color32[] pixels = tex.GetPixels32(); Color32[] array = (Color32[])(object)new Color32[pixels.Length]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { array[j * height + (height - 1 - i)] = pixels[i * width + j]; } } Texture2D val = new Texture2D(height, width, (TextureFormat)4, false); val.SetPixels32(array); val.Apply(false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Object.Destroy((Object)(object)tex); return val; } private static Sprite Bundle(string name) { if (Preload.bundleResources == null) { return null; } if (!Preload.bundleResources.TryGetValue(name, out var value)) { return null; } return (Sprite)((value is Sprite) ? value : null); } private static Sprite Inventory(string objectName, out string note) { return Inventory(objectName, null, out note); } private static Sprite Inventory(string objectName, string parentName, out string note) { note = ""; if (scan == null) { scan = Resources.FindObjectsOfTypeAll<Transform>(); } int num = ((parentName != null) ? 1 : 2); for (int i = 0; i < num; i++) { for (int j = 0; j < scan.Length; j++) { Transform val = scan[j]; if ((Object)(object)val == (Object)null || ((Object)val).name != objectName) { continue; } if (parentName != null) { if ((Object)(object)val.parent == (Object)null || ((Object)val.parent).name != parentName) { continue; } } else if (i == 0) { string text = (((Object)(object)val.parent != (Object)null) ? ((Object)val.parent).name : ""); if (text != "Radial Layout" && text != "Cloak States") { continue; } } Sprite val2 = IconOf(val); if (!((Object)(object)val2 == (Object)null)) { note = "инвентарь: " + Path(val) + " (спрайт " + ((Object)val2).name + ")"; return val2; } } } return null; } private static Sprite IconOf(Transform t) { //IL_00cf: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer[] componentsInChildren = ((Component)t).GetComponentsInChildren<SpriteRenderer>(true); Sprite result = null; float num = -1f; foreach (SpriteRenderer val in componentsInChildren) { Sprite sprite = val.sprite; if ((Object)(object)sprite == (Object)null) { continue; } string text = ((Object)val).name.ToLowerInvariant(); if (!text.Contains("orb") && !text.Contains("flash") && !text.Contains("glow") && !text.Contains("frame") && !text.Contains("back") && !text.Contains("shadow") && !text.Contains("select") && !text.Contains("arrow") && !text.Contains("amount")) { Rect rect = sprite.rect; float width = ((Rect)(ref rect)).width; rect = sprite.rect; float num2 = width * ((Rect)(ref rect)).height + ((text == "icon") ? 1E+09f : 0f); if (num2 > num) { num = num2; result = sprite; } } } return result; } private static string Path(Transform t) { string text = ((Object)t).name; int num = 0; while ((Object)(object)t.parent != (Object)null && num < 6) { t = t.parent; text = ((Object)t).name + "/" + text; num++; } return text; } private static void DropStrays(Texture2D tex) { int width = ((Texture)tex).width; int height = ((Texture)tex).height; if (width < 8 || height < 8 || width * height > 1048576) { return; } Color32[] pixels = tex.GetPixels32(); int num = pixels.Length; int[] array = new int[num]; int[] array2 = new int[num]; List<int> list = new List<int>(); List<bool> list2 = new List<bool>(); for (int i = 0; i < num; i++) { if (pixels[i].a < 24 || array[i] != 0) { continue; } int num2 = list.Count + 1; int num3 = 0; int num4 = 0; bool item = false; array2[num3++] = i; array[i] = num2; while (num3 > 0) { int num5 = array2[--num3]; num4++; int num6 = num5 % width; int num7 = num5 / width; if (num6 == 0 || num7 == 0 || num6 == width - 1 || num7 == height - 1) { item = true; } for (int j = -1; j <= 1; j++) { int num8 = num7 + j; if (num8 < 0 || num8 >= height) { continue; } for (int k = -1; k <= 1; k++) { int num9 = num6 + k; if (num9 >= 0 && num9 < width && (k != 0 || j != 0)) { int num10 = num8 * width + num9; if (array[num10] == 0 && pixels[num10].a >= 24) { array[num10] = num2; array2[num3++] = num10; } } } } } list.Add(num4); list2.Add(item); } if (list.Count < 2) { return; } int num11 = 0; for (int l = 0; l < list.Count; l++) { if (list[l] > num11) { num11 = list[l]; } } bool flag = false; for (int m = 0; m < num; m++) { int num12 = array[m]; if (num12 != 0 && list2[num12 - 1] && (float)list[num12 - 1] < (float)num11 * 0.15f) { pixels[m].a = 0; flag = true; } } if (flag) { tex.SetPixels32(pixels); tex.Apply(false); } } private static void ReleaseBake() { if ((Object)(object)bakeRt != (Object)null) { RenderTexture.ReleaseTemporary(bakeRt); } bakeRt = null; bakeSrc = null; } private static Texture2D Bake(Sprite sprite, bool strip) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) Texture2D texture = sprite.texture; if ((Object)(object)texture == (Object)null) { return null; } Texture2D val = BakeRegion((Texture)(object)texture, sprite.textureRect); if ((Object)(object)val != (Object)null && strip) { DropStrays(val); } return val; } private static Texture2D BakeRegion(Texture src, Rect r) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown int num = Mathf.Max(1, (int)((Rect)(ref r)).width); int num2 = Mathf.Max(1, (int)((Rect)(ref r)).height); RenderTexture active = RenderTexture.active; try { if ((Object)(object)bakeRt == (Object)null || (Object)(object)bakeSrc != (Object)(object)src) { ReleaseBake(); bakeRt = RenderTexture.GetTemporary(src.width, src.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)0); Graphics.Blit(src, bakeRt); bakeSrc = src; } RenderTexture.active = bakeRt; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); val.ReadPixels(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, (float)num, (float)num2), 0, 0); val.Apply(false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; return val; } finally { RenderTexture.active = active; } } } internal static class Immortal { private sealed class Verdict { internal bool Target; internal int LastHp; } private const int LogLimit = 24; private static bool armed; private static string scene; private static int floor = 50; private static int[] summonHp; private static int logged; private static bool failed; private static readonly Dictionary<int, Verdict> verdicts = new Dictionary<int, Verdict>(); private static MethodInfo scaling; private static bool scalingLooked; internal static bool Armed => armed; internal static void Arm(string bossName, string sceneName, bool on, int customHp, int[] summons) { Disarm(); if (on && !failed && PhaseLock.ImmortalCapable(bossName)) { armed = true; scene = sceneName; floor = ImmortalMath.Floor(customHp); summonHp = summons; Plugin.Log.LogInfo((object)("Бессмертие: " + bossName + " (порог босса " + floor + " здоровья)")); Runner.MarkPractice(); } } internal static void LeaveScene(string newScene) { if (armed && !Rooms.Same(newScene, scene)) { Disarm(); } } internal static void Disarm() { armed = false; scene = null; floor = 50; summonHp = null; logged = 0; verdicts.Clear(); } internal static bool Guards(HealthManager hm) { if (!armed || (Object)(object)hm == (Object)null) { return false; } int hp = hm.hp; if (hp <= 0) { return false; } int instanceID = ((Object)hm).GetInstanceID(); if (!verdicts.TryGetValue(instanceID, out var value) || hp > value.LastHp) { value = new Verdict(); value.Target = ImmortalMath.IsBoss(hp, floor, summonHp); verdicts[instanceID] = value; if (logged < 24) { logged++; Plugin.Log.LogInfo((object)("Бессмертие: «" + ((Object)((Component)hm).gameObject).name + "» здоровье " + hp + " — " + (value.Target ? "босс, защищаю" : "не босс, не трогаю"))); } } value.LastHp = hp; return value.Target; } internal static void Fail(Exception ex) { if (!failed) { failed = true; armed = false; Plugin.Log.LogError((object)("Бессмертие остановлено: " + ex)); } } internal static HitInstance Scaled(HealthManager hm, HitInstance hit) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!scalingLooked) { scalingLooked = true; try { scaling = typeof(HealthManager).GetMethod("ApplyDamageScaling", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(HitInstance) }, null); } catch (Exception) { scaling = null; } } if (scaling == null) { return hit; } try { return (HitInstance)scaling.Invoke(hm, new object[1] { hit }); } catch (Exception) { return hit; } } } internal static class ImmortalPatches { [HarmonyPrefix] [HarmonyPatch(typeof(HealthManager), "TakeDamage")] private static void BeforeTakeDamage(HealthManager __instance, ref HitInstance hitInstance) { try { if (Immortal.Guards(__instance)) { hitInstance.NonLethal = true; } } catch (Exception ex) { Immortal.Fail(ex); } } [HarmonyPrefix] [HarmonyPatch(typeof(HealthManager), "ApplyExtraDamage", new Type[] { typeof(int) })] private static void BeforeExtraInt(HealthManager __instance, ref int damageAmount) { try { if (Immortal.Guards(__instance)) { damageAmount = ImmortalMath.Allowed(__instance.hp, damageAmount); } } catch (Exception ex) { Immortal.Fail(ex); } } [HarmonyPrefix] [HarmonyPatch(typeof(HealthManager), "ApplyExtraDamage", new Type[] { typeof(HitInstance) })] private static bool BeforeExtraHit(HealthManager __instance, HitInstance hitInstance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) try { if (!Immortal.Guards(__instance)) { return true; } HitInstance val = Immortal.Scaled(__instance, hitInstance); __instance.hp -= ImmortalMath.Allowed(__instance.hp, val.DamageDealt); return false; } catch (Exception ex) { Immortal.Fail(ex); return true; } } } internal static class L { private static string mode = "auto"; private static bool known; private static bool ru; internal static string Mode { get { return mode; } set { mode = value; known = false; } } internal static bool IsRu { get { if (!known) { ru = Detect(); known = true; } return ru; } } internal static string T(string ru, string en) { if (!IsRu) { return en; } return ru; } private static bool Detect() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 if (mode == "ru") { return true; } if (mode == "en") { return false; } SystemLanguage systemLanguage = Application.systemLanguage; if ((int)systemLanguage != 30 && (int)systemLanguage != 38) { return (int)systemLanguage == 3; } return true; } } internal static class Load { private const float ReportEverySec = 30f; internal static bool On; private static long frameTicks; private static long sumTicks; private static long worstTicks; private static int frames; private static int draws; private static float windowStart = -1f; private static long startTotal; private static long startLast; private static readonly StringBuilder laps = new StringBuilder(); internal static void StartBegin() { startTotal = Stopwatch.GetTimestamp(); startLast = startTotal; laps.Length = 0; } internal static void Lap(string name) { long timestamp = Stopwatch.GetTimestamp(); if (laps.Length > 0) { laps.Append(", "); } laps.Append(name).Append(' ').Append(Ms(timestamp - startLast)); startLast = timestamp; } internal static string StartReport() { return "Запуск мода занял " + Ms(Stopwatch.GetTimestamp() - startTotal) + " мс (" + laps?.ToString() + ")"; } internal static string Ms(long ticks) { return ((double)ticks * 1000.0 / (double)Stopwatch.Frequency).ToString("0.0"); } internal static long Begin() { if (!On) { return 0L; } return Stopwatch.GetTimestamp(); } internal static void End(long started) { if (On && started != 0L) { frameTicks += Stopwatch.GetTimestamp() - started; } } internal static void CountDraw() { if (On) { draws++; } } internal static void NextFrame() { if (!On) { windowStart = -1f; return; } if (windowStart < 0f) { Reset(); return; } sumTicks += frameTicks; if (frameTicks > worstTicks) { worstTicks = frameTicks; } frameTicks = 0L; frames++; float num = Time.unscaledTime - windowStart; if (!(num < 30f)) { double num2 = 1000.0 / (double)Stopwatch.Frequency; string text = ((double)sumTicks * num2 / (double)frames).ToString("0.0000"); string text2 = ((double)worstTicks * num2).ToString("0.000"); Plugin.Log.LogInfo((object)("Нагрузка за " + num.ToString("0") + " с (" + ((float)frames / num).ToString("0") + " кадров/с): в среднем " + text + " мс на кадр, худший кадр " + text2 + " мс; окно и плашки рисовались " + draws + " раз")); Reset(); } } private static void Reset() { frameTicks = 0L; sumTicks = 0L; worstTicks = 0L; frames = 0; draws = 0; windowStart = Time.unscaledTime; } } internal sealed class Menu { private sealed class BossLayout { internal float rowH; internal float sumH; internal float hpH; internal float numberW; internal float nameX; internal float countX; internal float buttonsX; internal float btnH; internal float gap; internal float fullW; internal float fullX; internal float width; internal float headH; internal float msgH; internal string info; } private sealed class StatRow { internal string Number; internal string Name; internal string Difficulty; internal string[] Cells; } private const float DeleteConfirmSec = 3f; private const float FadeSec = 0.12f; private const int NameMaxLength = 40; private const string NameField = "encore-name"; private const string RandomField = "encore-random"; private const string SeedField = "encore-seed"; internal bool Open; private List<string> catalog = new List<string>(); private Vector2 scrollPresets; private Vector2 scrollEntries; private Vector2 scrollCatalog; private string nameEdit = ""; private string randomEdit = ""; private string seedEdit = ""; private bool seedTyped; private Preset nameEditFor; private Preset deleteArmed; private float deleteArmedUntil; private string status = ""; private float openedAt; private string summaryText; private int summaryBosses; private int summaryBenches; private bool summaryRu; private readonly TextWidth startTextW = new TextWidth(); private readonly TextWidth startKeyW = new TextWidth(); private readonly TextWidth closeTextW = new TextWidth(); private readonly TextWidth closeKeyW = new TextWidth(); private bool cursorWasVisible; private CursorLockMode cursorWasLocked; private HeroController blockedHero; private bool catalogReported; private bool showBosses; private Vector2 scrollBosses; private readonly Dictionary<Entry, string> hpEdit = new Dictionary<Entry, string>(); private readonly Dictionary<Entry, string[]> shpEdit = new Dictionary<Entry, string[]>(); private readonly HashSet<Entry> folded = new HashSet<Entry>(); private bool byPreset; private readonly Dictionary<string, Entry> proxies = new Dictionary<string, Entry>(); private readonly HashSet<Preset> foldedPresets = new HashSet<Preset>(); private const float PresetHeadH = 44f; private const float PresetMsgH = 38f; private const float ChLabelW = 104f; private const float ChBtnW = 32f; private const float ChBtnGap = 3f; private const float ChValW = 58f; private const float ChGroupGap = 14f; private const float ChAsIsW = 140f; private const float ChAsIsX = 200f; private const float BossSetRowH = 54f; private const float BossBtnH = 34f; private const float BossBtnGap = 8f; private const float BossAllW = 100f; private const float BossNumW = 64f; private const float BossFullW = 250f; private const float BossNameW = 400f; private const float BossCountW = 110f; private const float BossArrowW = 44f; private const float SumRowH = 42f; private const float SumLabelW = 130f; private const float SumVanillaW = 130f; private const float SumNumW = 64f; private const float SumOffW = 90f; private const float SumGroupGap = 28f; private const float HpRowH = 42f; private const float HpFieldW = 110f; private const int AtkPerLine = 5; private const float SumHpLabelW = 172f; private const float SumHpFieldW = 80f; private const float SumHpHintW = 50f; private const float SumHpGroupGap = 14f; private bool showBuild; private const float FrameX0 = 40f; private const float FrameY0 = 142f; private const float FrameX1 = 1660f; private const float FrameY1 = 888f; private const float RefK = 0.862f; private const float FrameK = 0.829f; private const float LeftAt = 70f; private const float MidAt = 956f; private const float DivX1 = 650f; private const float DivX2 = 1262f; private const float InfoX = 1286f; private const float InfoW = 352f; private const float BindD = 92f; private const float CrestD = 66f; private const float SlotD = 70f; private const float ToolD = 52f; private const float TileGap = 8f; private const float BuildBtnGap = 10f; private const int KindBinding = 1; private const int KindSkill = 2; private const int KindGear = 3; private const int KindCloak = 4; private const int KindSpecial = 5; private const int KindCrest = 6; private const int KindSlot = 7; private const int KindTool = 8; private int hoverKind; private int hoverIndex; private int selKind = 1; private int selIndex; private const int LookRing = 0; private const int LookBoard = 1; private const int LookBare = 2; private int pickSlot = -1; private string pickCrest = ""; private List<ToolItem> pickList = new List<ToolItem>(); private ToolItemType pickType; private float pickAt = -10f; private bool pickHas; private const float WinW = 1700f; private const float WinH = 968f; private const float Pad = 28f; private const float Top = 140f; private const float TabsY = 104f; private const float TabH = 30f; private const float TabW = 200f; private const float TabGap = 8f; private const int TabCount = 4; private const float Foot = 46f; private const float FootPad = 84f; private const float RuleInset = 10f; private const float Col1W = 400f; private const float Col2W = 760f; private const float Gap = 20f; private const float Col1X = 28f; private const float Col2X = 448f; private const float Col3X = 1228f; private const float Col3W = 444f; private const float ColH = 734f; private const float Inner = 16f; private const float ListTop = 192f; private const float PresetRowH = 38f; private const float EntryRowH = 40f; private const float BossRowH = 34f; private const float ButtonH = 38f; private const float ChipW = 128f; private const float IconGap = 6f; private const float StartW = 290f; private const float CloseW = 230f; private const float HitlessW = 370f; private const float StopW = 210f; private const float PhaseTagW = 170f; private const string HiddenName = "? ? ?"; private float originX; private float originY; private float fade; private const float StatsW = 1224f;