refactor(Facility): 使用继承让所有机关都拥有了独自的 可交互 可编辑 可连接设定。大面积重构

This commit is contained in:
2025-10-22 17:34:58 +08:00
parent acd8282ff0
commit 5198a80318
61 changed files with 1516 additions and 889 deletions

View File

@@ -47,10 +47,9 @@ namespace Script.Gameplay.Player
var input = InputManager.Instance.Input;
input.Player.Interact.performed += ctx =>
{
if (CurrentTarget != null)
{
CurrentTarget.Interact(this.gameObject);
}
if(CurrentTarget == null) return;
if (!CurrentTarget.IsEnableInteract) return;
CurrentTarget.Interact(this.gameObject);
};
ControllerLocator.Instance.Register(this);
@@ -72,17 +71,17 @@ namespace Script.Gameplay.Player
// 如果命中对象与之前注视的不一样,触发进入/离开事件
if (hitInteractable != previousGazedTarget)
{
if (previousGazedTarget != null)
{
previousGazedTarget.OnGazeExit(this.gameObject);
}
if (hitInteractable != null)
{
hitInteractable.OnGazeEnter(this.gameObject);
// 这里可以显示交互提示UI例如 “E - 开门”
//Debug.Log(hitInteractable.GetInteractPrompt());
}
// if (previousGazedTarget != null)
// {
// previousGazedTarget.OnGazeExit(this.gameObject);
// }
//
// if (hitInteractable != null)
// {
// hitInteractable.OnGazeEnter(this.gameObject);
// // 这里可以显示交互提示UI例如 “E - 开门”
// //Debug.Log(hitInteractable.GetInteractPrompt());
// }
previousGazedTarget = hitInteractable;
}
@@ -95,7 +94,7 @@ namespace Script.Gameplay.Player
isEnablePlayerInteraction = isEnabled;
if (!isEnabled && previousGazedTarget != null)
{
previousGazedTarget.OnGazeExit(this.gameObject);
// previousGazedTarget.OnGazeExit(this.gameObject);
previousGazedTarget = null;
CurrentTarget = null;
}