* Xenoartifact: Fixed ambient radiation damage not triggering Fixed ambient radiation damage not triggering artifact. * Revert "Xenoartifact: Fixed ambient radiation damage not triggering" This reverts commit 30e5c7cdb49c15574b49ddd1a1f7b1768abd2614. * Fix radiation damage misattribution
81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using Content.Server.Radiation.Components;
|
|
using Content.Shared.Radiation.Components;
|
|
using Content.Shared.Radiation.Events;
|
|
using Content.Shared.Stacks;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.Server.Radiation.Systems;
|
|
|
|
public sealed partial class RadiationSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
|
[Dependency] private readonly SharedStackSystem _stack = default!;
|
|
[Dependency] private readonly SharedMapSystem _maps = default!;
|
|
|
|
private EntityQuery<RadiationBlockingContainerComponent> _blockerQuery;
|
|
private EntityQuery<RadiationGridResistanceComponent> _resistanceQuery;
|
|
private EntityQuery<MapGridComponent> _gridQuery;
|
|
private EntityQuery<StackComponent> _stackQuery;
|
|
|
|
private float _accumulator;
|
|
private List<SourceData> _sources = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeCvars();
|
|
InitRadBlocking();
|
|
|
|
_blockerQuery = GetEntityQuery<RadiationBlockingContainerComponent>();
|
|
_resistanceQuery = GetEntityQuery<RadiationGridResistanceComponent>();
|
|
_gridQuery = GetEntityQuery<MapGridComponent>();
|
|
_stackQuery = GetEntityQuery<StackComponent>();
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
_accumulator += frameTime;
|
|
if (_accumulator < GridcastUpdateRate)
|
|
return;
|
|
|
|
UpdateGridcast();
|
|
UpdateResistanceDebugOverlay();
|
|
_accumulator = 0f;
|
|
}
|
|
|
|
public void IrradiateEntity(EntityUid uid, float radsPerSecond, float time, EntityUid? origin = null)
|
|
{
|
|
var msg = new OnIrradiatedEvent(time, radsPerSecond, origin);
|
|
RaiseLocalEvent(uid, msg);
|
|
}
|
|
|
|
public void SetSourceEnabled(Entity<RadiationSourceComponent?> entity, bool val)
|
|
{
|
|
if (!Resolve(entity, ref entity.Comp, false))
|
|
return;
|
|
|
|
entity.Comp.Enabled = val;
|
|
}
|
|
|
|
/// <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);
|
|
}
|
|
}
|
|
}
|