From fbc3104836229a8300f5c10e674c5a0e9e63c5bc Mon Sep 17 00:00:00 2001 From: Vanessa <908648+ShepardToTheStars@users.noreply.github.com> Date: Wed, 24 Jun 2026 08:15:01 -0500 Subject: [PATCH] Fix Infinite Cloaking (#6085) Fix infinite cloaking because I guess power draw doesn't count as using the battery charge. --- .../EntitySystems/SharedBatterySystem.cs | 13 +++++++++ .../Components/PowerCellDrawComponent.cs | 6 ++++ .../PowerCell/PowerCellSystem.Draw.cs | 10 +++++-- .../Specific/Xenoborg/cloaking_device.yml | 2 ++ .../Specific/Robotics/borg_modules.yml | 28 +++++++++++++++++-- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Power/EntitySystems/SharedBatterySystem.cs b/Content.Shared/Power/EntitySystems/SharedBatterySystem.cs index e150fd60d88..0928fca6cad 100644 --- a/Content.Shared/Power/EntitySystems/SharedBatterySystem.cs +++ b/Content.Shared/Power/EntitySystems/SharedBatterySystem.cs @@ -120,10 +120,23 @@ public abstract partial class SharedBatterySystem : EntitySystem var rechargerQuery = EntityQueryEnumerator(); while (rechargerQuery.MoveNext(out var uid, out var recharger, out var battery)) { + + // BEGIN DeltaV - Battery Drain + // Currently, NextAutoRecharge is only set when there's an explicit power draw from + // the battery, and it doesn't count a negative charge rate as battery charge being used + // so, this is to patch that in the case that the drain exceeds the recharge. + if (recharger.AutoRechargePauseTime > TimeSpan.Zero && battery.ChargeRate < 0) + { + TrySetChargeCooldown((uid, recharger)); + continue; + } + // END DeltaV + if (recharger.NextAutoRecharge == null || curTime < recharger.NextAutoRecharge) continue; recharger.NextAutoRecharge = null; // Don't refresh every tick. + Dirty(uid, recharger); RefreshChargeRate((uid, battery)); // Cooldown is over, apply the new recharge rate. } diff --git a/Content.Shared/PowerCell/Components/PowerCellDrawComponent.cs b/Content.Shared/PowerCell/Components/PowerCellDrawComponent.cs index d09c3ed798f..0ba73a46d15 100644 --- a/Content.Shared/PowerCell/Components/PowerCellDrawComponent.cs +++ b/Content.Shared/PowerCell/Components/PowerCellDrawComponent.cs @@ -32,4 +32,10 @@ public sealed partial class PowerCellDrawComponent : Component /// [DataField, AutoNetworkedField] public float UseCharge; + + /// + /// DeltaV - If the battery's recharge should be paused while power draw is active. + /// + [DataField, AutoNetworkedField] + public bool PauseRecharging; } diff --git a/Content.Shared/PowerCell/PowerCellSystem.Draw.cs b/Content.Shared/PowerCell/PowerCellSystem.Draw.cs index 8790ec941c3..5c08ce51b27 100644 --- a/Content.Shared/PowerCell/PowerCellSystem.Draw.cs +++ b/Content.Shared/PowerCell/PowerCellSystem.Draw.cs @@ -17,8 +17,14 @@ public sealed partial class PowerCellSystem ent.Comp.Enabled = enabled; Dirty(ent, ent.Comp); - if (TryGetBatteryFromSlot(ent.Owner, out var battery)) - _battery.RefreshChargeRate(battery.Value.AsNullable()); + // BEGIN DeltaV - Allow PowerDraw to prevent recharge + if (TryGetBatteryFromSlot(ent.Owner, out var battery) && battery is { } existingBattery) + { + _battery.RefreshChargeRate(existingBattery.AsNullable()); + + if (ent.Comp.PauseRecharging) _battery.TrySetChargeCooldown(existingBattery.Owner); + } + // END DeltaV } diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoborg/cloaking_device.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoborg/cloaking_device.yml index 02036b64633..5aab5281bf4 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Xenoborg/cloaking_device.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoborg/cloaking_device.yml @@ -16,6 +16,7 @@ lastVisibility: 0.1 - type: PowerCellDraw drawRate: 3.6 # 100 seconds + pauseRecharging: true # DeltaV - Pause recharge while draining - type: ToggleCellDraw - type: PowerCellSlot cellSlotId: cell_slot @@ -44,3 +45,4 @@ lastVisibility: -1 - type: PowerCellDraw drawRate: 12 # 30 seconds + pauseRecharging: true # DeltaV - Pause recharge while draining diff --git a/Resources/Prototypes/_DV/Entities/Objects/Specific/Robotics/borg_modules.yml b/Resources/Prototypes/_DV/Entities/Objects/Specific/Robotics/borg_modules.yml index 0c251c934d2..ab4614e0c40 100644 --- a/Resources/Prototypes/_DV/Entities/Objects/Specific/Robotics/borg_modules.yml +++ b/Resources/Prototypes/_DV/Entities/Objects/Specific/Robotics/borg_modules.yml @@ -472,13 +472,37 @@ icon: { sprite: _DV/Interface/Actions/actions_borg.rsi, state: syndicate-infiltrator-module } - type: entity - parent: CloakingDevice + parent: [ BaseItem, BaseSyndicateContraband ] id: CloakingDeviceSyndicateBorg + name: syndicate cloaking device description: A device that allows the borg to become cloaked for a short amount of time. Will recharge after 30 seconds of non-use. components: - type: Sprite - sprite: Objects/Tools/access_breaker.rsi # Finally using this awesome icon + sprite: Objects/Tools/access_breaker.rsi # Finally using this awesome sprite state: icon + - type: ItemToggle + - type: ComponentToggler + parent: true + components: + - type: Stealth + minVisibility: 0.1 + lastVisibility: 0.1 + - type: PowerCellDraw + drawRate: 3.6 + pauseRecharging: true + - type: ToggleCellDraw + - type: PowerCellSlot + cellSlotId: cell_slot + - type: ContainerContainer + containers: + cell_slot: !type:ContainerSlot + - type: ItemSlots + slots: + cell_slot: + name: power-cell-slot-component-slot-name-default + startingItem: PowerCellSmallNuclear + disableEject: true + swap: false # Service Modules