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:
chromiumboy
2023-09-11 14:58:25 -05:00
committed by GitHub
parent 5ca34e5578
commit c853f0bfb7
4 changed files with 58 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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));
}
@@ -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);
}
}

View File

@@ -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

View File

@@ -44,6 +44,8 @@
- Artifact
- type: Weldable
- type: SuppressArtifactContainer
- type: RadiationBlockingContainer
resistance: 5
- type: PlaceableSurface
isPlaceable: false
- type: Damageable