diff --git a/Content.Server/SS220/RadiationDecrease/RadiationDecreaseSystem.cs b/Content.Server/SS220/RadiationDecrease/RadiationDecreaseSystem.cs new file mode 100644 index 00000000000000..bc63587976a343 --- /dev/null +++ b/Content.Server/SS220/RadiationDecrease/RadiationDecreaseSystem.cs @@ -0,0 +1,77 @@ +using Content.Server.Power.Components; +using Content.Shared.Radiation.Components; +using Content.Shared.SS220.RadiationDecrease; +using Robust.Shared.Timing; + +namespace Content.Server.SS220.RadiationDecrease; + +public sealed partial class RadiationDecreaseSystem : EntitySystem +{ + [Dependency] private readonly IGameTiming _gameTiming = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnCompInit); + } + + private void OnCompInit(EntityUid uid, RadiationDecreaseComponent comp, ComponentInit args) + { + if (TryComp(uid, out var radSourceComponent) && radSourceComponent.Intensity != 0) + { + comp.Intensity = radSourceComponent.Intensity; + } + if (TryComp(uid, out var supplyComp) && supplyComp.MaxSupply != 0) + { + comp.Supply = supplyComp.MaxSupply; + } + } + + public override void Update(float delta) + { + base.Update(delta); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var comp)) + { + if (TryComp(uid, out var radSourceComponent) && radSourceComponent.Intensity != 0) + { + var decreasePerSecond = comp.Intensity / comp.TotalAliveTime; + + var curTime = _gameTiming.CurTime; + + if (curTime - comp.LastTimeDecreaseRad < comp.CoolDown) + { + return; + } + + comp.LastTimeDecreaseRad = curTime; + if (radSourceComponent.Intensity - decreasePerSecond < 0) // without if - crash Pow3r + { + radSourceComponent.Intensity = 0; + decreasePerSecond = 0; + } + radSourceComponent.Intensity -= decreasePerSecond; + } + + if (TryComp(uid, out var powerSupply) && powerSupply.MaxSupply != 0) + { + var decreasePerSecond = comp.Supply / comp.TotalAliveTime; + + var curTime = _gameTiming.CurTime; + + if (curTime - comp.LastTimeDecreaseSupply < comp.CoolDown) + { + return; + } + + comp.LastTimeDecreaseSupply = curTime; + if (powerSupply.MaxSupply - decreasePerSecond < 0) // without if - crash Pow3r + { + powerSupply.MaxSupply = 0; + decreasePerSecond = 0; + } + powerSupply.MaxSupply -= decreasePerSecond; + } + } + } +} diff --git a/Content.Shared/SS220/RadiationDecrease/RadiationDecreaseComponent.cs b/Content.Shared/SS220/RadiationDecrease/RadiationDecreaseComponent.cs new file mode 100644 index 00000000000000..950893a3378f71 --- /dev/null +++ b/Content.Shared/SS220/RadiationDecrease/RadiationDecreaseComponent.cs @@ -0,0 +1,19 @@ +namespace Content.Shared.SS220.RadiationDecrease; + +/// +/// Decrease radiation per second in Damaged RTG +/// +[RegisterComponent] +public sealed partial class RadiationDecreaseComponent : Component +{ + public readonly int TotalAliveTime = 1200; // 20 minutes + + public readonly TimeSpan CoolDown = TimeSpan.FromSeconds(1f); + + public TimeSpan LastTimeDecreaseRad = TimeSpan.Zero; + public TimeSpan LastTimeDecreaseSupply = TimeSpan.Zero; + + public float Intensity = 0; // radiation capacity in RadiationSourceComponent + public float Supply = 0; // powersupp in PowerSupplierComponent + +} diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml index 861de57ba161dc..d9636b2a1731c5 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml @@ -125,7 +125,7 @@ Blunt: 0.9 Slash: 0.9 Piercing: 0.9 - Radiation: 0.3 #salv is supposed to have radiation hazards in the future + Radiation: 0.8 #salv is supposed to have radiation hazards in the future # ss220 rad fix 0.3 -> 0.8 (20%) Caustic: 0.8 Stamina: 0.8 - type: ClothingSpeedModifier diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml index 817e9120250bf3..343851ebef1764 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/generators.yml @@ -295,6 +295,7 @@ - type: PowerMonitoringDevice sprite: Structures/Power/Generation/rtg.rsi state: rtg_damaged + - type: RadiationDecrease #ss220 damage rtg fix - type: RadiationSource # ideally only when opened. intensity: 2 - type: Destructible