Scale radiation intensity with stack size (#19869)
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Server.Radiation.Components;
|
|||||||
using Content.Server.Radiation.Events;
|
using Content.Server.Radiation.Events;
|
||||||
using Content.Shared.Radiation.Components;
|
using Content.Shared.Radiation.Components;
|
||||||
using Content.Shared.Radiation.Systems;
|
using Content.Shared.Radiation.Systems;
|
||||||
|
using Content.Shared.Stacks;
|
||||||
using Robust.Shared.Collections;
|
using Robust.Shared.Collections;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
@@ -14,6 +15,8 @@ namespace Content.Server.Radiation.Systems;
|
|||||||
// main algorithm that fire radiation rays to target
|
// main algorithm that fire radiation rays to target
|
||||||
public partial class RadiationSystem
|
public partial class RadiationSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedStackSystem _stack = default!;
|
||||||
|
|
||||||
private void UpdateGridcast()
|
private void UpdateGridcast()
|
||||||
{
|
{
|
||||||
// should we save debug information into rays?
|
// should we save debug information into rays?
|
||||||
@@ -23,19 +26,20 @@ public partial class RadiationSystem
|
|||||||
var stopwatch = new Stopwatch();
|
var stopwatch = new Stopwatch();
|
||||||
stopwatch.Start();
|
stopwatch.Start();
|
||||||
|
|
||||||
var sources = EntityQuery<RadiationSourceComponent, TransformComponent>();
|
var sources = EntityQueryEnumerator<RadiationSourceComponent, TransformComponent>();
|
||||||
var destinations = EntityQuery<RadiationReceiverComponent, TransformComponent>();
|
var destinations = EntityQuery<RadiationReceiverComponent, TransformComponent>();
|
||||||
var resistanceQuery = GetEntityQuery<RadiationGridResistanceComponent>();
|
var resistanceQuery = GetEntityQuery<RadiationGridResistanceComponent>();
|
||||||
var transformQuery = GetEntityQuery<TransformComponent>();
|
var transformQuery = GetEntityQuery<TransformComponent>();
|
||||||
var gridQuery = GetEntityQuery<MapGridComponent>();
|
var gridQuery = GetEntityQuery<MapGridComponent>();
|
||||||
|
var stackQuery = GetEntityQuery<StackComponent>();
|
||||||
|
|
||||||
// precalculate world positions for each source
|
// precalculate world positions for each source
|
||||||
// so we won't need to calc this in cycle over and over again
|
// so we won't need to calc this in cycle over and over again
|
||||||
var sourcesData = new ValueList<(RadiationSourceComponent, TransformComponent, Vector2)>();
|
var sourcesData = new ValueList<(EntityUid, RadiationSourceComponent, TransformComponent, Vector2)>();
|
||||||
foreach (var (source, sourceTrs) in sources)
|
while (sources.MoveNext(out var uid, out var source, out var sourceTrs))
|
||||||
{
|
{
|
||||||
var worldPos = _transform.GetWorldPosition(sourceTrs, transformQuery);
|
var worldPos = _transform.GetWorldPosition(sourceTrs, transformQuery);
|
||||||
var data = (source, sourceTrs, worldPos);
|
var data = (uid, source, sourceTrs, worldPos);
|
||||||
sourcesData.Add(data);
|
sourcesData.Add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,12 +51,15 @@ public partial class RadiationSystem
|
|||||||
var destWorld = _transform.GetWorldPosition(destTrs, transformQuery);
|
var destWorld = _transform.GetWorldPosition(destTrs, transformQuery);
|
||||||
|
|
||||||
var rads = 0f;
|
var rads = 0f;
|
||||||
foreach (var (source, sourceTrs, sourceWorld) in sourcesData)
|
foreach (var (uid, source, sourceTrs, sourceWorld) in sourcesData)
|
||||||
{
|
{
|
||||||
|
stackQuery.TryGetComponent(uid, out var stack);
|
||||||
|
var intensity = source.Intensity * _stack.GetCount(uid, stack);
|
||||||
|
|
||||||
// send ray towards destination entity
|
// send ray towards destination entity
|
||||||
var ray = Irradiate(sourceTrs.Owner, sourceTrs, sourceWorld,
|
var ray = Irradiate(uid, sourceTrs, sourceWorld,
|
||||||
destTrs.Owner, destTrs, destWorld,
|
destTrs.Owner, destTrs, destWorld,
|
||||||
source.Intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
|
intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
|
||||||
if (ray == null)
|
if (ray == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -415,7 +415,7 @@
|
|||||||
- bananium
|
- bananium
|
||||||
- bananium_1
|
- bananium_1
|
||||||
- type: RadiationSource
|
- type: RadiationSource
|
||||||
intensity: 0.3
|
intensity: 0.1
|
||||||
- type: FlavorProfile
|
- type: FlavorProfile
|
||||||
flavors:
|
flavors:
|
||||||
- banana
|
- banana
|
||||||
|
|||||||
Reference in New Issue
Block a user