Fix Sloth's power crime (#6443)
This commit is contained in:
@@ -15,6 +15,8 @@ namespace Content.Server.Power.Components
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class PowerNetworkBatteryComponent : Component
|
public sealed class PowerNetworkBatteryComponent : Component
|
||||||
{
|
{
|
||||||
|
[ViewVariables] public float LastSupply = 0f;
|
||||||
|
|
||||||
[DataField("maxChargeRate")]
|
[DataField("maxChargeRate")]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float MaxChargeRate
|
public float MaxChargeRate
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using Content.Server.NodeContainer.EntitySystems;
|
using Content.Server.NodeContainer.EntitySystems;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.Power.NodeGroups;
|
using Content.Server.Power.NodeGroups;
|
||||||
@@ -7,6 +8,7 @@ using Content.Server.Power.Pow3r;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
namespace Content.Server.Power.EntitySystems
|
namespace Content.Server.Power.EntitySystems
|
||||||
@@ -21,8 +23,6 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
private readonly HashSet<PowerNet> _powerNetReconnectQueue = new();
|
private readonly HashSet<PowerNet> _powerNetReconnectQueue = new();
|
||||||
private readonly HashSet<ApcNet> _apcNetReconnectQueue = new();
|
private readonly HashSet<ApcNet> _apcNetReconnectQueue = new();
|
||||||
|
|
||||||
private readonly Dictionary<PowerNetworkBatteryComponent, float> _lastSupply = new();
|
|
||||||
|
|
||||||
private readonly BatteryRampPegSolver _solver = new();
|
private readonly BatteryRampPegSolver _solver = new();
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -208,14 +208,6 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
// Setup for events.
|
|
||||||
{
|
|
||||||
foreach (var powerNetBattery in EntityManager.EntityQuery<PowerNetworkBatteryComponent>())
|
|
||||||
{
|
|
||||||
_lastSupply[powerNetBattery] = powerNetBattery.CurrentSupply;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reconnect networks.
|
// Reconnect networks.
|
||||||
{
|
{
|
||||||
foreach (var apcNet in _apcNetReconnectQueue)
|
foreach (var apcNet in _apcNetReconnectQueue)
|
||||||
@@ -276,24 +268,20 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
|
|
||||||
foreach (var powerNetBattery in EntityManager.EntityQuery<PowerNetworkBatteryComponent>())
|
foreach (var powerNetBattery in EntityManager.EntityQuery<PowerNetworkBatteryComponent>())
|
||||||
{
|
{
|
||||||
if (!_lastSupply.TryGetValue(powerNetBattery, out var lastPowerSupply))
|
var lastSupply = powerNetBattery.LastSupply;
|
||||||
{
|
|
||||||
lastPowerSupply = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentSupply = powerNetBattery.CurrentSupply;
|
var currentSupply = powerNetBattery.CurrentSupply;
|
||||||
|
|
||||||
if (lastPowerSupply == 0f && currentSupply != 0f)
|
if (lastSupply == 0f && currentSupply != 0f)
|
||||||
{
|
{
|
||||||
RaiseLocalEvent(powerNetBattery.Owner, new PowerNetBatterySupplyEvent {Supply = true});
|
RaiseLocalEvent(powerNetBattery.Owner, new PowerNetBatterySupplyEvent {Supply = true});
|
||||||
}
|
}
|
||||||
else if (lastPowerSupply > 0f && currentSupply == 0f)
|
else if (lastSupply > 0f && currentSupply == 0f)
|
||||||
{
|
{
|
||||||
RaiseLocalEvent(powerNetBattery.Owner, new PowerNetBatterySupplyEvent {Supply = false});
|
RaiseLocalEvent(powerNetBattery.Owner, new PowerNetBatterySupplyEvent {Supply = false});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_lastSupply.Clear();
|
powerNetBattery.LastSupply = currentSupply;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user