Skip to content

Commit

Permalink
add: РИТЭГ теперь периодически теряет свой запас радиации
Browse files Browse the repository at this point in the history
  • Loading branch information
ReeZer2 committed Jul 26, 2024
1 parent 5f3c429 commit 2b62671
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 1 deletion.
77 changes: 77 additions & 0 deletions Content.Server/SS220/RadiationDecrease/RadiationDecreaseSystem.cs
Original file line number Diff line number Diff line change
@@ -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<RadiationDecreaseComponent, ComponentInit>(OnCompInit);
}

private void OnCompInit(EntityUid uid, RadiationDecreaseComponent comp, ComponentInit args)
{
if (TryComp<RadiationSourceComponent>(uid, out var radSourceComponent) && radSourceComponent.Intensity != 0)
{
comp.Intensity = radSourceComponent.Intensity;
}
if (TryComp<PowerSupplierComponent>(uid, out var supplyComp) && supplyComp.MaxSupply != 0)
{
comp.Supply = supplyComp.MaxSupply;
}
}

public override void Update(float delta)
{
base.Update(delta);
var query = EntityQueryEnumerator<RadiationDecreaseComponent>();
while (query.MoveNext(out var uid, out var comp))
{
if (TryComp<RadiationSourceComponent>(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<PowerSupplierComponent>(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;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Content.Shared.SS220.RadiationDecrease;

/// <summary>
/// Decrease radiation per second in Damaged RTG
/// </summary>
[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

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b62671

Please sign in to comment.