Nuke PowerChangedMessage (#7231)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,20 +62,6 @@ namespace Content.Server.AME.Components
|
||||
_jarSlot = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-fuelJarContainer");
|
||||
}
|
||||
|
||||
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
{
|
||||
#pragma warning disable 618
|
||||
base.HandleMessage(message, component);
|
||||
#pragma warning restore 618
|
||||
switch (message)
|
||||
{
|
||||
case PowerChangedMessage powerChanged:
|
||||
OnPowerChanged(powerChanged);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnUpdate(float frameTime)
|
||||
{
|
||||
if (!_injecting)
|
||||
@@ -111,11 +97,6 @@ namespace Content.Server.AME.Components
|
||||
|
||||
}
|
||||
|
||||
private void OnPowerChanged(PowerChangedMessage e)
|
||||
{
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
// Used to update core count
|
||||
public void OnAMENodeGroupUpdate()
|
||||
{
|
||||
@@ -151,7 +132,7 @@ namespace Content.Server.AME.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateUserInterface()
|
||||
public void UpdateUserInterface()
|
||||
{
|
||||
var state = GetUserInterfaceState();
|
||||
UserInterface?.SetState(state);
|
||||
|
||||
Reference in New Issue
Block a user