Downstream fixes for battery unification

This commit is contained in:
BarryNorfolk 2026-01-02 14:03:49 +01:00
parent 17ff77b61f
commit 349337e1d5
20 changed files with 52 additions and 65 deletions

View File

@ -7,7 +7,7 @@ using Content.Shared.Body.Systems;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Power.Components; // ough BatteryComponent why are you in server
using Content.Shared.Power.Components;
using Content.Shared.PowerCell.Components;
using Content.Shared.Power.EntitySystems;
@ -16,7 +16,7 @@ namespace Content.Server._DV.Augments;
public sealed class AugmentPowerCellSystem : EntitySystem
{
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly PredictedBatterySystem _battery = default!;
[Dependency] private readonly SharedBatterySystem _battery = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly SharedBodySystem _body = default!;
@ -41,7 +41,7 @@ public sealed class AugmentPowerCellSystem : EntitySystem
}
}
public (Entity<AugmentPowerCellSlotComponent, OrganComponent, PowerCellSlotComponent> Organ, Entity<PredictedBatteryComponent>? Battery)? TryGetAugmentPowerCell(EntityUid body)
public (Entity<AugmentPowerCellSlotComponent, OrganComponent, PowerCellSlotComponent> Organ, Entity<BatteryComponent>? Battery)? TryGetAugmentPowerCell(EntityUid body)
{
foreach (var organ in _body.GetBodyOrganEntityComps<AugmentPowerCellSlotComponent>(body))
{
@ -59,7 +59,7 @@ public sealed class AugmentPowerCellSystem : EntitySystem
return null;
}
public (Entity<AugmentPowerCellSlotComponent, OrganComponent, PowerCellSlotComponent> Organ, Entity<PredictedBatteryComponent>? Battery)? TryGetAugmentPowerCellFromAugment(EntityUid augment)
public (Entity<AugmentPowerCellSlotComponent, OrganComponent, PowerCellSlotComponent> Organ, Entity<BatteryComponent>? Battery)? TryGetAugmentPowerCellFromAugment(EntityUid augment)
{
if (!TryComp<OrganComponent>(augment, out var organ) || organ.Body is not {} uid)
return null;

View File

@ -23,7 +23,7 @@ public sealed class BatteryDrinkerSystem : EntitySystem
{
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly PredictedBatterySystem _battery = default!;
[Dependency] private readonly SharedBatterySystem _battery = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!; // DeltaV - people with augment power cells can drink batteries
@ -97,17 +97,18 @@ public sealed class BatteryDrinkerSystem : EntitySystem
var sourceBattery = Comp<BatteryComponent>(source);
// Begin DeltaV - people with augment power cells can drink batteries
if (!_powerCell.TryGetBatteryFromEntityOrSlot(drinker, out var battery))
if (!_powerCell.TryGetBatteryFromEntityOrSlot(drinker, out var augmentBattery))
return;
TryComp<BatteryDrinkerSourceComponent>(source, out var sourceComp);
var currentCharge = _battery.GetCharge(battery.Value.Owner);
var augmentCharge = _battery.GetCharge(augmentBattery.Value.Owner);
// End DeltaV - people with augment power cells can drink batteries
var sourceCharge = _battery.GetCharge((source, sourceBattery));
var amountToDrink = drinkerComp.DrinkMultiplier * 1000;
amountToDrink = MathF.Min(amountToDrink, sourceBattery.CurrentCharge);
amountToDrink = MathF.Min(amountToDrink, battery.Value.Comp!.MaxCharge - currentCharge); // DeltaV - people with augment power cells can drink batteries
amountToDrink = MathF.Min(amountToDrink, sourceCharge);
amountToDrink = MathF.Min(amountToDrink, augmentBattery.Value.Comp!.MaxCharge - augmentCharge); // DeltaV - people with augment power cells can drink batteries
if (sourceComp != null && sourceComp.MaxAmount > 0)
amountToDrink = MathF.Min(amountToDrink, (float) sourceComp.MaxAmount);
@ -119,10 +120,10 @@ public sealed class BatteryDrinkerSystem : EntitySystem
}
if (_battery.TryUseCharge(source, amountToDrink))
_battery.SetCharge(battery.Value.AsNullable(), currentCharge + amountToDrink); // DeltaV - people with augment power cells can drink batteries
_battery.SetCharge(augmentBattery.Value.AsNullable(), augmentCharge + amountToDrink); // DeltaV - people with augment power cells can drink batteries
else
{
_battery.SetCharge(battery.Value.AsNullable(), sourceBattery.CurrentCharge + currentCharge); // DeltaV - people with augment power cells can drink batteries
_battery.SetCharge(augmentBattery.Value.AsNullable(), sourceCharge + augmentCharge); // DeltaV - people with augment power cells can drink batteries
_battery.SetCharge(source, 0);
}

View File

@ -35,7 +35,7 @@ public sealed class BatteryElectrocuteChargeSystem : EntitySystem
battery.MaxCharge * 0.25f)
* _random.NextFloat(0.75f, 1.25f);
_battery.SetCharge(uid, battery.CurrentCharge + charge);
_battery.SetCharge(uid, _battery.GetCharge((uid, battery)) + charge);
_popup.PopupEntity(Loc.GetString("battery-electrocute-charge"), uid, uid);
}

