Skip to content

Commit

Permalink
SectorService: init/remove
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Oct 14, 2024
1 parent cfbb5a2 commit 15a5576
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions Content.Server/_NF/SectorServices/SectorServiceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,32 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<StationSectorServiceHostComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<StationSectorServiceHostComponent, ComponentShutdown>(OnComponentShutdown);
SubscribeLocalEvent<StationSectorServiceHostComponent, ComponentInit>(OnMapInit);
SubscribeLocalEvent<StationSectorServiceHostComponent, ComponentRemove>(OnMapRemove);
//SubscribeLocalEvent<MapComponent, ComponentInit>(OnMapInit);
//SubscribeLocalEvent<MapComponent, ComponentRemove>(OnMapRemove);
}

private void OnMapInit(EntityUid uid, MapComponent map, ComponentInit args)
private void OnMapInit(EntityUid uid, StationSectorServiceHostComponent map, ComponentInit args)
{
Log.Debug($"OnMapInit! Entity: {uid} internal: {_entity}");
if (map.MapId == _gameTicker.DefaultMap)
{
if (_entity != EntityUid.Invalid)
return;

Spawn();
if (_entity != EntityUid.Invalid)
return;

Spawn();

foreach (var servicePrototype in _prototypeManager.EnumeratePrototypes<SectorServicePrototype>())
{
Log.Debug($"Adding components for service {servicePrototype.ID}");
_entityManager.AddComponents(_entity, servicePrototype.Components, false); // removeExisting false - do not override existing components.
}
foreach (var servicePrototype in _prototypeManager.EnumeratePrototypes<SectorServicePrototype>())
{
Log.Debug($"Adding components for service {servicePrototype.ID}");
_entityManager.AddComponents(_entity, servicePrototype.Components, false); // removeExisting false - do not override existing components.
}
}

private void OnMapRemove(EntityUid uid, MapComponent map, ComponentRemove args)
private void OnMapRemove(EntityUid uid, StationSectorServiceHostComponent map, ComponentRemove args)
{
Log.Debug($"OnMapRemove! Entity: {_entity}");
if (map.MapId == _gameTicker.DefaultMap)
if (_entity != EntityUid.Invalid)
{
Del(_entity);
_entity = EntityUid.Invalid;
Expand Down

0 comments on commit 15a5576

Please sign in to comment.