feat(Cycle):实现循环提前检测,修复交互提示消失,按键绑定的事件在重启的时候没能正确,触发循环的提前检测有错误

This commit is contained in:
2025-10-27 10:31:01 +08:00
parent e8b9f47067
commit 9646483fa6
36 changed files with 6743 additions and 5221 deletions

View File

@@ -3,6 +3,7 @@ using Script.Gameplay.Interface;
using System;
using Core;
using Script.Gameplay.Input;
using UnityEngine.InputSystem;
namespace Script.Gameplay.Player
{
@@ -46,16 +47,19 @@ namespace Script.Gameplay.Player
Debug.LogWarning("FirstPersonRaycaster not found! Please assign or add it to the player.");
var input = InputManager.Instance.Input;
input.Player.Interact.performed += ctx =>
{
if(CurrentTarget == null) return;
if (!CurrentTarget.IsEnableInteract) return;
CurrentTarget.Interact(this.gameObject);
};
input.Player.Interact.performed += OnInteractOnperformed;
ControllerLocator.Instance.Register(this);
}
private void OnInteractOnperformed(InputAction.CallbackContext ctx)
{
if (CurrentTarget == null) return;
if (!CurrentTarget.IsEnableInteract) return;
CurrentTarget.Interact(this.gameObject);
}
void Update()
{
DetectInteractable();
@@ -81,6 +85,14 @@ namespace Script.Gameplay.Player
}
}
private void OnDestroy()
{
ControllerLocator.Instance.Unregister<PlayerInteractorController>(this);
var input = InputManager.Instance.Input;
input.Player.Interact.performed -= OnInteractOnperformed;
}
void OnDrawGizmos()
{
// 交由 FirstPersonRaycaster 绘制射线