mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
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).
This commit is contained in:
25
code/datums/elements/openspace_item_click_handler.dm
Normal file
25
code/datums/elements/openspace_item_click_handler.dm
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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)
|
||||
@@ -1193,3 +1193,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e
|
||||
if(ismob(loc))
|
||||
var/mob/mob_loc = loc
|
||||
mob_loc.regenerate_icons()
|
||||
|
||||
/// Called on [/datum/element/openspace_item_click_handler/proc/on_afterattack]. Check the relative file for information.
|
||||
/obj/item/proc/handle_openspace_click(turf/target, mob/user, proximity_flag, click_parameters)
|
||||
stack_trace("Undefined handle_openspace_click() behaviour. Ascertain the openspace_item_click_handler element has been attached to the right item and that its proc override doesn't call parent.")
|
||||
|
||||
@@ -186,6 +186,8 @@ RLD
|
||||
return .
|
||||
|
||||
/obj/item/construction/proc/range_check(atom/A, mob/user)
|
||||
if(A.z != user.z)
|
||||
return
|
||||
if(!(A in view(7, get_turf(user))))
|
||||
to_chat(user, span_warning("The \'Out of Range\' light on [src] blinks red."))
|
||||
return FALSE
|
||||
@@ -270,6 +272,15 @@ GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window())
|
||||
|
||||
return getHologramIcon(grille_icon)
|
||||
|
||||
/obj/item/construction/rcd/Initialize(mapload)
|
||||
. = ..()
|
||||
AddElement(/datum/element/openspace_item_click_handler)
|
||||
|
||||
/obj/item/construction/rcd/handle_openspace_click(turf/target, mob/user, proximity_flag, click_parameters)
|
||||
if(proximity_flag)
|
||||
mode = construction_mode
|
||||
rcd_create(target, user)
|
||||
|
||||
/obj/item/construction/rcd/ui_action_click(mob/user, actiontype)
|
||||
if (!COOLDOWN_FINISHED(src, destructive_scan_cooldown))
|
||||
to_chat(user, span_warning("[src] lets out a low buzz."))
|
||||
@@ -867,6 +878,10 @@ GLOBAL_VAR_INIT(icon_holographic_window, init_holographic_window())
|
||||
pre_attack_secondary(target, user)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
|
||||
/obj/item/construction/rcd/arcd/handle_openspace_click(turf/target, mob/user, proximity_flag, click_parameters)
|
||||
if(ranged && range_check(target, user))
|
||||
mode = construction_mode
|
||||
rcd_create(target, user)
|
||||
|
||||
/obj/item/construction/rcd/arcd/rcd_create(atom/A, mob/user)
|
||||
. = ..()
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
var/holosign_type = /obj/structure/holosign/wetsign
|
||||
var/holocreator_busy = FALSE //to prevent placing multiple holo barriers at once
|
||||
|
||||
/obj/item/holosign_creator/Initialize(mapload)
|
||||
. = ..()
|
||||
AddElement(/datum/element/openspace_item_click_handler)
|
||||
|
||||
/obj/item/holosign_creator/handle_openspace_click(turf/target, mob/user, proximity_flag, click_parameters)
|
||||
afterattack(target, user, proximity_flag, click_parameters)
|
||||
|
||||
/obj/item/holosign_creator/examine(mob/user)
|
||||
. = ..()
|
||||
if(!signs)
|
||||
|
||||
@@ -39,6 +39,11 @@ GLOBAL_LIST_INIT(rod_recipes, list ( \
|
||||
/obj/item/stack/rods/Initialize(mapload, new_amount, merge = TRUE, list/mat_override=null, mat_amt=1)
|
||||
. = ..()
|
||||
update_appearance()
|
||||
AddElement(/datum/element/openspace_item_click_handler)
|
||||
|
||||
/obj/item/stack/rods/handle_openspace_click(turf/target, mob/user, proximity_flag, click_parameters)
|
||||
if(proximity_flag)
|
||||
target.attackby(src, user, click_parameters)
|
||||
|
||||
/obj/item/stack/rods/get_main_recipes()
|
||||
. = ..()
|
||||
|
||||
@@ -725,6 +725,7 @@
|
||||
#include "code\datums\elements\light_eater.dm"
|
||||
#include "code\datums\elements\movetype_handler.dm"
|
||||
#include "code\datums\elements\obj_regen.dm"
|
||||
#include "code\datums\elements\openspace_item_click_handler.dm"
|
||||
#include "code\datums\elements\pet_bonus.dm"
|
||||
#include "code\datums\elements\plant_backfire.dm"
|
||||
#include "code\datums\elements\point_of_interest.dm"
|
||||
|
||||
Reference in New Issue
Block a user