mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-10 08:54:15 +00:00
* Removes some food initialize arguments (#78322) ## About The Pull Request A prior PR added some new initialize arguments to the food subtype which did not strictly need to be there, this caused a large number of bugs as a result of places which already had extra initialize arguments not correctly accounting for these new ones. As a result I have removed these again in favour of performing the required operations in a different way (one of these arguments was seemingly used for butter purity and literally nothing else), for this food and also some of its subtypes. In some other cases where it _did_ make sense to have arguments in `initialize` I also added them to `new` so they can be passed by name. This will hopefully make the food more maintainable if in the future if someone does something similar, and solve any remaining bugs related to "not passing the arguments properly". ## Changelog Hopefully not player facing * Removes some food initialize arguments --------- Co-authored-by: Jacquerel <hnevard@gmail.com>
52 lines
2.0 KiB
Plaintext
52 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())
|
|
resulting_food.reagents.clear_reagents()
|
|
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)
|
|
|