mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
Fix Infinite Cloaking (#6085)
Fix infinite cloaking because I guess power draw doesn't count as using the battery charge.
This commit is contained in:
@@ -120,10 +120,23 @@ public abstract partial class SharedBatterySystem : EntitySystem
|
||||
var rechargerQuery = EntityQueryEnumerator<BatterySelfRechargerComponent, BatteryComponent>();
|
||||
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.
|
||||
}
|
||||
|
||||
@@ -32,4 +32,10 @@ public sealed partial class PowerCellDrawComponent : Component
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public float UseCharge;
|
||||
|
||||
/// <summary>
|
||||
/// DeltaV - If the battery's recharge should be paused while power draw is active.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool PauseRecharging;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user