Artifact containers can safely store radioactive objects (version 2) (#19652)
* Artifact containers suppress the radioactive of artifacts inside them * Updated to reflect changes to RobustToolbox * Made necessary changes after updating RT * Removed test code * Made requested change * Updated due to changes to RobustToolbox * Renamed function * Updated to accommodate changes to RobustToolbox * Actually resolve merge conflict? * Removed unnecessary change * Made requested changes * retrigger checks * Retrigger checks --------- Co-authored-by: root <root@DESKTOP-HJPF29C>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using Content.Server.Radiation.Systems;
|
||||
|
||||
namespace Content.Server.Radiation.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Prevents entities from emitting or receiving radiation when placed inside this container.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Access(typeof(RadiationSystem))]
|
||||
public sealed partial class RadiationBlockingContainerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// How many rads per second does the blocker absorb?
|
||||
/// </summary>
|
||||
[DataField("resistance")]
|
||||
public float RadResistance = 1f;
|
||||
}
|
||||
@@ -5,10 +5,11 @@ using Content.Shared.Radiation.Components;
|
||||
using Content.Shared.Radiation.Systems;
|
||||
using Content.Shared.Stacks;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Server.Radiation.Systems;
|
||||
|
||||
@@ -16,6 +17,9 @@ namespace Content.Server.Radiation.Systems;
|
||||
public partial class RadiationSystem
|
||||
{
|
||||
[Dependency] private readonly SharedStackSystem _stack = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
private EntityQuery<RadiationBlockingContainerComponent> _radiationBlockingContainers;
|
||||
|
||||
private void UpdateGridcast()
|
||||
{
|
||||
@@ -33,6 +37,8 @@ public partial class RadiationSystem
|
||||
var gridQuery = GetEntityQuery<MapGridComponent>();
|
||||
var stackQuery = GetEntityQuery<StackComponent>();
|
||||
|
||||
_radiationBlockingContainers = GetEntityQuery<RadiationBlockingContainerComponent>();
|
||||
|
||||
// precalculate world positions for each source
|
||||
// so we won't need to calc this in cycle over and over again
|
||||
var sourcesData = new ValueList<(EntityUid, RadiationSourceComponent, TransformComponent, Vector2)>();
|
||||
@@ -71,6 +77,9 @@ public partial class RadiationSystem
|
||||
rads += ray.Rads;
|
||||
}
|
||||
|
||||
// Apply modifier if the destination entity is hidden within a radiation blocking container
|
||||
rads = GetAdjustedRadiationIntensity(dest.Owner, rads);
|
||||
|
||||
receiversTotalRads.Add((dest, rads));
|
||||
}
|
||||
|
||||
@@ -89,7 +98,7 @@ public partial class RadiationSystem
|
||||
|
||||
// also send an event with combination of total rad
|
||||
if (rads > 0)
|
||||
IrradiateEntity(receiver.Owner, rads,GridcastUpdateRate);
|
||||
IrradiateEntity(receiver.Owner, rads, GridcastUpdateRate);
|
||||
}
|
||||
|
||||
// raise broadcast event that radiation system has updated
|
||||
@@ -114,8 +123,13 @@ public partial class RadiationSystem
|
||||
// check if receiver is too far away
|
||||
if (dist > GridcastMaxDistance)
|
||||
return null;
|
||||
|
||||
// will it even reach destination considering distance penalty
|
||||
var rads = incomingRads - slope * dist;
|
||||
|
||||
// Apply rad modifier if the source is enclosed within a radiation blocking container
|
||||
rads = GetAdjustedRadiationIntensity(sourceUid, rads);
|
||||
|
||||
if (rads <= MinIntensity)
|
||||
return null;
|
||||
|
||||
@@ -218,4 +232,15 @@ public partial class RadiationSystem
|
||||
|
||||
return ray;
|
||||
}
|
||||
|
||||
private float GetAdjustedRadiationIntensity(EntityUid uid, float rads)
|
||||
{
|
||||
var radblockingComps = new List<RadiationBlockingContainerComponent>();
|
||||
if (_container.TryFindComponentsOnEntityContainerOrParent(uid, _radiationBlockingContainers, radblockingComps))
|
||||
{
|
||||
rads -= radblockingComps.Sum(x => x.RadResistance);
|
||||
}
|
||||
|
||||
return float.Max(rads, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,3 +414,15 @@
|
||||
layers:
|
||||
- state: box
|
||||
- state: syringe
|
||||
|
||||
- type: entity
|
||||
name: lead-lined box
|
||||
parent: BoxCardboard
|
||||
suffix: Debug
|
||||
id: BoxLeadLined
|
||||
description: This box stymies the transmission of harmful radiation.
|
||||
components:
|
||||
- type: Sprite
|
||||
state: box
|
||||
- type: RadiationBlockingContainer
|
||||
resistance: 2
|
||||
@@ -44,6 +44,8 @@
|
||||
- Artifact
|
||||
- type: Weldable
|
||||
- type: SuppressArtifactContainer
|
||||
- type: RadiationBlockingContainer
|
||||
resistance: 5
|
||||
- type: PlaceableSurface
|
||||
isPlaceable: false
|
||||
- type: Damageable
|
||||
|
||||
Reference in New Issue
Block a user