-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors the paper bin behavior for dragging to pick up into an elem…
…ent (#57501) * Drag pickup element for the paper bin behavior * invokes async on put_in_hands to comply with the linter * documented and like better names * blackspace
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* drag_pickup element; for allowing things to be picked up by dragging. | ||
* | ||
* Used for paper bins. | ||
*/ | ||
/datum/element/drag_pickup | ||
element_flags = ELEMENT_DETACH | ||
|
||
/datum/element/drag_pickup/Attach(datum/target) | ||
if(!ismovable(target)) | ||
return ELEMENT_INCOMPATIBLE | ||
RegisterSignal(target, COMSIG_MOUSEDROP_ONTO, .proc/pick_up) | ||
return ..() | ||
|
||
/datum/element/drag_pickup/Detach(datum/source, force) | ||
UnregisterSignal(source, COMSIG_MOUSEDROP_ONTO) | ||
return ..() | ||
|
||
/datum/element/drag_pickup/proc/pick_up(atom/source, atom/over, mob/user) | ||
SIGNAL_HANDLER | ||
var/mob/living/picker = user | ||
if(!istype(picker) || picker.incapacitated() || !source.Adjacent(picker)) | ||
return | ||
|
||
if(over == picker) | ||
INVOKE_ASYNC(picker, /mob/.proc/put_in_hands, source) | ||
else if(istype(over, /atom/movable/screen/inventory/hand)) | ||
var/atom/movable/screen/inventory/hand/Selected_hand = over | ||
picker.putItemFromInventoryInHandIfPossible(source, Selected_hand.held_index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters