CatStation/Content.Shared/ComponentTable/SharedComponentTableSystem.cs
Whatstone a8453723d8
Cleanup: ProtoMan Part 1 - remove Shared EntitySystem IPrototypeManager instances (#44386)
* Remove Shared System IPrototypeManager instances

* Remove RecipeManager IPrototypeManager instance

* Fix ItemSystem IPrototypeManager refs, use TryComp

* SharedItemSystem changes, EntWhitelist CompName

* HasComponent->HasComp
2026-06-29 10:18:44 +00:00

31 lines
893 B
C#

using Content.Shared.EntityTable;
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!;
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 (ProtoMan.Resolve(entity, out var entProto))
{
EntityManager.AddComponents(ent, entProto.Components);
}
}
}
}