CatStation/Content.Server/Animals/Systems/EntityProducerActionSystem.cs
AndrewFenriz 6dc1aae3f2
Refactor animal reagent/entity production (#45019)
* port 35190

* HungerProduction

* SolutionProducer

* update

* move to server

* small tweak for Shearable

* fix

* ProductionAttemptEvent

* EntityProducer

* update EggLayer

* EntityTable

* no more actions on EggLayer

* move popups to comp

* kill EggLayer

* new locale

* rename field

* upd

* SatiationType

* rename to SatiationProduction and lil docs

* EntityQuery

* more docs for god of docs

* small fix

* more queries
2026-08-16 19:15:52 +00:00

36 lines
1.4 KiB
C#

using Content.Server.Animals.Components;
using Content.Server.Popups;
using Content.Shared.Animals.Events;
using Content.Shared.IdentityManagement;
using Robust.Server.Audio;
namespace Content.Server.Animals.Systems;
/// <summary>
/// Handles entity production actions and their feedback.
/// </summary>
public sealed partial class EntityProducerActionSystem : EntitySystem
{
[Dependency] private AudioSystem _audio = default!;
[Dependency] private SatiationProductionSystem _satiationProduction = default!;
[Dependency] private PopupSystem _popup = default!;
[SubscribeLocalEvent]
private void OnProductionAction(Entity<EntityProducerActionComponent> ent, ref EntityProductionActionEvent args)
{
args.Handled = _satiationProduction.TryProduce(ent.Owner, out var failure);
if (failure == SatiationProductionFailure.InsufficientSatiation)
_popup.PopupEntity(Loc.GetString(ent.Comp.InsufficientSatiationPopup), ent.Owner, ent.Owner);
}
[SubscribeLocalEvent]
private void OnEntitiesProduced(Entity<EntityProducerActionComponent> ent, ref EntitiesProducedEvent args)
{
_audio.PlayPvs(ent.Comp.ProductionSound, args.Owner);
_popup.PopupEntity(
Loc.GetString(ent.Comp.UserPopup),
Loc.GetString(ent.Comp.OthersPopup, ("entity", Identity.Entity(args.Owner, EntityManager))),
args.Owner,
args.Owner);
}
}