Skip to content

Commit

Permalink
Collapsing fireplace logic into bonfire.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 18, 2024
1 parent 00bed6e commit db2e2c0
Show file tree
Hide file tree
Showing 18 changed files with 341 additions and 469 deletions.
454 changes: 0 additions & 454 deletions code/game/objects/structures/bonfire.dm

This file was deleted.

325 changes: 325 additions & 0 deletions code/game/objects/structures/wood_fire.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
/obj/structure/wood_fire // abstract type, do not use

icon = 'icons/obj/structures.dmi'
density = FALSE
anchored = TRUE
buckle_lying = FALSE
layer = TURF_LAYER + 0.5 // We want it to layer underneath food and things on top of it.

var/base_icon_state = "bonfire"
var/can_dismantle = TRUE
var/burning = FALSE
var/next_fuel_consumption = 0 // world.time of when next item in fuel list gets eatten to sustain the fire.
var/grill = FALSE
var/datum/material/material
var/set_temperature = T0C + 30 //K
var/heating_power = 80000
var/datum/looping_sound/fire_crackles/fire_loop
var/datum/looping_sound/grill/grill_loop // Used when food is cooking on the fire.

/obj/structure/wood_fire/Initialize(var/ml, material_name)
. = ..()
fire_loop = new(list(src), FALSE)
grill_loop = new(list(src), FALSE)
if(!material_name)
material_name = MAT_WOOD
material = get_material_by_name("[material_name]")
if(!material)
qdel(src)
return
color = material.icon_colour

/obj/structure/wood_fire/Destroy()
QDEL_NULL(fire_loop)
QDEL_NULL(grill_loop)
return ..()

/obj/structure/wood_fire/proc/try_build_feature(var/mob/user, var/obj/item/stack/rods/rods)
if(!istype(rods))
return FALSE
if(can_buckle || grill)
return FALSE

var/choice = input(user, "What would you like to construct?", "Constructing Grill") as null|anything in list("Stake","Grill")
if(!choice || user.incapacitated() || !Adjacent(user))
return TRUE

switch(choice)
if("Stake")
rods.use(1)
can_buckle = TRUE
buckle_require_restraints = TRUE
to_chat(user, SPAN_NOTICE("You add a rod to \the [src]."))
var/mutable_appearance/rod_underlay = mutable_appearance('icons/obj/structures.dmi', "[base_icon_state]_rod")
rod_underlay.pixel_y = 16
rod_underlay.appearance_flags = RESET_COLOR | PIXEL_SCALE | TILE_BOUND | KEEP_APART
underlays += rod_underlay
if("Grill")
rods.use(1)
grill = TRUE
to_chat(user, SPAN_NOTICE("You add a grill to \the [src]."))
update_icon()
return TRUE


/obj/structure/wood_fire/attackby(obj/item/W, mob/user)

// Place food on the grill.
if(istype(W, /obj/item/reagent_containers/food/snacks) && grill)
if(user.unEquip(W))
W.dropInto(loc)
// Place it on top of the grill.
W.pixel_x = 0
W.pixel_y = 12
return TRUE

if(try_build_feature(user, W))
return TRUE

if(istype(W, /obj/item/stack/material/fuel))
add_fuel(W, user)
return TRUE

if(W.is_hot())
ignite()
return TRUE

return ..()

/obj/structure/wood_fire/attack_hand(mob/user)
if(!has_buckled_mobs())
if(get_fuel_amount())
remove_fuel(user)
return TRUE
if(can_dismantle)
dismantle(user)
return TRUE
return ..()

/obj/structure/wood_fire/proc/dismantle(mob/user)
if(!burning)
user.visible_message("[user] starts dismantling \the [src].", "You start dismantling \the [src].")
if(do_after(user, 5 SECONDS))
for(var/i = 1 to 5)
material.place_dismantled_product(get_turf(src))
user.visible_message("[user] dismantles down \the [src].", "You dismantle \the [src].")
qdel(src)
else
to_chat(user, SPAN_WARNING("\The [src] is still burning. Extinguish it first if you want to dismantle it."))

/obj/structure/wood_fire/proc/get_fuel_amount()
. = 0
for(var/obj/item/stack/material/fuel/fuel in contents)
. += (fuel.amount * fuel.bonfire_fuel_time) / (2 MINUTES)

