refactor(Connect): 重构连接体系,实现一个物体拥有多个连接线
This commit is contained in:
@@ -19,14 +19,14 @@ namespace Script.Gameplay.Player
|
||||
|
||||
private IConnectable outTarget;
|
||||
private IConnectable inputTarget;
|
||||
public event Action<IConnectable> OnSetOutputTarget;
|
||||
public event Action<IConnectable> OnSetInputTarget;
|
||||
public event Action<IConnectable> OnSetPointA;
|
||||
public event Action<IConnectable> OnSetPointB;
|
||||
|
||||
void Start()
|
||||
{
|
||||
inputManager = InputManager.Instance;
|
||||
inputManager.Input.Player.SetOutput.performed += ctx => SetOutTarget(currentTarget);
|
||||
inputManager.Input.Player.SetInput.performed += ctx => SetInputTarget(currentTarget);
|
||||
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);
|
||||
|
||||
@@ -77,34 +77,27 @@ namespace Script.Gameplay.Player
|
||||
return currentTarget;
|
||||
}
|
||||
|
||||
public void SetOutTarget(IConnectable target)
|
||||
public void SetPointA(IConnectable target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if(!IsEnableConnecting) return;
|
||||
if (!target.IsConnectedOutput)
|
||||
{
|
||||
outTarget = target;
|
||||
OnSetOutputTarget?.Invoke(outTarget);
|
||||
}
|
||||
outTarget = target;
|
||||
OnSetPointA?.Invoke(outTarget);
|
||||
}
|
||||
|
||||
public void SetInputTarget(IConnectable target)
|
||||
public void SetPointB(IConnectable target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if(!IsEnableConnecting) return;
|
||||
if (!target.IsConnectedInput)
|
||||
{
|
||||
inputTarget = currentTarget;
|
||||
OnSetInputTarget?.Invoke(inputTarget);
|
||||
}
|
||||
inputTarget = target;
|
||||
OnSetPointB?.Invoke(inputTarget);
|
||||
}
|
||||
|
||||
public void CutConnectLine(IConnectable target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if(target.OutputConnectionLine != null && target.InputConnectionLine != null) return;
|
||||
target.OutputConnectionLine?.DeleteConnection();
|
||||
target.InputConnectionLine?.DeleteConnection();
|
||||
if(!IsEnableConnecting) return;
|
||||
ConnectionLineManager.Instance.CutTargetConnectionLines(target);
|
||||
}
|
||||
|
||||
private void CreateConnection()
|
||||
|
Reference in New Issue
Block a user