Priority Deliveries (#36968)

This commit is contained in:
ScarKy0
2025-04-27 11:13:52 +02:00
committed by GitHub
parent 497f43ec65
commit 2a5cf10aa6
9 changed files with 230 additions and 13 deletions

View File

@@ -0,0 +1,33 @@
using Content.Shared.EntityTable;
using Robust.Shared.Prototypes;
namespace Content.Shared.ComponentTable;
/// <summary>
/// Applies an entity prototype to an entity on map init. Taken from entities inside an EntityTableSelector.
/// </summary>
public sealed class SharedComponentTableSystem : EntitySystem
{
[Dependency] private readonly EntityTableSystem _entTable = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ComponentTableComponent, MapInitEvent>(OnTableInit);
}
private void OnTableInit(Entity<ComponentTableComponent> ent, ref MapInitEvent args)
{
var spawns = _entTable.GetSpawns(ent.Comp.Table);
foreach (var entity in spawns)
{
if (_proto.TryIndex(entity, out var entProto))
{
EntityManager.AddComponents(ent, entProto.Components);
}
}
}
}