Class DragDropManager
Manages drag and drop operations for DraggableModel instances. Handles mouse state tracking, drag detection, and 3D mouse projection.
public class DragDropManager
- Inheritance
-
DragDropManager
- Inherited Members
Constructors
DragDropManager()
public DragDropManager()
Properties
CurrentDraggedModel
Gets the currently dragged model, if any.
public DraggableModel? CurrentDraggedModel { get; }
Property Value
- DraggableModel
The dragged model or null
DragPlaneY
World-space Y of the plane the dragged model tracks the cursor on. Set this to the play surface height (e.g. a board top) so the dragged model's X/Z stay under the cursor instead of leading it. Default 0 preserves the historical ground-plane behavior.
public float DragPlaneY { get; set; }
Property Value
IsDragging
Checks if any drag operation is currently in progress.
public bool IsDragging { get; }
Property Value
- bool
True if dragging, false otherwise
Methods
CancelDrag()
Cancels the current drag operation, returning the model to its original position.
public void CancelDrag()
CheckDragStart(DraggableModel, Ray)
Checks if a drag operation should start with the given model.
public bool CheckDragStart(DraggableModel model, Ray ray)
Parameters
modelDraggableModelThe model to potentially start dragging
rayRayThe ray from the mouse click
Returns
- bool
True if drag started, false otherwise
EndDrag(Vector3)
Ends the current drag operation.
public void EndDrag(Vector3 dropWorldPosition)
Parameters
dropWorldPositionVector3The world position where the model was dropped
FindDropTarget(IEnumerable<DraggableModel>, float)
Finds the closest model that can be a drop target for the currently dragged model.
public DraggableModel? FindDropTarget(IEnumerable<DraggableModel> models, float maxDistance = 2)
Parameters
modelsIEnumerable<DraggableModel>Collection of models to check
maxDistancefloatMaximum distance to consider for drop targeting
Returns
- DraggableModel
The closest valid drop target or null
ProjectMouseToWorld(Vector2)
Projects mouse coordinates to a 3D world position using the drag plane (Y=DragPlaneY).
public Vector3 ProjectMouseToWorld(Vector2 mousePosition)
Parameters
mousePositionVector2Screen mouse position
Returns
- Vector3
World position on the drag plane
SetCamera(Camera3D)
Sets the camera used for 3D mouse projections.
public void SetCamera(Camera3D camera)
Parameters
cameraCamera3DThe 3D camera
StartDrag(DraggableModel, Vector3, Ray)
Starts dragging the specified model.
public void StartDrag(DraggableModel model, Vector3 hitPoint, Ray ray)
Parameters
modelDraggableModelThe model to drag
hitPointVector3The 3D point where the mouse ray hit the model
rayRayThe mouse ray
Update(double)
Updates the drag drop manager, handling mouse input and drag state.
public void Update(double deltaTime)
Parameters
deltaTimedoubleTime since last update
UpdateDropTargets(IEnumerable<DraggableModel>, float)
Updates drop target highlighting for all models based on current drag state.
public void UpdateDropTargets(IEnumerable<DraggableModel> models, float maxDistance = 2)
Parameters
modelsIEnumerable<DraggableModel>Collection of models to update
maxDistancefloatMaximum distance for drop targeting