View File

@ -37,7 +37,7 @@ public sealed class SiliconChargeSystem : EntitySystem
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly SharedJetpackSystem _jetpack = default!; // TheDen - IPC Dynamic Power draw
[Dependency] private readonly PredictedBatterySystem _battery = default!;
[Dependency] private readonly SharedBatterySystem _battery = default!;
public override void Initialize()
{
base.Initialize();
@ -45,7 +45,7 @@ public sealed class SiliconChargeSystem : EntitySystem
SubscribeLocalEvent<SiliconComponent, ComponentStartup>(OnSiliconStartup);
}
public bool TryGetSiliconBattery(EntityUid silicon, [NotNullWhen(true)] out Entity<PredictedBatteryComponent>? batteryComp)
public bool TryGetSiliconBattery(EntityUid silicon, [NotNullWhen(true)] out Entity<BatteryComponent>? batteryComp)
{
batteryComp = null;
if (!HasComp<SiliconComponent>(silicon))
@ -53,7 +53,7 @@ public sealed class SiliconChargeSystem : EntitySystem
// try get a battery directly on the inserted entity
if (TryComp<PredictedBatteryComponent>(silicon, out var comp))
if (TryComp<BatteryComponent>(silicon, out var comp))
{
batteryComp = (silicon, comp);
return true;

View File

@ -28,7 +28,7 @@ public sealed class DeadStartupButtonSystem : SharedDeadStartupButtonSystem
[Dependency] private readonly LightningSystem _lightning = default!;
[Dependency] private readonly SiliconChargeSystem _siliconChargeSystem = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly PredictedBatterySystem _battery = default!;
[Dependency] private readonly SharedBatterySystem _battery = default!;
/// <inheritdoc/>
public override void Initialize()

View File

@ -37,7 +37,7 @@ public sealed class SiliconDeathSystem : EntitySystem
SiliconUnDead(uid, siliconDeadComp, batteryComp, uid);
}
private void SiliconDead(EntityUid uid, SiliconDownOnDeadComponent siliconDeadComp, PredictedBatteryComponent? batteryComp, EntityUid batteryUid)
private void SiliconDead(EntityUid uid, SiliconDownOnDeadComponent siliconDeadComp, BatteryComponent? batteryComp, EntityUid batteryUid)
{
var deadEvent = new SiliconChargeDyingEvent(uid, batteryComp, batteryUid);
RaiseLocalEvent(uid, deadEvent);
@ -59,7 +59,7 @@ public sealed class SiliconDeathSystem : EntitySystem
RaiseLocalEvent(uid, new SiliconChargeDeathEvent(uid, batteryComp, batteryUid));
}
private void SiliconUnDead(EntityUid uid, SiliconDownOnDeadComponent siliconDeadComp, PredictedBatteryComponent? batteryComp, EntityUid batteryUid)
private void SiliconUnDead(EntityUid uid, SiliconDownOnDeadComponent siliconDeadComp, BatteryComponent? batteryComp, EntityUid batteryUid)
{
RemComp<ForcedSleepingStatusEffectComponent>(uid);
_sleep.TryWaking(uid, true, null);
@ -80,10 +80,10 @@ public sealed class SiliconDeathSystem : EntitySystem
public sealed class SiliconChargeDyingEvent : CancellableEntityEventArgs
{
public EntityUid SiliconUid { get; }
public PredictedBatteryComponent? BatteryComp { get; }
public BatteryComponent? BatteryComp { get; }
public EntityUid BatteryUid { get; }
public SiliconChargeDyingEvent(EntityUid siliconUid, PredictedBatteryComponent? batteryComp, EntityUid batteryUid)
public SiliconChargeDyingEvent(EntityUid siliconUid, BatteryComponent? batteryComp, EntityUid batteryUid)
{
SiliconUid = siliconUid;
BatteryComp = batteryComp;
@ -97,10 +97,10 @@ public sealed class SiliconChargeDyingEvent : CancellableEntityEventArgs
public sealed class SiliconChargeDeathEvent : EntityEventArgs
{
public EntityUid SiliconUid { get; }
public PredictedBatteryComponent? BatteryComp { get; }
public BatteryComponent? BatteryComp { get; }
public EntityUid BatteryUid { get; }
public SiliconChargeDeathEvent(EntityUid siliconUid, PredictedBatteryComponent? batteryComp, EntityUid batteryUid)
public SiliconChargeDeathEvent(EntityUid siliconUid, BatteryComponent? batteryComp, EntityUid batteryUid)
{
SiliconUid = siliconUid;
BatteryComp = batteryComp;
@ -114,10 +114,10 @@ public sealed class SiliconChargeDeathEvent : EntityEventArgs
public sealed class SiliconChargeAliveEvent : EntityEventArgs
{
public EntityUid SiliconUid { get; }
public PredictedBatteryComponent? BatteryComp { get; }
public BatteryComponent? BatteryComp { get; }
public EntityUid BatteryUid { get; }
public SiliconChargeAliveEvent(EntityUid siliconUid, PredictedBatteryComponent? batteryComp, EntityUid batteryUid)
public SiliconChargeAliveEvent(EntityUid siliconUid, BatteryComponent? batteryComp, EntityUid batteryUid)
{
SiliconUid = siliconUid;
BatteryComp = batteryComp;

View File

@ -259,7 +259,7 @@ public struct SearchForBatteryEvent
{
public EntityUid? Uid;
public PredictedBatteryComponent? Component;
public BatteryComponent? Component;
public bool Handled;
}

View File

@ -941,7 +941,6 @@
maxCharge: 720 # Delta V - Was 480
startingCharge: 720
- type: BatterySelfRecharger #Delta V - Self recharging not removed
autoRecharge: true
autoRechargeRate: 72 # Delta V - Was 10
autoRechargePauseTime: 30

View File

@ -120,9 +120,9 @@
- type: BatteryAmmoProvider
proto: CartridgeLightRifle
fireCost: 100
- type: PredictedBattery
- type: Battery
maxCharge: 10000
startingCharge: 10000
- type: PredictedBatterySelfRecharger
- type: BatterySelfRecharger
autoRechargeRate: 25
- type: AmmoCounter

View File

@ -136,10 +136,10 @@
- type: BatteryAmmoProvider
proto: BulletPistol
fireCost: 100
- type: PredictedBattery
- type: Battery
maxCharge: 1000
startingCharge: 1000
- type: PredictedBatterySelfRecharger
- type: BatterySelfRecharger
autoRechargeRate: 25
- type: AmmoCounter

View File

@ -156,10 +156,10 @@
- type: BatteryAmmoProvider
proto: CartridgePistol
fireCost: 100
- type: PredictedBattery
- type: Battery
maxCharge: 3000
startingCharge: 3000
- type: PredictedBatterySelfRecharger
- type: BatterySelfRecharger
autoRechargeRate: 25
- type: AmmoCounter

View File

@ -77,11 +77,10 @@
# minValue: 0.1 # These don't exist in the component
# maxValue: 2.0
isLooped: true
- type: PredictedBattery
- type: Battery
maxCharge: 100
startingCharge: 100
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 5
# COSMIC CULT HARDSUIT HELMET

View File

@ -143,11 +143,10 @@
fireCost: 1
# TODO: implement upstream or make it use a proper thing, maybe copy dragon
#examinable: false
- type: PredictedBattery
- type: Battery
maxCharge: 1000
startingCharge: 1000
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 100
# AI
- type: HTN

View File

@ -10,7 +10,7 @@
- type: BatteryAmmoProvider
proto: GamblagatorLaser
fireCost: 1000
- type: PredictedBattery
- type: Battery
maxCharge: 2000 # Shenanigan Prevention
startingCharge: 2000
- type: Item

View File

@ -5,7 +5,6 @@
categories: [ HideSpawnMenu ]
components:
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 12
- type: GuideHelp
guides:

View File

@ -26,7 +26,7 @@
path: /Audio/_DV/Weapons/Guns/Gunshots/laser.ogg
soundEmpty:
path: /Audio/_DV/Weapons/Guns/Empty/dry_fire.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 1500
startingCharge: 1500
- type: BatteryAmmoProvider
@ -79,7 +79,7 @@
path: /Audio/_DV/Weapons/Guns/Gunshots/laser.ogg
soundEmpty:
path: /Audio/_DV/Weapons/Guns/Empty/dry_fire.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 1000
startingCharge: 1000
- type: BatteryAmmoProvider
@ -145,7 +145,7 @@
path: /Audio/_DV/Weapons/Guns/Gunshots/laser.ogg
soundEmpty:
path: /Audio/_DV/Weapons/Guns/Empty/dry_fire.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 500
startingCharge: 500
- type: BatteryAmmoProvider
@ -198,7 +198,7 @@
path: /Audio/_DV/Weapons/Guns/Gunshots/laser.ogg
soundEmpty:
path: /Audio/_DV/Weapons/Guns/Empty/dry_fire.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 900
startingCharge: 900
- type: BatteryAmmoProvider
@ -258,7 +258,7 @@
availableModes:
- SemiAuto
- FullAuto
- type: PredictedBattery
- type: Battery
maxCharge: 3000
startingCharge: 3000
- type: BatteryAmmoProvider
@ -316,7 +316,7 @@
selectedMode: FullAuto
fireRate: 15
availableModes: FullAuto
- type: PredictedBattery
- type: Battery
maxCharge: 3000
startingCharge: 3000
- type: BatteryAmmoProvider
@ -355,7 +355,7 @@
- type: BatteryAmmoProvider
proto: BeamDev
fireCost: 1200
- type: PredictedBattery
- type: Battery
maxCharge: 300000
startingCharge: 300000
- type: Tag
@ -392,11 +392,10 @@
fireCost: 100
- proto: BulletDisabler
fireCost: 50
- type: PredictedBattery
- type: Battery
maxCharge: 1000
startingCharge: 1000
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 30
- type: entity
@ -424,7 +423,7 @@
- type: BatteryAmmoProvider
proto: BulletEnergyGunMediumImmolator
fireCost: 100
- type: PredictedBattery
- type: Battery
maxCharge: 800
startingCharge: 800
- type: GunRequiresWield
@ -460,7 +459,7 @@
fireCost: 100
- proto: BulletEnergyGunLightImmolatorSpread
fireCost: 100
- type: PredictedBattery
- type: Battery
maxCharge: 800
startingCharge: 800
- type: GunRequiresWield
@ -471,7 +470,6 @@
description: A self-defense weapon that exhausts organic targets, weakening them until they collapse. This one recharges
components:
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 50
- type: entity
@ -539,11 +537,10 @@
- type: BatteryAmmoProvider
proto: BulletBuccaneer
fireCost: 100
- type: PredictedBattery
- type: Battery
maxCharge: 400
startingCharge: 400
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 25
- type: entity

View File

@ -19,14 +19,13 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 600
startingCharge: 300
- type: BatteryAmmoProvider
proto: GrenadeFrag
fireCost: 300
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 2
- type: entity
@ -53,14 +52,13 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 600
startingCharge: 200
- type: BatteryAmmoProvider
proto: GrenadeFlash
fireCost: 200
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 6
- type: GunWieldBonus
wieldBonusExamineMessage: null
@ -96,14 +94,13 @@
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg
- type: AmmoCounter
- type: PredictedBattery
- type: Battery
maxCharge: 600
startingCharge: 200
- type: BatteryAmmoProvider
proto: GrenadeCleanade
fireCost: 100
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 10
- type: GunWieldBonus
wieldBonusExamineMessage: null
@ -128,14 +125,13 @@
fireRate: 1
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/mateba.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 750
startingCharge: 750
- type: BatteryAmmoProvider
proto: CannonBall
fireCost: 750
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 25
- type: AmmoCounter
- type: BatteryWeaponFireModes

View File

@ -86,7 +86,7 @@
path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg
soundEmpty:
path: /Audio/Weapons/Guns/Empty/empty.ogg
- type: PredictedBattery
- type: Battery
maxCharge: 400
startingCharge: 200
- type: BatteryAmmoProvider
@ -94,7 +94,6 @@
fireCost: 100
- type: AmmoCounter
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 20
- type: entity

View File

@ -54,5 +54,4 @@
- type: StaticPrice
price: 1750
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 30 # DeltaV - double to compensate for increased cost, was 15

View File

@ -50,9 +50,8 @@
proto: RedLightLaser
fireCost: 50
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 25
- type: PredictedBattery
- type: Battery
maxCharge: 100
startingCharge: 0
- type: Gun