Files
Bubberstation/code/datums/elements/dryable.dm
Andrew c04af38744 Dehydrator, machine version of drying rack (#85141)
## About The Pull Request


![image](https://github.com/user-attachments/assets/7b2cf788-7590-4d0b-a5f3-bfeec8276565)

Added dehydrator, a machine version of drying rack.

Replaced the second fryer with this rack on some maps to be available
roundstart.

Also changed the colors of Smart Fridge to be more in line with other
kitchen appliances.

## Why It's Good For The Game

We have plenty of recipes requiring dried items, and it's silly that the
chef has to break down a cafeteria table to build a rack for regular
recipes.

## Changelog

🆑
add: Dehydrator, a machine version of drying rack, with a circuit board
and available on some kitchens roundstart.
image: Updated the color palette of Smart Fridge
/🆑
2024-07-21 21:59:05 -07:00

56 lines
2.2 KiB
Plaintext

// If an item has this element, it can be dried on a drying rack.
/datum/element/dryable
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// The type of atom that is spawned by this element on drying.
var/dry_result
/datum/element/dryable/Attach(datum/target, atom/dry_result)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
src.dry_result = dry_result
RegisterSignal(target, COMSIG_ITEM_DRIED, PROC_REF(finish_drying))
ADD_TRAIT(target, TRAIT_DRYABLE, ELEMENT_TRAIT(type))
/datum/element/dryable/Detach(datum/target)
. = ..()
UnregisterSignal(target, COMSIG_FOOD_CONSUMED)
REMOVE_TRAIT(target, TRAIT_DRYABLE, ELEMENT_TRAIT(type))
/datum/element/dryable/proc/finish_drying(atom/source, datum/weakref/drying_user)
SIGNAL_HANDLER
var/atom/dried_atom = source
if(dry_result == dried_atom.type)//if the dried type is the same as our currrent state, don't bother creating a whole new item, just re-color it.
var/atom/movable/resulting_atom = dried_atom
resulting_atom.add_atom_colour(COLOR_DRIED_TAN, FIXED_COLOUR_PRIORITY)
apply_dried_status(resulting_atom, drying_user)
return
else if(isstack(source)) //Check if its a sheet
var/obj/item/stack/itemstack = dried_atom
for(var/i in 1 to itemstack.amount)
var/atom/movable/resulting_atom = new dry_result(source.loc)
apply_dried_status(resulting_atom, drying_user)
qdel(source)
return
else if(istype(source, /obj/item/food) && ispath(dry_result, /obj/item/food))
var/obj/item/food/source_food = source
var/obj/item/food/resulting_food = new dry_result(source.loc)
resulting_food.reagents.clear_reagents()
source_food.reagents.trans_to(resulting_food, source_food.reagents.total_volume)
apply_dried_status(resulting_food, drying_user)
qdel(source)
return
else
var/atom/movable/resulting_atom = new dry_result(source.loc)
apply_dried_status(resulting_atom, drying_user)
qdel(source)
/datum/element/dryable/proc/apply_dried_status(atom/target, datum/weakref/drying_user)
ADD_TRAIT(target, TRAIT_DRIED, ELEMENT_TRAIT(type))
var/datum/mind/user_mind = drying_user?.resolve()
if(drying_user && istype(target, /obj/item/food))
ADD_TRAIT(target, TRAIT_FOOD_CHEF_MADE, REF(user_mind))