private IEnumerator FollowSuccession(IGraph graph, INode node, IFlowPort port) { PullData(graph, node); //Debug.Log($"Triggering: '{node}.{port}'"); port.Trigger(this); if (!port.HasSuccession) { yield break; } if (port.IsAsync) { var succession = port.AsyncSuccession(this); while (succession.MoveNext()) { if (succession.Current is IFlowPort successionPort) { //Debug.Log($"Following Succession from '{node}.{port}' to '{node}.{successionPort}'"); SetData(node); yield return(FollowConnections(graph, node, successionPort)); } yield return(succession.Current); } } else { var successionPort = port.SerialSuccession(this); //Debug.Log($"Following Succession from '{node}.{port}' to '{node}.{successionPort}'"); SetData(node); yield return(FollowConnections(graph, node, successionPort)); } }
public IFlowPort Clone(IGraph graph) { string newName = (Node is IGraphFlowPortNode graphPortNode) ? graphPortNode.Name : $"On {Name}"; var port = new FlowPort { Id = new PortId(graph.NodeId, newName), Node = graph, Name = newName, Direction = Direction.Flip(), Capacity = Capacity, Flow = Flow, }; switch (Direction) { case PortDirection.Input: Linked = port; break; case PortDirection.Output: port.Linked = this; break; } return(port); }
internal FlowPort(IFlowPort symmetrical) { Node = symmetrical.Node; Io = symmetrical.Io.IsOutput() ? PortIO.In : PortIO.Out; Name = symmetrical.Name; Id = RedOwlHash.GetHashId($"{Node.Id}.{Name}.{Io}"); SerialSuccession = (flow) => symmetrical; }
private void WalkFlowPort(IFlowPort port) { foreach (var next in port.Execute()) { // TODO: Handle Yield Instructions / Custom Yield Instructions if (next is IFlowPort nextPort) { // Debug.Log($"Moving Towards Next Port {nextPort}"); if (nextPort.Direction == PortDirection.Input) { WalkValuePorts(nextPort.Node); } WalkFlowPort(nextPort); } } }
private IEnumerator FollowConnections(IGraph graph, INode node, IFlowPort port) { //Debug.Log($"Triggering: '{node}.{port}'"); port.Trigger(this); foreach (var connection in node.GetFlowConnections(port.Id)) { var nextNode = graph.GetNode(connection.TargetNode); var nextPort = nextNode.GetFlowPort(connection.TargetPort); //Debug.Log($"Following Connection from '{node}.{port}' to '{nextNode}.{nextPort}'"); _cycles += 1; if (_cycles > 250) { _cycles = 0; yield return(null); } _stack += 1; yield return(FollowSuccession(graph, nextNode, nextPort)); } }
public static IEnumerable <IFlowPort> GetConnectedPorts(this IFlowPort self) { return(self.Connections.Select(c => c.Source == self ? (IFlowPort)c.Destination : c.Source)); }