diff --git a/Content.Server/PowerCell/PowerCellDrawComponent.cs b/Content.Server/PowerCell/PowerCellDrawComponent.cs
index 7697fa2654..743eeea973 100644
--- a/Content.Server/PowerCell/PowerCellDrawComponent.cs
+++ b/Content.Server/PowerCell/PowerCellDrawComponent.cs
@@ -1,3 +1,5 @@
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
+
namespace Content.Server.PowerCell;
///
@@ -22,4 +24,10 @@ public sealed class PowerCellDrawComponent : Component
///
[ViewVariables(VVAccess.ReadWrite), DataField("useRate")]
public float UseRate = 0f;
+
+ ///
+ /// When the next automatic power draw will occur
+ ///
+ [DataField("nextUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
+ public TimeSpan NextUpdateTime;
}
diff --git a/Content.Server/PowerCell/PowerCellSystem.cs b/Content.Server/PowerCell/PowerCellSystem.cs
index 5d2eaa01d5..c6112c7355 100644
--- a/Content.Server/PowerCell/PowerCellSystem.cs
+++ b/Content.Server/PowerCell/PowerCellSystem.cs
@@ -15,12 +15,14 @@ using Content.Server.UserInterface;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Popups;
using Content.Shared.Rejuvenate;
+using Robust.Shared.Timing;
namespace Content.Server.PowerCell;
public sealed class PowerCellSystem : SharedPowerCellSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ActivatableUISystem _activatable = default!;
[Dependency] private readonly BatterySystem _battery = default!;
[Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!;
@@ -40,6 +42,9 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
SubscribeLocalEvent(OnCellExamined);
+ SubscribeLocalEvent(OnMapInit);
+ SubscribeLocalEvent(OnUnpaused);
+
// funny
SubscribeLocalEvent(OnSlotMicrowaved);
SubscribeLocalEvent(OnMicrowaved);
@@ -55,10 +60,14 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
if (!comp.Enabled)
continue;
+ if (_timing.CurTime < comp.NextUpdateTime)
+ continue;
+ comp.NextUpdateTime += TimeSpan.FromSeconds(1);
+
if (!TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery, slot))
continue;
- if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate * frameTime, battery))
+ if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate, battery))
continue;
comp.Enabled = false;
@@ -127,6 +136,17 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
RaiseLocalEvent(uid, ref ev);
}
+ private void OnMapInit(EntityUid uid, PowerCellDrawComponent component, MapInitEvent args)
+ {
+ if (component.NextUpdateTime < _timing.CurTime)
+ component.NextUpdateTime = _timing.CurTime;
+ }
+
+ private void OnUnpaused(EntityUid uid, PowerCellDrawComponent component, ref EntityUnpausedEvent args)
+ {
+ component.NextUpdateTime += args.PausedTime;
+ }
+
private void Explode(EntityUid uid, BatteryComponent? battery = null, EntityUid? cause = null)
{
if (!Resolve(uid, ref battery))
diff --git a/Resources/Prototypes/Entities/Objects/Specific/Research/anomaly.yml b/Resources/Prototypes/Entities/Objects/Specific/Research/anomaly.yml
index f58ee19e65..32d8caa07e 100644
--- a/Resources/Prototypes/Entities/Objects/Specific/Research/anomaly.yml
+++ b/Resources/Prototypes/Entities/Objects/Specific/Research/anomaly.yml
@@ -44,7 +44,7 @@
True: { visible: true }
False: { visible: false }
- type: PowerCellDraw
- drawRate: 10
+ drawRate: 5
useRate: 0
- type: ProximityBeeper
component: Anomaly