CatStation/Content.Server/Animals/Systems/EntityProducerSystem.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

31 lines
895 B
C#

using Content.Server.Animals.Components;
using Content.Shared.EntityTable;
namespace Content.Server.Animals.Systems;
/// <summary>
/// Handles producing configured entities in response to production attempts.
/// </summary>
public sealed partial class EntityProducerSystem : EntitySystem
{
[Dependency] private EntityTableSystem _entityTable = default!;
[SubscribeLocalEvent]
private void OnProduce(Entity<EntityProducerComponent> ent, ref ProductionAttemptEvent args)
{
var produced = new List<EntityUid>();
foreach (var spawn in _entityTable.GetSpawns(ent.Comp.Table))
{
produced.Add(SpawnNextToOrDrop(spawn, args.Owner));
}
if (produced.Count == 0)
return;
args.Produced = true;
var ev = new EntitiesProducedEvent(args.Owner, produced);
RaiseLocalEvent(ent.Owner, ref ev);
}
}