Одержимость: подсказка блока при наведении на дверь или выключатель (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);
|
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;
|
PlayerActionsLocal input = _player.playerInput;
|
||||||
bool gui = _player.PlayerUI != null && _player.PlayerUI.windowManager.IsModalWindowOpen();
|
bool gui = _player.PlayerUI != null && _player.PlayerUI.windowManager.IsModalWindowOpen();
|
||||||
if (input != null && !gui && (input.Reload.WasPressed || input.PermanentActions.Reload.WasPressed))
|
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,
|
/// (TEFeatureDoor - open/close), выключатели и лампы (light), рычаги квестов (activate). Без take, lock, edit,
|
||||||
/// trigger. Запертую чужую дверь не откроет - замок проверяет сама дверь.</summary>
|
/// trigger. Запертую чужую дверь не откроет - замок проверяет сама дверь.</summary>
|
||||||
static readonly string[] UseCommands = { "open", "close", "light", "activate" };
|
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;
|
Transform cam = _player?.cameraTransform;
|
||||||
if (cam == null || _world == null)
|
if (cam == null || _world == null)
|
||||||
{
|
{
|
||||||
@@ -2178,13 +2205,16 @@ namespace NecromancerTome
|
|||||||
Vector3 head = _z.getHeadPosition();
|
Vector3 head = _z.getHeadPosition();
|
||||||
Vector3 from = camW + fwd * Mathf.Max(0f, Vector3.Dot(head - camW, fwd));
|
Vector3 from = camW + fwd * Mathf.Max(0f, Vector3.Dot(head - camW, fwd));
|
||||||
if (!Voxel.Raycast(_world, new Ray(from, fwd), UseReach, -555266077, 69, 0f))
|
if (!Voxel.Raycast(_world, new Ray(from, fwd), UseReach, -555266077, 69, 0f))
|
||||||
|
{
|
||||||
|
if (_log)
|
||||||
{
|
{
|
||||||
Debug.Log("[NecromancerTome] Possession: E - под прицелом в " + UseReach + " м блока нет");
|
Debug.Log("[NecromancerTome] Possession: E - под прицелом в " + UseReach + " м блока нет");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Vector3i pos = Voxel.voxelRayHitInfo.hit.blockPos;
|
pos = Voxel.voxelRayHitInfo.hit.blockPos;
|
||||||
BlockValue bv = _world.GetBlock(pos);
|
bv = _world.GetBlock(pos);
|
||||||
Block b = bv.Block;
|
b = bv.Block;
|
||||||
// Створка большой двери - клетка-«ребёнок»; функция двери - у главной клетки. Как у персонажа
|
// Створка большой двери - клетка-«ребёнок»; функция двери - у главной клетки. Как у персонажа
|
||||||
// (PlayerMoveController): multiBlockPos.GetParentPos (тест 13.10: двустворчатая дверь не открывалась).
|
// (PlayerMoveController): multiBlockPos.GetParentPos (тест 13.10: двустворчатая дверь не открывалась).
|
||||||
if (bv.ischild && b?.multiBlockPos != null)
|
if (bv.ischild && b?.multiBlockPos != null)
|
||||||
@@ -2199,15 +2229,30 @@ namespace NecromancerTome
|
|||||||
}
|
}
|
||||||
// Дальность - самого блока, как у персонажа (GetActivationDistanceSq), от головы зомби.
|
// Дальность - самого блока, как у персонажа (GetActivationDistanceSq), от головы зомби.
|
||||||
if ((Voxel.voxelRayHitInfo.hit.pos - _z.getHeadPosition()).sqrMagnitude >= b.GetActivationDistanceSq())
|
if ((Voxel.voxelRayHitInfo.hit.pos - _z.getHeadPosition()).sqrMagnitude >= b.GetActivationDistanceSq())
|
||||||
|
{
|
||||||
|
if (_log)
|
||||||
{
|
{
|
||||||
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " - далеко");
|
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " - далеко");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Только двери (функция двери у составного блока) и выключатели, лампы, рычаги - E по ящику остаётся лутом.
|
// Только двери (функция двери у составного блока) и выключатели, лампы, рычаги - E по ящику остаётся лутом.
|
||||||
bool door = _world.GetTileEntity(pos) is TileEntityComposite tec && tec.GetFeature<TEFeatureDoor>() != null;
|
bool door = _world.GetTileEntity(pos) is TileEntityComposite tec && tec.GetFeature<TEFeatureDoor>() != null;
|
||||||
if (!door && !(b is BlockSwitch) && !(b is BlockLight) && !(b is BlockActivateSwitch))
|
if (!door && !(b is BlockSwitch) && !(b is BlockLight) && !(b is BlockActivateSwitch))
|
||||||
|
{
|
||||||
|
if (_log)
|
||||||
{
|
{
|
||||||
Debug.Log("[NecromancerTome] Possession: E по " + b.GetBlockName() + " (" + b.GetType().Name + ") " + pos + " - не дверь и не выключатель");
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
BlockActivationCommand[] cmds = b.GetBlockActivationCommands(_world, bv, pos, _player);
|
BlockActivationCommand[] cmds = b.GetBlockActivationCommands(_world, bv, pos, _player);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user