mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-06-02 04:27:42 +01:00
6620bffa84
* Collected food fixes (#78190) I went through the code and tried to find all of the remaining places we forgot to update the arguments passed into `item/food/Initialize` after more arguments were added to it, because there were a couple and they caused things to stop working. Most notably, golems were unable to eat anything because nothing would correctly spawn "golem food". _Additionally_ we were using a bunch of named arguments in new whenever crafting or cooking food. This runtimed, causing the food not to init properly. _On top of that_ a late code review on a recent PR processed a list into a string_assoc_list twice causing it to become null. Finally, we were trying to check the food preferences of examining ghosts or dogs or other non-human mobs. We shouldn't do that. I also added a unit test for moth and golem food in the hopes that we'll notice them breaking. * Collected food fixes --------- Co-authored-by: Jacquerel <hnevard@gmail.com>
55 lines
2.0 KiB
Plaintext
55 lines
2.0 KiB
Plaintext
// 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/food) && ispath(dry_result, /obj/item/food))
|
|
var/obj/item/food/source_food = source
|
|
var/obj/item/food/resulting_food = new dry_result(
|
|
source.drop_location(),
|
|
/* starting_reagent_purity = */ null,
|
|
/* no_base_reagents = */ TRUE,
|
|
)
|
|
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)
|
|
|