PetFarRecall: при выходе из одержимости питомцем - отзыв как книгой, если до тела хозяина дальше порога; ближе - идёт своим ходом. Консоль: necropetfar <блоки>|off. Логист: строки LogistForm в логе на нажатие R и на сборку меню блока - временно, до причины #77. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
3.4 KiB
C#
79 lines
3.4 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace NecromancerTome
|
|
{
|
|
/// <summary>
|
|
/// Дальний питомец после одержимости (указание 23.10.2026, #35: «Если питомец далеко от хозяина и хозяин вышел из режима
|
|
/// одержимости, то питомец должен сразу быть отозван. Скажем, если больше 100 блоков, то отзовём, если меньше, то
|
|
/// возвращается своим ходом»). Отзыв - тот же, что книгой (RecallPet: подсказка «… отозван», книга назад, если призыв её
|
|
/// тратит). Далеко ушедший питомец иначе остаётся в выгруженном участке, и PetFollowPatch снимает с него владение.
|
|
/// </summary>
|
|
public static class PetFarRecall
|
|
{
|
|
/// <summary>Порог в блоках; 0 - выключено (питомец всегда идёт своим ходом, как раньше).</summary>
|
|
public static float Distance = 100f;
|
|
|
|
/// <summary>true - питомец отозван (дальше ничего с ним не делать).</summary>
|
|
public static bool TryRecall(EntityPlayer _owner, EntityAlive _pet)
|
|
{
|
|
if (Distance <= 0f || _owner == null || _pet == null || _pet.IsDead())
|
|
{
|
|
return false;
|
|
}
|
|
float d = Vector3.Distance(_owner.position, _pet.position);
|
|
string cls = EntityClass.list.TryGetValue(_pet.entityClass, out EntityClass ec) ? ec.entityClassName : null;
|
|
if (d <= Distance || cls == null ||
|
|
!Patch_ItemActionSpawnEntity_Spawn_PetLimit.LimitedPets.TryGetValue(cls, out Patch_ItemActionSpawnEntity_Spawn_PetLimit.PetInfo info) ||
|
|
info.RecalledKey == null)
|
|
{
|
|
return false;
|
|
}
|
|
Debug.Log("[NecromancerTome] PetFarRecall: " + cls + " " + _pet.entityId + " в " + Mathf.RoundToInt(d) + " блоках от хозяина - отозван");
|
|
Patch_ItemActionSpawnEntity_Spawn_PetLimit.RecallPet(_owner, _pet.entityId, info.RecalledKey, info.ConsumesBook ? info.SummonItemName : null);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public class ConsoleCmdNecroPetFar : ConsoleCmdAbstract
|
|
{
|
|
public override bool IsExecuteOnClient => true;
|
|
|
|
public override bool AllowedInMainMenu => false;
|
|
|
|
public override string[] getCommands()
|
|
{
|
|
return new string[] { "necropetfar" };
|
|
}
|
|
|
|
public override string getDescription()
|
|
{
|
|
return "Necromancer's Tome: recall a far pet when leaving possession - distance.";
|
|
}
|
|
|
|
public override string getHelp()
|
|
{
|
|
return "necropetfar - status\n" +
|
|
"necropetfar <blocks> - recall the pet if it is farther than this from you\n" +
|
|
"necropetfar off - never recall, the pet always walks back";
|
|
}
|
|
|
|
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
|
{
|
|
SdtdConsole con = SingletonMonoBehaviour<SdtdConsole>.Instance;
|
|
if (_params.Count >= 1)
|
|
{
|
|
if (_params[0] == "off")
|
|
{
|
|
PetFarRecall.Distance = 0f;
|
|
}
|
|
else if (float.TryParse(_params[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out float v) && v >= 0f)
|
|
{
|
|
PetFarRecall.Distance = v;
|
|
}
|
|
}
|
|
con.Output("necropetfar: " + (PetFarRecall.Distance > 0f ? "recall farther than " + PetFarRecall.Distance + " blocks" : "off - the pet always walks back"));
|
|
}
|
|
}
|
|
}
|