refactor(Facility): 使用继承让所有机关都拥有了独自的 可交互 可编辑 可连接设定。大面积重构
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user