Skip to content

Commit

Permalink
Generalizing drying racks.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 18, 2024
1 parent 23756fd commit 1dc9de3
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 160 deletions.
26 changes: 26 additions & 0 deletions code/game/objects/items_drying.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Stubs/vars for use with the drying rack.
/obj/item
var/drying_threshold_temperature = 500 // Kelvin, checked in fire_act()
var/dried_type // If set to a type, drying this item will convert it to that type.

/obj/item/proc/is_dryable()
return !isnull(dried_type)

// Returns null for no change, or an instance for a successful drying.
/obj/item/proc/dry_out(var/obj/rack, var/drying_power = 1)
if(dried_type)
. = new dried_type(loc)
qdel(src)

// Returns a string used in drying rack examine().
/obj/item/proc/get_dryness_text(var/obj/rack)
return "dry"

// Returns an icon_state used by drying rack update_icon().
/obj/item/proc/get_drying_state(var/obj/rack)
return

/obj/item/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
..()
if(exposed_temperature >= drying_threshold_temperature)
dry_out()
45 changes: 19 additions & 26 deletions code/game/objects/structures/bonfire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,35 +239,28 @@
if(grill)
for(var/obj/item/reagent_containers/food/snacks/snack in loc)
snack.grill(src)
for(var/obj/item/thing in view(2, src))
thing.dry_out(src, rand(1,4))
else
burn()

if(burning)
var/W = get_fuel_amount()
if(W >= 5)
var/datum/gas_mixture/env = loc.return_air()
if(env && abs(env.temperature - set_temperature) > 0.1)
var/transfer_moles = 0.25 * env.total_moles
var/datum/gas_mixture/removed = env.remove(transfer_moles)

if(removed)
var/heat_transfer = removed.get_thermal_energy_change(set_temperature)
if(heat_transfer > 0)
heat_transfer = min(heat_transfer , heating_power)

removed.add_thermal_energy(heat_transfer)

for(var/mob/living/L in view(3, src))
L.add_modifier(/datum/modifier/endothermic, 10 SECONDS, null, TRUE)

for(var/obj/item/stack/wetleather/WL in view(2, src))
if(WL.wetness >= 0)
WL.dry()
continue

WL.wetness = max(0, WL.wetness - rand(1, 4))

env.merge(removed)
if(!burning)
return
var/W = get_fuel_amount()
if(W < 5)
return
var/datum/gas_mixture/env = loc.return_air()
if(!env || abs(env.temperature - set_temperature) <= 0.1)
return
var/transfer_moles = 0.25 * env.total_moles
var/datum/gas_mixture/removed = env.remove(transfer_moles)
var/heat_transfer = removed?.get_thermal_energy_change(set_temperature)
if(heat_transfer > 0)
heat_transfer = min(heat_transfer, heating_power)
removed.add_thermal_energy(heat_transfer)
for(var/mob/living/L in view(3, src))
L.add_modifier(/datum/modifier/endothermic, 10 SECONDS, null, TRUE)
env.merge(removed)

/obj/structure/bonfire/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
ignite()
Expand Down
15 changes: 14 additions & 1 deletion code/modules/food/food/snacks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
var/trash = null
var/slice_path
var/slices_num
var/dried_type = null
var/dry = 0
var/survivalfood = FALSE
var/nutriment_amt = 0
Expand Down Expand Up @@ -45,6 +44,20 @@
. = ..()
nutriment_desc = null

/obj/item/reagent_containers/food/snacks/is_dryable()
return !dry

/obj/item/reagent_containers/food/snacks/dry_out(var/obj/rack, var/drying_power = 1)
if(!dried_type || dry)
return null
if(dried_type == type)
dry = TRUE
name = "dried [name]"
color = "#aaaaaa"
rack?.visible_message(SPAN_NOTICE("\The [src] is dry!"))
return src
return ..()

/obj/item/reagent_containers/food/snacks

// Halfassed version of Crabs' cooking system on Cit, should
Expand Down
62 changes: 17 additions & 45 deletions code/modules/food/kitchen/smartfridge/drying_rack.dm
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/obj/machinery/smartfridge/drying_rack
name = "\improper Drying Rack"
/obj/machinery/smartfridge/drying_oven
name = "drying oven"
desc = "A machine for drying plants."
wrenchable = 1
icon_state = "drying_rack"
icon_base = "drying_rack"

