Debody Food and Drink Systems, Combine Food and Drink into One System. (#39031)

* Shelve

* 22 file diff

* What if it was just better

* Hold that thought

* Near final Commit, then YAML hell

* 95% done with cs

* Working Commit

* Final Commit (Before reviews tear it apart and kill me)

* Add a really stupid comment.

* KILL

* EXPLODE TEST FAILS WITH MY MIND

* I hate it here

* TACTICAL NUCLEAR STRIKE

* Wait what the fuck was I doing?

* Comments

* Me when I'm stupid

* Food doesn't need solutions

* API improvements with some API weirdness

* Move non-API out of API

* Better comment

* Fixes and spelling mistakes

* Final fixes

* Final fixes for real...

* Kill food and drink localization files because I hate them.

* Water droplet fix

* Utensil fixes

* Fix verb priority (It should've been 2)

* A few minor localization fixes

* merge conflict and stuff

* MERGE CONFLICT NUCLEAR WAR!!!

* Cleanup

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
Princess Cheeseballs
2025-08-06 09:53:38 -07:00
committed by GitHub
parent 02382045ab
commit 91854e0776
52 changed files with 2169 additions and 1024 deletions

View File

@@ -44,9 +44,9 @@ public sealed class NPCUtilitySystem : EntitySystem
[Dependency] private readonly ContainerSystem _container = default!;
[Dependency] private readonly DrinkSystem _drink = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FoodSystem _food = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly IngestionSystem _ingestion = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly OpenableSystem _openable = default!;
@@ -174,14 +174,8 @@ public sealed class NPCUtilitySystem : EntitySystem
{
case FoodValueCon:
{
if (!TryComp<FoodComponent>(targetUid, out var food))
return 0f;
// mice can't eat unpeeled bananas, need monkey's help
if (_openable.IsClosed(targetUid))
return 0f;
if (!_food.IsDigestibleBy(owner, targetUid, food))
// do we have a mouth available? Is the food item opened?
if (!_ingestion.CanConsume(owner, targetUid))
return 0f;
var avoidBadFood = !HasComp<IgnoreBadFoodComponent>(owner);
@@ -194,15 +188,16 @@ public sealed class NPCUtilitySystem : EntitySystem
if (avoidBadFood && HasComp<BadFoodComponent>(targetUid))
return 0f;
var nutrition = _ingestion.TotalNutrition(targetUid, owner);
if (nutrition <= 1.0f)
return 0f;
return 1f;
}
case DrinkValueCon:
{
if (!TryComp<DrinkComponent>(targetUid, out var drink))
return 0f;
// can't drink closed drinks
if (_openable.IsClosed(targetUid))
// can't drink closed drinks and can't drink with a mask on...
if (!_ingestion.CanConsume(owner, targetUid))
return 0f;
// only drink when thirsty
@@ -214,7 +209,9 @@ public sealed class NPCUtilitySystem : EntitySystem
return 0f;
// needs to have something that will satiate thirst, mice wont try to drink 100% pure mutagen.
var hydration = _drink.TotalHydration(targetUid, drink);
// We don't check if the solution is metabolizable cause all drinks should be currently.
// If that changes then simply use the other overflow.
var hydration = _ingestion.TotalHydration(targetUid);
if (hydration <= 1.0f)
return 0f;