Skip to content

Commit

Permalink
SectorServices: spawn in nullspace
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Oct 14, 2024
1 parent 9d51d43 commit ae81bc1
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions Content.Server/_NF/SectorServices/SectorServiceSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Server.GameTicking;
using Content.Shared._NF.SectorServices.Prototypes;
using JetBrains.Annotations;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;


Expand All @@ -12,8 +14,9 @@ namespace Content.Server._NF.SectorServices;
[PublicAPI]
public sealed class SectorServiceSystem : EntitySystem
{
[Robust.Shared.IoC.Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Robust.Shared.IoC.Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;

[ViewVariables(VVAccess.ReadOnly)]
private EntityUid _entity = EntityUid.Invalid; // The station entity that's storing our services.
Expand All @@ -22,16 +25,18 @@ public override void Initialize()
{
base.Initialize();

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

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

foreach (var servicePrototype in _prototypeManager.EnumeratePrototypes<SectorServicePrototype>())
{
Expand All @@ -41,16 +46,12 @@ private void OnComponentStartup(EntityUid uid, StationSectorServiceHostComponent
}
}

private void OnComponentShutdown(EntityUid uid, StationSectorServiceHostComponent component, ComponentShutdown args)
private void OnMapRemove(EntityUid uid, MapComponent map, ComponentRemove args)
{
Log.Debug($"OnComponentShutdown! Entity: {_entity}");
if (_entity != EntityUid.Invalid)
Log.Debug($"OnMapRemove! Entity: {_entity}");
if (map.MapId == _gameTicker.DefaultMap)
{
foreach (var servicePrototype in _prototypeManager.EnumeratePrototypes<SectorServicePrototype>())
{
Log.Debug($"Removing component for service {servicePrototype.ID}");
_entityManager.RemoveComponents(_entity, servicePrototype.Components);
}
Del(_entity);
_entity = EntityUid.Invalid;
}
}
Expand Down

0 comments on commit ae81bc1

Please sign in to comment.