refactor(Facility): 使用继承让所有机关都拥有了独自的 可交互 可编辑 可连接设定。大面积重构
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using Script.Gameplay.Connect;
|
||||
using Script.Gameplay.Interface;
|
||||
using Script.Gameplay.Input;
|
||||
using System;
|
||||
|
||||
@@ -9,14 +10,14 @@ namespace Script.Gameplay.Player
|
||||
{
|
||||
public class PlayerConnectController : MonoBehaviour
|
||||
{
|
||||
private bool isEnableConnecting = false;
|
||||
public bool IsEnableConnecting
|
||||
private bool _isEnablePlayerConnecting = false;
|
||||
public bool IsEnablePlayerConnecting
|
||||
{
|
||||
get => isEnableConnecting;
|
||||
get => _isEnablePlayerConnecting;
|
||||
set
|
||||
{
|
||||
isEnableConnecting = value;
|
||||
if (isEnableConnecting == false)
|
||||
_isEnablePlayerConnecting = value;
|
||||
if (_isEnablePlayerConnecting == false)
|
||||
{
|
||||
// 重置当前目标
|
||||
CurrentTarget = null;
|
||||
@@ -83,26 +84,16 @@ namespace Script.Gameplay.Player
|
||||
void DetectConnectable()
|
||||
{
|
||||
if (raycaster == null) return;
|
||||
if(!IsEnableConnecting) return;
|
||||
if(!IsEnablePlayerConnecting) return;
|
||||
|
||||
GameObject lookAtObj = raycaster.CurrentLookAtObject;
|
||||
IConnectable hitConnectable = lookAtObj != null ? lookAtObj.GetComponent<IConnectable>() : null;
|
||||
|
||||
// 注视对象变化时触发进入/离开(使用接口方法)
|
||||
if (hitConnectable != previousGazedTarget)
|
||||
{
|
||||
if (previousGazedTarget != null)
|
||||
{
|
||||
previousGazedTarget.OnGazeExit();
|
||||
}
|
||||
|
||||
if (hitConnectable != null)
|
||||
{
|
||||
hitConnectable.OnGazeEnter();
|
||||
}
|
||||
|
||||
previousGazedTarget = hitConnectable;
|
||||
}
|
||||
// if (hitConnectable != previousGazedTarget)
|
||||
// {
|
||||
// previousGazedTarget = hitConnectable;
|
||||
// }
|
||||
|
||||
CurrentTarget = hitConnectable;
|
||||
}
|
||||
@@ -110,8 +101,8 @@ namespace Script.Gameplay.Player
|
||||
public void SetPointA(IConnectable target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if (!IsEnableConnecting) return;
|
||||
if (!target.IsEnablePlayerConnect) return;
|
||||
if (!IsEnablePlayerConnecting) return;
|
||||
if (!target.IsEnableConnect) return;
|
||||
outTarget = target;
|
||||
OnSetPointA?.Invoke(outTarget);
|
||||
}
|
||||
@@ -119,9 +110,9 @@ namespace Script.Gameplay.Player
|
||||
public void SetPointB(IConnectable target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if (!IsEnableConnecting) return;
|
||||
if (!target.IsEnablePlayerConnect) return;
|
||||
|
||||
if (!IsEnablePlayerConnecting) return;
|
||||
if (!target.IsEnableConnect) return;
|
||||
|
||||
inputTarget = target;
|
||||
OnSetPointB?.Invoke(inputTarget);
|
||||
}
|
||||
@@ -129,13 +120,13 @@ namespace Script.Gameplay.Player
|
||||
public void CutConnectLine(IConnectable target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if(!IsEnableConnecting) return;
|
||||
if(!IsEnablePlayerConnecting) return;
|
||||
ConnectionLineManager.Instance.CutTargetConnectionLines(target);
|
||||
}
|
||||
|
||||
private void CreateConnection()
|
||||
{
|
||||
if(!IsEnableConnecting) return;
|
||||
if(!IsEnablePlayerConnecting) return;
|
||||
if (outTarget != null && inputTarget != null && outTarget != inputTarget)
|
||||
{
|
||||
//计算距离
|
||||
|
||||
Reference in New Issue
Block a user