Одержимость: подсказка блока при наведении на дверь или выключатель (GetActivationText, клавиша E игрока)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0211fea34a
commit
fada747164
@@ -573,6 +573,27 @@ namespace NecromancerTome
|
||||
{
|
||||
XUiC_InteractionPrompt.SetText(ui, null);
|
||||
}
|
||||
// Подсказка на дверь или выключатель под прицелом одержимого (указание 13.10: «подсказка при наведении будет?»):
|
||||
// текст даёт сам блок (GetActivationText), клавиша - E игрока, как у персонажа.
|
||||
if (ui != null && !IsPet)
|
||||
{
|
||||
if (Time.time >= _promptNext)
|
||||
{
|
||||
_promptNext = Time.time + 0.15f;
|
||||
_prompt = null;
|
||||
if (FindUsable(world, z, false, out Vector3i ppos, out BlockValue pbv, out Block pb))
|
||||
{
|
||||
PlayerActionsLocal pin = _player.playerInput;
|
||||
string key = pin != null ? pin.Activate.GetBindingXuiMarkupString() + pin.PermanentActions.Activate.GetBindingXuiMarkupString() : "E";
|
||||
string t = pb.GetActivationText(world, pbv, ppos, _player);
|
||||
_prompt = t != null ? string.Format(t, key) : null;
|
||||
}
|
||||
}
|
||||
if (_prompt != null)
|
||||
{
|
||||
XUiC_InteractionPrompt.SetText(ui, _prompt);
|
||||
}
|
||||
}
|
||||
PlayerActionsLocal input = _player.playerInput;
|
||||
bool gui = _player.PlayerUI != null && _player.PlayerUI.windowManager.IsModalWindowOpen();
|
||||
if (input != null && !gui && (input.Reload.WasPressed || input.PermanentActions.Reload.WasPressed))
|
||||
@@ -2159,10 +2180,16 @@ namespace NecromancerTome
|
||||
/// (TEFeatureDoor - open/close), выключатели и лампы (light), рычаги квестов (activate). Без take, lock, edit,
|
||||
/// trigger. Запертую чужую дверь не откроет - замок проверяет сама дверь.</summary>
|
||||
static readonly string[] UseCommands = { "open", "close", "light", "activate" };
|
||||
public const float UseReach = 6f; // дальше луч не ищет; сама дальность - у блока (GetActivationDistanceSq)
|
||||
public const float UseReach = 6f;
|
||||
static float _promptNext;
|
||||
static string _prompt; // дальше луч не ищет; сама дальность - у блока (GetActivationDistanceSq)
|
||||
|
||||
static bool UseDoorOrSwitch(World _world, EntityAlive _z)
|
||||
/// <summary>Дверь, выключатель, лампа или рычаг под прицелом одержимого в пределах дальности блока - для E и подсказки.</summary>
|
||||
static bool FindUsable(World _world, EntityAlive _z, bool _log, out Vector3i pos, out BlockValue bv, out Block b)
|
||||
{
|
||||
pos = Vector3i.zero;
|
||||
bv = BlockValue.Air;
|
||||
b = null;
|
||||
Transform cam = _player?.cameraTransform;
|
||||
if (cam == null || _world == null)
|
||||
{
|
||||
@@ -2179,12 +2206,15 @@ namespace NecromancerTome
|
||||
Vector3 from = camW + fwd * Mathf.Max(0f, Vector3.Dot(head - camW, fwd));
|
||||
if (!Voxel.Raycast(_world, new Ray(from, fwd), UseReach, -555266077, 69, 0f))
|
||||
{
|
||||
Debug.Log("[NecromancerTome] Possession: E - под прицелом в " + UseReach + " м блока нет");
|
||||
if (_log)
|
||||
{
|
||||
Debug.Log("[NecromancerTome] Possession: E - под прицелом в " + UseReach + " м блока нет");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Vector3i pos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
BlockValue bv = _world.GetBlock(pos);
|
||||
Block b = bv.Block;
|
||||
pos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||
bv = _world.GetBlock(pos);
|
||||
b = bv.Block;
|
||||
// Створка большой двери - клетка-«ребёнок»; функция двери - у главной клетки. Как у персонажа
|
||||
// (PlayerMoveController): multiBlockPos.GetParentPos (тест 13.10: двустворчатая дверь не открывалась).
|
||||
if (bv.ischild && b?.multiBlockPos != null)
|
||||
@@ -2200,14 +2230,29 @@ namespace NecromancerTome
|
||||
// Дальность - самого блока, как у персонажа (GetActivationDistanceSq), от головы зомби.
|
||||
if ((Voxel.voxelRayHitInfo.hit.pos - _z.getHeadPosition()).sqrMagnitude >= b.GetActivationDistanceSq())
|
||||
{
|
||||
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " - далеко");
|
||||
if (_log)
|
||||
{
|
||||
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " - далеко");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Только двери (функция двери у составного блока) и выключатели, лампы, рычаги - E по ящику остаётся лутом.
|
||||
bool door = _world.GetTileEntity(pos) is TileEntityComposite tec && tec.GetFeature<TEFeatureDoor>() != null;
|
||||
if (!door && !(b is BlockSwitch) && !(b is BlockLight) && !(b is BlockActivateSwitch))
|
||||
{
|
||||
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " (" + b.GetType().Name + ") " + pos + " - не дверь и не выключатель");
|
||||
if (_log)
|
||||
{
|
||||
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " (" + b.GetType().Name + ") " + pos + " - не дверь и не выключатель");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool UseDoorOrSwitch(World _world, EntityAlive _z)
|
||||
{
|
||||
if (!FindUsable(_world, _z, true, out Vector3i pos, out BlockValue bv, out Block b))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BlockActivationCommand[] cmds = b.GetBlockActivationCommands(_world, bv, pos, _player);
|
||||
|
||||
Reference in New Issue
Block a user