mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 23:02:22 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
34 lines
985 B
C#
34 lines
985 B
C#
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 partial class SharedComponentTableSystem : EntitySystem
|
|
{
|
|
[Dependency] private EntityTableSystem _entTable = default!;
|
|
[Dependency] private 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.Resolve(entity, out var entProto))
|
|
{
|
|
EntityManager.AddComponents(ent, entProto.Components);
|
|
}
|
|
}
|
|
}
|
|
}
|