Files
Bubberstation/code/modules/wiremod/marker.dm
Watermelon914 375a20e49b Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
2021-06-14 13:03:53 -07:00

61 lines
1.7 KiB
Plaintext

/obj/item/multitool/circuit
name = "circuit multitool"
desc = "A circuit multitool. Used to mark entities which can then be uploaded to components by pressing the upload button on a port. \
Acts as a normal multitool otherwise. Use in hand to clear marked entity so that you can mark another entity."
icon_state = "multitool_circuit"
/// The marked atom of this multitool
var/atom/marked_atom
/obj/item/multitool/circuit/Destroy()
marked_atom = null
return ..()
/obj/item/multitool/circuit/examine(mob/user)
. = ..()
. += span_notice("It has [marked_atom? "a" : "no"] marked entity registered.")
/obj/item/multitool/circuit/attack_self(mob/user, modifiers)
. = ..()
if(.)
return
if(!marked_atom)
return
say("Cleared marked targets.")
clear_marked_atom()
return TRUE
/obj/item/multitool/circuit/melee_attack_chain(mob/user, atom/target, params)
var/is_right_clicking = LAZYACCESS(params2list(params), RIGHT_CLICK)
if(marked_atom || !user.Adjacent(target) || is_right_clicking)
return ..()
say("Marked [target].")
marked_atom = target
RegisterSignal(marked_atom, COMSIG_PARENT_QDELETING, .proc/cleanup_marked_atom)
update_icon()
flick("multitool_circuit_flick", src)
playsound(src.loc, 'sound/misc/compiler-stage2.ogg', 30, TRUE)
return TRUE
/obj/item/multitool/circuit/update_overlays()
. = ..()
cut_overlays()
if(marked_atom)
. += "marked_overlay"
/// Clears the current marked atom
/obj/item/multitool/circuit/proc/clear_marked_atom()
if(!marked_atom)
return
UnregisterSignal(marked_atom, COMSIG_PARENT_QDELETING)
marked_atom = null
update_icon()
/obj/item/multitool/circuit/proc/cleanup_marked_atom(datum/source)
SIGNAL_HANDLER
if(source == marked_atom)
clear_marked_atom()