/obj/structure/wood_fire/permanent/get_fuel_amount()
return 10

/obj/structure/wood_fire/proc/remove_fuel(mob/user)
if(!get_fuel_amount())
return
var/atom/movable/AM = pop(contents)
if(!istype(AM))
return
AM.forceMove(get_turf(src))
to_chat(user, SPAN_NOTICE("You take \the [AM] out of \the [src] before it has a chance to burn away."))
update_icon()

/obj/structure/wood_fire/permanent/remove_fuel(mob/user)
dismantle(user)

/obj/structure/wood_fire/proc/add_fuel(atom/movable/new_fuel, mob/user)
if(get_fuel_amount() >= 10)
to_chat(user, SPAN_WARNING("\The [src] already has enough fuel!"))
return FALSE
if(istype(new_fuel, /obj/item/stack/material/fuel/wood) || istype(new_fuel, /obj/item/stack/material/fuel/log) )
var/obj/item/stack/F = new_fuel
var/obj/item/stack/S = F.split(1)
if(S)
S.forceMove(src)
to_chat(user, SPAN_WARNING("You add \the [new_fuel] to \the [src]."))
update_icon()
return TRUE
return FALSE
else
to_chat(user, SPAN_WARNING("\The [src] needs raw wood to burn, \a [new_fuel] won't work."))
return FALSE

/obj/structure/wood_fire/permanent/add_fuel(mob/user)
to_chat(user, SPAN_WARNING("\The [src] has plenty of fuel and doesn't need more fuel."))

/obj/structure/wood_fire/proc/consume_fuel(var/obj/item/stack/consumed_fuel)
if(!istype(consumed_fuel, /obj/item/stack/material/fuel))
qdel(consumed_fuel) // Don't know, don't care.
return FALSE
var/obj/item/stack/material/fuel/fuel_stack = consumed_fuel
next_fuel_consumption = world.time + max(1 MINUTE, fuel_stack.bonfire_fuel_time)
fuel_stack.use(1)
update_icon()
return TRUE

/obj/structure/wood_fire/permanent/consume_fuel()
return TRUE

/obj/structure/wood_fire/proc/check_oxygen()
var/datum/gas_mixture/G = loc.return_air()
if(G.gas["oxygen"] < 1)
return FALSE
return TRUE

/obj/structure/wood_fire/proc/extinguish()
if(!burning)
return
burning = FALSE
update_icon()
STOP_PROCESSING(SSobj, src)
visible_message(SPAN_NOTICE("\The [src] stops burning."))
if(fire_loop?.started)
fire_loop.stop(src)

/obj/structure/wood_fire/proc/ignite()
if(burning || !get_fuel_amount())
return
burning = TRUE
update_icon()
START_PROCESSING(SSobj, src)
visible_message(SPAN_NOTICE("\The [src] starts burning!"))
if(fire_loop && !fire_loop.started)
fire_loop.start(src)

/obj/structure/wood_fire/proc/burn()
var/turf/current_location = get_turf(src)
current_location.hotspot_expose(1000, 500)
for(var/A in current_location)
if(A == src)
continue
if(isobj(A))
var/obj/O = A
O.fire_act(null, 1000, 500)
else if(isliving(A) && get_fuel_amount() > 4)
var/mob/living/L = A
L.adjust_fire_stacks(get_fuel_amount() / 4)
L.IgniteMob()

/obj/structure/wood_fire/update_icon()
cut_overlays()
if(burning)
var/state
switch(get_fuel_amount())
if(0 to 4.5)
state = "[base_icon_state]_warm"
if(4.6 to 10)
state = "[base_icon_state]_hot"
var/image/I = image(icon, state)
I.appearance_flags = RESET_COLOR | KEEP_APART
add_overlay(I)
if(is_intense_fire())
I = image(icon, "[base_icon_state]_intense")
I.pixel_y = 13
I.layer = MOB_LAYER + 0.1
I.appearance_flags = RESET_COLOR | KEEP_APART
add_overlay(I)

var/light_strength = max(get_fuel_amount() / 2, 2)
set_light(light_strength, light_strength, "#FF9933")
else
set_light(0)

if(grill)
var/image/grille_image = image(icon, "[base_icon_state]_grill")
grille_image.appearance_flags = RESET_COLOR | KEEP_APART
add_overlay(grille_image)

