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 NokepMagicStaffs v1.0.0
plugins\NokepMagic.dll
Decompiled 3 hours 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.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using NokepCommon; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace NokepCommon { internal static class Icons { private static readonly Dictionary<string, Sprite> cache = new Dictionary<string, Sprite>(); public static Sprite Get(string name) { if (cache.TryGetValue(name, out var value)) { return value; } Sprite val = Load(name); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Иконка " + name + " не загрузилась")); } cache[name] = val; return val; } private static Sprite Load(string name) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetName().Name + ".Assets." + name.Replace("/", ".") + ".png"; using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream == null) { Logger.LogWarning((object)("Не нашёл ресурс " + text)); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = AssetUtils.LoadImage(array); if ((Object)(object)val == (Object)null) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } public static void LogResourceNames() { string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); Logger.LogInfo((object)("Встроенные ресурсы: " + string.Join(", ", manifestResourceNames))); } } internal static class Translations { private static readonly string[] Languages = new string[3] { "English", "Russian", "German" }; public static void Load() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetName().Name; string[] languages = Languages; foreach (string text in languages) { string text2 = name + ".Translations." + text + ".strings.json"; using Stream stream = executingAssembly.GetManifestResourceStream(text2); if (stream == null) { Logger.LogWarning((object)("Не нашёл перевод " + text2)); continue; } using StreamReader streamReader = new StreamReader(stream); localization.AddJsonFile(text, streamReader.ReadToEnd()); } } public static string Get(string text) { return Localization.instance.Localize(text); } } internal static class NokepUtils { public static Dictionary<string, int> ParseRecipe(string text) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); if (string.IsNullOrEmpty(text)) { return dictionary; } string[] array = text.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(new char[1] { ':' }); if (array2.Length == 2) { string text2 = array2[0].Trim(); if (text2.Length != 0 && int.TryParse(array2[1].Trim(), out var result) && result >= 1) { dictionary[text2] = result; } } } return dictionary; } } internal enum DamageGroup { Melee, Ranged, Magic } internal static class DamageGroups { private static readonly Dictionary<DamageGroup, HashSet<SkillType>> GroupSkills = new Dictionary<DamageGroup, HashSet<SkillType>> { [DamageGroup.Melee] = new HashSet<SkillType> { (SkillType)1, (SkillType)2, (SkillType)3, (SkillType)7, (SkillType)4, (SkillType)5, (SkillType)11 }, [DamageGroup.Ranged] = new HashSet<SkillType> { (SkillType)8, (SkillType)14 }, [DamageGroup.Magic] = new HashSet<SkillType> { (SkillType)9, (SkillType)10 } }; private static readonly Dictionary<int, Dictionary<DamageGroup, float>> Bonuses = new Dictionary<int, Dictionary<DamageGroup, float>>(); public static void Set(StatusEffect effect, DamageGroup group, float percent) { int key = effect.NameHash(); if (!Bonuses.TryGetValue(key, out var value)) { value = (Bonuses[key] = new Dictionary<DamageGroup, float>()); } if (percent == 0f) { value.Remove(group); } else { value[group] = percent; } } public static IEnumerable<KeyValuePair<DamageGroup, float>> Get(StatusEffect effect) { if (Bonuses.TryGetValue(effect.NameHash(), out var value)) { return value; } return new KeyValuePair<DamageGroup, float>[0]; } public static float Multiplier(StatusEffect effect, SkillType skill) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!Bonuses.TryGetValue(effect.NameHash(), out var value)) { return 1f; } float num = 0f; foreach (KeyValuePair<DamageGroup, float> item in value) { if (GroupSkills[item.Key].Contains(skill)) { num += item.Value; } } return 1f + num / 100f; } } [HarmonyPatch(typeof(SE_Stats), "ModifyAttack")] internal static class DamageGroups_ModifyAttack { private static void Postfix(SE_Stats __instance, SkillType skill, ref HitData hitData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float num = DamageGroups.Multiplier((StatusEffect)(object)__instance, skill); if (num != 1f) { ((DamageTypes)(ref hitData.m_damage)).Modify(num); } } } internal abstract class CraftTabSource { public abstract int Count { get; } public abstract KeyCode NextKey { get; } public abstract KeyCode PrevKey { get; } public abstract string Name(int page); public abstract bool IsActive(CraftingStation station); public abstract int PageOf(Recipe recipe); public virtual void OnStationOpened(CraftingStation station) { } } internal static class CraftTabs { private const float Width = 130f; private const float Gap = 8f; private static CraftTabSource source; private static string buttonPrefix; public static int Current; private static bool[] present; private static int presentCount; private static CraftingStation openStation; private static CraftingStation checkedStation; private static bool checkedActive; private static GameObject prevButton; private static GameObject nextButton; private static TMP_Text prevText; private static TMP_Text nextText; public static string CurrentName => source.Name(Current); public static void Install(Harmony harmony, CraftTabSource tabSource, string namePrefix) { source = tabSource; buttonPrefix = namePrefix; present = new bool[source.Count]; Patch(harmony, "Awake", null, "AwakePostfix"); Patch(harmony, "Update", null, "UpdatePostfix"); Patch(harmony, "UpdateRecipeList", "RecipeListPrefix"); Patch(harmony, "UpdateRecipe", null, "TitlePostfix"); } private static void Patch(Harmony harmony, string method, string prefix = null, string postfix = null) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) harmony.Patch((MethodBase)AccessTools.Method(typeof(InventoryGui), method, (Type[])null, (Type[])null), (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(CraftTabs), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(CraftTabs), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static CraftingStation ActiveStation() { Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)val == (Object)null) { return null; } if ((Object)(object)val != (Object)(object)checkedStation) { checkedStation = val; checkedActive = source.IsActive(val); } if (!checkedActive) { return null; } return val; } public static void ResetCache() { checkedStation = null; openStation = null; } private static int Step(int dir) { int count = source.Count; int num = Current; for (int i = 0; i < count; i++) { num = (num + dir + count) % count; if (present[num]) { return num; } } return Current; } private static void Go(InventoryGui gui, int dir) { Current = Step(dir); gui.UpdateCraftingPanel(true); } private static void RecipeListPrefix(InventoryGui __instance, List<Recipe> recipes) { if (!__instance.InCraftTab()) { return; } CraftingStation val = ActiveStation(); if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)val != (Object)(object)openStation) { openStation = val; Current = 0; source.OnStationOpened(val); } Array.Clear(present, 0, present.Length); present[0] = true; foreach (Recipe recipe in recipes) { if ((Object)(object)recipe != (Object)null) { present[Clamp(source.PageOf(recipe))] = true; } } presentCount = 0; bool[] array = present; for (int i = 0; i < array.Length; i++) { if (array[i]) { presentCount++; } } if (!present[Current]) { Current = 0; } if (Current != 0) { recipes.RemoveAll((Recipe r) => (Object)(object)r == (Object)null || Clamp(source.PageOf(r)) != Current); } } private static int Clamp(int page) { if (page >= 1 && page < source.Count) { return page; } return source.Count - 1; } private static void TitlePostfix(InventoryGui __instance) { if (__instance.InCraftTab() && !((Object)(object)ActiveStation() == (Object)null)) { TMP_Text craftingStationName = __instance.m_craftingStationName; craftingStationName.text = craftingStationName.text + " — " + CurrentName; if ((Object)(object)prevText != (Object)null) { prevText.text = "← " + source.Name(Step(-1)); } if ((Object)(object)nextText != (Object)null) { nextText.text = source.Name(Step(1)) + " →"; } } } private static void UpdatePostfix(InventoryGui __instance) { //IL_005d: 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) bool num = InventoryGui.IsVisible(); if (!num) { openStation = null; } bool flag = num && __instance.InCraftTab() && (Object)(object)ActiveStation() != (Object)null && presentCount > 1; Show(prevButton, flag); Show(nextButton, flag); if (flag && !__instance.m_splitDialog.IsActive) { if (ZInput.GetKeyDown(source.NextKey, true)) { Go(__instance, 1); } else if (ZInput.GetKeyDown(source.PrevKey, true)) { Go(__instance, -1); } } } private static void AwakePostfix(InventoryGui __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown RectTransform parent = (RectTransform)((Component)__instance.m_tabUpgrade).transform; prevButton = MakeButton(__instance, parent, buttonPrefix + "Prev", (UnityAction)delegate { Go(__instance, -1); }); PlaceInTabRow(prevButton, 8f); nextButton = MakeButton(__instance, parent, buttonPrefix + "Next", (UnityAction)delegate { Go(__instance, 1); }); PlaceInTabRow(nextButton, 142f); prevText = prevButton.GetComponentInChildren<TMP_Text>(true); nextText = nextButton.GetComponentInChildren<TMP_Text>(true); TMP_Text craftingStationName = __instance.m_craftingStationName; if ((Object)(object)craftingStationName != (Object)null && !craftingStationName.enableAutoSizing) { craftingStationName.fontSizeMax = craftingStationName.fontSize; craftingStationName.fontSizeMin = Mathf.Min(12f, craftingStationName.fontSize); craftingStationName.enableAutoSizing = true; } } private static void PlaceInTabRow(GameObject go, float offset) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0055: 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) RectTransform val = (RectTransform)go.transform; val.anchorMin = new Vector2(1f, 0f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(0f, 0.5f); val.sizeDelta = new Vector2(130f, 0f); val.anchoredPosition = new Vector2(offset, 0f); } private static GameObject MakeButton(InventoryGui gui, RectTransform parent, string name, UnityAction onClick) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)gui.m_tabCraft).gameObject, (Transform)(object)parent); ((Object)val).name = name; UIGamePad[] componentsInChildren = val.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val2 in componentsInChildren) { if ((Object)(object)val2.m_hint != (Object)null) { Object.DestroyImmediate((Object)(object)val2.m_hint); } Object.DestroyImmediate((Object)(object)val2); } MonoBehaviour[] componentsInChildren2 = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val3 in componentsInChildren2) { if (((object)val3).GetType().Name == "Localize") { Object.DestroyImmediate((Object)(object)val3); } } TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontSizeMax = componentInChildren.fontSize; componentInChildren.fontSizeMin = 10f; componentInChildren.enableAutoSizing = true; } val.transform.localScale = Vector3.one; Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((Selectable)component).interactable = true; ((UnityEvent)component.onClick).AddListener(onClick); val.SetActive(false); return val; } private static void Show(GameObject go, bool visible) { if ((Object)(object)go != (Object)null && go.activeSelf != visible) { go.SetActive(visible); } } } } namespace NokepMagic { internal static class Enchant { private const string StaffPrefix = "Nokep_Staff_"; private static Recipe probe; public static bool IsBlank(ItemData item) { if (item != null) { return item.m_shared.m_name == "$nokep_magic_staff_blank"; } return false; } public static bool TryGetStaff(ItemData item, out StaffType type, out int level) { type = null; level = 0; string text = (((Object)(object)item?.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : null); if (text == null || !text.StartsWith("Nokep_Staff_")) { return false; } string[] array = text.Substring("Nokep_Staff_".Length).Split(new char[1] { '_' }); if (array.Length != 2 || !int.TryParse(array[1], out level)) { return false; } string element = array[0]; type = Plugin.StaffTypes.Find((StaffType t) => t.Element == element); return type != null; } public static Sprite IconOf(StaffType type, int level) { GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(type.Prefab(level)) : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if (!((Object)(object)val2 != (Object)null)) { return null; } return val2.m_itemData.GetIcon(); } public static bool CanGoInSlot(ItemData item) { StaffType type; int level; if (!IsBlank(item)) { return TryGetStaff(item, out type, out level); } return true; } public static List<Requirement> Cost(StaffType type, int level) { List<Requirement> list = new List<Requirement>(); if ((Object)(object)ObjectDB.instance != (Object)null) { Recipes.AddItems(list, NokepUtils.ParseRecipe(type.Cost(level))); } return list; } public static bool HaveAll(Player player, List<Requirement> cost) { if (player.NoCostCheat()) { return true; } foreach (Requirement item in cost) { if (!HasEnough(player, item)) { return false; } } return true; } public static bool HasEnough(Player player, Requirement req) { if ((Object)(object)probe == (Object)null) { probe = ScriptableObject.CreateInstance<Recipe>(); ((Object)probe).name = "NokepMagic_CostCheck"; } GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("Nokep_Staff_Blank") : null); probe.m_item = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); probe.m_amount = 1; probe.m_requireOnlyOneIngredient = false; probe.m_resources = (Requirement[])(object)new Requirement[1] { req }; return player.HaveRequirementItems(probe, false, 1, 1); } public static string CostText(Player player, List<Requirement> cost) { if (Plugin.FreeForTesting) { return "<color=#7CFC7C>" + Translations.Get("$nokep_magic_free") + "</color>"; } StringBuilder stringBuilder = new StringBuilder(); Inventory inventory = ((Humanoid)player).GetInventory(); foreach (Requirement item in cost) { string name = item.m_resItem.m_itemData.m_shared.m_name; int num = inventory.CountItems(name, -1, true); string arg = (HasEnough(player, item) ? "#FFFFFF" : "#FF5050"); if (stringBuilder.Length > 0) { stringBuilder.Append('\n'); } stringBuilder.Append($"<color={arg}>{Translations.Get(name)} {item.m_amount}</color> " + string.Format("({0} {1})", Translations.Get("$nokep_magic_have"), num)); } return stringBuilder.ToString(); } public static bool Apply(Player player, CraftingStation station, ItemData item, StaffType type, int level) { //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = ((Humanoid)player).GetInventory(); if (item == null || !inventory.ContainsItem(item) || level < 1 || level > 7) { return false; } bool num; if (!IsBlank(item)) { if (!TryGetStaff(item, out var type2, out var level2) || type2 != type) { goto IL_004a; } num = level == level2 + 1; } else { num = level == 1; } if (num) { if (!station.CheckUsable(player, true)) { return false; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(type.Prefab(level)); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Logger.LogError((object)("Нет префаба " + type.Prefab(level))); return false; } if (StationLevel.Get(station) < type.RequiredBench(level)) { ((Character)player).Message((MessageType)2, string.Format("{0} {1}", Translations.Get("$nokep_magic_need_bench"), type.RequiredBench(level)), 0, (Sprite)null, false); return false; } string text = type.Cost(level); List<Requirement> list = Cost(type, level); if (list.Count == 0 && NokepUtils.ParseRecipe(text).Count > 0) { Logger.LogWarning((object)("Цена " + type.Prefab(level) + " не распознана: " + text)); return false; } if (!HaveAll(player, list)) { ((Character)player).Message((MessageType)2, Translations.Get("$nokep_magic_need") + ":\n" + CostText(player, list), 0, (Sprite)null, false); return false; } if (!player.NoCostCheat()) { player.ConsumeResources(list.ToArray(), 1, -1, 1); } bool num2 = ((Humanoid)player).IsItemEquiped(item); if (num2) { ((Humanoid)player).UnequipItem(item, false); } GameObject dropPrefab = item.m_dropPrefab; string arg = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); item.m_shared = val.m_itemData.m_shared; item.m_dropPrefab = itemPrefab; item.m_quality = 1; item.m_variant = 0; item.m_durability = item.GetMaxDurability(); inventory.Changed(false, false); if (num2) { ((Humanoid)player).EquipItem(item, true); } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null) { instance.m_craftItemEffects.Create(((Component)player).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } ((Character)player).Message((MessageType)2, Translations.Get("$nokep_magic_done") + ": " + Translations.Get(item.m_shared.m_name), 0, (Sprite)null, false); Logger.LogInfo((object)$"Посох: {arg} -> {type.Prefab(level)}, доп. данных: {item.m_customData?.Count ?? 0}"); MagicPanel.SetSlot(item); return true; } goto IL_004a; IL_004a: GameObject dropPrefab2 = item.m_dropPrefab; Logger.LogWarning((object)("Посох: неверный шаг " + ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null) + " -> " + type.Prefab(level))); return false; } } internal static class LevelBadge { private const string BadgeName = "NokepStaffLevel"; private static readonly string[] Roman = new string[8] { "", "I", "II", "III", "IV", "V", "VI", "VII" }; public static string RomanOf(int level) { if (level < 1 || level >= Roman.Length) { return level.ToString(); } return Roman[level]; } public static Color ColorOf(StaffType type) { //IL_002e: 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_0033: 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) return Color.Lerp(Elements.All.Find((ElementInfo e) => e.Type == type)?.Color ?? Color.white, Color.white, 0.25f); } public static void Show(TMP_Text template, ItemData item, bool corner) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)template == (Object)null) { return; } Transform val = template.transform.parent.Find("NokepStaffLevel"); if (!Enchant.TryGetStaff(item, out var type, out var level)) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } else { TMP_Text obj = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<TMP_Text>() : Create(template, corner)); ((Component)obj).gameObject.SetActive(true); ((Behaviour)obj).enabled = true; obj.text = RomanOf(level); ((Graphic)obj).color = ColorOf(type); } } private static TMP_Text Create(TMP_Text template, bool corner) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, template.transform.parent, false); ((Object)val).name = "NokepStaffLevel"; Component[] components = val.GetComponents<Component>(); foreach (Component val2 in components) { if (!(val2 is Transform) && !(val2 is TMP_Text) && !(val2 is CanvasRenderer) && !(val2 is BaseMeshEffect)) { Object.Destroy((Object)(object)val2); } } foreach (Transform item in val.transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } TMP_Text component = val.GetComponent<TMP_Text>(); ((Graphic)component).raycastTarget = false; component.fontStyle = (FontStyles)(component.fontStyle | 1); component.textWrappingMode = (TextWrappingModes)0; component.overflowMode = (TextOverflowModes)0; component.alignment = (TextAlignmentOptions)260; if (corner) { RectTransform val3 = (RectTransform)val.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(1f, 1f); val3.pivot = val4; Vector2 anchorMin = (val3.anchorMax = val4); val3.anchorMin = anchorMin; val3.anchoredPosition = new Vector2(-3f, -1f); val3.sizeDelta = new Vector2(40f, 22f); component.alignment = (TextAlignmentOptions)260; component.textWrappingMode = (TextWrappingModes)0; } return component; } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui")] internal static class LevelBadge_Grid { private static void Postfix(InventoryGrid __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_inventory == null || __instance.m_elements == null) { return; } foreach (InventoryElement element in __instance.m_elements) { Vector2i position = element.Position; LevelBadge.Show(element.m_quality, __instance.m_inventory.GetItemAt(position.x, position.y), corner: false); } } } [HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")] internal static class LevelBadge_Hotbar { private static void Postfix(HotkeyBar __instance) { if (__instance.m_elements == null) { return; } int i; for (i = 0; i < __instance.m_elements.Count; i++) { ItemData item = null; if (__instance.m_items != null) { item = __instance.m_items.Find((ItemData it) => it.m_gridPos.x == i && it.m_gridPos.y == 0); } LevelBadge.Show(__instance.m_elements[i].m_amount, item, corner: true); } } } internal static class MagicConfirm { private const float Aspect = 0.77079105f; private const float WindowHeight = 760f; private static readonly Dictionary<string, Rect> Areas = new Dictionary<string, Rect> { ["titleL"] = Rect.MinMaxRect(0.0917f, 0.8822f, 0.438f, 0.9522f), ["titleR"] = Rect.MinMaxRect(0.5537f, 0.8822f, 0.9009f, 0.9522f), ["circleL"] = Rect.MinMaxRect(0.112f, 0.641f, 0.4f, 0.8594f), ["circleR"] = Rect.MinMaxRect(0.575f, 0.6417f, 0.8639f, 0.8601f), ["descL"] = Rect.MinMaxRect(0.0856f, 0.3534f, 0.4264f, 0.6039f), ["descR"] = Rect.MinMaxRect(0.58f, 0.3534f, 0.89f, 0.6039f), ["cost"] = Rect.MinMaxRect(0.54f, 0.17f, 0.898f, 0.34f), ["ok"] = Rect.MinMaxRect(0.0731f, 0.0579f, 0.4593f, 0.1514f), ["cancel"] = Rect.MinMaxRect(0.5352f, 0.0579f, 0.9231f, 0.1514f), ["close"] = Rect.MinMaxRect(0.9167f, 0.9393f, 0.9991f, 0.9986f) }; private static GameObject root; private static TMP_Text titleL; private static TMP_Text titleR; private static TMP_Text descL; private static TMP_Text descR; private static TMP_Text cost; private static TMP_Text okText; private static TMP_Text cancelText; private static Image iconL; private static Image iconR; private static GameObject okGray; private static Button okButton; private static Image okGlow; private static UISparks okSparks; private static ItemData item; private static StaffType type; private static int level; public static bool IsOpen { get { if ((Object)(object)root != (Object)null) { return root.activeSelf; } return false; } } public static void Create(InventoryGui gui, RectTransform parent) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00c1: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022e: 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_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Expected O, but got Unknown Sprite val = Icons.Get("MagicBench/confirm"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Окно подтверждения: нет картинки MagicBench/confirm"); return; } root = ((Component)MagicPanel.NewRect("NokepMagicConfirm", (Transform)(object)parent)).gameObject; RectTransform val2 = (RectTransform)root.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.sizeDelta = new Vector2(10000f, 10000f); ((Graphic)root.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.55f); RectTransform val4 = MagicPanel.NewRect("Window", (Transform)(object)val2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val4.anchorMax = val3; val4.anchorMin = val3; val4.sizeDelta = new Vector2(585.8012f, 760f); ((Component)val4).gameObject.AddComponent<Image>().sprite = val; TMP_Text recipeDecription = gui.m_recipeDecription; TMP_Text recipeName = gui.m_recipeName; titleL = Text(recipeName, val4, "titleL", (TextAlignmentOptions)514, 10f); titleR = Text(recipeName, val4, "titleR", (TextAlignmentOptions)514, 10f); titleL.textWrappingMode = (TextWrappingModes)0; titleR.textWrappingMode = (TextWrappingModes)0; iconL = Icon(val4, "circleL"); iconR = Icon(val4, "circleR"); descL = Text(recipeDecription, val4, "descL", (TextAlignmentOptions)258, 10f); descR = Text(recipeDecription, val4, "descR", (TextAlignmentOptions)258, 10f); RectTransform val5 = MagicPanel.NewRect("CostPlate", (Transform)(object)val4); MagicPanel.Place(val5, Areas["cost"]); Image obj = ((Component)val5).gameObject.AddComponent<Image>(); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0.45f); ((Graphic)obj).raycastTarget = false; cost = MagicPanel.CloneText(recipeDecription, (Transform)(object)val5, "Cost"); RectTransform val6 = (RectTransform)cost.transform; val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = new Vector2(10f, 6f); val6.offsetMax = new Vector2(-10f, -6f); cost.alignment = (TextAlignmentOptions)258; MagicPanel.AutoSize(cost, 9f); RectTransform val7 = MagicPanel.CreateButtonArea(val4, "ok", Areas, new UnityAction(OnOk), null, strong: true); okGray = MagicPanel.CreateGray(val7, "MagicBench/gray_ok"); okButton = ((Component)val7).GetComponent<Button>(); okGlow = ((Component)((Transform)val7).Find("Glow")).GetComponent<Image>(); okSparks = ((Component)val7).gameObject.AddComponent<UISparks>(); okText = Text(recipeName, val7, null, (TextAlignmentOptions)514, 10f); okText.textWrappingMode = (TextWrappingModes)0; RectTransform parent2 = MagicPanel.CreateButtonArea(val4, "cancel", Areas, new UnityAction(Close)); cancelText = Text(recipeName, parent2, null, (TextAlignmentOptions)514, 10f); cancelText.textWrappingMode = (TextWrappingModes)0; MagicPanel.CreateButtonArea(val4, "close", Areas, new UnityAction(Close)); root.SetActive(false); } private static TMP_Text Text(TMP_Text template, RectTransform parent, string area, TextAlignmentOptions align, float min) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0048: 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_005d: 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_007d: Unknown result type (might be due to invalid IL or missing references) TMP_Text obj = MagicPanel.CloneText(template, (Transform)(object)parent, area ?? "Label"); RectTransform val = (RectTransform)obj.transform; if (area != null) { MagicPanel.Place(val, Areas[area]); } else { MagicPanel.Place(val, new Rect(0f, 0f, 1f, 1f)); } val.offsetMin = new Vector2(8f, 4f); val.offsetMax = new Vector2(-8f, -4f); obj.alignment = align; MagicPanel.AutoSize(obj, min); return obj; } private static Image Icon(RectTransform parent, string area) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) RectTransform val = MagicPanel.NewRect(area, (Transform)(object)parent); MagicPanel.Place(val, Areas[area]); RectTransform obj = MagicPanel.NewRect("Icon", (Transform)(object)val); MagicPanel.Place(obj, Rect.MinMaxRect(0.2f, 0.2f, 0.8f, 0.8f)); Image obj2 = ((Component)obj).gameObject.AddComponent<Image>(); obj2.preserveAspect = true; ((Graphic)obj2).raycastTarget = false; return obj2; } public static void Open(ItemData from, StaffType toType, int toLevel) { if (!((Object)(object)root == (Object)null)) { item = from; type = toType; level = toLevel; root.SetActive(true); root.transform.SetAsLastSibling(); Refresh(); } } public static void Close() { if ((Object)(object)root != (Object)null) { root.SetActive(false); } item = null; type = null; } public static void Refresh() { //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; CraftingStation station = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if (!IsOpen || (Object)(object)localPlayer == (Object)null || item == null || type == null || !StationLevel.IsOurs(station) || !((Humanoid)localPlayer).GetInventory().ContainsItem(item)) { Close(); return; } bool flag = Enchant.IsBlank(item); Enchant.TryGetStaff(item, out var staffType, out var num); titleL.text = Translations.Get(item.m_shared.m_name); titleR.text = Translations.Get(type.ItemName(level)); iconL.sprite = item.GetIcon(); iconR.sprite = Enchant.IconOf(type, level); ((Behaviour)iconR).enabled = (Object)(object)iconR.sprite != (Object)null; descL.text = (flag ? Translations.Get("$nokep_magic_no_magic") : Stats(staffType, num, null, 0)); descR.text = Stats(type, level, staffType, num); okText.text = Translations.Get(flag ? "$nokep_magic_label_enchant" : "$nokep_magic_label_upgrade_short"); cancelText.text = Translations.Get("$nokep_magic_cancel"); MagicPanel.UniformSize((IList<TMP_Text>)(object)new TMP_Text[2] { titleL, titleR }); MagicPanel.UniformSize((IList<TMP_Text>)(object)new TMP_Text[2] { okText, cancelText }); MagicPanel.UniformSize((IList<TMP_Text>)(object)new TMP_Text[2] { descL, descR }); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<color=#FFD94A>" + Translations.Get(flag ? "$nokep_magic_cost_enchant" : "$nokep_magic_cost_upgrade") + "</color>\n"); int num2 = type.RequiredBench(level); bool flag2; if (StationLevel.Get(station) < num2) { stringBuilder.Append(string.Format("<color=#FF5050>{0} {1}</color>", Translations.Get("$nokep_magic_need_bench"), num2)); flag2 = false; } else { List<Requirement> list = Enchant.Cost(type, level); stringBuilder.Append(Enchant.CostText(localPlayer, list)); flag2 = Enchant.HaveAll(localPlayer, list); } cost.text = stringBuilder.ToString(); okGray.SetActive(!flag2); ((Selectable)okButton).interactable = flag2; Color color = Elements.All.Find((ElementInfo e) => e.Type == type)?.Color ?? MagicPanel.GoldGlow; ((Graphic)okGlow).color = color; okSparks.Color = color; okSparks.Allowed = flag2; } private static string Stats(StaffType t, int lvl, StaffType prev, int prevLvl) { bool flag = prev == t && prevLvl > 0; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(ShotLine("$nokep_magic_dmg", t.Shots(lvl), t.Damage(lvl), flag ? ((float)prev.Shots(prevLvl) * prev.Damage(prevLvl)) : (-1f))); if (t.HasBurn) { stringBuilder.Append(ShotLine(t.DotLabelKey, t.Shots(lvl), t.Burn(lvl), flag ? ((float)prev.Shots(prevLvl) * prev.Burn(prevLvl)) : (-1f))); } stringBuilder.Append(Line("$nokep_magic_eitr", t.Eitr(lvl), -1f)); if (t.HasAoe(lvl)) { string text = Translations.Get(t.AoeLabelKey); bool flag2 = flag && !prev.HasAoe(prevLvl); stringBuilder.Append(flag2 ? ("<color=#7CFC7C>+ " + text + "</color>\n") : (text + "\n")); } if (t.EffectKey != null) { stringBuilder.Append(Translations.Get(t.EffectKey) + "\n"); } if (t.HasMining) { stringBuilder.Append(MiningLine(t, lvl, flag ? prevLvl : 0)); } stringBuilder.Append(SpecialLines(t, lvl, flag ? prevLvl : (-1))); return stringBuilder.ToString(); } public static string SpecialLines(StaffType t, int lvl, int prevLvl) { StringBuilder stringBuilder = new StringBuilder(); foreach (Special special2 in t.Specials) { if (special2.Level <= lvl) { string text = Translations.Get(special2.LabelKey); stringBuilder.Append((prevLvl >= 0 && special2.Level > prevLvl) ? ("<color=#7CFC7C>+ " + text + "</color>\n") : (text + "\n")); } } Special? special = t.NextSpecial(lvl); if (special.HasValue) { stringBuilder.Append(string.Format("<color=#9A9A9A>{0} {1}: ", Translations.Get("$nokep_magic_lvl"), special.Value.Level) + Translations.Get(special.Value.LabelKey) + "</color>\n"); } return stringBuilder.ToString(); } private static string ShotLine(string key, int shots, float perShot, float beforeTotal) { if (shots <= 1) { return Line(key, perShot, beforeTotal); } string text = $"{shots} × {perShot:0.#}"; bool flag = beforeTotal >= 0f && (float)shots * perShot > beforeTotal + 0.05f; return Translations.Get(key) + ": " + (flag ? ("<color=#7CFC7C>" + text + " ↑</color>\n") : (text + "\n")); } private static string MiningLine(StaffType t, int lvl, int prevLvl) { string text = Translations.Get("$nokep_magic_mining") + "\n"; if (lvl < 2) { return text + Translations.Get("$nokep_magic_ore_none") + "\n"; } string text2 = Translations.Get("$nokep_magic_ore") + ": " + Biomes.NameForLevel(lvl); return text + ((prevLvl > 0 && lvl > prevLvl) ? ("<color=#7CFC7C>" + text2 + " ↑</color>\n") : (text2 + "\n")); } private static string Line(string key, float value, float before) { string arg = Translations.Get(key) + ": "; if (before >= 0f && value > before + 0.05f) { return $"{arg}<color=#7CFC7C>{value:0.#} ↑</color>\n"; } return $"{arg}{value:0.#}\n"; } private static void OnOk() { Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if (!((Object)(object)val == (Object)null) && item != null && type != null) { if (Enchant.Apply(localPlayer, val, item, type, level)) { Close(); } else { Refresh(); } } } } internal static class MagicPanel { private class ElementButton { public ElementInfo Info; public GameObject Gray; public Image Frame; public TMP_Text Label; public Button Button; public UISparks Sparks; public bool Pulse; } private const float BoardAspect = 1.8045113f; private const float HeaderHeight = 0.12f; private const float PanelAspect = 1.4833127f; private const float BoardTop = 0.8220025f; private static readonly Dictionary<string, Rect> Areas = new Dictionary<string, Rect> { ["fire"] = Rect.MinMaxRect(0.3358f, 0.7263f, 0.6158f, 0.8947f), ["ice"] = Rect.MinMaxRect(0.6475f, 0.7263f, 0.9408f, 0.8947f), ["water"] = Rect.MinMaxRect(0.3358f, 0.5188f, 0.6158f, 0.6947f), ["poison"] = Rect.MinMaxRect(0.6475f, 0.5188f, 0.9408f, 0.6947f), ["earth"] = Rect.MinMaxRect(0.3358f, 0.3113f, 0.6158f, 0.4887f), ["arcane"] = Rect.MinMaxRect(0.6467f, 0.3113f, 0.9408f, 0.4887f), ["anvil"] = Rect.MinMaxRect(0.1842f, 0.0782f, 0.4867f, 0.2331f), ["up"] = Rect.MinMaxRect(0.5133f, 0.0782f, 0.8192f, 0.2331f), ["slot"] = Rect.MinMaxRect(0.0822f, 0.4f, 0.2775f, 0.7524f), ["slotName"] = Rect.MinMaxRect(0.04f, 0.275f, 0.32f, 0.38f) }; private static GameObject root; private static TMP_Text title; private static TMP_Text hint; private static TMP_Text slotName; private static Image slotIcon; private static readonly List<ElementButton> elements = new List<ElementButton>(); private static GameObject anvilGray; private static GameObject upGray; private static ItemData slotItem; private static float refreshTimer; private static readonly List<GameObject> hidden = new List<GameObject>(); private static Image craftingBg; private static bool craftingBgHidden; public static readonly Color GoldGlow = new Color(1f, 0.78f, 0.35f); private const float GlowPadX = 1f / 22f; private const float GlowPadY = 2f / 15f; public static void SetSlot(ItemData item) { slotItem = item; Refresh(); } public static void Create(InventoryGui gui) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00a4: 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_00ce: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Expected O, but got Unknown //IL_017c: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_03f3: Expected O, but got Unknown //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Expected O, but got Unknown //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Expected O, but got Unknown if ((Object)(object)root != (Object)null) { return; } elements.Clear(); hidden.Clear(); slotItem = null; craftingBgHidden = false; Sprite val = Icons.Get("MagicBench/board"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Окно верстака: нет картинки MagicBench/board"); return; } RectTransform crafting = gui.m_crafting; craftingBg = ((Component)crafting).GetComponent<Image>(); root = new GameObject("NokepMagicPanel", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)root.transform; ((Transform)val2).SetParent((Transform)(object)crafting, false); val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); Vector2 offsetMin = (val2.offsetMax = Vector2.zero); val2.offsetMin = offsetMin; AspectRatioFitter obj = root.AddComponent<AspectRatioFitter>(); obj.aspectMode = (AspectMode)1; obj.aspectRatio = 1.4833127f; ((Transform)val2).SetAsLastSibling(); RectTransform obj2 = NewRect("Header", (Transform)(object)val2); Place(obj2, Rect.MinMaxRect(0f, 0.8220025f, 1f, 1f)); Image val3 = ((Component)obj2).gameObject.AddComponent<Image>(); if ((Object)(object)craftingBg != (Object)null && (Object)(object)craftingBg.sprite != (Object)null) { val3.sprite = craftingBg.sprite; val3.type = craftingBg.type; val3.pixelsPerUnitMultiplier = craftingBg.pixelsPerUnitMultiplier; ((Graphic)val3).color = new Color(((Graphic)craftingBg).color.r, ((Graphic)craftingBg).color.g, ((Graphic)craftingBg).color.b, 1f); } else { ((Graphic)val3).color = new Color(0.13f, 0.1f, 0.07f, 1f); } title = CloneText(gui.m_craftingStationName, (Transform)(object)val2, "Title"); Place((RectTransform)title.transform, Rect.MinMaxRect(0.03f, 0.8967614f, 0.97f, 0.995f)); title.alignment = (TextAlignmentOptions)514; AutoSize(title, 12f); hint = CloneText(gui.m_recipeDecription, (Transform)(object)val2, "Hint"); Place((RectTransform)hint.transform, Rect.MinMaxRect(0.04f, 0.82912236f, 0.96f, 0.8967614f)); hint.alignment = (TextAlignmentOptions)514; AutoSize(hint, 9f); RectTransform val4 = NewRect("BoardArea", (Transform)(object)val2); Place(val4, Rect.MinMaxRect(0f, 0f, 1f, 0.8220025f)); RectTransform val5 = NewRect("Board", (Transform)(object)val4); Image obj3 = ((Component)val5).gameObject.AddComponent<Image>(); obj3.sprite = val; ((Graphic)obj3).raycastTarget = true; AspectRatioFitter obj4 = ((Component)val5).gameObject.AddComponent<AspectRatioFitter>(); obj4.aspectMode = (AspectMode)3; obj4.aspectRatio = 1.8045113f; CreateSlot(gui, val5); slotName = CloneText(gui.m_recipeDecription, (Transform)(object)val5, "SlotName"); Place((RectTransform)slotName.transform, Areas["slotName"]); slotName.alignment = (TextAlignmentOptions)514; AutoSize(slotName, 8f); foreach (ElementInfo item in Elements.All) { elements.Add(CreateElement(gui, val5, item)); } RectTransform obj5 = CreateButtonArea(val5, "anvil", Areas, new UnityAction(OnRepair)); anvilGray = CreateGray(obj5, "MagicBench/gray_anvil"); Tip(obj5, RepairTip); RectTransform obj6 = CreateButtonArea(val5, "up", Areas, new UnityAction(OnUpgradeBench)); upGray = CreateGray(obj6, "MagicBench/gray_up"); Tip(obj6, BenchTip); RectTransform parent = (RectTransform)gui.m_inventoryRoot; MagicConfirm.Create(gui, parent); MagicTooltip.Create(parent, gui.m_recipeDecription); root.SetActive(false); Logger.LogInfo((object)"Окно магического верстака создано"); } private static void CreateSlot(InventoryGui gui, RectTransform board) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) RectTransform val = NewRect("Slot", (Transform)(object)board); Place(val, Areas["slot"]); ((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0f); Button obj = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj).transition = (Transition)0; ((UnityEvent)obj.onClick).AddListener((UnityAction)delegate { OnSlotClick(gui); }); RectTransform obj2 = NewRect("Icon", (Transform)(object)val); Place(obj2, Rect.MinMaxRect(0.18f, 0.18f, 0.82f, 0.82f)); slotIcon = ((Component)obj2).gameObject.AddComponent<Image>(); slotIcon.preserveAspect = true; ((Graphic)slotIcon).raycastTarget = false; Tip(val, () => ((slotItem != null) ? Translations.Get(slotItem.m_shared.m_name) : "", Translations.Get("$nokep_magic_slot_hint"))); } private static ElementButton CreateElement(InventoryGui gui, RectTransform board, ElementInfo element) { //IL_0036: 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_0051: Expected O, but got Unknown //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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown ElementButton elementButton = new ElementButton(); elementButton.Info = element; RectTransform val = CreateButtonArea(board, element.Button, Areas, (UnityAction)delegate { OnElementClick(element); }, element.Color, strong: true); elementButton.Button = ((Component)val).GetComponent<Button>(); elementButton.Sparks = ((Component)val).gameObject.AddComponent<UISparks>(); elementButton.Sparks.Color = element.Color; elementButton.Gray = CreateGray(val, "MagicBench/gray_" + element.Button); RectTransform val2 = NewRect("Selected", (Transform)(object)val); Stretch(val2); elementButton.Frame = ((Component)val2).gameObject.AddComponent<Image>(); elementButton.Frame.sprite = Icons.Get("MagicBench/frame_selected"); ((Graphic)elementButton.Frame).raycastTarget = false; ((Component)val2).gameObject.SetActive(false); elementButton.Label = CloneText(gui.m_recipeDecription, (Transform)(object)val, "Label"); Place((RectTransform)elementButton.Label.transform, Rect.MinMaxRect(0.05f, 0.04f, 0.95f, 0.36f)); elementButton.Label.alignment = (TextAlignmentOptions)514; elementButton.Label.textWrappingMode = (TextWrappingModes)0; AutoSize(elementButton.Label, 7f); Tip(val, () => ElementTip(element)); return elementButton; } public static void Tick(InventoryGui gui) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; CraftingStation station = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if (!InventoryGui.IsVisible() || !StationLevel.IsOurs(station)) { if (root.activeSelf) { MagicConfirm.Close(); MagicTooltip.Hide(null); root.SetActive(false); RestoreHidden(); slotItem = null; } return; } if (!root.activeSelf) { root.SetActive(true); refreshTimer = 0f; } HideVanilla(gui); if (slotItem != null && !((Humanoid)localPlayer).GetInventory().ContainsItem(slotItem)) { SetSlot(null); } float num = 0.55f + 0.45f * Mathf.Sin(Time.unscaledTime * 4f); foreach (ElementButton element in elements) { if (element.Pulse) { ((Graphic)element.Frame).color = new Color(1f, 1f, 1f, num); } } MagicTooltip.Refresh(); refreshTimer -= Time.deltaTime; if (refreshTimer <= 0f) { Refresh(); MagicConfirm.Refresh(); } } private static void HideVanilla(InventoryGui gui) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown foreach (Transform item in (Transform)gui.m_crafting) { Transform val = item; if ((Object)(object)((Component)val).gameObject != (Object)(object)root) { Hide(((Component)val).gameObject); } } Hide(((Component)gui.m_tabCraft).gameObject); Hide(((Component)gui.m_tabUpgrade).gameObject); Hide(((Component)gui.m_craftingStationName).gameObject); Hide(((Component)gui.m_craftingStationIcon).gameObject); Hide(((Component)gui.m_craftingStationLevelRoot).gameObject); if ((Object)(object)gui.m_repairPanel != (Object)null) { Hide(((Component)gui.m_repairPanel).gameObject); } else { Hide(((Component)gui.m_repairButton).gameObject); } if ((Object)(object)craftingBg != (Object)null && ((Behaviour)craftingBg).enabled) { ((Behaviour)craftingBg).enabled = false; craftingBgHidden = true; } } private static void Hide(GameObject go) { if (!((Object)(object)go == (Object)null) && go.activeSelf) { go.SetActive(false); if (!hidden.Contains(go)) { hidden.Add(go); } } } private static void RestoreHidden() { foreach (GameObject item in hidden) { if ((Object)(object)item != (Object)null) { item.SetActive(true); } } hidden.Clear(); if (craftingBgHidden && (Object)(object)craftingBg != (Object)null) { ((Behaviour)craftingBg).enabled = true; } craftingBgHidden = false; } private static bool StepFor(ElementInfo element, out StaffType type, out int level) { type = element.Type; level = 0; if (slotItem == null || type == null) { return false; } if (Enchant.IsBlank(slotItem)) { level = 1; return true; } if (Enchant.TryGetStaff(slotItem, out var type2, out var level2) && type2 == type && level2 < 7) { level = level2 + 1; return true; } return false; } private static void Refresh() { //IL_023a: Unknown result type (might be due to invalid IL or missing references) refreshTimer = 0.25f; Player localPlayer = Player.m_localPlayer; CraftingStation station = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)root == (Object)null || (Object)(object)localPlayer == (Object)null || !StationLevel.IsOurs(station)) { return; } int num = StationLevel.Get(station); title.text = string.Format("{0} — {1} {2} ", Translations.Get(Table.StationName), Translations.Get("$nokep_magic_lvl"), num) + "(" + Biomes.NameForLevel(num) + ")"; Image obj = slotIcon; ItemData obj2 = slotItem; obj.sprite = ((obj2 != null) ? obj2.GetIcon() : null); ((Behaviour)slotIcon).enabled = slotItem != null; slotName.text = ((slotItem != null) ? Translations.Get(slotItem.m_shared.m_name) : Translations.Get("$nokep_magic_slot_empty")); bool flag = Enchant.IsBlank(slotItem); Enchant.TryGetStaff(slotItem, out var slotType, out var level); foreach (ElementButton element in elements) { ElementInfo info = element.Info; bool flag2 = info.Type == null || num < info.UnlockLevel; bool flag3 = slotType != null && slotType != info.Type; StaffType type; int level2; bool flag4 = StepFor(info, out type, out level2) && !flag2; bool flag5 = flag4 && num >= type.RequiredBench(level2); element.Gray.SetActive(flag2 || flag3); ((Selectable)element.Button).interactable = !flag2 && !flag3; element.Sparks.Allowed = !flag2 && !flag3; element.Pulse = flag4 && flag5 && slotType != null; ((Component)element.Frame).gameObject.SetActive(element.Pulse || (slotType != null && slotType == info.Type)); if (!element.Pulse) { ((Graphic)element.Frame).color = Color.white; } if (flag2) { element.Label.text = ((info.Type == null) ? string.Format("{0} · {1} {2}", Translations.Get("$nokep_magic_soon"), Translations.Get("$nokep_magic_bench_short"), info.UnlockLevel) : string.Format("{0} {1}", Translations.Get("$nokep_magic_need_bench_short"), info.UnlockLevel)); } else if (flag4 && !flag5) { element.Label.text = string.Format("<color=#FF7070>{0} {1}</color>", Translations.Get("$nokep_magic_need_bench_short"), type.RequiredBench(level2)); } else if (flag4 && flag) { element.Label.text = Translations.Get("$nokep_magic_label_enchant"); } else if (flag4) { element.Label.text = string.Format("<color=#FFD94A>{0} {1} {2}</color>", Translations.Get("$nokep_magic_label_upgrade"), Translations.Get("$nokep_magic_lvl"), level2); } else if (slotType == info.Type && level >= 7) { element.Label.text = Translations.Get("$nokep_magic_label_max"); } else { element.Label.text = ""; } } UniformSize(elements.ConvertAll((ElementButton b) => b.Label)); if (slotItem == null) { hint.text = Translations.Get("$nokep_magic_slot_hint"); } else if (flag) { hint.text = Translations.Get("$nokep_magic_hint_choose"); } else if (slotType != null && level >= 7) { hint.text = Translations.Get("$nokep_magic_max"); } else if (slotType != null) { hint.text = Translations.Get("$nokep_magic_hint_upgrade") + " <color=#FFD94A>" + Translations.Get(Elements.All.Find((ElementInfo e) => e.Type == slotType)?.NameKey ?? "") + "</color>"; } else { hint.text = ""; } bool flag6 = RepairableItems(localPlayer).Count == 0; anvilGray.SetActive(flag6); ((Selectable)((Component)anvilGray.transform.parent).GetComponent<Button>()).interactable = !flag6; bool flag7 = num >= 7; upGray.SetActive(flag7); ((Selectable)((Component)upGray.transform.parent).GetComponent<Button>()).interactable = !flag7; } private static (string, string) ElementTip(ElementInfo e) { Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); int num = ((!((Object)(object)val != (Object)null)) ? 1 : StationLevel.Get(val)); string item = Translations.Get(e.NameKey); if (e.Type == null) { return (item, string.Format("{0}\n{1} {2}", Translations.Get("$nokep_magic_soon"), Translations.Get("$nokep_magic_need_bench"), e.UnlockLevel)); } if (num < e.UnlockLevel) { return (item, string.Format("{0} {1}", Translations.Get("$nokep_magic_need_bench"), e.UnlockLevel)); } if (StepFor(e, out var type, out var level)) { return (item, Translations.Get(type.ItemName(level)) + "\n" + LevelText(type, level)); } return (item, Translations.Get(e.Type.Description)); } private static (string, string) RepairTip() { Player localPlayer = Player.m_localPlayer; int num = (((Object)(object)localPlayer != (Object)null) ? RepairableItems(localPlayer).Count : 0); return (Translations.Get("$nokep_magic_repair"), (num > 0) ? string.Format("{0}: {1}", Translations.Get("$nokep_magic_repair_count"), num) : Translations.Get("$nokep_magic_nothing_to_repair")); } private static (string, string) BenchTip() { Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)val == (Object)null) { return ("", ""); } int num = StationLevel.Get(val) + 1; if (num > 7) { return (Translations.Get("$nokep_magic_bench_max"), ""); } return (Translations.Get("$nokep_magic_upgrade_title") + ": " + Biomes.NameForLevel(num), Upgrade.CostText(localPlayer, num)); } public static string LevelText(StaffType type, int level) { int num = type.Shots(level); string arg = ((num > 1) ? $"{num} × " : ""); string text = string.Format("{0}: {1}{2:0.#}", Translations.Get("$nokep_magic_dmg"), arg, type.Damage(level)); if (type.HasBurn) { text += $" {Translations.Get(type.DotLabelKey)}: {arg}{type.Burn(level):0.#}"; } if (type.HasAoe(level)) { text = text + " " + Translations.Get(type.AoeLabelKey); } text += string.Format(" {0}: {1:0.#}", Translations.Get("$nokep_magic_eitr"), type.Eitr(level)); foreach (Special special in type.Specials) { if (special.Level == level) { text = text + "\n<color=#7CFC7C>+ " + Translations.Get(special.LabelKey) + "</color>"; } } return text; } private static void OnSlotClick(InventoryGui gui) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } if (gui.m_dragItem != null) { ItemData dragItem = gui.m_dragItem; if (gui.m_dragInventory == ((Humanoid)localPlayer).GetInventory() && Enchant.CanGoInSlot(dragItem)) { gui.SetupDragItem((ItemData)null, (Inventory)null, 1); SetSlot(dragItem); } else { ((Character)localPlayer).Message((MessageType)2, Translations.Get("$nokep_magic_slot_wrong"), 0, (Sprite)null, false); } } else { SetSlot(null); } } private static void OnElementClick(ElementInfo element) { Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if (!((Object)(object)val == (Object)null) && element.Type != null && StationLevel.Get(val) >= element.UnlockLevel) { StaffType type; int level; if (slotItem == null) { ((Character)localPlayer).Message((MessageType)2, Translations.Get("$nokep_magic_slot_hint"), 0, (Sprite)null, false); } else if (StepFor(element, out type, out level)) { MagicConfirm.Open(slotItem, type, level); } } } private static void OnRepair() { //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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)val == (Object)null || !val.CheckUsable(localPlayer, true)) { return; } List<ItemData> list = RepairableItems(localPlayer); if (list.Count == 0) { ((Character)localPlayer).Message((MessageType)2, Translations.Get("$nokep_magic_nothing_to_repair"), 0, (Sprite)null, false); return; } foreach (ItemData item in list) { item.m_durability = item.GetMaxDurability(); } val.m_repairItemDoneEffects.Create(((Component)val).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); ((Character)localPlayer).Message((MessageType)2, string.Format("{0}: {1}", Translations.Get("$nokep_magic_repaired"), list.Count), 0, (Sprite)null, false); Refresh(); } private static List<ItemData> RepairableItems(Player player) { List<ItemData> list = new List<ItemData>(); List<ItemData> list2 = new List<ItemData>(); InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { return list2; } ((Humanoid)player).GetInventory().GetWornItems(list); foreach (ItemData item in list) { if (instance.CanRepair(item)) { list2.Add(item); } } return list2; } private static void OnUpgradeBench() { Player localPlayer = Player.m_localPlayer; CraftingStation station = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if (StationLevel.IsOurs(station)) { Upgrade.TryUpgrade(localPlayer, station); Refresh(); } } public static RectTransform NewRect(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent(parent, false); return val; } public static void Stretch(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; } public static void Place(RectTransform rt, Rect area) { //IL_0003: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = ((Rect)(ref area)).min; rt.anchorMax = ((Rect)(ref area)).max; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; } public static RectTransform CreateButtonArea(RectTransform parent, string name, Dictionary<string, Rect> areas, UnityAction onClick, Color? glow = null, bool strong = false) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01e7: Expected O, but got Unknown RectTransform val = NewRect("Button_" + name, (Transform)(object)parent); Place(val, areas[name]); ((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0f); RectTransform obj = NewRect("Glow", (Transform)(object)val); obj.anchorMin = new Vector2(-1f / 22f, -2f / 15f); obj.anchorMax = new Vector2(1.0454545f, 1.1333333f); Vector2 offsetMin = (obj.offsetMax = Vector2.zero); obj.offsetMin = offsetMin; Image val2 = ((Component)obj).gameObject.AddComponent<Image>(); val2.sprite = Icons.Get("MagicBench/frame_hover"); ((Graphic)val2).color = (Color)(((??)glow) ?? GoldGlow); ((Graphic)val2).raycastTarget = false; Button obj2 = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj2).targetGraphic = (Graphic)(object)val2; ColorBlock colors = ((Selectable)obj2).colors; ((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0f); ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 1f, 1f, strong ? 0.65f : 0.45f); ((ColorBlock)(ref colors)).pressedColor = new Color(1f, 1f, 1f, strong ? 0.85f : 0.7f); ((ColorBlock)(ref colors)).selectedColor = new Color(1f, 1f, 1f, 0f); ((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0f); ((ColorBlock)(ref colors)).colorMultiplier = 1f; ((ColorBlock)(ref colors)).fadeDuration = 0.12f; ((Selectable)obj2).colors = colors; ((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate { if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject((GameObject)null); } onClick.Invoke(); }); return val; } public static GameObject CreateGray(RectTransform parent, string sprite) { RectTransform obj = NewRect("Gray", (Transform)(object)parent); Stretch(obj); Image obj2 = ((Component)obj).gameObject.AddComponent<Image>(); obj2.sprite = Icons.Get(sprite); ((Graphic)obj2).raycastTarget = false; ((Component)obj).gameObject.SetActive(false); return ((Component)obj).gameObject; } private static void Tip(RectTransform target, Func<(string, string)> content) { ((Component)target).gameObject.AddComponent<HoverTip>().Content = content; } public static Sprite SlicedSprite(string name, float border) { //IL_0032: 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_0051: Unknown result type (might be due to invalid IL or missing references) Sprite val = Icons.Get(name); if ((Object)(object)val == (Object)null) { return null; } Texture2D texture = val.texture; return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(border, border, border, border)); } public static TMP_Text CloneText(TMP_Text template, Transform parent, string name) { GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false); ((Object)val).name = name; val.SetActive(true); MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (((object)val2).GetType().Name == "Localize") { Object.DestroyImmediate((Object)(object)val2); } } for (int num = val.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(num)).gameObject); } ContentSizeFitter[] components = val.GetComponents<ContentSizeFitter>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } LayoutElement[] components2 = val.GetComponents<LayoutElement>(); for (int i = 0; i < components2.Length; i++) { Object.DestroyImmediate((Object)(object)components2[i]); } TMP_Text component = val.GetComponent<TMP_Text>(); component.text = ""; ((Graphic)component).raycastTarget = false; component.richText = true; component.textWrappingMode = (TextWrappingModes)1; return component; } public static void UniformSize(IList<TMP_Text> texts) { float num = float.MaxValue; foreach (TMP_Text text in texts) { text.enableAutoSizing = true; if (!string.IsNullOrEmpty(text.text)) { text.ForceMeshUpdate(false, false); num = Mathf.Min(num, text.fontSize); } } if (num == float.MaxValue) { return; } foreach (TMP_Text text2 in texts) { text2.enableAutoSizing = false; text2.fontSize = num; } } public static void AutoSize(TMP_Text text, float min) { text.fontSizeMax = text.fontSize; text.fontSizeMin = min; text.enableAutoSizing = true; } } internal static class MagicTooltip { private const float Width = 300f; private const float Padding = 16f; private const float Border = 40f; private static readonly Vector2 Offset = new Vector2(18f, -18f); private static RectTransform root; private static TMP_Text text; private static Canvas canvas; private static HoverTip owner; public static void Create(RectTransform parent, TMP_Text template) { //IL_003b: 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_0056: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) Sprite sprite = MagicPanel.SlicedSprite("MagicBench/tooltip", 40f); root = MagicPanel.NewRect("NokepMagicTooltip", (Transform)(object)parent); RectTransform obj = root; RectTransform obj2 = root; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); obj2.anchorMax = val; obj.anchorMin = val; root.pivot = new Vector2(0f, 1f); Image obj3 = ((Component)root).gameObject.AddComponent<Image>(); obj3.sprite = sprite; obj3.type = (Type)1; obj3.pixelsPerUnitMultiplier = 2.5f; ((Graphic)obj3).raycastTarget = false; text = MagicPanel.CloneText(template, (Transform)(object)root, "Text"); RectTransform val2 = (RectTransform)text.transform; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = new Vector2(16f, 16f); val2.offsetMax = new Vector2(-16f, -16f); text.alignment = (TextAlignmentOptions)257; text.enableAutoSizing = false; canvas = ((Component)parent).GetComponentInParent<Canvas>(); ((Component)root).gameObject.SetActive(false); } public static void Show(HoverTip from) { if (!((Object)(object)root == (Object)null)) { owner = from; ((Component)root).gameObject.SetActive(true); ((Transform)root).SetAsLastSibling(); Refresh(); } } public static void Hide(HoverTip from) { if (!((Object)(object)root == (Object)null) && (!((Object)(object)from != (Object)null) || !((Object)(object)from != (Object)(object)owner))) { owner = null; ((Component)root).gameObject.SetActive(false); } } public static void Refresh() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null || (Object)(object)owner == (Object)null || !((Component)root).gameObject.activeSelf) { return; } if (!((Behaviour)owner).isActiveAndEnabled) { Hide(null); return; } (string, string) tuple = owner.Content(); string item = tuple.Item1; string item2 = tuple.Item2; string text = (string.IsNullOrEmpty(item) ? item2 : ("<color=#FFD94A><b>" + item + "</b></color>\n" + item2)); MagicTooltip.text.text = text; Vector2 preferredValues = MagicTooltip.text.GetPreferredValues(text, 268f, 0f); root.sizeDelta = new Vector2(300f, preferredValues.y + 32f); Canvas val = (((Object)(object)canvas != (Object)null) ? canvas.rootCanvas : null); Camera val2 = (((Object)(object)val != (Object)null && (int)val.renderMode != 0) ? val.worldCamera : null); RectTransform val3 = (RectTransform)((Transform)root).parent; Vector2 val4 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val3, Vector2.op_Implicit(Input.mousePosition), val2, ref val4)) { Vector2 val5 = val4 + Offset; Rect rect = val3.rect; val5.x = Mathf.Min(val5.x, ((Rect)(ref rect)).xMax - root.sizeDelta.x); val5.y = Mathf.Max(val5.y, ((Rect)(ref rect)).yMin + root.sizeDelta.y); root.anchoredPosition = val5; } } } internal class HoverTip : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public Func<(string, string)> Content = () => ("", ""); public void OnPointerEnter(PointerEventData eventData) { MagicTooltip.Show(this); } public void OnPointerExit(PointerEventData eventData) { MagicTooltip.Hide(this); } private void OnDisable() { MagicTooltip.Hide(this); } } internal static class Recipes { private const string Workbench = "piece_workbench"; public static void AddBlank() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown RecipeConfig val = new RecipeConfig(); val.Name = "Recipe_Nokep_Staff_Blank"; val.Item = "Nokep_Staff_Blank"; val.CraftingStation = "piece_workbench"; val.MinStationLevel = 1; val.AddRequirement("Wood", 1, 0); ItemManager.Instance.AddRecipe(new CustomRecipe(val)); } public static void Apply() { if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_recipes == null) { return; } Recipe val = Find("Nokep_Staff_Blank"); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"Не нашёл свой рецепт для Nokep_Staff_Blank"); return; } if (Plugin.FreeForTesting) { val.m_resources = (Requirement[])(object)new Requirement[0]; Logger.LogInfo((object)"Чистый посох — бесплатно (проверка)"); return; } List<Requirement> list = new List<Requirement>(); AddItems(list, NokepUtils.ParseRecipe(ModConfig.BlankRecipe.Value), 0); if (list.Count == 0) { Logger.LogWarning((object)"Пустой рецепт для Nokep_Staff_Blank — оставляю прежний"); return; } val.m_resources = list.ToArray(); Logger.LogInfo((object)"Рецепт чистого посоха обновлён"); } public static void AddItems(List<Requirement> list, Dictionary<string, int> items, int perLevel = 1) { //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_0079: 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_008c: Expected O, but got Unknown foreach (KeyValuePair<string, int> item in items) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item.Key); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Не нашёл ресурс " + item.Key + " — проверь написание в настройках")); continue; } list.Add(new Requirement { m_resItem = val, m_amount = item.Value, m_amountPerLevel = perLevel, m_recover = true }); } } private static Recipe Find(string itemPrefabName) { foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if (!((Object)(object)recipe == (Object)null) && !((Object)(object)recipe.m_item == (Object)null) && ((Object)((Component)recipe.m_item).gameObject).name == itemPrefabName) { return recipe; } } return null; } } internal static class Recolor { private static readonly MethodInfo CloneMethod = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly int MainTex = Shader.PropertyToID("_MainTex"); private static readonly HashSet<string> NotTinted = new HashSet<string> { "Chunks" }; private static readonly ParticleSystemCustomData[] CustomStreams = (ParticleSystemCustomData[])(object)new ParticleSystemCustomData[2] { default(ParticleSystemCustomData), (ParticleSystemCustomData)1 }; public static T ShallowCopy<T>(T obj) where T : class { if (obj != null) { return (T)CloneMethod.Invoke(obj, null); } return null; } public static GameObject ClonePrefab(GameObject original, string name, ElementColor? color, Action<GameObject> prepare = null) { if ((Object)(object)original == (Object)null) { return null; } GameObject prefab = PrefabManager.Instance.GetPrefab(name); if ((Object)(object)prefab != (Object)null) { return prefab; } GameObject val = PrefabManager.Instance.CreateClonedPrefab(name, original); prepare?.Invoke(val); if (color.HasValue) { Apply(val, color.Value.Hue, color.Value.MinSaturation, color.Value.Max); } PrefabManager.Instance.AddPrefab(val); return val; } public static EffectList CloneEffects(EffectList list, string prefix, ElementColor? color, Action<GameObject> prepare = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown EffectList val = new EffectList(); if (list == null || list.m_effectPrefabs == null) { return val; } List<EffectData> list2 = new List<EffectData>(); EffectData[] effectPrefabs = list.m_effectPrefabs; foreach (EffectData val2 in effectPrefabs) { if (val2 != null) { EffectData val3 = ShallowCopy<EffectData>(val2); if ((Object)(object)val2.m_prefab != (Object)null) { val3.m_prefab = ClonePrefab(val2.m_prefab, prefix + "_" + ((Object)val2.m_prefab).name, color, prepare); } list2.Add(val3); } } val.m_effectPrefabs = list2.ToArray(); return val; } public static void ScaleVisual(GameObject go, float factor) { //IL_0068: 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_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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Approximately(factor, 1f)) { return; } if ((Object)(object)go.GetComponent<Projectile>() != (Object)null) { foreach (Transform item in go.transform) { item.localScale *= factor; } } else { Transform transform = go.transform; transform.localScale *= factor; } ParticleSystem[] componentsInChildren = go.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; } Light[] componentsInChildren2 = go.GetComponentsInChildren<Light>(true); foreach (Light obj in componentsInChildren2) { obj.range *= factor; } } public static void Apply(GameObject go, float hue, float minSaturation, float maxSaturation = 1f) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] componentsInChildren = go.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { if (Skip(((Component)val).transform)) { continue; } MainModule main = val.main; ((MainModule)(ref main)).startColor = Shift(((MainModule)(ref main)).startColor, hue, minSaturation, maxSaturation); ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Shift(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, hue, minSaturation, maxSaturation); } CustomDataModule customData = val.customData; if (!((CustomDataModule)(ref customData)).enabled) { continue; } ParticleSystemCustomData[] customStreams = CustomStreams; foreach (ParticleSystemCustomData val2 in customStreams) { if ((int)((CustomDataModule)(ref customData)).GetMode(val2) == 2) { ((CustomDataModule)(ref customData)).SetColor(val2, Shift(((CustomDataModule)(ref customData)).GetColor(val2), hue, minSaturation, maxSaturation)); } } } Renderer[] componentsInChildren2 = go.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren2) { if (Skip(((Component)val3).transform)) { continue; } Material[] sharedMaterials = val3.sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { if (!((Object)(object)sharedMaterials[k] == (Object)null)) { sharedMaterials[k] = ShiftMaterial(sharedMaterials[k], hue, minSaturation, maxSaturation); } } val3.sharedMaterials = sharedMaterials; TrailRenderer val4 = (TrailRenderer)(object)((val3 is TrailRenderer) ? val3 : null); if (val4 != null) { val4.colorGradient = Shift(val4.colorGradient, hue, minSaturation, maxSaturation); continue; } LineRenderer val5 = (LineRenderer)(object)((val3 is LineRenderer) ? val3 : null); if (val5 != null) { val5.colorGradient = Shift(val5.colorGradient, hue, minSaturation, maxSaturation); } } Light[] componentsInChildren3 = go.GetComponentsInChildren<Light>(true); foreach (Light obj in componentsInChildren3) { obj.color = Shift(obj.color, hue, minSaturation, maxSaturation); } } private static Material ShiftMaterial(Material original, float hue, float minSaturation, float maxSaturation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(original) { name = ((Object)original).name.Replace(" (nokep)", "") + " (nokep)" }; Shader shader = val.shader; if (val.HasProperty(MainTex) && (Object)(object)val.GetTexture(MainTex) != (Object)null) { Texture val2 = (Texture)(object)TextureRecolor.Gray(val.GetTexture(MainTex)); if ((Object)(object)val2 != (Object)null) { val.SetTexture(MainTex, val2); } } for (int i = 0; i < shader.GetPropertyCount(); i++) { if ((int)shader.GetPropertyType(i) == 0) { int propertyNameId = shader.GetPropertyNameId(i); val.SetColor(propertyNameId, Shift(val.GetColor(propertyNameId), hue, minSaturation, maxSaturation)); } } return val; } private static bool Skip(Transform t) { return NotTinted.Contains(((Object)t).name); } public static Color Shift(Color c, float hue, float minSaturation, float maxSaturation = 1f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); Color result = Color.HSVToRGB(hue, Mathf.Clamp(num2, minSaturation, maxSaturation), num3, true); result.a = c.a; return result; } private static Gradient Shift(Gradient g, float hue, float minSaturation, float maxSaturation) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown if (g == null) { return null; } GradientColorKey[] colorKeys = g.colorKeys; for (int i = 0; i < colorKeys.Length; i++) { colorKeys[i].color = Shift(colorKeys[i].color, hue, minSaturation, maxSaturation); } Gradient val = new Gradient { mode = g.mode }; val.SetKeys(colorKeys, g.alphaKeys); return val; } private static MinMaxGradient Shift(MinMaxGradient g, float hue, float min, float max) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode; switch ((int)mode) { case 0: return new MinMaxGradient(Shift(((MinMaxGradient)(ref g)).color, hue, min, max)); case 2: return new MinMaxGradient(Shift(((MinMaxGradient)(ref g)).colorMin, hue, min, max), Shift(((MinMaxGradient)(ref g)).colorMax, hue, min, max)); case 1: return new MinMaxGradient(Shift(((MinMaxGradient)(ref g)).gradient, hue, min, max)); case 3: return new MinMaxGradient(Shift(((MinMaxGradient)(ref g)).gradientMin, hue, min, max), Shift(((MinMaxGradient)(ref g)).gradientMax, hue, min, max)); case 4: { MinMaxGradient result = default(MinMaxGradient); ((MinMaxGradient)(ref result))..ctor(Shift(((MinMaxGradient)(ref g)).gradient, hue, min, max)); ((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4; return result; } default: return g; } } } internal static class StaffEffects { public static StatusEffect Soaked; public static StatusEffect ArmorBreak; public static StatusEffect Weaken; public static StatusEffect Freeze; public static void AddAll() { Soaked = (StatusEffect)(object)Add("Nokep_SE_Soaked", "soaked", 10f, delegate(SoakedEffect se) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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) ((SE_Stats)se).m_mods = new List<DamageModPair> { new DamageModPair { m_type = (DamageType)64, m_modifier = (DamageModifier)8 }, new DamageModPair { m_type = (DamageType)128, m_modifier = (DamageModifier)8 } }; }); ArmorBreak = (StatusEffect)(object)Add<SE_Stats>("Nokep_SE_ArmorBreak", "armorbreak", 8f, (Action<SE_Stats>)delegate(SE_Stats se) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references)