Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@
#define COMPONENT_BAKING_BAD_RESULT (1<<2)
///Called when an object is turned into another item through baking in an oven
#define COMSIG_ITEM_BAKED "item_bake_completed"

// Grilling foods (griddle, grill, and bonfire)
///Called when an object is placed onto a griddle
#define COMSIG_ITEM_GRILL_PLACED "item_placed_on_griddle"
///Called when a griddle is turned on
#define COMSIG_ITEM_GRILL_TURNED_ON "item_grill_turned_on"
///Called when a griddle is turned off
#define COMSIG_ITEM_GRILL_TURNED_OFF "item_grill_turned_off"
///Called when an object is grilled ontop of a griddle
#define COMSIG_ITEM_GRILL_PROCESS "item_griddled"
/// Return to not burn the item
#define COMPONENT_HANDLED_GRILLING (1<<0)
///Called when an object is turned into another item through grilling ontop of a griddle
#define COMSIG_ITEM_GRILLED "item_grill_completed"
6 changes: 6 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,9 @@ GLOBAL_LIST_INIT(book_types, typecacheof(list(
/obj/item/book,
/obj/item/spellbook,
/obj/item/storage/book)))

#define ICON_SIZE_ALL 32
/// The X/Width dimension of ICON_SIZE. This will more than likely be the bigger axis.
#define ICON_SIZE_X 32
/// The Y/Height dimension of ICON_SIZE. This will more than likely be the smaller axis.
#define ICON_SIZE_Y 32
152 changes: 152 additions & 0 deletions code/datums/components/food/grillable.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/datum/component/grillable
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS // So you can change grill results with various cookstuffs
///Result atom type of grilling this object
var/atom/cook_result
///Amount of time required to cook the food
var/required_cook_time = 2 MINUTES
///Is this a positive grill result?
var/positive_result = TRUE
///Time spent cooking so far
var/current_cook_time = 0
///Do we use the large steam sprite?
var/use_large_steam_sprite = FALSE
/// REF() to the mind which placed us on the griddle
var/who_placed_us
/// Reagents that should be added to the result
var/list/added_reagents

/datum/component/grillable/Initialize(cook_result, required_cook_time, positive_result, use_large_steam_sprite, list/added_reagents)
. = ..()
if(!isitem(parent)) //Only items support grilling at the moment
return COMPONENT_INCOMPATIBLE

src.cook_result = cook_result
src.required_cook_time = required_cook_time
src.positive_result = positive_result
src.use_large_steam_sprite = use_large_steam_sprite
src.added_reagents = added_reagents

/datum/component/grillable/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_GRILL_PLACED, PROC_REF(on_grill_placed))
RegisterSignal(parent, COMSIG_ITEM_GRILL_TURNED_ON, PROC_REF(on_grill_turned_on))
RegisterSignal(parent, COMSIG_ITEM_GRILL_TURNED_OFF, PROC_REF(on_grill_turned_off))
RegisterSignal(parent, COMSIG_ITEM_GRILL_PROCESS, PROC_REF(on_grill))
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))

/datum/component/grillable/UnregisterFromParent()
UnregisterSignal(parent, list(
COMSIG_ATOM_EXAMINE,
COMSIG_ITEM_GRILL_TURNED_ON,
COMSIG_ITEM_GRILL_TURNED_OFF,
COMSIG_ITEM_GRILL_PROCESS,
COMSIG_ITEM_GRILL_PLACED,
))

// Inherit the new values passed to the component
/datum/component/grillable/InheritComponent(datum/component/grillable/new_comp, original, cook_result, required_cook_time, positive_result, use_large_steam_sprite)
if(!original)
return
if(cook_result)
src.cook_result = cook_result
if(required_cook_time)
src.required_cook_time = required_cook_time
if(positive_result)
src.positive_result = positive_result
if(use_large_steam_sprite)
src.use_large_steam_sprite = use_large_steam_sprite

/// Signal proc for [COMSIG_ITEM_GRILL_PLACED], item is placed on the grill.
/datum/component/grillable/proc/on_grill_placed(datum/source, mob/griller)
SIGNAL_HANDLER

if(griller && griller.mind)
who_placed_us = REF(griller.mind)

RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))

/// Signal proc for [COMSIG_ITEM_GRILL_TURNED_ON], starts the grilling process.
/datum/component/grillable/proc/on_grill_turned_on(datum/source)
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(add_grilled_item_overlay))

var/atom/atom_parent = parent
atom_parent.update_appearance()

/// Signal proc for [COMSIG_ITEM_GRILL_TURNED_OFF], stops the grilling process.
/datum/component/grillable/proc/on_grill_turned_off(datum/source)
UnregisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS)

var/atom/atom_parent = parent
atom_parent.update_appearance()

///Ran every time an item is grilled by something
/datum/component/grillable/proc/on_grill(datum/source, atom/used_grill, seconds_per_tick = 1)
SIGNAL_HANDLER

. = COMPONENT_HANDLED_GRILLING

