refactor(Connect): 重构连接体系,实现一个物体拥有多个连接线
This commit is contained in:
@@ -23,20 +23,35 @@ namespace Script.Gameplay.Connect
|
||||
GeneratePreviousConnectionLines(preConnectionLines);
|
||||
}
|
||||
|
||||
public ConnectionLine GenerateConnectionLine(IConnectable source, IConnectable target)
|
||||
public ConnectionLine GenerateConnectionLine(IConnectable a, IConnectable b)
|
||||
{
|
||||
GameObject lineObject = Instantiate(linePrefab, this.transform);
|
||||
ConnectionLine connectionLine = lineObject.GetComponent<ConnectionLine>();
|
||||
if (connectionLine != null)
|
||||
{
|
||||
source.OutputConnectionLine = connectionLine;
|
||||
target.InputConnectionLine = connectionLine;
|
||||
connectionLine.SetConnectable(source, target);
|
||||
connectionLine.SetConnectable(a, b);
|
||||
connectionLines.Add(connectionLine);
|
||||
return connectionLine;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void CutTargetConnectionLines(IConnectable target)
|
||||
{
|
||||
List<ConnectionLine> linesToRemove = new List<ConnectionLine>();
|
||||
foreach (var line in connectionLines)
|
||||
{
|
||||
if (line != null && (line.Equals(target)))
|
||||
{
|
||||
linesToRemove.Add(line);
|
||||
}
|
||||
}
|
||||
foreach (var line in linesToRemove)
|
||||
{
|
||||
connectionLines.Remove(line);
|
||||
Destroy(line.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void GeneratePreviousConnectionLines(List<PreviousConnection> previousConnections)
|
||||
{
|
||||
|
Reference in New Issue
Block a user