mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-13 11:12:14 +00:00
## About The Pull Request ports https://github.com/DaedalusDock/daedalusdock/pull/1144 ports https://github.com/DaedalusDock/daedalusdock/pull/1147 full credit to @Kapu1178 for the juice instead of `reacher.CanReach(target)` we now do `target.CanBeReachedBy(reacher)`, this allows us to give special behavior to atoms which we want to reach, which is exactly what I need for a feature I'm working on. ## Why It's Good For The Game allows us to be more flexible with reachability ## Changelog 🆑 refactor: refactored how reaching items works, report any oddities with being unable to reach something you should be able to! /🆑
27 lines
1.2 KiB
Plaintext
27 lines
1.2 KiB
Plaintext
/**
|
|
* allow players to easily use items such as iron rods, rcds on open space without
|
|
* having to pixelhunt for portions not occupied by object or mob visuals.
|
|
*/
|
|
/datum/element/openspace_item_click_handler
|
|
|
|
/datum/element/openspace_item_click_handler/Attach(datum/target)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
RegisterSignal(target, COMSIG_RANGED_ITEM_INTERACTING_WITH_ATOM, PROC_REF(divert_interaction))
|
|
|
|
/datum/element/openspace_item_click_handler/Detach(datum/source)
|
|
UnregisterSignal(source, COMSIG_RANGED_ITEM_INTERACTING_WITH_ATOM)
|
|
return ..()
|
|
|
|
//Invokes the proctype with a turf above as target.
|
|
/datum/element/openspace_item_click_handler/proc/divert_interaction(obj/item/source, mob/user, atom/target, list/modifiers)
|
|
SIGNAL_HANDLER
|
|
if((target.z == 0) || (user.z == 0) || target.z == user.z)
|
|
return NONE
|
|
var/turf/target_turf = parse_caught_click_modifiers(modifiers, get_turf(user.client?.eye || user), user.client)
|
|
if(target_turf?.z == user.z && target_turf.IsReachableBy(user, source?.reach))
|
|
INVOKE_ASYNC(source, TYPE_PROC_REF(/obj/item, handle_openspace_click), target_turf, user, modifiers)
|
|
return ITEM_INTERACT_BLOCKING
|
|
return NONE
|