From 15a55766b0fb5d6b01240a0c1c7dff45a4486676 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Mon, 14 Oct 2024 19:50:52 -0400 Subject: [PATCH] SectorService: init/remove --- .../_NF/SectorServices/SectorServiceSystem.cs | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Content.Server/_NF/SectorServices/SectorServiceSystem.cs b/Content.Server/_NF/SectorServices/SectorServiceSystem.cs index 891b20c6111..fd2fc8665ac 100644 --- a/Content.Server/_NF/SectorServices/SectorServiceSystem.cs +++ b/Content.Server/_NF/SectorServices/SectorServiceSystem.cs @@ -25,34 +25,32 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnComponentStartup); - SubscribeLocalEvent(OnComponentShutdown); + SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnMapRemove); //SubscribeLocalEvent(OnMapInit); //SubscribeLocalEvent(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()) - { - 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()) + { + 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;