Hunger ECS (#14939)

This commit is contained in:
Nemanja
2023-04-02 22:42:30 -04:00
committed by GitHub
parent 19277a2276
commit 0f0b534239
14 changed files with 440 additions and 364 deletions

View File

@@ -1,11 +1,13 @@
using Content.Server.Animals.Components;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.DoAfter;
using Content.Shared.IdentityManagement;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Udder;
using Content.Shared.Verbs;
@@ -18,6 +20,7 @@ namespace Content.Server.Animals.Systems
internal sealed class UdderSystem : EntitySystem
{
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly HungerSystem _hunger = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
@@ -41,10 +44,8 @@ namespace Content.Server.Animals.Systems
// Actually there is food digestion so no problem with instant reagent generation "OnFeed"
if (EntityManager.TryGetComponent<HungerComponent?>(udder.Owner, out var hunger))
{
hunger.HungerThresholds.TryGetValue(HungerThreshold.Peckish, out var targetThreshold);
// Is there enough nutrition to produce reagent?
if (hunger.CurrentHunger < targetThreshold)
if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Peckish)
continue;
}