mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 08:08:49 +01:00
[MIRROR] Adds a food trash element (#574)
* Adds a food trash element (#53225) adds a food trash element, for dumping trash when u eat food unused now, needed for food refactor. spawns trash in your hands (or on the floor) when the food this is attached to is eaten. * Adds a food trash element Co-authored-by: Qustinnus <Floydje123@hotmail.com>
This commit is contained in:
@@ -157,7 +157,6 @@ Behavior that's still missing from this component that original food items had t
|
||||
return
|
||||
if(!owner.reagents.total_volume)//Shouldn't be needed but it checks to see if it has anything left in it.
|
||||
to_chat(feeder, "<span class='warning'>None of [owner] left, oh no!</span>")
|
||||
on_consume?.Invoke(eater, feeder)
|
||||
if(isturf(parent))
|
||||
var/turf/T = parent
|
||||
T.ScrapeAway(1, CHANGETURF_INHERIT_AIR)
|
||||
@@ -230,7 +229,8 @@ Behavior that's still missing from this component that original food items had t
|
||||
var/fraction = min(bite_consumption / owner.reagents.total_volume, 1)
|
||||
owner.reagents.trans_to(eater, bite_consumption, transfered_by = feeder, methods = INGEST)
|
||||
bitecount++
|
||||
On_Consume(eater)
|
||||
if(!owner.reagents.total_volume)
|
||||
On_Consume(eater, feeder)
|
||||
checkLiked(fraction, eater)
|
||||
|
||||
//Invoke our after eat callback if it is valid
|
||||
@@ -283,18 +283,16 @@ Behavior that's still missing from this component that original food items had t
|
||||
last_check_time = world.time
|
||||
|
||||
///Delete the item when it is fully eaten
|
||||
/datum/component/edible/proc/On_Consume(mob/living/eater)
|
||||
/datum/component/edible/proc/On_Consume(mob/living/eater, mob/living/feeder)
|
||||
SEND_SIGNAL(parent, COMSIG_FOOD_CONSUMED, eater, feeder)
|
||||
|
||||
var/atom/owner = parent
|
||||
on_consume?.Invoke(eater, feeder)
|
||||
|
||||
if(!eater)
|
||||
return
|
||||
if(!owner.reagents.total_volume)
|
||||
if(isturf(parent))
|
||||
var/turf/T = parent
|
||||
T.ScrapeAway(1, CHANGETURF_INHERIT_AIR)
|
||||
else
|
||||
qdel(parent)
|
||||
if(isturf(parent))
|
||||
var/turf/T = parent
|
||||
T.ScrapeAway(1, CHANGETURF_INHERIT_AIR)
|
||||
else
|
||||
qdel(parent)
|
||||
|
||||
///Ability to feed food to puppers
|
||||
/datum/component/edible/proc/UseByAnimal(datum/source, mob/user)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// If an item has the food_trash element it will drop an item when it is consumed.
|
||||
/datum/element/food_trash
|
||||
element_flags = ELEMENT_BESPOKE
|
||||
id_arg_index = 2
|
||||
/// The type of trash that is spawned by this element
|
||||
var/trash
|
||||
|
||||
/datum/element/food_trash/Attach(datum/target, atom/trash)
|
||||
. = ..()
|
||||
if(!isatom(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
src.trash = trash
|
||||
RegisterSignal(target, COMSIG_FOOD_CONSUMED, .proc/generate_trash)
|
||||
|
||||
/datum/element/food_trash/Detach(datum/target)
|
||||
. = ..()
|
||||
UnregisterSignal(target, COMSIG_FOOD_CONSUMED)
|
||||
|
||||
/datum/element/food_trash/proc/generate_trash(datum/source, mob/living/eater, mob/living/feeder)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
///cringy signal_handler shouldnt be needed if you dont want to return but oh well
|
||||
INVOKE_ASYNC(src, .proc/async_generate_trash, source)
|
||||
|
||||
/datum/element/food_trash/proc/async_generate_trash(datum/source)
|
||||
var/datum/component/edible/edible_component = source
|
||||
|
||||
var/obj/item/trash_item = new trash()
|
||||
|
||||
var/atom/edible_object = edible_component.parent
|
||||
|
||||
var/mob/living/mob_location = edible_object.loc //The foods location
|
||||
|
||||
if(istype(mob_location))
|
||||
mob_location.put_in_hands(trash_item)
|
||||
else
|
||||
trash_item.forceMove(get_turf(edible_component.parent))
|
||||
Reference in New Issue
Block a user