ApcNet updating fix (#3078)
* GridPowerComponent * ApcNet Powered update bugfix * PowerTest fix * Add GridPower to Saltern * test fix * Update canceling cleanup * code cleanup * nullable & code cleanup for test * undo power test nullable * Replaces GridPowerSystem with ApcNetSystem * build fix * Update Content.Server/GameObjects/EntitySystems/ApcNetSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
39
Content.Server/GameObjects/EntitySystems/ApcNetSystem.cs
Normal file
39
Content.Server/GameObjects/EntitySystems/ApcNetSystem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Timing;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ApcNetSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||
|
||||
private HashSet<IApcNet> _apcNets = new();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user