/obj/structure/wood_fire/proc/is_intense_fire()
return has_buckled_mobs() && get_fuel_amount() >= 5

/obj/structure/wood_fire/process()
if(!check_oxygen())
extinguish()
return
if(world.time >= next_fuel_consumption)
if(!consume_fuel(pop(contents)))
extinguish()
return

var/do_grill_sound = FALSE
if(grill)
for(var/obj/item/thing in view(2, src))
if(thing.dry_out(src, 3 - get_dist(thing, src), (thing.loc == loc), silent = TRUE))
do_grill_sound = TRUE
else
burn()

if(grill_loop)
if(do_grill_sound)
if(!grill_loop.started)
grill_loop.start(src)
else
if(grill_loop.started)
grill_loop.stop(src)

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/wood_fire/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
ignite()

/obj/structure/wood_fire/water_act(amount)
if(prob(amount * 10))
extinguish()

/obj/structure/wood_fire/post_buckle_mob(mob/living/M)
if(M.buckled == src) // Just buckled someone
M.pixel_y += 13
else // Just unbuckled someone
M.pixel_y -= 13
update_icon()

// A freestanding fire for cooking food on.
/obj/structure/wood_fire/bonfire
name = "bonfire"
desc = "For grilling, broiling, charring, smoking, heating, roasting, toasting, simmering, searing, melting, and occasionally burning things."
icon_state = "bonfire"

// Blue wood.
/obj/structure/wood_fire/bonfire/sifwood/Initialize(var/ml, material_name)
. = ..(ml, MAT_SIFWOOD)

/obj/structure/wood_fire/bonfire/permanent/Initialize(var/ml, material_name)
. = ..()
ignite()

/obj/structure/wood_fire/bonfire/permanent/sifwood/Initialize(var/ml, material_name)
. = ..(ml, MAT_SIFWOOD)

// more like a space heater than a bonfire. A cozier alternative to both.
/obj/structure/wood_fire/fireplace
name = "fireplace"
desc = "The sound of the crackling hearth reminds you of home."
icon_state = "fireplace"
density = TRUE
set_temperature = T0C + 20 //K
heating_power = 40000
can_dismantle = FALSE
can_buckle = FALSE

/obj/structure/wood_fire/fireplace/is_intense_fire()
return get_fuel_amount() >= 5

/obj/structure/wood_fire/fireplace/try_build_feature(var/mob/user)
return FALSE
2 changes: 1 addition & 1 deletion code/modules/materials/materials/organic/wood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

/datum/material/wood/log/generate_recipes()
recipes = list(
new /datum/stack_recipe("bonfire", /obj/structure/bonfire, 5, time = 50, supplied_material = "[name]", pass_stack_color = TRUE, recycle_material = "[name]")
new /datum/stack_recipe("bonfire", /obj/structure/wood_fire/bonfire, 5, time = 50, supplied_material = "[name]", pass_stack_color = TRUE, recycle_material = "[name]")
)

