using Content.Server.Radiation.Events;
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.Map.Components;
// main algorithm that fire radiation rays to target
public partial class RadiationSystem
{
+ [Dependency] private readonly SharedStackSystem _stack = default!;
+
private void UpdateGridcast()
{
// should we save debug information into rays?
var stopwatch = new Stopwatch();
stopwatch.Start();
- var sources = EntityQuery<RadiationSourceComponent, TransformComponent>();
+ var sources = EntityQueryEnumerator<RadiationSourceComponent, TransformComponent>();
var destinations = EntityQuery<RadiationReceiverComponent, TransformComponent>();
var resistanceQuery = GetEntityQuery<RadiationGridResistanceComponent>();
var transformQuery = GetEntityQuery<TransformComponent>();
var gridQuery = GetEntityQuery<MapGridComponent>();
+ var stackQuery = GetEntityQuery<StackComponent>();
// precalculate world positions for each source
// so we won't need to calc this in cycle over and over again
- var sourcesData = new ValueList<(RadiationSourceComponent, TransformComponent, Vector2)>();
- foreach (var (source, sourceTrs) in sources)
+ var sourcesData = new ValueList<(EntityUid, RadiationSourceComponent, TransformComponent, Vector2)>();
+ while (sources.MoveNext(out var uid, out var source, out var sourceTrs))
{
var worldPos = _transform.GetWorldPosition(sourceTrs, transformQuery);
- var data = (source, sourceTrs, worldPos);
+ var data = (uid, source, sourceTrs, worldPos);
sourcesData.Add(data);
}
var destWorld = _transform.GetWorldPosition(destTrs, transformQuery);
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
- var ray = Irradiate(sourceTrs.Owner, sourceTrs, sourceWorld,
+ var ray = Irradiate(uid, sourceTrs, sourceWorld,
destTrs.Owner, destTrs, destWorld,
- source.Intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
+ intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
if (ray == null)
continue;