Files
Bubberstation/code/datums/elements/openspace_item_click_handler.dm
SkyratBot 5591d15b5f [MIRROR] fix tile/rod/rcd multi-z hole repairs (#28387)
* fix tile/rod/rcd multi-z hole repairs (#84255)

## About The Pull Request
Fixes some interactions with attempting to patch multi-z holes.

1. openspace clicks happen on different z levels, so it's inherently a
*ranged* interaction- it was being ignored due to using the non ranged
signal
2. RCD was lacking the open space click handler,
3. #77540 still exists to a degree, I've refactored the click handler to
use parse_caught_click_modifiers to always grab the tile you're aiming
at rather than going off of whatever item you happened to click on
4. handle_openspace_click was treating the modifiers list as the old
parameters list
## Why It's Good For The Game
fix bugs, being able to repair holes is a very important and time
sensitive task that needs to flow well, and not require pixel hunting
## Changelog
🆑
fix: multi-z hole repair works better, especially when the turf below is
blocked by items
/🆑

* fix tile/rod/rcd multi-z hole repairs

---------

Co-authored-by: FlufflesTheDog <piecopresident@gmail.com>
2024-06-25 16:25:26 +05:30

27 lines
1.1 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 && user.CanReach(target_turf, source))
INVOKE_ASYNC(source, TYPE_PROC_REF(/obj/item, handle_openspace_click), target_turf, user, modifiers)
return ITEM_INTERACT_BLOCKING
return NONE