Decouple power sink from tickrate (#40789)

* Fix typo in `BatterySystem.ChangeCharge`.

* Decouple power sink behavior from tickrate.

* Fix power sink's price per joule
This commit is contained in:
YotaXP
2025-10-10 19:01:33 -04:00
committed by GitHub
parent 21460c86b0
commit 6f02e6c19c
3 changed files with 4 additions and 4 deletions

View File

@@ -171,7 +171,7 @@ namespace Content.Server.Power.EntitySystems
if (!Resolve(uid, ref battery))
return 0;
var newValue = Math.Clamp(0, battery.CurrentCharge + value, battery.MaxCharge);
var newValue = Math.Clamp(battery.CurrentCharge + value, 0, battery.MaxCharge);
var delta = newValue - battery.CurrentCharge;
battery.CurrentCharge = newValue;

View File

@@ -66,7 +66,7 @@ namespace Content.Server.PowerSink
if (!transform.Anchored)
continue;
_battery.SetCharge(entity, battery.CurrentCharge + networkLoad.NetworkLoad.ReceivingPower / 1000, battery);
_battery.ChangeCharge(entity, networkLoad.NetworkLoad.ReceivingPower * frameTime, battery);
var currentBatteryThreshold = battery.CurrentCharge / battery.MaxCharge;

View File

@@ -40,8 +40,8 @@
acts: [ "Destruction" ]
- type: PowerSink
- type: Battery
maxCharge: 7500000
pricePerJoule: 0.0003
maxCharge: 250000000
pricePerJoule: 0.000009
- type: ExaminableBattery
- type: PowerConsumer
voltage: High