mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 13:05:36 +01:00
[MIRROR] Simple mouse drop improvements (#28597)
* Simple mouse drop improvements (#84406) ## About The Pull Request 1. Mouse drop now uses `CanReach()` which is more versatile instead of `Adjacent()` for adjacency checks 2. `CanReach()` & `DirectAccess()` are now part of `atom`. It's been moved up from `atom/movable` 3. It won't again check for adjacency inside `can_perform_action()` saving some overhead 4. Removing the nested `if` conditions from code is always a plus ## Changelog 🆑 code: improved mouse drag & drop code /🆑 * Simple mouse drop improvements --------- Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
This commit is contained in:
@@ -197,7 +197,7 @@
|
||||
* A backwards depth-limited breadth-first-search to see if the target is
|
||||
* logically "in" anything adjacent to us.
|
||||
*/
|
||||
/atom/movable/proc/CanReach(atom/ultimate_target, obj/item/tool, view_only = FALSE)
|
||||
/atom/proc/CanReach(atom/ultimate_target, obj/item/tool, view_only = FALSE)
|
||||
var/list/direct_access = DirectAccess()
|
||||
var/depth = 1 + (view_only ? STORAGE_VIEW_DEPTH : INVENTORY_DEPTH)
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
|
||||
return FALSE
|
||||
|
||||
/atom/movable/proc/DirectAccess()
|
||||
/atom/proc/DirectAccess()
|
||||
return list(src, loc)
|
||||
|
||||
/mob/DirectAccess(atom/target)
|
||||
|
||||
@@ -37,17 +37,13 @@
|
||||
// only if both dragged object & receiver agree to do checks do we proceed
|
||||
var/combined_atom_flags = interaction_flags_atom | over.interaction_flags_atom
|
||||
if(!(combined_atom_flags & INTERACT_ATOM_MOUSEDROP_IGNORE_CHECKS))
|
||||
if(!(combined_atom_flags & INTERACT_ATOM_MOUSEDROP_IGNORE_ADJACENT))
|
||||
if(!Adjacent(user) || !over.Adjacent(user))
|
||||
return // should stop you from dragging through windows
|
||||
//Check for adjacency
|
||||
if(!(combined_atom_flags & INTERACT_ATOM_MOUSEDROP_IGNORE_ADJACENT) && (!CanReach(user) || !over.CanReach(user)))
|
||||
return // should stop you from dragging through windows
|
||||
|
||||
if(!(combined_atom_flags & INTERACT_ATOM_MOUSEDROP_IGNORE_USABILITY))
|
||||
var/combined_flags = interaction_flags_mouse_drop | over.interaction_flags_mouse_drop
|
||||
if(combined_atom_flags & INTERACT_ATOM_MOUSEDROP_IGNORE_ADJACENT)
|
||||
combined_flags |= BYPASS_ADJACENCY
|
||||
else
|
||||
combined_flags |= SILENT_ADJACENCY
|
||||
if(!user.can_perform_action(src, combined_flags))
|
||||
//Bypass adjacency cause we already checked for it above
|
||||
if(!user.can_perform_action(src, interaction_flags_mouse_drop | over.interaction_flags_mouse_drop | BYPASS_ADJACENCY))
|
||||
return // is the mob not able to drag the object with both sides conditions applied
|
||||
|
||||
mouse_drop_dragged(over, user, src_location, over_location, params)
|
||||
|
||||
Reference in New Issue
Block a user