]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix PowerCellDrawComponent draw rate (#38562)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Wed, 25 Jun 2025 13:38:57 +0000 (15:38 +0200)
committerGitHub <noreply@github.com>
Wed, 25 Jun 2025 13:38:57 +0000 (09:38 -0400)
* fix power cell draw rate

* comment

Content.Server/PowerCell/PowerCellSystem.Draw.cs
Content.Shared/PowerCell/PowerCellDrawComponent.cs

index ae43b6dae9d2fa817ca8ea2dd6ab1bc4267402f6..9156d30b1fc74b62ad4063d2bb5fc1fd71fbac9b 100644 (file)
@@ -28,7 +28,7 @@ public sealed partial class PowerCellSystem
             if (!TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery, slot))
                 continue;
 
-            if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate, battery))
+            if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate * (float)comp.Delay.TotalSeconds, battery))
                 continue;
 
             var ev = new PowerCellSlotEmptyEvent();
index 7af44420a7122e6c7d46480b8877ba3bfee39f6d..cecf23d041be881cd339089532b4e58e212e44b0 100644 (file)
@@ -18,13 +18,13 @@ public sealed partial class PowerCellDrawComponent : Component
     /// <summary>
     /// Whether there is any charge available to draw.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite), DataField("canDraw"), AutoNetworkedField]
+    [DataField, AutoNetworkedField]
     public bool CanDraw;
 
     /// <summary>
     /// Whether there is sufficient charge to use.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite), DataField("canUse"), AutoNetworkedField]
+    [DataField, AutoNetworkedField]
     public bool CanUse;
 
     #endregion
@@ -37,17 +37,20 @@ public sealed partial class PowerCellDrawComponent : Component
     public bool Enabled = true;
 
     /// <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.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite), DataField("drawRate")]
+    [DataField]
     public float DrawRate = 1f;
 
     /// <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.
     /// </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;
 
     /// <summary>