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 SkillBooks v1.0.0
plugins/SkillBooks/SkillBooks.dll
Decompiled 12 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("JotunnModStub")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JotunnModStub")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("6.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("6.1.0.0")] namespace JotunnModStub; [BepInPlugin("com.user.skillbooks", "SkillBooks", "6.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class JotunnModStub : BaseUnityPlugin { [HarmonyPatch(typeof(FishingFloat), "Catch")] public static class FishingFloat_Catch_Patch { public static void Postfix(Fish fish, Character owner) { if ((Object)(object)fish == (Object)null) { return; } Player val = (Player)(object)((owner is Player) ? owner : null); if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && Random.value <= 0.03f) { GameObject prefab = PrefabManager.Instance.GetPrefab("SunkenChest"); if ((Object)(object)prefab != (Object)null && ((Humanoid)val).GetInventory() != null) { GiveOrDropItem(val, ((Humanoid)val).GetInventory(), prefab, 1); ((MonoBehaviour)val).StartCoroutine(NotifyChestCaughtRoutine(val)); } } } } [HarmonyPatch(typeof(Humanoid), "UseItem")] public static class Humanoid_UseItem_Patch { public static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer && item != null) { Inventory inventory2 = inventory ?? ((Humanoid)val).GetInventory(); if (HandleItemActivation(val, inventory2, item)) { return false; } } return true; } } [HarmonyPatch(typeof(InventoryGrid), "OnRightClick")] public static class InventoryGrid_OnRightClick_Patch { public static bool Prefix(InventoryGrid __instance, UIInputHandler element) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)element == (Object)null) { return true; } Inventory inventory = __instance.GetInventory(); if (inventory == null || inventory != ((Humanoid)Player.m_localPlayer).GetInventory()) { return true; } Vector2i val = (Vector2i)AccessTools.Method(typeof(InventoryGrid), "GetButtonPos", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { ((Component)element).gameObject }); ItemData itemAt = inventory.GetItemAt(val.x, val.y); if (itemAt != null && HandleItemActivation(Player.m_localPlayer, inventory, itemAt)) { return false; } return true; } } public const string PluginVersion = "6.1.0"; private readonly Harmony _harmony = new Harmony("com.user.skillbooks"); private static bool _isBusy = false; private static string _pluginFolder; private static readonly List<SkillType> All24Skills = new List<SkillType> { (SkillType)7, (SkillType)3, (SkillType)1, (SkillType)6, (SkillType)12, (SkillType)13, (SkillType)104, (SkillType)110, (SkillType)8, (SkillType)14, (SkillType)2, (SkillType)5, (SkillType)102, (SkillType)100, (SkillType)108, (SkillType)107, (SkillType)10, (SkillType)9, (SkillType)105, (SkillType)106, (SkillType)101, (SkillType)103, (SkillType)4, (SkillType)11 }; private static readonly Dictionary<string, List<SkillType>> BooksById = new Dictionary<string, List<SkillType>> { { "SkillBook_Haldor", new List<SkillType> { (SkillType)7, (SkillType)3, (SkillType)1, (SkillType)6, (SkillType)12, (SkillType)13, (SkillType)104, (SkillType)110 } }, { "SkillBook_Hildir", new List<SkillType> { (SkillType)8, (SkillType)14, (SkillType)2, (SkillType)5, (SkillType)102, (SkillType)100, (SkillType)108, (SkillType)107 } }, { "SkillBook_BogWitch", new List<SkillType> { (SkillType)10, (SkillType)9, (SkillType)105, (SkillType)106, (SkillType)101, (SkillType)103, (SkillType)4, (SkillType)11 } }, { "SkillBook_Universal", All24Skills } }; private static readonly Dictionary<string, int> BookLevelBonus = new Dictionary<string, int> { { "SkillBook_Haldor", 1 }, { "SkillBook_Hildir", 1 }, { "SkillBook_BogWitch", 1 }, { "SkillBook_Universal", 3 } }; private static readonly Dictionary<string, string> ExactSharedNameToId = new Dictionary<string, string>(); private static string _chestSharedName = ""; private static string _keySharedName = ""; private void Awake() { _pluginFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); PrefabManager.OnVanillaPrefabsAvailable += CreateItemsAndRecipes; _harmony.PatchAll(); Logger.LogInfo((object)"Мод SkillBooks v6.1.0 успешно загружен!"); } private static void PlayEffect(string effectName, Vector3 position) { //IL_0021: 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) ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(effectName) : null); if ((Object)(object)val != (Object)null) { Object.Instantiate<GameObject>(val, position, Quaternion.identity); } } private void CreateItemsAndRecipes() { //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_0041: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00ea: Expected O, but got Unknown //IL_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown RegisterBigGoldCoin(); RegisterSunkenChestAndKey(); RegisterBook("SkillBook_Haldor", "Трактат Воина и Добытчика", "Высеченные на бересте заветы сынов Ивальди. В строках этих таится звон наковален Нидавеллира и ярость берсерков, что ведут руку воина в бою и в глубинах недр.\n\n(ПКМ в инвентаре или клавиша 1-8: +1 к случайному навыку боя или добычи)", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "BigGoldCoin", Amount = 5 }, new RequirementConfig { Item = "SurtlingCore", Amount = 5 } }); RegisterBook("SkillBook_Hildir", "Руководство Следопыта", "Потрепанный путевой дневник, хранящий шепот ветров Иггдрасиля. Мудрость древних охотников учит ступать бесшумно, разить без промаха и не знать усталости в пути.\n\n(ПКМ в инвентаре или клавиша 1-8: +1 к случайному навыку ловкости, ремесла или стрельбы)", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "BigGoldCoin", Amount = 5 }, new RequirementConfig { Item = "Feathers", Amount = 15 } }); RegisterBook("SkillBook_BogWitch", "Гримуар Болотной Ведьмы", "Тяжелый фолиант в переплете из кожи драугра, пахнущий тиной и полынью. В его рунах сокрыты тайны сейда, древних отваров и шепот богов, забытых в туманах.\n\n(ПКМ в инвентаре или клавиша 1-8: +1 к случайному навыку магии, скрытности или хозяйства)", (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "BigGoldCoin", Amount = 5 }, new RequirementConfig { Item = "AncientSeed", Amount = 5 } }); RegisterBook("SkillBook_Universal", "Утерянный Фолиант Всеотца", "<color=#FFA500>Реликвия</color>\nДревний свиток, извлеченный из затонувшего ларца. В его рунах заключена мудрость всех путей Мидгарда.\n\n(ПКМ в инвентаре или клавиша 1-8: +3 уровня к случайному навыку из всех 24)", null); PrefabManager.OnVanillaPrefabsAvailable -= CreateItemsAndRecipes; } private void RegisterSunkenChestAndKey() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0127: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0143: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) Sprite icon = LoadCustomIcon("SunkenChest"); ItemConfig val = new ItemConfig { Name = "Затонувший ларец", Description = "<color=#00FFFF>Редкость</color>\nТяжелый кованый ларец из почерневшего от морской соли дуба, опутанный водорослями. Внутри слышен звон монет и шелест древнего пергамента, но массивный замок намертво заклинило.\n\n(Требуется Рунный ключ глубин. Нажмите ПКМ в инвентаре, чтобы отпереть)", Amount = 1, Weight = 5f, StackSize = 5, Icon = icon }; CustomItem val2 = new CustomItem("SunkenChest", "AmberPearl", val); SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)1; shared.m_maxStackSize = 5; _chestSharedName = shared.m_name; ItemManager.Instance.AddItem(val2); Sprite icon2 = LoadCustomIcon("TreasureKey"); ItemConfig val3 = new ItemConfig(); val3.Name = "Рунный ключ глубин"; val3.Description = "<color=#FFFF00>Ключ</color>\nТяжелый ключ, выкованный из панциря левиафана, чешуи морского змея и бронзы. Древний хитин слишком хрупок для заржавевших механизмов — ключ рассыплется сразу после отпирания одного ларца."; val3.Amount = 1; val3.Weight = 0.5f; val3.StackSize = 10; val3.Icon = icon2; val3.CraftingStation = CraftingStations.Forge; val3.MinStationLevel = 1; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = "Chitin", Amount = 40 }, new RequirementConfig { Item = "SerpentScale", Amount = 5 }, new RequirementConfig { Item = "Bronze", Amount = 5 } }; ItemConfig val4 = val3; CustomItem val5 = new CustomItem("TreasureKey", "CryptKey", val4); SharedData shared2 = val5.ItemDrop.m_itemData.m_shared; shared2.m_itemType = (ItemType)1; shared2.m_maxStackSize = 10; _keySharedName = shared2.m_name; ItemManager.Instance.AddItem(val5); } private void RegisterBigGoldCoin() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown Sprite icon = LoadCustomIcon("BigGoldCoin"); ItemConfig val = new ItemConfig(); val.Name = "Большая золотая монета"; val.Description = "<color=yellow>Ценные</color>\nУвесистый диск червонного золота, переплавленный в жару кузнечного горна из сотни мелких монет. Хранит блеск сокровищниц Нидавеллира, но при обратной переплавке малая часть металла неизбежно выгорает в огне."; val.Amount = 1; val.Weight = 1f; val.StackSize = 100; val.Icon = icon; val.CraftingStation = CraftingStations.Forge; val.MinStationLevel = 1; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Coins", Amount = 100 }, new RequirementConfig { Item = "Coal", Amount = 1 } }; ItemConfig val2 = val; CustomItem val3 = new CustomItem("BigGoldCoin", "Coins", val2); SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_value = 90; shared.m_maxStackSize = 100; ItemManager.Instance.AddItem(val3); RecipeConfig val4 = new RecipeConfig(); val4.Name = "Recipe_UncraftBigGoldCoin"; val4.Item = "Coins"; val4.Amount = 90; val4.CraftingStation = CraftingStations.Workbench; val4.MinStationLevel = 1; val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "BigGoldCoin", Amount = 1 } }; RecipeConfig val5 = val4; ItemManager.Instance.AddRecipe(new CustomRecipe(val5)); } private void RegisterBook(string id, string title, string desc, RequirementConfig[] reqs) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) Sprite icon = LoadCustomIcon(id); ItemConfig val = new ItemConfig { Name = title, Description = desc, Amount = 1, Weight = 0.5f, StackSize = 20, Icon = icon }; if (reqs != null) { val.CraftingStation = CraftingStations.Workbench; val.MinStationLevel = 1; val.Requirements = reqs; } CustomItem val2 = new CustomItem(id, "AmberPearl", val); SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)1; shared.m_maxStackSize = 20; ExactSharedNameToId[shared.m_name] = id; ItemManager.Instance.AddItem(val2); } private static Sprite LoadCustomIcon(string id) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00ff: 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) Assembly executingAssembly = Assembly.GetExecutingAssembly(); string value = id + ".png"; MethodInfo methodInfo = AccessTools.Method("UnityEngine.ImageConversion:LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }, (Type[])null); if (methodInfo == null) { return null; } string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.EndsWith(value, StringComparison.OrdinalIgnoreCase)) { continue; } using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream != null) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if ((bool)methodInfo.Invoke(null, new object[2] { val, array })) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } } return null; } private static bool IsSunkenChest(ItemData item) { if (item == null || item.m_shared == null) { return false; } return item.m_shared.m_name == _chestSharedName || item.m_shared.m_name.ToLowerInvariant().Contains("sunkenchest"); } private static bool IsTreasureKey(ItemData item) { if (item == null || item.m_shared == null) { return false; } return item.m_shared.m_name == _keySharedName || item.m_shared.m_name.ToLowerInvariant().Contains("treasurekey"); } private static bool TryUnlockSunkenChest(Player player, Inventory inventory, ItemData clickedItem) { bool flag = IsSunkenChest(clickedItem); bool flag2 = IsTreasureKey(clickedItem); if (!flag && !flag2) { return false; } if (_isBusy) { ((Character)player).Message((MessageType)2, "Вы уже заняты делом...", 0, (Sprite)null, false); return true; } ItemData val = (ItemData)(flag ? ((object)clickedItem) : ((object)inventory.GetAllItems().Find(IsSunkenChest))); ItemData val2 = (ItemData)(flag2 ? ((object)clickedItem) : ((object)inventory.GetAllItems().Find(IsTreasureKey))); if (val == null) { ((Character)player).Message((MessageType)2, "В инвентаре нет Затонувшего ларца для этого ключа.", 0, (Sprite)null, false); return true; } if (val2 == null) { ((Character)player).Message((MessageType)2, "Замок заклинило! Нужен Рунный ключ глубин.", 0, (Sprite)null, false); return true; } ((MonoBehaviour)player).StartCoroutine(UnlockChestRoutine(player, inventory, val, val2)); return true; } private static IEnumerator UnlockChestRoutine(Player player, Inventory inventory, ItemData chestItem, ItemData keyItem) { _isBusy = true; ((Character)player).Message((MessageType)2, "Отпирание рунного замка...", 0, (Sprite)null, false); yield return (object)new WaitForSeconds(1.5f); _isBusy = false; if (!((Object)(object)player == (Object)null) && !((Character)player).IsDead() && inventory != null && inventory.ContainsItem(chestItem) && inventory.ContainsItem(keyItem)) { inventory.RemoveOneItem(chestItem); inventory.RemoveOneItem(keyItem); PlayEffect("sfx_build_hammer_metal", ((Component)player).transform.position); ((Character)player).Message((MessageType)2, "Затонувший ларец открыт! Сокровища получены.", 0, (Sprite)null, false); GiveOrDropItem(player, inventory, PrefabManager.Instance.GetPrefab("SkillBook_Universal"), 1); GiveOrDropItem(player, inventory, ZNetScene.instance.GetPrefab("Coins"), Random.Range(80, 151)); GiveOrDropItem(player, inventory, ZNetScene.instance.GetPrefab("Ruby"), Random.Range(2, 5)); GiveOrDropItem(player, inventory, ZNetScene.instance.GetPrefab("AmberPearl"), Random.Range(3, 7)); } } private static void GiveOrDropItem(Player player, Inventory inventory, GameObject prefab, int amount) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0073: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null || amount <= 0) { return; } if (inventory.CanAddItem(prefab, amount)) { inventory.AddItem(prefab, amount); return; } Vector3 val = ((Component)player).transform.position + ((Component)player).transform.forward * 1.2f + Vector3.up * 1f; GameObject val2 = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity); ItemDrop component = val2.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_stack = amount; } } private static string GetBookId(ItemData item) { if (item == null || item.m_shared == null) { return null; } if (ExactSharedNameToId.TryGetValue(item.m_shared.m_name, out var value)) { return value; } string text = item.m_shared.m_name.ToLowerInvariant(); if (text.Contains("skillbook_haldor")) { return "SkillBook_Haldor"; } if (text.Contains("skillbook_hildir")) { return "SkillBook_Hildir"; } if (text.Contains("skillbook_bogwitch")) { return "SkillBook_BogWitch"; } if (text.Contains("skillbook_universal")) { return "SkillBook_Universal"; } return null; } private static bool HandleItemActivation(Player player, Inventory inventory, ItemData item) { if (TryUnlockSunkenChest(player, inventory, item)) { return true; } string bookId = GetBookId(item); if (bookId == null) { return false; } if (_isBusy) { ((Character)player).Message((MessageType)2, "Вы уже изучаете книгу...", 0, (Sprite)null, false); return true; } Skills skills = ((Character)player).GetSkills(); List<SkillType> list = BooksById[bookId].FindAll((SkillType s) => skills.GetSkillLevel(s) < 100f); if (list.Count == 0) { ((Character)player).Message((MessageType)2, "Все навыки из этой книги уже достигли 100 уровня!", 0, (Sprite)null, false); return true; } int value; int bonusLevels = ((!BookLevelBonus.TryGetValue(bookId, out value)) ? 1 : value); ((MonoBehaviour)player).StartCoroutine(ReadBookRoutine(player, inventory, item, list, bonusLevels)); return true; } private unsafe static IEnumerator ReadBookRoutine(Player player, Inventory inventory, ItemData item, List<SkillType> available, int bonusLevels) { _isBusy = true; ((Character)player).Message((MessageType)2, "Изучение...", 0, (Sprite)null, false); yield return (object)new WaitForSeconds(1.5f); _isBusy = false; if ((Object)(object)player == (Object)null || ((Character)player).IsDead() || inventory == null || item == null || !inventory.ContainsItem(item)) { yield break; } Skills skills = ((Character)player).GetSkills(); SkillType chosen = available[Random.Range(0, available.Count)]; if (AccessTools.Field(typeof(Skills), "m_skillData")?.GetValue(skills) is Dictionary<SkillType, Skill> skillMap) { if (!skillMap.TryGetValue(chosen, out var skillData)) { ((Character)player).RaiseSkill(chosen, 0.01f); skillMap.TryGetValue(chosen, out skillData); } if (skillData != null) { float oldLevel = Mathf.Floor(skillData.m_level); skillData.m_level = Mathf.Min(100f, oldLevel + (float)bonusLevels); skillData.m_accumulator = 0f; int gained = (int)(skillData.m_level - oldLevel); EffectList skillLevelupEffects = player.m_skillLevelupEffects; if (skillLevelupEffects != null) { skillLevelupEffects.Create(((Character)player).GetHeadPoint(), Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } AccessTools.Method(typeof(Player), "OnSkillLevelUp", (Type[])null, (Type[])null)?.Invoke(player, new object[2] { chosen, skillData.m_level }); string skillName = Localization.instance.Localize("$skill_" + ((object)(*(SkillType*)(&chosen))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant()); ((Character)player).Message((MessageType)2, $"{skillName} +{gained} (уровень {(int)skillData.m_level})", 0, (Sprite)null, false); } } inventory.RemoveOneItem(item); } private static IEnumerator NotifyChestCaughtRoutine(Player player) { yield return (object)new WaitForSeconds(1.5f); if ((Object)(object)player != (Object)null && !((Character)player).IsDead()) { PlayEffect("sfx_coins_placed", ((Component)player).transform.position); ((Character)player).Message((MessageType)2, "<color=#00FFFF>Вместе с уловом вы вытянули Затонувший ларец!", 0, (Sprite)null, false); ((Character)player).Message((MessageType)1, "Получено: Затонувший ларец", 0, (Sprite)null, false); } } }