diff --git a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs
index 30522c28f3..7870234aab 100644
--- a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs
+++ b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs
@@ -11,12 +11,22 @@ namespace Content.Server.Singularity.Components;
public sealed partial class RadiationCollectorComponent : Component
{
///
- /// How much joules will collector generate for each rad.
+ /// Power output (in Watts) per unit of radiation collected.
///
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public float ChargeModifier = 30000f;
+ ///
+ /// Number of power ticks that the power supply can remain active for. This is needed since
+ /// power and radiation don't update at the same tickrate, and since radiation does not provide
+ /// an update when radiation is removed. When this goes to zero, zero out the power supplier
+ /// to model the radiation source going away.
+ ///
+ [DataField]
+ [ViewVariables(VVAccess.ReadWrite)]
+ public int PowerTicksLeft = 0;
+
///
/// Is the machine enabled.
///
diff --git a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs
index 83666776a0..92b963e201 100644
--- a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs
+++ b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs
@@ -38,6 +38,7 @@ public sealed class RadiationCollectorSystem : EntitySystem
SubscribeLocalEvent(OnMapInit);
SubscribeLocalEvent(OnTankChanged);
SubscribeLocalEvent(OnTankChanged);
+ SubscribeLocalEvent(PostSync);
}
private bool TryGetLoadedGasTank(EntityUid uid, [NotNullWhen(true)] out GasTankComponent? gasTankComponent)
@@ -107,20 +108,34 @@ public sealed class RadiationCollectorSystem : EntitySystem
}
}
- // No idea if this is even vaguely accurate to the previous logic.
- // The maths is copied from that logic even though it works differently.
- // But the previous logic would also make the radiation collectors never ever stop providing energy.
- // And since frameTime was used there, I'm assuming that this is what the intent was.
- // This still won't stop things being potentially hilariously unbalanced though.
- if (TryComp(uid, out var batteryComponent))
+ if (TryComp(uid, out var comp))
{
- _batterySystem.SetCharge(uid, charge, batteryComponent);
+ int powerHoldoverTicks = _gameTiming.TickRate * 2; // number of ticks to hold radiation
+ component.PowerTicksLeft = powerHoldoverTicks;
+ comp.MaxSupply = component.Enabled ? charge : 0;
}
// Update appearance
UpdatePressureIndicatorAppearance(uid, component, gasTankComponent);
}
+ private void PostSync(NetworkBatteryPostSync ev)
+ {
+ // This is run every power tick. Used to decrement the PowerTicksLeft counter.
+ var query = EntityQueryEnumerator();
+ while (query.MoveNext(out var uid, out var component))
+ {
+ if (component.PowerTicksLeft > 0)
+ {
+ component.PowerTicksLeft -= 1;
+ }
+ else if (TryComp(uid, out var comp))
+ {
+ comp.MaxSupply = 0;
+ }
+ }
+ }
+
private void OnExamined(EntityUid uid, RadiationCollectorComponent component, ExaminedEvent args)
{
if (!TryGetLoadedGasTank(uid, out var gasTank))
diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml
index 73ce221787..3742c037ff 100644
--- a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml
+++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/collector.yml
@@ -62,21 +62,11 @@
- reactantPrototype: Plasma
powerGenerationEfficiency: 1
reactantBreakdownRate: 0.0001
- # Note that this doesn't matter too much (see next comment)
- # However it does act as a cap on power receivable via the collector.
- - type: Battery
- maxCharge: 100000
- startingCharge: 0
- - type: BatteryDischarger
- # This is JUST a default. It has to be dynamically adjusted to ensure that the battery doesn't discharge "too fast" & run out immediately, while still scaling by input power.
- activeSupplyRate: 100000
- type: RadiationReceiver
+ - type: PowerSupplier
- type: Anchorable
- type: Rotatable
- type: Pullable
- - type: PowerNetworkBattery
- maxSupply: 1000000000
- supplyRampTolerance: 1000000000
- type: GuideHelp
guides: [ Singularity, Power ]
- type: ContainerContainer