mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
[MIRROR] Bit of reference handling for custom food holders (#26321)
* Bit of reference handling for custom food holders (#81195) ## About The Pull Request `ingredients` seems to hold a reference to all the food in our atom's contents that are used to make up our custom food, but it doesn't clear it anywhere. So I implemented `Exited`, as well as cutting the list on component `Destroy`. * Bit of reference handling for custom food holders --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
|
||||
/datum/component/customizable_reagent_holder/Destroy(force)
|
||||
QDEL_NULL(top_overlay)
|
||||
LAZYCLEARLIST(ingredients)
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -64,6 +65,7 @@
|
||||
. = ..()
|
||||
RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(customizable_attack))
|
||||
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
|
||||
RegisterSignal(parent, COMSIG_ATOM_EXITED, PROC_REF(food_exited))
|
||||
RegisterSignal(parent, COMSIG_ATOM_PROCESSED, PROC_REF(on_processed))
|
||||
RegisterSignal(parent, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, PROC_REF(on_requesting_context_from_item))
|
||||
ADD_TRAIT(parent, TRAIT_CUSTOMIZABLE_REAGENT_HOLDER, REF(src))
|
||||
@@ -74,6 +76,7 @@
|
||||
UnregisterSignal(parent, list(
|
||||
COMSIG_ATOM_ATTACKBY,
|
||||
COMSIG_ATOM_EXAMINE,
|
||||
COMSIG_ATOM_EXITED,
|
||||
COMSIG_ATOM_PROCESSED,
|
||||
COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM,
|
||||
))
|
||||
@@ -91,20 +94,13 @@
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/atom/atom_parent = parent
|
||||
var/ingredients_listed = ""
|
||||
if (LAZYLEN(ingredients))
|
||||
for (var/i in 1 to ingredients.len)
|
||||
var/obj/item/ingredient = ingredients[i]
|
||||
var/ending = ", "
|
||||
switch(length(ingredients))
|
||||
if (2)
|
||||
if (i == 1)
|
||||
ending = " and "
|
||||
if (3 to INFINITY)
|
||||
if (i == ingredients.len - 1)
|
||||
ending = ", and "
|
||||
ingredients_listed += "\a [ingredient.name][ending]"
|
||||
examine_list += "It [LAZYLEN(ingredients) ? "contains [ingredients_listed]making a [custom_adjective()]-sized [initial(atom_parent.name)]" : "does not contain any ingredients"]."
|
||||
var/list/ingredients_listed = list()
|
||||
for(var/obj/item/ingredient as anything in ingredients)
|
||||
ingredients_listed += "\a [ingredient.name]"
|
||||
|
||||
examine_list += "It [LAZYLEN(ingredients) \
|
||||
? "contains [english_list(ingredients_listed)] making a [custom_adjective()]-sized [initial(atom_parent.name)]" \
|
||||
: "does not contain any ingredients"]."
|
||||
|
||||
//// Proc that checks if an ingredient is valid or not, returning false if it isnt and true if it is.
|
||||
/datum/component/customizable_reagent_holder/proc/valid_ingredient(obj/ingredient)
|
||||
@@ -289,3 +285,8 @@
|
||||
context[SCREENTIP_CONTEXT_LMB] = "[screentip_verb] [held_item]"
|
||||
|
||||
return CONTEXTUAL_SCREENTIP_SET
|
||||
|
||||
/// Clear refs if our food "goes away" somehow
|
||||
/datum/component/customizable_reagent_holder/proc/food_exited(datum/source, atom/movable/gone)
|
||||
SIGNAL_HANDLER
|
||||
LAZYREMOVE(ingredients, gone)
|
||||
|
||||
Reference in New Issue
Block a user