mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* 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
36 lines
1.4 KiB
C#
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);
|
|
}
|
|
}
|