/obj/machinery/smartfridge/drying_rack/accept_check(var/obj/item/O as obj)
if(istype(O, /obj/item/reagent_containers/food/snacks/))
var/obj/item/reagent_containers/food/snacks/S = O
if (S.dried_type)
return 1
/obj/machinery/smartfridge/drying_oven/accept_check(var/obj/item/O)
return istype(O) && O.is_dryable()

if(istype(O, /obj/item/stack/wetleather))
return 1

return 0

/obj/machinery/smartfridge/drying_rack/process()
/obj/machinery/smartfridge/drying_oven/process()
..()
if(stat & (BROKEN|NOPOWER))
return
if(contents.len)
dry()
var/do_update = FALSE
for(var/obj/item/thing in contents)
var/obj/item/product = thing.dry_out(src)
if(product)
product.dropInto(loc)
do_update = TRUE
if(QDELETED(thing) || !(thing in contents))
for(var/datum/stored_item/I in item_records)
I.instances -= thing
if(do_update)
update_icon()

/obj/machinery/smartfridge/drying_rack/update_icon()
/obj/machinery/smartfridge/drying_oven/update_icon()
var/not_working = stat & (BROKEN|NOPOWER)
var/hasItems
for(var/datum/stored_item/I in item_records)
if(I.get_amount())
hasItems = 1
hasItems = TRUE
break
if(hasItems)
if(not_working)
Expand All @@ -41,31 +41,3 @@
icon_state = "[icon_base]-off"
else
icon_state = "[icon_base]"

/obj/machinery/smartfridge/drying_rack/proc/dry()
for(var/datum/stored_item/I in item_records)
for(var/obj/item/reagent_containers/food/snacks/S in I.instances)
if(S.dry) continue
if(S.dried_type == S.type)
S.dry = 1
S.name = "dried [S.name]"
S.color = "#AAAAAA"
I.instances -= S
S.forceMove(get_turf(src))
else
var/D = S.dried_type
new D(get_turf(src))
qdel(S)
return

for(var/obj/item/stack/wetleather/WL in I.instances)
if(!WL.wetness)
if(WL.amount)
WL.forceMove(get_turf(src))
WL.dry()
I.instances -= WL
break

WL.wetness = max(0, WL.wetness - rand(1, 3))

return
3 changes: 1 addition & 2 deletions code/modules/materials/materials/metals/steel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,5 @@
new /datum/stack_recipe("floor lamp fixture frame", /obj/machinery/light_construct/flamp, 2, recycle_material = "[name]"),
new /datum/stack_recipe("apc frame", /obj/item/frame/apc, 2, recycle_material = "[name]"),
new /datum/stack_recipe("desk bell", /obj/item/deskbell, 1, on_floor = 1, supplied_material = "[name]"),
new /datum/stack_recipe("tanning rack", /obj/structure/tanning_rack, 3, one_per_turf = TRUE, time = 20, on_floor = TRUE, supplied_material = "[name]")
new /datum/stack_recipe("drying rack", /obj/structure/drying_rack, 3, one_per_turf = TRUE, time = 20, on_floor = TRUE, supplied_material = "[name]")
)

