mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +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
31 lines
895 B
C#
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);
|
|
}
|
|
}
|