current_cook_time += seconds_per_tick * 10 //turn it into ds
if(current_cook_time >= required_cook_time)
finish_grilling(used_grill)

///Ran when an object finished grilling
/datum/component/grillable/proc/finish_grilling(atom/grill_source)
var/atom/original_object = parent
var/atom/grilled_result

if(isstack(parent)) //Check if its a sheet, for grilling multiple things in a stack
var/obj/item/stack/stack_parent = original_object
grilled_result = new cook_result(original_object.loc, stack_parent.amount)

else
grilled_result = new cook_result(original_object.loc)
if(original_object.custom_materials)
grilled_result.set_custom_materials(original_object.custom_materials)

if(IsEdible(grilled_result) && positive_result)
BLACKBOX_LOG_FOOD_MADE(grilled_result.type)
grilled_result.reagents.clear_reagents()
original_object.reagents?.trans_to(grilled_result, original_object.reagents.total_volume)
if(added_reagents) // Add any new reagents that should be added
grilled_result.reagents.add_reagent_list(added_reagents)

SEND_SIGNAL(parent, COMSIG_ITEM_GRILLED, grilled_result)
if(who_placed_us)
ADD_TRAIT(grilled_result, TRAIT_FOOD_CHEF_MADE, who_placed_us)

grill_source.visible_message("<span class='[positive_result ? "notice" : "warning"]'>[parent] turns into \a [grilled_result]!</span>")
grilled_result.pixel_x = original_object.pixel_x
grilled_result.pixel_y = original_object.pixel_y
qdel(parent)

///Ran when an object almost finishes grilling
/datum/component/grillable/proc/on_examine(atom/A, mob/user, list/examine_list)
SIGNAL_HANDLER

if(!current_cook_time) //Not grilled yet
if(positive_result)
if(initial(cook_result.name) == PLURAL)
examine_list += span_notice("[parent] can be [span_bold("grilled")] into some [initial(cook_result.name)].")
else
examine_list += span_notice("[parent] can be [span_bold("grilled")] into \a [initial(cook_result.name)].")
return

if(positive_result)
if(current_cook_time <= required_cook_time * 0.75)
examine_list += span_notice("[parent] probably needs to be cooked a bit longer!")
else if(current_cook_time <= required_cook_time)
examine_list += span_notice("[parent] seems to be almost finished cooking!")
else
examine_list += span_danger("[parent] should probably not be put on the grill.")

///Ran when an object moves from the grill
/datum/component/grillable/proc/on_moved(atom/source, atom/OldLoc, Dir, Forced)
SIGNAL_HANDLER

UnregisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS)
UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)
source.update_appearance()

/datum/component/grillable/proc/add_grilled_item_overlay(datum/source, list/overlays)
SIGNAL_HANDLER

overlays += mutable_appearance('icons/effects/steam.dmi', "[use_large_steam_sprite ? "steam_triple" : "steam_single"]", ABOVE_OBJ_LAYER)
2 changes: 2 additions & 0 deletions code/datums/looping_sounds/machinery_sounds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@
end_sound = 'sound/machines/oven/oven_loop_end.ogg'
volume = 100
falloff_exponent = 4

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -1555,3 +1555,10 @@
icon_state = "engineering"
build_path = /obj/machinery/suit_storage_unit
req_components = list(/obj/item/stock_parts/micro_laser = 4)

/obj/item/circuitboard/machine/griddle
name = "Griddle (Machine Board)"
icon_state = "service"
build_path = /obj/machinery/griddle
req_components = list(/obj/item/stock_parts/micro_laser = 1,)
needs_anchored = TRUE
14 changes: 14 additions & 0 deletions code/game/objects/items/food/_food.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
make_processable()
make_bakeable()
make_leave_trash()
make_grillable()

///This proc adds the edible component, overwrite this if you for some reason want to change some specific args like callbacks.
/obj/item/food/proc/make_edible()
Expand Down Expand Up @@ -71,3 +72,16 @@
AddElement(/datum/element/food_trash, trash_type)
return

///This proc handles grillable components, overwrite if you want different grill results etc.
/obj/item/food/proc/make_grillable()
AddComponent(/datum/component/grillable, /obj/item/reagent_containers/food/snacks/badrecipe, rand(20 SECONDS, 30 SECONDS), FALSE)
return

///returns if something can be consumed, drink or food
/proc/IsEdible(obj/item/thing)
if(!istype(thing))
return FALSE
if(IS_EDIBLE(thing))
return TRUE
return FALSE

4 changes: 4 additions & 0 deletions code/modules/food_and_drinks/food.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@
if((foodtype & BREAKFAST) && world.time - SSticker.round_start_time < STOP_SERVING_BREAKFAST)
SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "breakfast", /datum/mood_event/breakfast)
last_check_time = world.time

/obj/item/reagent_containers/food/proc/make_grillable()
AddComponent(/datum/component/grillable, /obj/item/reagent_containers/food/snacks/badrecipe, rand(20 SECONDS, 30 SECONDS), FALSE)
return
Loading