-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collapsing fireplace logic into bonfire.
- Loading branch information
1 parent
00bed6e
commit db2e2c0
Showing
18 changed files
with
341 additions
and
469 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.