using System;
using System.Collections.Generic;
using UnityEngine;
namespace XNode
{
[Serializable]
public class PortConnection {
[SerializeField] public string fieldName;
[SerializeField] public string connectionLabel;
[SerializeField] public Node node;
public NodePort Port { get { return port != null ? port : port = GetPort(); } }
[NonSerialized] protected NodePort port;
/// Extra connection path points for organization
[SerializeField] public List reroutePoints = new List();
public PortConnection(NodePort port, string connectionLabel = null) {
this.port = port;
node = port.node;
fieldName = port.fieldName;
this.connectionLabel = connectionLabel;
}
/// Returns the port that this points to
private NodePort GetPort() {
if (node == null || string.IsNullOrEmpty(fieldName)) return null;
return node.GetPort(fieldName);
}
}
}