Pow3r bugfixes (#16941)

This commit is contained in:
Pieter-Jan Briers
2023-05-30 02:32:59 +02:00
committed by GitHub
parent 1d72e0f133
commit 2ec53b818c
3 changed files with 7 additions and 5 deletions

View File

@@ -194,7 +194,7 @@ namespace Content.Server.Power.Pow3r
foreach (var batteryId in network.BatteryLoads)
{
var battery = state.Batteries[batteryId];
if (!battery.Enabled || battery.DesiredPower == 0 || battery.Paused)
if (!battery.Enabled || battery.DesiredPower == 0 || battery.Paused || !battery.CanCharge)
continue;
battery.LoadingMarked = true;
@@ -240,7 +240,7 @@ namespace Content.Server.Power.Pow3r
foreach (var batteryId in network.BatterySupplies)
{
var battery = state.Batteries[batteryId];
if (!battery.Enabled || battery.Paused)
if (!battery.Enabled || battery.Paused || !battery.CanDischarge)
continue;
battery.SupplyingMarked = true;

View File

@@ -151,6 +151,7 @@ namespace Content.Server.Power.Pow3r
slot.Generation = id.Generation;
slot.Value = value;
slot.NextSlot = -1;
}
// Go through empty slots and build the free chain.
@@ -159,7 +160,7 @@ namespace Content.Server.Power.Pow3r
{
ref var slot = ref storage._storage[i];
if (slot.Generation != 0)
if (slot.NextSlot == -1)
// Slot in use.
continue;
@@ -170,8 +171,7 @@ namespace Content.Server.Power.Pow3r
storage.Count = cache.Length;
storage._nextFree = nextFree;
// I think there is some issue with Pow3er's Save & Load to json leading to it constructing invalid GenIdStorages from json?
// If you get this error, clear out your data.json
// Sanity check for a former bug with save/load.
DebugTools.Assert(storage.Values.Count() == storage.Count);
return storage;

View File

@@ -237,6 +237,8 @@ namespace Pow3r
Begin($"Battery {battery.Id}##Bat{battery.Id}");
Checkbox("Enabled", ref battery.Enabled);
Checkbox("CanDischarge", ref battery.CanDischarge);
Checkbox("CanCharge", ref battery.CanCharge);
SliderFloat("Capacity", ref battery.Capacity, 0, 100000, "%.0f J");
SliderFloat("Max charge rate", ref battery.MaxChargeRate, 0, 1000, "%.0f W");
SliderFloat("Max supply", ref battery.MaxSupply, 0, 1000, "%.0f W");