4 changes: 2 additions & 2 deletions code/modules/materials/materials/organic/wood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
new /datum/stack_recipe("coilgun stock", /obj/item/coilgun_assembly, 5, pass_stack_color = TRUE, recycle_material = "[name]"),
new /datum/stack_recipe("crude fishing rod", /obj/item/material/fishing_rod/built, 8, time = 10 SECONDS, pass_stack_color = TRUE, recycle_material = "[name]"),
new /datum/stack_recipe("noticeboard", /obj/structure/noticeboard, 1, recycle_material = "[name]"),
new /datum/stack_recipe("tanning rack", /obj/structure/tanning_rack, 3, one_per_turf = TRUE, time = 20, on_floor = TRUE, supplied_material = "[name]"),
new /datum/stack_recipe("drying rack", /obj/structure/drying_rack, 3, one_per_turf = TRUE, time = 20, on_floor = TRUE, supplied_material = "[name]"),
new /datum/stack_recipe("roofing tile", /obj/item/stack/tile/roofing, 3, 4, 20, recycle_material = "[name]"),
new /datum/stack_recipe("shovel", /obj/item/shovel/wood, 2, time = 10, on_floor = TRUE, supplied_material = "[name]")
)
Expand Down Expand Up @@ -82,4 +82,4 @@
name = MAT_SIFLOG
icon_colour = "#0099cc" // Cyan-ish
stack_origin_tech = list(TECH_MATERIAL = 2, TECH_BIO = 2)
stack_type = /obj/item/stack/material/log/sif
stack_type = /obj/item/stack/material/log/sif
14 changes: 1 addition & 13 deletions code/modules/materials/sheets/organic/tanning/hide_hairless.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if(HS.amount < HS.max_amount)
H = HS
break

// Either we found a valid stack, in which case increment amount,
// Or we need to make a new stack
if(istype(H))
Expand All @@ -34,15 +34,3 @@

// Increment the amount
src.use(1)

/obj/item/stack/hairlesshide/proc/rapidcure(var/stacknum = 1)
stacknum = min(stacknum, amount)

while(stacknum)
var/obj/item/stack/wetleather/I = new /obj/item/stack/wetleather(get_turf(src))

if(istype(I))
I.dry()

use(1)
stacknum -= 1
41 changes: 21 additions & 20 deletions code/modules/materials/sheets/organic/tanning/leather_wet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,49 @@
desc = "This leather has been cleaned but still needs to be dried."
description_info = "To finish tanning the leather, you need to dry it. \
You could place it under a <b><font color='red'>fire</font></b>, \
put it in a <b><font color='blue'>drying rack</font></b>, \
or build a <b><font color='brown'>tanning rack</font></b> from steel or wooden boards."
put it in a <b><font color='blue'>drying oven</font></b>, \
or build a <b><font color='brown'>drying rack</font></b> from steel or wooden boards."
singular_name = "wet leather piece"
icon_state = "sheet-wetleather"
var/wetness = 30 //Reduced when exposed to high temperautres
var/drying_threshold_temperature = 500 //Kelvin to start drying
no_variants = FALSE
max_amount = 20
stacktype = "wetleather"
var/wetness = 30 //Reduced when exposed to high temperautres

var/dry_type = /obj/item/stack/material/leather
/obj/item/stack/wetleather/is_dryable()
return wetness > 0

/obj/item/stack/wetleather/get_drying_state(var/obj/rack)
if(wetness)
return "leather_wet"
return "leather_dry"

/obj/item/stack/wetleather/examine(var/mob/user)
. = ..()
. += description_info
. += "\The [src] is [get_dryness_text()]."

/obj/item/stack/wetleather/proc/get_dryness_text()
/obj/item/stack/wetleather/get_dryness_text(var/obj/rack)
if(wetness > 20)
return "wet"
if(wetness > 10)
return "damp"
if(wetness)
return "almost dry"
return "dry"

/obj/item/stack/wetleather/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
..()
if(exposed_temperature >= drying_threshold_temperature)
wetness--
if(wetness == 0)
dry()

/obj/item/stack/wetleather/proc/dry()
var/obj/item/stack/material/leather/L = new(src.loc)
L.amount = amount
use(amount)
return L
return ..()

/obj/item/stack/wetleather/transfer_to(obj/item/stack/S, var/tamount=null, var/type_verified)
. = ..()
if(.) // If it transfers any, do a weighted average of the wetness
var/obj/item/stack/wetleather/W = S
var/oldamt = W.amount - .
W.wetness = round(((oldamt * W.wetness) + (. * wetness)) / W.amount)

/obj/item/stack/wetleather/dry_out(var/obj/rack, var/drying_power = 1)
if(wetness <= 0)
return null
wetness -= drying_power
if(wetness <= 0)
. = new /obj/item/stack/material/leather(loc, amount)
rack?.visible_message(SPAN_NOTICE("The [src] is dry!"))
qdel(src)
Loading

0 comments on commit 1dc9de3

Please sign in to comment.