Interface ICollisionProvider
Interface for providing collision detection and prevention during node drag operations. External systems (like collision managers) can implement this interface to prevent nodes from overlapping during drag without directly modifying node positions themselves.
public interface ICollisionProvider
Remarks
This follows the "single authority" pattern where the drag system remains the sole authority for setting node positions. Collision providers suggest offsets to prevent overlap, and the drag system applies them after snap offsets.
Semantic difference from ISnapProvider:
- Snap = attraction (guide lines pull nodes toward alignment)
- Collision = repulsion (prevents nodes from overlapping)
Methods
GetCollisionOffset(IReadOnlyList<Node>, Point)
Calculate an offset to prevent collision for nodes being dragged.
Point? GetCollisionOffset(IReadOnlyList<Node> nodes, Point proposedPosition)
Parameters
nodesIReadOnlyList<Node>The nodes currently being dragged.
proposedPositionPointThe position the drag system is proposing for the primary node (after applying delta, grid snapping, and snap provider offset).
Returns
- Point?
An offset to apply to prevent collision, or null if no collision would occur. The offset is relative to the proposed position.
OnDragEnd(IReadOnlyList<Node>, bool)
Called when a drag operation ends.
void OnDragEnd(IReadOnlyList<Node> nodes, bool cancelled)
Parameters
nodesIReadOnlyList<Node>The nodes that were dragged.
cancelledboolWhether the drag was cancelled.
OnDragStart(IReadOnlyList<Node>, Point)
Called when a drag operation starts.
void OnDragStart(IReadOnlyList<Node> nodes, Point startPosition)
Parameters
nodesIReadOnlyList<Node>The nodes being dragged.
startPositionPointThe starting canvas position of the drag.