Фиксы энергии (#3604)

This commit is contained in:
iertis 2026-01-04 16:17:33 +05:00 committed by GitHub
parent d9f405de74
commit fdfcd9a394
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 43 additions and 16 deletions

View file

@ -217,7 +217,7 @@ public sealed partial class EnergyDomeSystem : EntitySystem
{
_battery.UseCharge(cell.Value.Owner, energyLeak);
if (cell.Value.Comp.LastCharge == 0)
if (cell.Value.Comp.State == BatteryState.Empty)
TurnOff((generatorUid, generatorComp), true);
}
}
@ -226,7 +226,7 @@ public sealed partial class EnergyDomeSystem : EntitySystem
if (TryComp<BatteryComponent>(generatorUid, out var battery)) {
_battery.UseCharge(generatorUid, energyLeak);
if (battery.LastCharge == 0)
if (battery.State == BatteryState.Empty)
TurnOff((generatorUid, generatorComp), true);
}
}
@ -278,7 +278,7 @@ public sealed partial class EnergyDomeSystem : EntitySystem
}
else if (TryComp<BatteryComponent>(generator, out var battery))
{
if (battery.LastCharge <= 0)
if (_battery.GetCharge((generator, battery)) <= 0)
{
Fail(generator, "energy-dome-no-power");
return false;

View file

@ -35,7 +35,7 @@ public sealed class MechGunSystem : EntitySystem
|| !TryComp<MechComponent>(mechEquipment.EquipmentOwner.Value, out var mech))
return;
var chargeDelta = component.MaxCharge - component.LastCharge;
var chargeDelta = component.MaxCharge - _battery.GetCharge((uid, component));
// TODO: The battery charge of the mech would be spent directly when fired.
if (chargeDelta <= 0
|| mech.Energy - chargeDelta < 0

View file

@ -1,4 +1,5 @@
using Content.Server.Ninja.Events;
using Content.Server.Power.EntitySystems;
using Content.Shared.Clothing;
using Content.Shared.Item.ItemToggle;
using Content.Shared.Ninja.Components;
@ -16,6 +17,7 @@ public sealed class NinjaSuitDrawSystem : SharedNinjaSuitDrawSystem
[Dependency] private readonly SpaceNinjaSystem _ninja = default!;
[Dependency] private readonly ItemToggleSystem _toggle = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly BatterySystem _battery = default!; // Sunrise
public override void Initialize()
{
@ -104,8 +106,8 @@ public sealed class NinjaSuitDrawSystem : SharedNinjaSuitDrawSystem
if (_ninja.GetNinjaBattery(user, out _, out var battery))
{
var canUse = ent.Comp.UseRate <= 0f || battery.LastCharge >= ent.Comp.UseRate;
var canDraw = ent.Comp.DrawRate <= 0f || battery.LastCharge > 0f;
var canUse = ent.Comp.UseRate <= 0f || _battery.GetCharge((user, battery)) >= ent.Comp.UseRate;
var canDraw = ent.Comp.DrawRate <= 0f || _battery.GetCharge((user, battery)) > 0f;
SetPowerStatus(ent, canDraw, canUse);
if (!canUse)
{
@ -138,7 +140,7 @@ public sealed class NinjaSuitDrawSystem : SharedNinjaSuitDrawSystem
if (!_ninja.IsNinja(user))
return false;
return _ninja.GetNinjaBattery(user, out _, out var battery) && battery.LastCharge > 0f;
return _ninja.GetNinjaBattery(user, out _, out var battery) && _battery.GetCharge((user, battery)) > 0f;
}
public override bool CanUse(Entity<NinjaSuitDrawComponent> ent)
@ -148,7 +150,7 @@ public sealed class NinjaSuitDrawSystem : SharedNinjaSuitDrawSystem
return false;
return _ninja.GetNinjaBattery(user, out _, out var battery) &&
(ent.Comp.UseRate <= 0f || battery.LastCharge >= ent.Comp.UseRate);
(ent.Comp.UseRate <= 0f || _battery.GetCharge((user, battery)) >= ent.Comp.UseRate);
}
}

View file

@ -8,6 +8,7 @@ using Content.Shared.Power.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Content.Shared.Damage.Systems;
using Content.Shared.PowerCell;
namespace Content.Server._Sunrise.EnergyShield;
@ -44,7 +45,7 @@ public sealed class EnergyShieldSystem : EntitySystem
_battery.UseCharge(ent.Owner, cost);
_audio.PlayPvs(ent.Comp.AbsorbSound, ent);
if (battery.LastCharge <= 0)
if (_battery.GetCharge((ent, battery)) <= 0)
{
_itemToggle.Toggle(ent.Owner);
_audio.PlayPvs(ent.Comp.ShutdownSound, ent);
@ -54,7 +55,7 @@ public sealed class EnergyShieldSystem : EntitySystem
private void OnToggleAttempt(Entity<EnergyShieldComponent> ent, ref ItemToggleActivateAttemptEvent args)
{
if (TryComp<BatteryComponent>(ent, out var battery) &&
battery.LastCharge >= battery.MaxCharge * ent.Comp.MinChargeFractionForActivation)
_battery.GetCharge((ent, battery)) >= battery.MaxCharge * ent.Comp.MinChargeFractionForActivation)
{
return;
}

View file

@ -55,7 +55,7 @@ public sealed class PowerDrainOnMeleeHitSystem : EntitySystem
// Fall back to direct BatteryComponent on the same entity
if (TryComp<BatteryComponent>(uid, out var directBattery))
{
if (directBattery.LastCharge < comp.ChargePerHit)
if (_battery.GetCharge((uid, directBattery)) < comp.ChargePerHit)
{
args.Handled = true;
return;

View file

@ -631,7 +631,7 @@
color: white
- type: ItemTogglePointLight
- type: Reflect
reflectProb: 1 # Sunrise-Edit
reflectProb: 1 # Sunrise-edit
reflects:
- Energy
- type: Blocking
@ -653,10 +653,36 @@
- type: Appearance
- type: Damageable
damageContainer: Shield
# - type: ExaminableDamage # Sunrise-edit
# messages: EnergyShieldMessages
# - type: Destructible # Sunrise-edit
# thresholds:
# - trigger:
# !type:DamageTrigger
# damage: 180
# behaviors:
# - !type:DoActsBehavior
# acts: [ "Destruction" ]
# - trigger:
# !type:DamageTrigger
# damage: 100
# behaviors:
# - !type:DoActsBehavior
# acts: [ "Destruction" ]
# - !type:PlaySoundBehavior
# sound:
# collection: GlassBreak
# - !type:SpawnEntitiesBehavior
# spawn:
# BrokenEnergyShield:
# min: 1
# max: 1
- type: StaticPrice
price: 7000
# Sunrise-Start
- type: BatterySelfRecharger
autoRechargeRate: 75
autoRechargePauseTime: 5
autoRechargeRate: 50
autoRechargePauseTime: 10
- type: EnergyShield
energyCostPerDamage: 15
- type: ExaminableBattery
@ -664,8 +690,6 @@
maxCharge: 1500
startingCharge: 1500
- type: EmpImmune
- type: StaticPrice
price: 7000
# Sunrise-End
- type: entity