Popcorning Guinea Pig
Search Results for

    Show / Hide Table of Contents

    Class DragDropManager

    Manages drag and drop operations for DraggableModel instances. Handles mouse state tracking, drag detection, and 3D mouse projection.

    Inheritance
    object
    DragDropManager
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: PopcorningGuineaPig.Engine.Gameplay
    Assembly: PopcorningGuineaPig.Engine.dll
    Syntax
    public class DragDropManager

    Constructors

    | Edit this page View Source

    DragDropManager()

    Declaration
    public DragDropManager()

    Properties

    | Edit this page View Source

    CurrentDraggedModel

    Gets the currently dragged model, if any.

    Declaration
    public DraggableModel? CurrentDraggedModel { get; }
    Property Value
    Type Description
    DraggableModel

    The dragged model or null

    | Edit this page View Source

    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
    | Edit this page View Source

    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 Source

    CancelDrag()

    Cancels the current drag operation, returning the model to its original position.

    Declaration
    public void CancelDrag()
    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    • Edit this page
    • View Source
    In this article
    Back to top © 2024 Popcorning Guinea Pig Game Engine. A custom C# game engine for indie developers.