Skip to content

DragController ​

Inherits: Node

Centralized drag-and-drop coordinator Handles all drag logic that was previously in DraggedItem Works with signals from UI components to coordinate operations

Variables ​

DragSourceInfocurrent_dragnull
ContentTypecurrent_content_typeContentType.NONE
DragTypedrag_typeDragType.NORMAL
ItemInstanceenchant_scrollnull

Methods ​

boolrequest_drag_from_inventory( item: ItemInstance, quantity: int, slot_data: SlotInstance )
boolrequest_drag_from_equipment( item: ItemInstance, slot_data: SlotInstance )
boolrequest_drag_from_action_bar( item: ItemInstance, quantity: int )
boolrequest_drag_ability( ability: AbilityInstance, source_type: String = "spellbook" )
boolrequest_enchanting_mode( scroll: ItemInstance, player: Entity )
DropResultrequest_drop_at_position( position: Vector2 )
voidcancel_drag()
voidexit_enchanting_mode()
boolcan_drop_on_target( target_type: DropTargetType, target_slot: SlotInstance = null )
boolis_dragging()
boolis_enchanting()
ItemInstanceget_current_drag_item()
AbilityInstanceget_current_drag_ability()
Variantget_current_drag_content()
boolis_dragging_item()
boolis_dragging_ability()

Signals ​

drag_started( item: ItemInstance, source_info: DragSourceInfo ) ​

========== SIGNALS ==========

drag_ended( success: bool ) ​

Emitted when a drag ends: whether it worked.

drop_processed( result: DropResult ) ​

Emitted when a drop was worked out, with its result.

enchanting_started( scroll: ItemInstance ) ​

Emitted when the player starts to use an enchant scroll: the scroll.

enchanting_ended( success: bool, target: ItemInstance ) ​

Emitted when the use of the scroll ends: whether it worked, and the target.

validation_failed( reason: String ) ​

Emitted when a drop is refused, with the reason.

Enumerations ​

enum DragType ​

========== ENUMS ==========

  • NORMAL = 0
  • ENCHANTING = 1
  • SPLIT_STACK = 2

enum ContentType ​

The options of content type: none, item, ability.

  • NONE = 0
  • ITEM = 1
  • ABILITY = 2

enum DropTargetType ​

The options of drop target type: inventory slot, equipment slot, vendor slot, action bar, socket slot, invalid.

  • INVENTORY_SLOT = 0
  • EQUIPMENT_SLOT = 1
  • VENDOR_SLOT = 2
  • ACTION_BAR = 3
  • SOCKET_SLOT = 4
  • INVALID = 5
  • WORLD = 6

Variable descriptions ​

DragSourceInfo current_drag = null ​

========== STATE ==========

ContentType current_content_type = ContentType.NONE ​

What is dragged now: an item, an ability or nothing.

DragType drag_type = DragType.NORMAL ​

What kind of drag it is (normal or enchanting).

ItemInstance enchant_scroll = null ​

The enchant scroll being used.

Method descriptions ​

bool request_drag_from_inventory( item: ItemInstance, quantity: int, slot_data: SlotInstance ) ​

Request to start dragging an item from inventory

bool request_drag_from_equipment( item: ItemInstance, slot_data: SlotInstance ) ​

Request to start dragging an item from equipment

bool request_drag_from_action_bar( item: ItemInstance, quantity: int ) ​

Request to start dragging from action bar (validation mode)

bool request_drag_ability( ability: AbilityInstance, source_type: String = "spellbook" ) ​

NEW: Request to start dragging ability from spellbook/action bar

bool request_enchanting_mode( scroll: ItemInstance, player: Entity ) ​

Request to start enchanting mode

DropResult request_drop_at_position( position: Vector2 ) ​

Request drop at position - determines target and processes

void cancel_drag() ​

Cancel current drag

void exit_enchanting_mode() ​

Exit enchanting mode

bool can_drop_on_target( target_type: DropTargetType, target_slot: SlotInstance = null ) ​

Check if item can drop on target

bool is_dragging() ​

Is something dragged?

bool is_enchanting() ​

Is an enchant scroll in use?

ItemInstance get_current_drag_item() ​

The item being dragged (or the scroll), or null.

AbilityInstance get_current_drag_ability() ​

The ability being dragged, or null.

Variant get_current_drag_content() ​

What is being dragged (an item or an ability), or null.

bool is_dragging_item() ​

Is an item dragged?

bool is_dragging_ability() ​

Is an ability dragged?