Table of Contents

Class DragDropManager

Namespace
PopcorningGuineaPig.Engine.Gameplay
Assembly
PopcorningGuineaPig.Engine.dll

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

float

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

model DraggableModel

The model to potentially start dragging

ray Ray

The 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

dropWorldPosition Vector3

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.

public DraggableModel? FindDropTarget(IEnumerable<DraggableModel> models, float maxDistance = 2)

Parameters

models IEnumerable<DraggableModel>

Collection of models to check

maxDistance float

Maximum 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

mousePosition Vector2

Screen 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

camera Camera3D

The 3D camera

StartDrag(DraggableModel, Vector3, Ray)

Starts dragging the specified model.

public void StartDrag(DraggableModel model, Vector3 hitPoint, Ray ray)

Parameters

model DraggableModel

The model to drag

hitPoint Vector3

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.

public void Update(double deltaTime)

Parameters

deltaTime double

Time 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

models IEnumerable<DraggableModel>

Collection of models to update

maxDistance float

Maximum distance for drop targeting