Nuke PowerChangedMessage (#7231)

This commit is contained in:
metalgearsloth
2022-03-29 03:58:51 +11:00
committed by GitHub
parent 2d610ebb52
commit 49163f1dec
18 changed files with 134 additions and 140 deletions

View File

@@ -1,6 +1,6 @@
using Content.Server.AME.Components;
using Content.Server.Power.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.AME
{
@@ -9,19 +9,33 @@ namespace Content.Server.AME
{
private float _accumulatedFrameTime;
private const float UpdateCooldown = 10f;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AMEControllerComponent, PowerChangedEvent>(OnAMEPowerChange);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
// TODO: Won't exactly work with replays I guess?
_accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime >= 10)
if (_accumulatedFrameTime >= UpdateCooldown)
{
foreach (var comp in EntityManager.EntityQuery<AMEControllerComponent>())
{
comp.OnUpdate(frameTime);
}
_accumulatedFrameTime -= 10;
_accumulatedFrameTime -= UpdateCooldown;
}
}
private static void OnAMEPowerChange(EntityUid uid, AMEControllerComponent component, PowerChangedEvent args)
{
component.UpdateUserInterface();
}
}
}