Class DragDropManager
Manages drag and drop operations for DraggableModel instances. Handles mouse state tracking, drag detection, and 3D mouse projection.
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Gameplay
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class DragDropManager
Constructors
| Edit this page View SourceDragDropManager()
Declaration
public DragDropManager()
Properties
| Edit this page View SourceCurrentDraggedModel
Gets the currently dragged model, if any.
Declaration
public DraggableModel? CurrentDraggedModel { get; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public float DragPlaneY { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
IsDragging
Checks if any drag operation is currently in progress.
Declaration
public bool IsDragging { get; }
Property Value
| Type | Description |
|---|---|
| bool | True if dragging, false otherwise |
Methods
| Edit this page View SourceCancelDrag()
Cancels the current drag operation, returning the model to its original position.
Declaration
public void CancelDrag()
CheckDragStart(DraggableModel, Ray)
Checks if a drag operation should start with the given model.
Declaration
public bool CheckDragStart(DraggableModel model, Ray ray)
Parameters
| Type | Name | Description |
|---|---|---|
| DraggableModel | model | The model to potentially start dragging |
| Ray | ray | The ray from the mouse click |
Returns
| Type | Description |
|---|---|
| bool | True if drag started, false otherwise |
EndDrag(Vector3)
Ends the current drag operation.
Declaration
public void EndDrag(Vector3 dropWorldPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | dropWorldPosition | The 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.
Declaration
public DraggableModel? FindDropTarget(IEnumerable<DraggableModel> models, float maxDistance = 2)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<DraggableModel> | models | Collection of models to check |
| float | maxDistance | Maximum distance to consider for drop targeting |
Returns
| Type | Description |
|---|---|
| DraggableModel | The closest valid drop target or null |
ProjectMouseToWorld(Vector2)
Projects mouse coordinates to a 3D world position using the drag plane (Y=DragPlaneY).
Declaration
public Vector3 ProjectMouseToWorld(Vector2 mousePosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | mousePosition | Screen mouse position |
Returns
| Type | Description |
|---|---|
| Vector3 | World position on the drag plane |
SetCamera(Camera3D)
Sets the camera used for 3D mouse projections.
Declaration
public void SetCamera(Camera3D camera)
Parameters
| Type | Name | Description |
|---|---|---|
| Camera3D | camera | The 3D camera |
StartDrag(DraggableModel, Vector3, Ray)
Starts dragging the specified model.
Declaration
public void StartDrag(DraggableModel model, Vector3 hitPoint, Ray ray)
Parameters
| Type | Name | Description |
|---|---|---|
| DraggableModel | model | The model to drag |
| Vector3 | hitPoint | The 3D point where the mouse ray hit the model |
| Ray | ray | The mouse ray |
Update(double)
Updates the drag drop manager, handling mouse input and drag state.
Declaration
public void Update(double deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| double | deltaTime | Time since last update |
UpdateDropTargets(IEnumerable<DraggableModel>, float)
Updates drop target highlighting for all models based on current drag state.
Declaration
public void UpdateDropTargets(IEnumerable<DraggableModel> models, float maxDistance = 2)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<DraggableModel> | models | Collection of models to update |
| float | maxDistance | Maximum distance for drop targeting |