Files
Bubberstation/code/datums/elements/openspace_item_click_handler.dm
SkyratBot a431d06e1e [MIRROR] Fixes difficulties with placing lattices on multiz maps. (#7126)
* Fixes difficulties with placing lattices on multiz maps. (#60124)

Title. Because of mob and object visuals under open space being able to be hovered over with the cursor and examined and in general acting as entities distint from the turf holding them it tends to be hard or even impossible to build floor and catwalks over these turfs. This PR aims to fix it with a basically simple, more-convenient-than-a-painstaking-refactor and easy to apply element (edit: and proc).

* Fixes difficulties with placing lattices on multiz maps.

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2021-07-26 15:47:43 +01:00

26 lines
1023 B
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
element_flags = ELEMENT_DETACH
/datum/element/openspace_item_click_handler/Attach(datum/target)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_ITEM_AFTERATTACK, .proc/on_afterattack)
/datum/element/openspace_item_click_handler/Detach(datum/source)
UnregisterSignal(source, COMSIG_ITEM_AFTERATTACK)
return ..()
//Invokes the proctype with a turf above as target.
/datum/element/openspace_item_click_handler/proc/on_afterattack(obj/item/source, atom/target, mob/user, proximity_flag, click_parameters)
SIGNAL_HANDLER
if(target.z == user.z)
return
var/turf/turf_above = get_step_multiz(target, UP)
if(turf_above?.z == user.z)
INVOKE_ASYNC(source, /obj/item.proc/handle_openspace_click, turf_above, user, user.CanReach(turf_above, source), click_parameters)