Fix PowerCellDrawComponent draw rate (#38562)

* fix power cell draw rate

* comment
This commit is contained in:
slarticodefast
2025-06-25 15:38:57 +02:00
committed by GitHub
parent 524725d378
commit d998d71ce2
2 changed files with 10 additions and 7 deletions

View File

@@ -28,7 +28,7 @@ public sealed partial class PowerCellSystem
if (!TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery, slot)) if (!TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery, slot))
continue; continue;
if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate, battery)) if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate * (float)comp.Delay.TotalSeconds, battery))
continue; continue;
var ev = new PowerCellSlotEmptyEvent(); var ev = new PowerCellSlotEmptyEvent();

View File

@@ -18,13 +18,13 @@ public sealed partial class PowerCellDrawComponent : Component
/// <summary> /// <summary>
/// Whether there is any charge available to draw. /// Whether there is any charge available to draw.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("canDraw"), AutoNetworkedField] [DataField, AutoNetworkedField]
public bool CanDraw; public bool CanDraw;
/// <summary> /// <summary>
/// Whether there is sufficient charge to use. /// Whether there is sufficient charge to use.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("canUse"), AutoNetworkedField] [DataField, AutoNetworkedField]
public bool CanUse; public bool CanUse;
#endregion #endregion
@@ -37,17 +37,20 @@ public sealed partial class PowerCellDrawComponent : Component
public bool Enabled = true; public bool Enabled = true;
/// <summary> /// <summary>
/// How much the entity draws while the UI is open. /// How much the entity draws while the UI is open (in Watts).
/// Set to 0 if you just wish to check for power upon opening the UI. /// Set to 0 if you just wish to check for power upon opening the UI.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("drawRate")] [DataField]
public float DrawRate = 1f; public float DrawRate = 1f;
/// <summary> /// <summary>
/// How much power is used whenever the entity is "used". /// How much power is used whenever the entity is "used" (in Joules).
/// This is used to ensure the UI won't open again without a minimum use power. /// This is used to ensure the UI won't open again without a minimum use power.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("useRate")] /// <remarks>
/// This is not a rate how the datafield name implies, but a one-time cost.
/// </remarks>
[DataField]
public float UseRate; public float UseRate;
/// <summary> /// <summary>