Files
Bubberstation/code/datums/components/technoshy.dm
Ghom 7663b39cc8 Refactoring aquariums into components (feat: portable fish tanks) (#87866)
## About The Pull Request
I've been meaning to do this for some time. I need this for
portable/handheld aquariums/fishtanks to be possible. I'll sprite and
code them before I call this PR ready, however suggestions and code
reviews are welcome in the meantime.

Being a pretty heavy refactor, some things might break (we have more
than a few unit tests so perhaps not) while others, coincidentally,
might be fixed without me knowing. Anyway I'm sure this PR fixes
aquarium beauty, which wasn't really working to begin with because the
code was so fucking bad. Nothing really worth of a CL entry tho.


TODO:
- [x] handheld aquariums, craftable with a kit and little plastic or
buyable from the fun vendor ig.
- [x] an aquarium upgrade for handheld aquariums to bypass possible
restrictions.
- [x] update the beauty element to consider items, which shouldn't
contribute to the area beauty when held or otherwise not on a turf.

## Why It's Good For The Game
This should make handheld aquariums possible.

## Changelog

🆑
refactor: refactored aquariums heavily. Please report any fishy bug.
add: Added portable/handheld fish tanks to the game. They can be crafted
with an aquarium kit and 5 sheets of plastic. While portable, they
cannot store fish that are too big or if there're too many already. This
restriction can be removed by using the new "bluespace fish tank kit"
techweb item.
map: Replaced the lawyer's stationary pet aquarium with a fish tank, so
you can carry McGill around.
balance: Reduced the iron cost of stationary aquariums a little.
/🆑
2024-11-21 09:45:49 +13: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(datum/new_parent)
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