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

@@ -3,6 +3,7 @@ using Content.Shared.Examine;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Nutrition;
using Content.Shared.Popups;
using Content.Shared.Storage.EntitySystems;
using JetBrains.Annotations;
@@ -37,6 +38,8 @@ namespace Content.Shared.Stacks
SubscribeLocalEvent<StackComponent, ComponentStartup>(OnStackStarted);
SubscribeLocalEvent<StackComponent, ExaminedEvent>(OnStackExamined);
SubscribeLocalEvent<StackComponent, InteractUsingEvent>(OnStackInteractUsing);
SubscribeLocalEvent<StackComponent, BeforeIngestedEvent>(OnBeforeEaten);
SubscribeLocalEvent<StackComponent, IngestedEvent>(OnEaten);
_vvm.GetTypeHandler<StackComponent>()
.AddPath(nameof(StackComponent.Count), (_, comp) => comp.Count, SetCount);
@@ -389,6 +392,51 @@ namespace Content.Shared.Stacks
)
);
}
private void OnBeforeEaten(Entity<StackComponent> eaten, ref BeforeIngestedEvent args)
{
if (args.Cancelled)
return;
if (args.Solution is not { } sol)
return;
// If the entity is empty and is a lingering entity we can't eat from it.
if (eaten.Comp.Count <= 0)
{
args.Cancelled = true;
return;
}
/*
Edible stacked items is near completely evil so we must choose one of the following:
- Option 1: Eat the entire solution each bite and reduce the stack by 1.
- Option 2: Multiply the solution eaten by the stack size.
- Option 3: Divide the solution consumed by stack size.
The easiest and safest option is and always will be Option 1 otherwise we risk reagent deletion or duplication.
That is why we cancel if we cannot set the minimum to the entire volume of the solution.
*/
if(args.TryNewMinimum(sol.Volume))
return;
args.Cancelled = true;
}
private void OnEaten(Entity<StackComponent> eaten, ref IngestedEvent args)
{
if (!Use(eaten, 1))
return;
// We haven't eaten the whole stack yet or are unable to eat it completely.
if (eaten.Comp.Count > 0 || eaten.Comp.Lingering)
{
args.Refresh = true;
return;
}
// Here to tell the food system to do destroy stuff.
args.Destroy = true;
}
}
/// <summary>