public override InputReturns MouseLeftUp(StateControls stateControls) { primaryLine.InsertAndAttach(stateControls.State.Wires, stateControls.State.Connections); secondaryLine.InsertAndAttach(stateControls.State.Wires, stateControls.State.Connections); if (primaryLine.StartPoint != secondaryLine.EndPoint) { stateControls.RegisterChange($"Created wire from {primaryLine.StartPoint}-{secondaryLine.EndPoint}"); } else { stateControls.State.Propogate(); } return(true, new WireToolState()); }
public override InputReturns Cut(StateControls stateControls, HashSet <BoardObject> clipBoard) { //if no objects can be cut, return if (selections.Count == 0) { return(false, this); } clipBoard.Clear(); foreach (var selection in selections) { selection.Delete(stateControls.State); clipBoard.Add((CircuitObject)selection.Copy()); } selections.Clear(); stateControls.RegisterChange("Cut selections"); return(true, this); }
public override InputReturns MouseLeftUp(StateControls stateControls) { CheckIntersections(stateControls.State); if (intersectedBoxes.Count > 0) { //If the objects were just created and are placed in an invalid state, they have nowhere //to be reset to and thus should be destroyed if (!resettable) { selections.Clear(); return(true, new SelectionToolState(selections)); } Vec2 totalOffset = startPosition - selectedObject.StartPoint; Vec2 totalOffsetR = startPosition.Round() - selectedObject.StartPoint.Round(); foreach (var selection in selections) { selection.OffsetPosition(selection.Gridded ? totalOffsetR : totalOffset); } } stateControls.State.AttachAll(selections); //If it has moved, register movement if (intersectedBoxes.Count == 0 && startPosition != selectedObject.StartPoint) { stateControls.RegisterChange(resettable ? "Moved selections" : "Placed selections"); } else { stateControls.State.Propogate(); } return(true, new SelectionToolState(selections)); }
public override InputReturns MouseRightUp(StateControls stateControls) { stateControls.RegisterChange("Deleted Wires"); return(true, new WireToolState()); }