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

@@ -5,6 +5,7 @@ using Script.Gameplay.Connect;
using Script.Gameplay.Interface;
using Script.Gameplay.Input;
using System;
using UnityEngine.InputSystem;
namespace Script.Gameplay.Player
{
@@ -66,10 +67,10 @@ namespace Script.Gameplay.Player
void Start()
{
inputManager = InputManager.Instance;
inputManager.Input.Player.SetOutput.performed += ctx => SetPointA(CurrentTarget);
inputManager.Input.Player.SetInput.performed += ctx => SetPointB(CurrentTarget);
inputManager.Input.Player.Connect.performed += ctx => CreateConnection();
inputManager.Input.Player.CutLine.performed += ctx => CutConnectLine(CurrentTarget);
inputManager.Input.Player.SetOutput.performed += OnSetOutputOnperformed;
inputManager.Input.Player.SetInput.performed += OnSetInputOnperformed;
inputManager.Input.Player.Connect.performed += OnConnectOnperformed;
inputManager.Input.Player.CutLine.performed += OnCutLineOnperformed;
if (raycaster == null)
raycaster = GetComponent<FirstPersonRaycaster>() ?? GetComponentInChildren<FirstPersonRaycaster>();
@@ -81,6 +82,26 @@ namespace Script.Gameplay.Player
ControllerLocator.Instance.Register(this);
}
private void OnCutLineOnperformed(InputAction.CallbackContext ctx)
{
CutConnectLine(CurrentTarget);
}
private void OnConnectOnperformed(InputAction.CallbackContext ctx)
{
CreateConnection();
}
private void OnSetInputOnperformed(InputAction.CallbackContext ctx)
{
SetPointB(CurrentTarget);
}
private void OnSetOutputOnperformed(InputAction.CallbackContext ctx)
{
SetPointA(CurrentTarget);
}
void Update()
{
DetectConnectable();
@@ -147,7 +168,17 @@ namespace Script.Gameplay.Player
Debug.Log("Cannot create connection: invalid targets.");
}
}
private void OnDestroy()
{
ControllerLocator.Instance.Unregister(this);
inputManager.Input.Player.SetOutput.performed -= OnSetOutputOnperformed;
inputManager.Input.Player.SetInput.performed -= OnSetInputOnperformed;
inputManager.Input.Player.Connect.performed -= OnConnectOnperformed;
inputManager.Input.Player.CutLine.performed -= OnCutLineOnperformed;
}
void OnDrawGizmos()
{
// 射线可视化交由 FirstPersonRaycaster 处理