diff --git a/HarmonySrc/CinerariumGenie.cs b/HarmonySrc/CinerariumGenie.cs index d64100f..f09c78c 100644 --- a/HarmonySrc/CinerariumGenie.cs +++ b/HarmonySrc/CinerariumGenie.cs @@ -437,6 +437,7 @@ namespace NecromancerTome float _nextSleepCheck; bool _asleep; + bool _hiddenApplied; void Update() { @@ -451,9 +452,14 @@ namespace NecromancerTome transform.localPosition = Home(); } _asleep = asleep; - foreach (Renderer r in GetComponentsInChildren(true)) + if (_hiddenApplied != CinerariumGenie.Hidden) { - r.enabled = !CinerariumGenie.Hidden; + // Только при смене (16.10, проверка на утечки: раньше список рендереров собирался каждые 0.5 с - мусор для GC). + _hiddenApplied = CinerariumGenie.Hidden; + foreach (Renderer r in GetComponentsInChildren(true)) + { + r.enabled = !_hiddenApplied; + } } } if (_stuck || _asleep) diff --git a/HarmonySrc/HeldTweak.cs b/HarmonySrc/HeldTweak.cs index d9d66b1..ee0e7dd 100644 --- a/HarmonySrc/HeldTweak.cs +++ b/HarmonySrc/HeldTweak.cs @@ -72,19 +72,44 @@ namespace NecromancerTome } } + /// Сменить хват (HoldType) предмета в руке и пересобрать его в руке, как BloodTide (16.10: «давай попробуем в + /// режиме нитей разные хваты. Ты будешь перебирать их по моей просьбе»). Меняется класс предмета - до перезапуска + /// игры или следующей команды; итог переносится в items.xml. + public static string SetHold(int _hold) + { + EntityPlayerLocal pl = GameManager.Instance?.World?.GetPrimaryPlayer(); + Inventory inv = pl?.inventory; + ItemInventoryData held = inv?.holdingItemData; + if (held?.item == null) + { + return "в руке ничего"; + } + if (pl.Hand != null && pl.Hand.isSwitching || inv.IsHoldingItemActionRunning()) + { + return "рука занята - повторите"; + } + int was = held.item.HoldType.Value; + held.item.HoldType.Value = _hold; + ItemValue pv = (held.physicalItemValue ?? held.itemValue).Clone(); + pv.Seed = (ushort)(pv.Seed + 1); // «собранный» предмет устарел - соберётся заново (NeedsRebuild) + held.physicalItemValue = pv; + inv.SetHoldingItemIdx(inv.holdingItemIdx); + return held.item.Name + ": хват " + was + " -> " + _hold; + } + public static string F(float _v) => _v.ToString("0.###", CultureInfo.InvariantCulture); public static string F(Vector3 _v) => F(_v.x) + " " + F(_v.y) + " " + F(_v.z); } /// /// necroheld - посадка модели в руке: - /// pos x y z (см) | add x y z (см) | rot x y z (градусы) | scale s | off | show + /// pos x y z (см) | add x y z (см) | rot x y z (градусы) | scale s | hold N (хват, HoldType) | off | show /// [Preserve] public class ConsoleCmdNecroHeld : ConsoleCmdAbstract { public override string[] getCommands() => new[] { "necroheld" }; - public override string getDescription() => "NecromancerTome: посадка модели в руке - pos x y z (см)|add x y z (см)|rot x y z|scale s|off|show"; + public override string getDescription() => "NecromancerTome: посадка модели в руке - pos x y z (см)|add x y z (см)|rot x y z|scale s|hold N|off|show"; static bool Num(List _p, int _i, out float _v) { @@ -117,6 +142,12 @@ namespace NecromancerTome case "scale" when Num(_params, 1, out float s) && s > 0f: HeldTweak.Scale = s; break; + case "hold" when Num(_params, 1, out float h): + Out(HeldTweak.SetHold((int)h)); + return; + case "hold": + Out("хват предмета в руке: " + (GameManager.Instance?.World?.GetPrimaryPlayer()?.inventory?.holdingItem?.HoldType.Value.ToString() ?? "нет")); + return; case "off": HeldTweak.Enabled = false; HeldTweak.Pos = Vector3.zero; diff --git a/NecromancerHarmony.dll b/NecromancerHarmony.dll index 93fd8b8..085acf6 100644 Binary files a/NecromancerHarmony.dll and b/NecromancerHarmony.dll differ