public override void Execute(Editor arg) { this.type = this.GetDeleteWireSegmentType(arg, out Wire wire, out Edge <WireNode> edge); this.sourcePos = edge.Source.GetPosition(); this.targetPos = edge.Target.GetPosition(); switch (this.type) { case DeleteWireSegmentType.DeleteWire: wire.DisconnectAllIOs(); arg.Simulator.RemoveWire(wire); this.deletedWire = wire; break; case DeleteWireSegmentType.DeleteTarget: wire.RemoveNode(edge.Target); this.deletedTarget = edge.Target; break; case DeleteWireSegmentType.DeleteSource: wire.RemoveNode(edge.Source); this.deletedSource = edge.Source; break; case DeleteWireSegmentType.DeleteEdge: if (wire.DisconnectNodes(edge.Source, edge.Target, out Wire? newWire)) { arg.Simulator.AddWire(newWire); } break; } }
public override ExecutionWireNode GetNextExecutionNode() { TruePin = Outputs[0]; FalsePin = Outputs[1]; bool conditionResult; InputWirePin conditionInput = Inputs[1]; WireNode conditionNode = conditionInput.GetConnectedPin().GetOwner(); if (conditionNode is ComparationWireNode) // If the condition input is linked to a comparation, then we get the value of this comparation { conditionResult = (conditionNode as ComparationWireNode).GetResult(); } else // Otherwise we just take the input value, which can only be a boolean { conditionResult = (bool)conditionInput.Value; } if (conditionResult) // The condition is true { // Try to return the TRUE pin target's node if (TruePin.IsConnected == false || TruePin.GetConnectedPin() == null) { return(null); } return(TruePin.GetConnectedPin().GetOwner() as ExecutionWireNode); } // Try to return the FALSE pin target's node if (FalsePin.IsConnected == false || FalsePin.GetConnectedPin() == null) { return(null); } return(FalsePin.GetConnectedPin().GetOwner() as ExecutionWireNode); }
public override void Undo(Editor arg) { switch (this.type) { case DeleteWireSegmentType.DeleteWire: arg.Simulator.AddWire(this.deletedWire); this.deletedWire.UpdateIOs(); break; case DeleteWireSegmentType.DeleteTarget: WireNode source = Util.GetWireNodeFromPos(arg.Simulator, this.sourcePos, out Wire sourceWire); sourceWire.AddNode(this.deletedTarget); sourceWire.ConnectNodes(source, sourceWire, this.deletedTarget); break; case DeleteWireSegmentType.DeleteSource: WireNode target = Util.GetWireNodeFromPos(arg.Simulator, this.targetPos, out Wire targetWire); targetWire.AddNode(this.deletedSource); targetWire.ConnectNodes(this.deletedSource, targetWire, target); break; case DeleteWireSegmentType.DeleteEdge: source = Util.GetWireNodeFromPos(arg.Simulator, this.sourcePos, out sourceWire); target = Util.GetWireNodeFromPos(arg.Simulator, this.targetPos, out targetWire); if (sourceWire.ConnectNodes(source, targetWire, target)) { arg.Simulator.RemoveWire(targetWire); } break; } }
void StopConnecting() { isConnecting = false; isEscapable = true; currentConnecting = null; }
/// <summary> /// Called every time a node is saved. /// </summary> /// <param name="node"></param> private void ManageNodeSaving(WireNode node) { if (node is SayReplyWireNode) { SayReplyWireNode replyNode = node as SayReplyWireNode; replyNode.ReplyResourcePath = AssetDatabase.GetAssetPath(replyNode.Reply).Replace("Assets/Resources/", "").Replace(".asset", ""); replyNode.TargetResourcePath = AssetDatabase.GetAssetPath(replyNode.Target).Replace("Assets/Resources/", "").Replace(".asset", ""); } else if (node is SetAnimatorVariableWireNode) { SetAnimatorVariableWireNode setVarNode = node as SetAnimatorVariableWireNode; setVarNode.TargetResourcePath = AssetDatabase.GetAssetPath(setVarNode.TargetActor).Replace("Assets/Resources/", "").Replace(".asset", ""); } else if (node is GetAnimatorVariableWireNode) { GetAnimatorVariableWireNode getVarNode = node as GetAnimatorVariableWireNode; getVarNode.TargetResourcePath = AssetDatabase.GetAssetPath(getVarNode.TargetActor).Replace("Assets/Resources/", "").Replace(".asset", ""); } if (node is ISavable) { (node as ISavable).Save(); } if (OnSaveNode != null) { OnSaveNode.Invoke(node); } }
void ConnectNodes(WireNode a, WireNode b) { a.Connect(); b.Connect(); //Debug.Log("Connected " + a + " to " + b); }
public override void Execute(Editor arg) { Edge <WireNode> onEdge = Util.GetEdgeFromPos(arg.Simulator, this.endPos, out Wire wire); this.sourcePos = onEdge.Source.GetPosition(); this.targetPos = onEdge.Target.GetPosition(); WireNode newJunc = wire.CreateJunctionWireNode(this.endPos); wire.InsertNodeBetween(onEdge.Source, onEdge.Target, newJunc); IOWireNode ioNode = wire.CreateIOWireNode(this.startIO); if (IsCornerNeeded()) { // INCLUDE CORNER JunctionWireNode cornerNode = wire.CreateJunctionWireNode(this.corner); wire.ConnectNodes(newJunc, wire, cornerNode); wire.ConnectNodes(cornerNode, wire, ioNode); } else { // NO CORNER wire.ConnectNodes(newJunc, wire, ioNode); } }
public override void Undo(Editor arg) { WireNode source = Util.GetWireNodeFromPos(arg !.Simulator !, this.sourcePos, out Wire sourceWire); WireNode target = Util.GetWireNodeFromPos(arg !.Simulator !, this.targetPos, out Wire targetWire); WireNode newJunc = Util.GetWireNodeFromPos(arg !.Simulator !, this.position, out Wire newJuncWire); newJuncWire.RemoveNode(newJunc); sourceWire.ConnectNodes(source, targetWire, target); }
public override ExecutionWireNode GetNextExecutionNode() { OutputWirePin output = Outputs[0]; InputWirePin connectedPin = output.GetConnectedPin() as InputWirePin; WireNode connectedPinOwner = connectedPin.GetOwner(); if (!output.IsConnected || connectedPin == null) { return(null); } return(connectedPinOwner as ExecutionWireNode); }
public override void Undo(Editor arg) { WireNode source = Util.GetWireNodeFromPos(arg.Simulator, this.sourcePos, out Wire sourceWire); WireNode target = Util.GetWireNodeFromPos(arg.Simulator, this.targetPos, out Wire targetWire); WireNode newJunc = sourceWire.CreateJunctionWireNode(this.position); sourceWire.Graph.RemoveEdgeIf(e => e.Source == source && e.Target == target); sourceWire.Graph.AddEdge(new Edge <WireNode>(source, newJunc)); targetWire.Graph.AddEdge(new Edge <WireNode>(newJunc, target)); }
public static WireNode[] GetRandomNodes(int count) { List <WireNode> wireNodes = new List <WireNode>(); for (int i = 0; i < count; i++) { WireNode node = new WireNode(); node.Color(new Random().Next(4)); node.character = new Random().Next(10); wireNodes.Add(node); } return(wireNodes.ToArray()); }
public override void Undo(Editor arg) { foreach (Component component in this.selectedComponents) { component.Move(-this.delta); } foreach (Vector2 wireNodePos in this.selectedWireNodes) { WireNode wn = Util.GetWireNodeFromPos(arg.Simulator, wireNodePos + delta, out Wire wire); wn.Move(-this.delta); } }
public override void Undo(Editor arg) { WireNode startNode = Util.GetWireNodeFromPos(arg.Simulator, this.startPos, out Wire startWire); WireNode endNode = Util.GetWireNodeFromPos(arg.Simulator, this.endPos, out Wire endWire); endWire.RemoveNode(endNode); if (IsCornerNeeded()) { WireNode cornerNode = Util.GetWireNodeFromPos(arg.Simulator, this.corner, out Wire cornerWire); cornerWire.RemoveNode(cornerNode); } }
public override void Undo(Editor arg) { WireNode junctionNode = Util.GetWireNodeFromPos(arg.Simulator, this.junctionPosition, out Wire wire); if (this.IsCornerNeeded()) { // CORNER IS INCLUDED WireNode corner = Util.GetWireNodeFromPos(arg.Simulator, this.corner, out Wire cornerWire); cornerWire.RemoveNode(corner); } // REMOVE START NODE IOWIRENODE IOWireNode startNode = Util.GetIOWireNodeFromPos(arg.Simulator, this.startIO.GetPosition(), out Wire startWire); startWire.RemoveNode(startNode); }
public override void Execute(Editor arg) { WireNode node = Util.GetWireNodeFromPos(arg.Simulator, this.position, out Wire wire); List <Edge <WireNode> > edges = wire.Graph.AdjacentEdges(node).ToList(); this.sourcePos = edges[0].GetOtherVertex(node).GetPosition(); this.targetPos = edges[1].GetOtherVertex(node).GetPosition(); wire.RemoveNode(node); WireNode source = Util.GetWireNodeFromPos(arg.Simulator, this.sourcePos, out Wire sourceWire); WireNode target = Util.GetWireNodeFromPos(arg.Simulator, this.targetPos, out Wire targetWire); sourceWire.ConnectNodes(source, targetWire, target); }
void StartConnecting(WireNode n) { isConnecting = true; isEscapable = false; currentConnecting = n; DrawnWire = new GameObject(); DrawnWire.AddComponent <LineRenderer>(); LineRenderer lr = DrawnWire.GetComponent <LineRenderer>(); lr.material = wireMat; lr.startWidth = wireWidth; lr.endWidth = wireWidth; lr.sortingLayerName = "extras"; lr.SetPosition(0, currentConnecting.transform.position); }
public WirePortDataType GetLastInputDataTypeRecursively() { if( m_outputPorts[ 0 ].ExternalReferences.Count > 0 ) { WireNode rightWire = m_outputPorts[ 0 ].GetInputNode( 0 ) as WireNode: if( rightWire != null ) return rightWire.GetLastInputDataTypeRecursively(): else { return m_outputPorts[ 0 ].GetInputConnection( 0 ).DataType: } } if( m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid ) return m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.DataType: else return m_visualDataType: }
public override void Undo(Editor arg) { WireNode startNode = Util.GetIOWireNodeFromPos(arg.Simulator, this.startIO.GetPosition(), out Wire startWire); startWire.RemoveNode(startNode); WireNode endNode = Util.GetIOWireNodeFromPos(arg.Simulator, this.endIO.GetPosition(), out Wire endWire); endWire.RemoveNode(endNode); if (IsCornerNeeded()) { WireNode cornerNode = Util.GetJunctionWireNodeFromPos(arg.Simulator, this.corner, out Wire cornerWire); cornerWire.RemoveNode(cornerNode); } arg.Simulator.RemoveWire(startWire); }
public override void Execute(Editor arg) { WireNode startNode = Util.GetWireNodeFromPos(arg.Simulator, this.startPos, out Wire startWire); WireNode endNode = startWire.CreateJunctionWireNode(this.endPos); if (IsCornerNeeded()) { // INCLUDE CORNER WireNode cornerNode = startWire.CreateJunctionWireNode(this.corner); startWire.ConnectNodes(startNode, startWire, cornerNode); startWire.ConnectNodes(cornerNode, startWire, endNode); } else { // NO CORNER startWire.ConnectNodes(startNode, startWire, endNode); } }
public void SetRenderedNode(WireNode node) { RenderedNode = node; if (node == null) { return; } InputPinsDisplayer.Clear(); OutputPinsDisplayer.Clear(); foreach (InputWirePin input in RenderedNode.Inputs) { InputPinsDisplayer.Add(new WirePinDisplayer(this, input)); } foreach (OutputWirePin output in RenderedNode.Outputs) { OutputPinsDisplayer.Add(new WirePinDisplayer(this, output)); } }
protected override void Start() { base.Start(); isComplete = false; nodeGroup = GetComponentsInChildren <WireNode>(); GenerateConnections(); AttachSymbolsToNodes(); for (int i = 0; i < nodeGroup.Length; i++) { WireNode n = nodeGroup[i]; n.AssignSymbol(SymbolsToAttach[i]); //Debug.Log("symbol to attach: (" + i + ") " + SymbolsToAttach[i]); n.DrawSymbol(); n.GetComponent <CircleCollider2D>().enabled = false; } }
public override void Execute(Editor arg) { Wire newWire = new Wire(); WireNode startNode = newWire.CreateIOWireNode(this.startIO); WireNode endNode = newWire.CreateIOWireNode(this.endIO); if (IsCornerNeeded()) { WireNode cornerNode = newWire.CreateJunctionWireNode(this.corner); newWire.AddNode(cornerNode); newWire.ConnectNodes(startNode, newWire, cornerNode); newWire.ConnectNodes(cornerNode, newWire, endNode); } else { newWire.ConnectNodes(startNode, newWire, endNode); } arg.Simulator.AddWire(newWire); }
public WireReference FindNewValidInputNode( WireNode current ) { if( current.InputPorts[ 0 ].IsConnected ) { ParentNode node = m_containerGraph.GetNode( current.InputPorts[ 0 ].ExternalReferences[ 0 ].NodeId ): if( node != null ) { WireNode wireNode = node as WireNode: if( wireNode != null && wireNode.MarkToDelete ) { return FindNewValidInputNode( wireNode ): } else { return current.InputPorts[ 0 ].ExternalReferences[ 0 ]: } } } return null: }
public override void Undo(Editor arg) { if (this.IsCornerNeeded()) { // INCLUDED CORNER // DISCONNECT CORNER FROM START NODE WireNode cornerNode = Util.GetWireNodeFromPos(arg.Simulator, this.corner, out Wire cornerWire); WireNode startNode = Util.GetWireNodeFromPos(arg.Simulator, this.startPos, out Wire startWire); if (cornerWire.DisconnectNodes(cornerNode, startNode, out Wire? newWire)) { arg.Simulator.AddWire(newWire); } // DELETE CORNER NODE cornerNode = Util.GetWireNodeFromPos(arg.Simulator, this.corner, out cornerWire); cornerWire.RemoveNode(cornerNode); } else { // NO CORNER // DISCONNECT END FROM START NODE WireNode startNode = Util.GetWireNodeFromPos(arg.Simulator, this.startPos, out Wire startWire); WireNode end = Util.GetWireNodeFromPos(arg.Simulator, this.endPos, out Wire endW); if (startWire.DisconnectNodes(startNode, end, out Wire? newWire)) { arg.Simulator.AddWire(newWire); } } // DELETE END NODE WireNode endNode = Util.GetWireNodeFromPos(arg.Simulator, this.endPos, out Wire endWire); WireNode oldSource = Util.GetWireNodeFromPos(arg.Simulator, this.sourcePos, out Wire oldSourceWire); WireNode oldTarget = Util.GetWireNodeFromPos(arg.Simulator, this.targetPos, out Wire oldTargetWire); endWire.RemoveNode(endNode); oldSourceWire.ConnectNodes(oldSource, oldTargetWire, oldTarget); }
public override void Undo(Editor arg) { WireNode startNode = Util.GetIOWireNodeFromPos(arg.Simulator, this.startIO.GetPosition(), out Wire startWire); startWire.RemoveNode(startNode); if (this.IsCornerNeeded()) { // INCLUDE CORNER WireNode cornerNode = Util.GetJunctionWireNodeFromPos(arg.Simulator, this.corner, out Wire cornerWire); cornerWire.RemoveNode(cornerNode); } WireNode endNode = Util.GetJunctionWireNodeFromPos(arg.Simulator, this.endPos, out Wire endWire); WireNode oldSource = Util.GetWireNodeFromPos(arg.Simulator, this.sourcePos, out Wire oldSourceWire); WireNode oldTarget = Util.GetWireNodeFromPos(arg.Simulator, this.targetPos, out Wire oldTargetWire); endWire.RemoveNode(endNode); oldSourceWire.ConnectNodes(oldSource, oldTargetWire, oldTarget); }
public override void Execute(Editor arg) { WireNode junctionNode = Util.GetWireNodeFromPos(arg.Simulator, this.junctionPosition, out Wire wire); WireNode startNode = wire.CreateIOWireNode(this.startIO); WireNode?cornerNode = this.IsCornerNeeded() ? wire.CreateJunctionWireNode(this.corner) : null; wire.AddNode(startNode); if (cornerNode != null) { // INCLUDE CORNER wire.AddNode(cornerNode); wire.ConnectNodes(startNode, wire, cornerNode); wire.ConnectNodes(cornerNode, wire, junctionNode); } else { // NO CORNER wire.ConnectNodes(startNode, wire, junctionNode); } }
public override void Execute(Editor arg) { Wire wire = new Wire(); WireNode startNode = wire.CreateIOWireNode(this.startIO); WireNode endNode = wire.CreateJunctionWireNode(this.endPos); if (IsCornerNeeded()) { // INCLUDE CORNER WireNode cornerNode = wire.CreateJunctionWireNode(this.corner); wire.AddNode(cornerNode); wire.ConnectNodes(startNode, wire, cornerNode); wire.ConnectNodes(cornerNode, wire, endNode); } else { // NO CORNER wire.ConnectNodes(startNode, wire, endNode); } arg.Simulator.AddWire(wire); }
public override void Undo(Editor arg) { WireNode startNode = Util.GetJunctionWireNodeFromPos(arg.Simulator, this.startJunc, out Wire startWire); WireNode endNode = Util.GetJunctionWireNodeFromPos(arg.Simulator, this.endJunc, out Wire endWire); if (IsCornerNeeded()) { // INCLUDED CORNER JunctionWireNode cornerNode = Util.GetJunctionWireNodeFromPos(arg.Simulator, this.corner, out Wire cornerWire); if (cornerWire.DisconnectNodes(cornerNode, endNode, out Wire? newWire)) { arg.Simulator.AddWire(newWire); } cornerWire.RemoveNode(cornerNode); } else { // NO CORNER if (startWire.DisconnectNodes(startNode, endNode, out Wire? newWire)) { arg.Simulator.AddWire(newWire); } } }
public bool isPartner(WireNode p) { return(Partner == p); }
public void setPartner(WireNode p) { Partner = p; }