diff --git a/Config/items.xml b/Config/items.xml index 1a082ea..96727b3 100644 --- a/Config/items.xml +++ b/Config/items.xml @@ -2021,14 +2021,15 @@ - + diff --git a/HarmonySrc/CinerariumThreads.cs b/HarmonySrc/CinerariumThreads.cs index 77e2179..42cbd61 100644 --- a/HarmonySrc/CinerariumThreads.cs +++ b/HarmonySrc/CinerariumThreads.cs @@ -15,7 +15,8 @@ namespace NecromancerTome /// ящики - любые. Урна с нитями - «логист»: её дух только перевозит, глазницы черепов светятся зелёным. /// /// Инструмент - нож некроманта «хватом для нитей»: отдельный предмет necroWpnBladeNecroKnifeThread (класс ножа в сейве - /// менять нельзя), переключение - меню по зажатому R, как у черепа (SkullDecorPlace); качество и моды переносятся + /// менять нельзя), переключение - пункт в меню ножа по R (то же меню, что «человек/змея/чертоги», SnakeMode.cs; 16.10: + /// своё меню по R перекрывало его - «ты убрал хваты чертогов памяти и духа змеи»); качество и моды переносятся /// (ItemValue.Clone со сменой типа). Как у стриппера: ПКМ - начать нить и закончить её (порядок = направление: ящик, потом /// урна - «откуда»; урна, потом ящик - «куда»), ЛКМ по урне или ящику - снять его нити. /// Первая версия - одиночная игра и хост (связи меняются на месте, клиентам сети - позже). @@ -58,37 +59,6 @@ namespace NecromancerTome Cancel(); } - public static void OnMenu(XUiC_Radial _sender, int _commandIndex, XUiC_Radial.RadialContextAbs _context) - { - EntityPlayerLocal pl = _sender?.xui?.playerUI?.entityPlayer; - if (_commandIndex == GripNormal) - { - Convert(pl, KnifeName); - } - else if (_commandIndex == GripThread) - { - Convert(pl, ThreadKnifeName); - } - } - - public static void OpenMenu(PlayerMoveController _pmc, EntityPlayerLocal _pl) - { - XUiC_Radial r = _pmc.playerUI?.xui?.RadialWindow; - if (r == null) - { - return; - } - bool thread = IsThreadKnife(_pl.inventory.holdingItem); - r.Open(); - r.ResetRadialEntries(); - r.CreateRadialEntry(GripNormal, "NecromancersKnife", "ItemIconAtlas", "", Localization.Get("necroKnifeGripNormal"), !thread); - // 16.10: «Есть в игре пиктограмма ниток, катушки?» - набор для шитья (катушка с иглой). - r.CreateRadialEntry(GripThread, "resourceSewingKit", "ItemIconAtlas", "", Localization.Get("necroKnifeGripThread"), thread); - r.SetCommonData(UIUtils.GetButtonIconForAction(_pmc.playerInput.Reload), OnMenu, - new XUiC_Radial.RadialContextHoldingSlotIndex(_pl.inventory.holdingItemIdx), thread ? GripThread : GripNormal, false, - XUiC_Radial.RadialValidSameHoldingSlotIndex); - } - // ------------------------------------------------------------------ // Соединение. // ------------------------------------------------------------------ @@ -414,28 +384,4 @@ namespace NecromancerTome return false; } } - - /// R с ножом некроманта (любым хватом) - меню хвата. Игра ножу по R ничего не открывает. - [HarmonyPatch(typeof(PlayerMoveController), nameof(PlayerMoveController.Update))] - public static class Patch_PlayerMoveController_Update_KnifeGrip - { - public static void Postfix(PlayerMoveController __instance) - { - EntityPlayerLocal pl = __instance.entityPlayerLocal; - if (pl == null || pl.inventory == null || !CinerariumThreads.IsKnife(pl.inventory.holdingItem) || pl.IsDead()) - { - return; - } - PlayerActionsLocal inp = __instance.playerInput; - if (inp == null || !(inp.Reload.WasPressed || inp.PermanentActions.Reload.WasPressed) || pl.inventory.IsHandSwitching()) - { - return; - } - if (__instance.playerUI == null || __instance.playerUI.windowManager.IsModalWindowOpen()) - { - return; - } - CinerariumThreads.OpenMenu(__instance, pl); - } - } } diff --git a/HarmonySrc/SnakeMode.cs b/HarmonySrc/SnakeMode.cs index a292e7d..a0e60fb 100644 --- a/HarmonySrc/SnakeMode.cs +++ b/HarmonySrc/SnakeMode.cs @@ -356,8 +356,22 @@ namespace NecromancerTome } } + public const int GripThreadIdx = 3; + public static void OnRadialCommand(XUiC_Radial _sender, int _commandIndex, XUiC_Radial.RadialContextAbs _context) { + EntityPlayerLocal pl = _sender.xui.playerUI.entityPlayer; + // Хват ножа (16.10, нити цинерария): 3 - хват для нитей; 0 у ножа-для-нитей - обычный хват. + if (_commandIndex == GripThreadIdx) + { + CinerariumThreads.Convert(pl, CinerariumThreads.ThreadKnifeName); + return; + } + if (_commandIndex == 0 && CinerariumThreads.IsThreadKnife(pl?.inventory?.holdingItem)) + { + CinerariumThreads.Convert(pl, CinerariumThreads.KnifeName); + return; + } if (_commandIndex == 1) { Enter(_sender.xui.playerUI.entityPlayer); @@ -374,7 +388,8 @@ namespace NecromancerTome { public static void Postfix(ItemAction __instance, ref bool __result) { - if (!__result && !SnakeMode.Active && !MindPalace.Active && SnakeMode.IsKnife(__instance.item)) + if (!__result && !SnakeMode.Active && !MindPalace.Active && + (SnakeMode.IsKnife(__instance.item) || CinerariumThreads.IsThreadKnife(__instance.item))) { __result = true; } @@ -389,6 +404,18 @@ namespace NecromancerTome public static bool Prefix(ItemAction __instance, XUiC_Radial _xuiRadialWindow, EntityPlayerLocal _epl) { + if (CinerariumThreads.IsThreadKnife(__instance.item)) + { + // Нож хватом для нитей: вернуть обычный хват (0) или остаться (3). + _xuiRadialWindow.ResetRadialEntries(); + _xuiRadialWindow.CreateRadialEntry(0, "NecromancersKnife", "ItemIconAtlas", "", + Localization.Get("necroKnifeGripNormal"), _highlighted: false); + _xuiRadialWindow.CreateRadialEntry(SnakeMode.GripThreadIdx, "resourceSewingKit", "ItemIconAtlas", "", + Localization.Get("necroKnifeGripThread"), _highlighted: true); + _xuiRadialWindow.SetCommonData(UIUtils.GetButtonIconForAction(_epl.playerInput.Reload), + SnakeMode.OnRadialCommand, null, SnakeMode.GripThreadIdx); + return false; + } if (!SnakeMode.IsKnife(__instance.item)) { return true; @@ -417,6 +444,9 @@ namespace NecromancerTome _xuiRadialWindow.CreateRadialEntry(2, SnakeMode.DayIcon, "UIAtlas", "", Localization.Get("necroSnakeModeDay"), _highlighted: false); } + // Хват для нитей (16.10: «Есть в игре пиктограмма ниток, катушки?» - набор для шитья) - в любое время суток. + _xuiRadialWindow.CreateRadialEntry(SnakeMode.GripThreadIdx, "resourceSewingKit", "ItemIconAtlas", "", + Localization.Get("necroKnifeGripThread"), _highlighted: false); _xuiRadialWindow.SetCommonData(UIUtils.GetButtonIconForAction(_epl.playerInput.Reload), SnakeMode.OnRadialCommand, null, 0); return false;