Files
OldThink/Content.Server/Radiation/Systems/RadiationSystem.cs

63 lines
1.5 KiB
C#
Raw Normal View History

2022-12-07 02:56:52 +01:00
using Content.Server.Radiation.Components;
using Content.Shared.Radiation.Events;
2022-10-11 05:09:10 +02:00
using Robust.Shared.Configuration;
using Robust.Shared.Map;
namespace Content.Server.Radiation.Systems;
2022-10-11 05:09:10 +02:00
public sealed partial class RadiationSystem : EntitySystem
{
2022-10-11 05:09:10 +02:00
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
2022-08-31 12:24:21 +02:00
private float _accumulator;
2022-10-11 05:09:10 +02:00
public override void Initialize()
2022-08-31 12:24:21 +02:00
{
2022-10-11 05:09:10 +02:00
base.Initialize();
SubscribeCvars();
InitRadBlocking();
}
2022-08-31 12:24:21 +02:00
2022-10-11 05:09:10 +02:00
public override void Shutdown()
{
base.Shutdown();
UnsubscribeCvars();
2022-08-31 12:24:21 +02:00
}
2022-10-11 05:09:10 +02:00
public override void Update(float frameTime)
{
2022-10-11 05:09:10 +02:00
base.Update(frameTime);
_accumulator += frameTime;
if (_accumulator < GridcastUpdateRate)
return;
UpdateGridcast();
UpdateResistanceDebugOverlay();
_accumulator = 0f;
}
public void IrradiateEntity(EntityUid uid, float radsPerSecond, float time)
{
var msg = new OnIrradiatedEvent(time, radsPerSecond);
2022-10-11 05:09:10 +02:00
RaiseLocalEvent(uid, msg);
}
2022-12-07 02:56:52 +01:00
/// <summary>
/// Marks entity to receive/ignore radiation rays.
/// </summary>
public void SetCanReceive(EntityUid uid, bool canReceive)
{
if (canReceive)
{
EnsureComp<RadiationReceiverComponent>(uid);
}
else
{
RemComp<RadiationReceiverComponent>(uid);
}
}
}