diff --git a/code/datums/components/food/edible.dm b/code/datums/components/food/edible.dm index da38c2431ee..da94d98c8ad 100644 --- a/code/datums/components/food/edible.dm +++ b/code/datums/components/food/edible.dm @@ -75,8 +75,8 @@ Behavior that's still missing from this component that original food items had t if (!item.grind_results) item.grind_results = list() //If this doesn't already exist, add it as an empty list. This is needed for the grinder to accept it. - else if(isturf(parent)) - RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, .proc/TryToEatTurf) + else if(isturf(parent) || isstructure(parent)) + RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, .proc/TryToEatIt) src.bite_consumption = bite_consumption src.food_flags = food_flags @@ -149,7 +149,7 @@ Behavior that's still missing from this component that original food items had t return TryToEat(M, user) -/datum/component/edible/proc/TryToEatTurf(datum/source, mob/user) +/datum/component/edible/proc/TryToEatIt(datum/source, mob/user) SIGNAL_HANDLER return TryToEat(user, user) @@ -250,28 +250,27 @@ Behavior that's still missing from this component that original food items had t else this_food.reagents.add_reagent(r_id, amount) +///Makes sure the thing hasn't been destroyed or fully eaten to prevent eating phantom edibles +/datum/component/edible/proc/IsFoodGone(atom/owner, mob/living/feeder) + if(QDELETED(owner)|| !(IS_EDIBLE(owner))) + return TRUE + if(owner.reagents.total_volume) + return FALSE + return TRUE ///All the checks for the act of eating itself and /datum/component/edible/proc/TryToEat(mob/living/eater, mob/living/feeder) set waitfor = FALSE - if(QDELETED(parent)) - return - var/atom/owner = parent - if(feeder.a_intent == INTENT_HARM) 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, "None of [owner] left, oh no!") - if(isturf(parent)) - var/turf/T = parent - T.ScrapeAway(1, CHANGETURF_INHERIT_AIR) - else - qdel(parent) + + if(IsFoodGone(owner, feeder)) return + if(!CanConsume(eater, feeder)) return var/fullness = eater.get_fullness() + 10 //The theoretical fullness of the person eating if they were to eat this @@ -281,6 +280,8 @@ Behavior that's still missing from this component that original food items had t if(eater == feeder)//If you're eating it yourself. if(!do_mob(feeder, eater, eat_time)) //Gotta pass the minimal eat time return + if(IsFoodGone(owner, feeder)) + return var/eatverb = pick(eatverbs) if(junkiness && eater.satiety < -150 && eater.nutrition > NUTRITION_LEVEL_STARVING + 50 && !HAS_TRAIT(eater, TRAIT_VORACIOUS)) to_chat(eater, "You don't feel like eating any more junk food at the moment!") @@ -309,7 +310,8 @@ Behavior that's still missing from this component that original food items had t return if(!do_mob(feeder, eater)) //Wait 3 seconds before you can feed return - + if(IsFoodGone(owner, feeder)) + return log_combat(feeder, eater, "fed", owner.reagents.log_list()) eater.visible_message("[feeder] forces [eater] to eat [parent]!", \ "[feeder] forces you to eat [parent]!") @@ -396,6 +398,7 @@ Behavior that's still missing from this component that original food items had t on_consume?.Invoke(eater, feeder) + to_chat(feeder, "There is nothing left of [parent], oh no!") if(isturf(parent)) var/turf/T = parent T.ScrapeAway(1, CHANGETURF_INHERIT_AIR)