/datum/material/wood/log/sif
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/mountains/IceCave1A.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"j" = (/obj/random/outcrop,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"r" = (/obj/random/medical/anom,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"x" = (/obj/random/multiple/corp_crate,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"B" = (/obj/structure/bonfire/sifwood,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"B" = (/obj/structure/wood_fire/bonfire/sifwood,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"C" = (/obj/structure/loot_pile/surface/bones,/obj/item/clothing/suit/storage/hooded/wintercoat/science,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"E" = (/obj/random/material/precious,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
"I" = (/obj/random/maintenance/anom,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/IceCave1A)
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/mountains/vault6.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"j" = (/turf/simulated/floor/cult,/area/submap/cave/vault6)
"k" = (/obj/random/tool/power,/obj/random/tech_supply,/turf/simulated/floor/cult,/area/submap/cave/vault6)
"l" = (/obj/structure/cliff/automatic{icon_state = "cliffbuilder"; dir = 8},/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/vault6)
"m" = (/obj/structure/bonfire/permanent/sifwood,/obj/structure/grille/rustic,/turf/simulated/floor/cult,/area/submap/cave/vault6)
"m" = (/obj/structure/wood_fire/bonfire/permanent/sifwood,/obj/structure/grille/rustic,/turf/simulated/floor/cult,/area/submap/cave/vault6)
"n" = (/obj/random/multiple/minevault,/turf/simulated/floor/cult,/area/submap/cave/vault6)
"o" = (/obj/structure/cliff/automatic/corner,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/vault6)
"p" = (/obj/structure/cliff/automatic{icon_state = "cliffbuilder"; dir = 5},/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/vault6)
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/plains/Peninsula.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"f" = (/turf/simulated/mineral/ignore_mapgen,/area/submap/Peninsula)
"g" = (/obj/structure/table/woodentable,/obj/item/flashlight,/turf/template_noop,/area/submap/Peninsula)
"h" = (/obj/structure/table/woodentable,/obj/item/cell/device,/obj/item/cell/device,/obj/random/tech_supply/anom,/turf/template_noop,/area/submap/Peninsula)
"i" = (/obj/structure/bonfire,/turf/template_noop,/area/submap/Peninsula)
"i" = (/obj/structure/wood_fire/bonfire,/turf/template_noop,/area/submap/Peninsula)
"j" = (/obj/structure/flora/tree/sif,/turf/template_noop,/area/template_noop)

(1,1,1) = {"
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/plains/bonfire.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"d" = (/obj/item/flame/lighter/random,/turf/template_noop,/area/submap/bonfire)
"e" = (/obj/item/reagent_containers/food/drinks/bottle/orangejuice,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
"f" = (/obj/item/stool/padded,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
"g" = (/obj/structure/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
"g" = (/obj/structure/wood_fire/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
"h" = (/obj/item/material/knife/machete,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
"i" = (/obj/item/clothing/head/helmet/material/makeshift,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
"j" = (/obj/item/stack/material/fuel/log/sif,/turf/simulated/floor/outdoors/dirt,/area/submap/bonfire)
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/plains/camp1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"k" = (/obj/structure/table/bench/wooden,/turf/simulated/floor/outdoors/dirt,/area/submap/camp1)
"l" = (/turf/simulated/floor/outdoors/dirt,/area/submap/camp1)
"m" = (/obj/item/material/knife/machete/hatchet,/turf/template_noop,/area/template_noop)
"n" = (/obj/structure/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/camp1)
"n" = (/obj/structure/wood_fire/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/camp1)
"o" = (/obj/item/flame/lighter,/turf/simulated/floor/outdoors/dirt,/area/submap/camp1)

(1,1,1) = {"
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/plains/hotspring.dmm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"a" = (/turf/template_noop,/area/submap/hotspring)
"c" = (/obj/structure/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/hotspring)
"c" = (/obj/structure/wood_fire/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/hotspring)
"d" = (/obj/effect/vfx/steam,/turf/simulated/floor/water/shoreline/corner{dir = 4},/area/submap/hotspring)
"e" = (/obj/structure/window/reinforced{dir = 8; health = 1e+006},/obj/structure/loot_pile/maint/trash,/turf/simulated/floor/outdoors/grass/sif,/area/submap/hotspring)
"f" = (/obj/effect/decal/cleanable/dirt,/obj/effect/decal/cleanable/dirt,/obj/effect/decal/cleanable/dirt,/obj/effect/decal/cleanable/dirt,/turf/simulated/floor/wood/sif,/area/submap/hotspring)
Expand Down
2 changes: 1 addition & 1 deletion maps/submaps/surface_submaps/plains/house1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ah" = (/obj/structure/table/bench/wooden,/turf/simulated/floor/outdoors/dirt,/area/submap/house1)
"ai" = (/obj/structure/railing{dir = 8},/turf/simulated/floor/outdoors/grass/sif,/area/submap/house1)
"aj" = (/obj/structure/target_stake,/turf/simulated/floor/outdoors/dirt,/area/submap/house1)
"ak" = (/obj/structure/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/house1)
"ak" = (/obj/structure/wood_fire/bonfire/sifwood,/turf/simulated/floor/outdoors/dirt,/area/submap/house1)
"al" = (/obj/item/target,/turf/simulated/floor/outdoors/grass/sif,/area/submap/house1)
"am" = (/obj/item/target/syndicate,/turf/simulated/floor/outdoors/grass/sif,/area/submap/house1)
"an" = (/turf/simulated/wall/wood,/area/submap/house1)
Expand Down
Loading

0 comments on commit db2e2c0

Please sign in to comment.