-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathdryable.dm
51 lines (45 loc) · 2.05 KB
/
dryable.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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)
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)
ADD_TRAIT(resulting_atom, TRAIT_DRIED, ELEMENT_TRAIT(type))
resulting_atom.forceMove(source.drop_location())
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.drop_location())
ADD_TRAIT(resulting_atom, TRAIT_DRIED, ELEMENT_TRAIT(type))
qdel(source)
return
else if(istype(source, /obj/item/reagent_containers/food) && ispath(dry_result, /obj/item/reagent_containers/food))
var/obj/item/reagent_containers/food/source_food = source
var/obj/item/reagent_containers/food/resulting_food = new dry_result(source.drop_location())
resulting_food.reagents.clear_reagents()
source_food.reagents.trans_to(resulting_food, source_food.reagents.total_volume)
ADD_TRAIT(resulting_food, TRAIT_DRIED, ELEMENT_TRAIT(type))
qdel(source)
return
else
var/atom/movable/resulting_atom = new dry_result(source.drop_location())
ADD_TRAIT(resulting_atom, TRAIT_DRIED, ELEMENT_TRAIT(type))
qdel(source)