Files
Bubberstation/code/datums/components/technoshy.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

56 lines
2.2 KiB
Plaintext

/// You can't use machines when they've been touched within the last [unused_duration], unless it was by a mob in [whitelist]
/datum/component/technoshy
can_transfer = TRUE
/// How long in deciseconds the machine can be untouched for
var/unused_duration = (2 MINUTES)
/// Typecache of allowed last_users
var/list/whitelist
/// Message presented if the machine was used too recently
var/message = "The %TARGET is way too fresh dude. Since we're like, <b>super</b> retro, we gotta wait for it to exit the mainstream."
/datum/component/technoshy/Initialize(unused_duration, message, whitelist)
if(!ismob(parent))
return COMPONENT_INCOMPATIBLE
if(unused_duration)
src.unused_duration = unused_duration
if(message)
src.message = message
if(!whitelist)
whitelist = typecacheof(parent.type)
src.whitelist = whitelist
/datum/component/technoshy/RegisterWithParent()
RegisterSignal(parent, COMSIG_TRY_USE_MACHINE, PROC_REF(on_try_use_machine))
RegisterSignal(parent, COMSIG_TRY_WIRES_INTERACT, PROC_REF(on_try_wires_interact))
/datum/component/technoshy/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_TRY_USE_MACHINE, COMSIG_TRY_WIRES_INTERACT))
/datum/component/technoshy/PostTransfer()
if(!ismob(parent))
return COMPONENT_INCOMPATIBLE
/datum/component/technoshy/InheritComponent(datum/component/technoshy/friend, i_am_original, list/arguments)
if(i_am_original)
whitelist = friend.whitelist
message = friend.message
/datum/component/technoshy/proc/is_not_touched(datum/source, obj/machinery/machine)
var/time_since = world.time - machine.last_used_time
if(time_since < unused_duration && !isnull(machine.last_user_mobtype) && !is_type_in_typecache(machine.last_user_mobtype, whitelist))
to_chat(source, span_warning("[replacetext(message, "%TARGET", machine)]"))
return TRUE
/datum/component/technoshy/proc/on_try_use_machine(datum/source, obj/machinery/machine)
SIGNAL_HANDLER
if(is_not_touched(source, machine))
return COMPONENT_CANT_USE_MACHINE_INTERACT | COMPONENT_CANT_USE_MACHINE_TOOLS
/datum/component/technoshy/proc/on_try_wires_interact(datum/source, atom/machine)
SIGNAL_HANDLER
if(!ismachinery(machine))
return
else if(is_not_touched(source, machine))
return COMPONENT_CANT_INTERACT_WIRES