Files
tbd-station-14/Content.Server/APC/ApcNetSystem.cs
Vera Aguilera Puerto bc7b315b18 Replace IResettingEntitySystem with RoundRestartCleanupEvent. (#4245)
* Replace IResettingEntitySystem with RoundRestartCleanupEvent.

* oops
2021-06-29 23:56:07 +10:00

53 lines
1.4 KiB
C#

#nullable enable
using System.Collections.Generic;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Content.Server.APC
{
[UsedImplicitly]
internal sealed class ApcNetSystem : EntitySystem
{
[Dependency] private readonly IPauseManager _pauseManager = default!;
private HashSet<IApcNet> _apcNets = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
}
public override void Update(float frameTime)
{
foreach (var apcNet in _apcNets)
{
var gridId = apcNet.GridId;
if (gridId != null && !_pauseManager.IsGridPaused(gridId.Value))
apcNet.Update(frameTime);
}
}
public void AddApcNet(ApcNetNodeGroup apcNet)
{
_apcNets.Add(apcNet);
}
public void RemoveApcNet(ApcNetNodeGroup apcNet)
{
_apcNets.Remove(apcNet);
}
public void Reset(RoundRestartCleanupEvent ev)
{
// NodeGroupSystem does not remake ApcNets affected during restarting until a frame later,
// when their grid is invalid. So, we are clearing them on round restart.
_apcNets.Clear();
}
}
}