Fix instant power cell drainage (#15927)
This commit is contained in:
@@ -5,11 +5,11 @@ namespace Content.Server.PowerCell;
|
||||
/// <summary>
|
||||
/// Indicates that the entity's ActivatableUI requires power or else it closes.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, Access(typeof(PowerCellSystem))]
|
||||
public sealed class PowerCellDrawComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("enabled")]
|
||||
public bool Enabled = false;
|
||||
public bool Enabled;
|
||||
|
||||
/// <summary>
|
||||
/// How much the entity draws while the UI is open.
|
||||
@@ -23,7 +23,7 @@ public sealed class PowerCellDrawComponent : Component
|
||||
/// This is used to ensure the UI won't open again without a minimum use power.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("useRate")]
|
||||
public float UseRate = 0f;
|
||||
public float UseRate;
|
||||
|
||||
/// <summary>
|
||||
/// When the next automatic power draw will occur
|
||||
|
||||
@@ -194,6 +194,15 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetPowerCellDrawEnabled(EntityUid uid, bool enabled, PowerCellDrawComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
|
||||
component.Enabled = enabled;
|
||||
component.NextUpdateTime = _timing.CurTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the entity has a slotted battery and charge for the requested action.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user