Exemplo n.º 1
0
    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);
        }
    }
Exemplo n.º 2
0
    public override void Undo(Editor arg)
    {
        arg.Simulator.AddComponent(this.c);

        foreach (KeyValuePair <Vector2, IO> kvp in changedPositions)
        {
            JunctionWireNode jwn = Util.GetJunctionWireNodeFromPos(arg.Simulator, kvp.Key, out Wire wire);
            wire.ChangeJunctionNodeToIONode(jwn, kvp.Value);
        }
    }
Exemplo n.º 3
0
    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);
            }
        }
    }
Exemplo n.º 4
0
    public override void Execute(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())
        {
            // INCLUDE CORNER
            JunctionWireNode cornerNode = startWire.CreateJunctionWireNode(this.corner);
            startWire.ConnectNodes(startNode, startWire, cornerNode);
            if (startWire.ConnectNodes(cornerNode, endWire, endNode))
            {
                arg.Simulator.RemoveWire(endWire);
            }
        }
        else
        {
            // NO CORNER
            if (startWire.ConnectNodes(startNode, endWire, endNode))
            {
                arg.Simulator.RemoveWire(endWire);
            }
        }
    }