快捷键重构

This commit is contained in:
2025-05-25 00:54:06 +08:00
parent d6327c7946
commit 68b88d57db
186 changed files with 2248 additions and 1066 deletions

View File

@@ -56,10 +56,12 @@ namespace NBF
transform.rotation = _player.Data.rotation;
App.Inst.SetMouseCurrsor(false);
InputManager.OnRunAction += OnRunAction;
InputManager.OnQuickIndexAction += OnQuickIndexAction;
InputManager.OnUseTorchAction += OnUseTorchAction;
InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
InputManager.OnPlayerCanceled += OnPlayerCanceled;
InputManager.OnPlayerPerformed += OnPlayerPerformed;
// InputManager.OnRunAction += OnRunAction;
// InputManager.OnQuickIndexAction += OnQuickIndexAction;
// InputManager.OnUseTorchAction += OnUseTorchAction;
// InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
interactableLayer = LayerMask.GetMask("Interactive");
}
@@ -93,9 +95,8 @@ namespace NBF
private void OnDestroy()
{
InputManager.OnQuickIndexAction -= OnQuickIndexAction;
InputManager.OnUseTorchAction -= OnUseTorchAction;
InputManager.OnUseTelescopeAction -= OnUseTelescopeAction;
InputManager.OnPlayerCanceled -= OnPlayerCanceled;
InputManager.OnPlayerPerformed -= OnPlayerPerformed;
}
#region
@@ -283,28 +284,29 @@ namespace NBF
#region
private void OnRunAction(bool performed)
private void OnPlayerPerformed(string action)
{
if (performed) Sprint();
else StopSprinting();
}
private void OnQuickIndexAction(int index)
{
nextShowSlotIndex = index;
}
private void OnUseTorchAction(bool ret)
{
if (!ret)
if (action == "Run")
{
_player.Data.openLight = !_player.Data.openLight;
Sprint();
}
}
private void OnUseTelescopeAction(bool ret)
private void OnPlayerCanceled(string action)
{
if (!ret)
if (action == "Run")
{
StopSprinting();
}
else if (action.StartsWith("Quick"))
{
nextShowSlotIndex = int.Parse(action.Substring("Quick".Length));
}
else if (action == "UseTorch")
{
_player.Data.openLight = !_player.Data.openLight;
}
else if (action == "UseTelescope")
{
_player.Data.openTelescope = !_player.Data.openTelescope;
_player.ToggleTelescope();