using Content.Shared.Anomaly.Effects.Components;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
+using Robust.Shared.Physics.Components;
using Robust.Shared.Random;
namespace Content.Server.Anomaly.Effects;
[Dependency] private readonly SharedAnomalySystem _anomaly = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
+
+ private EntityQuery<PhysicsComponent> _physicsQuery;
/// <inheritdoc/>
public override void Initialize()
{
+ _physicsQuery = GetEntityQuery<PhysicsComponent>();
+
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse);
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyStabilityChangedEvent>(OnStabilityChanged);
private void SpawnEntities(Entity<EntitySpawnAnomalyComponent> anomaly, EntitySpawnSettingsEntry entry, float stability, float severity)
{
var xform = Transform(anomaly);
- if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
+ if (!TryComp(xform.GridUid, out MapGridComponent? grid))
return;
var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings);
foreach (var tileref in tiles)
{
- Spawn(_random.Pick(entry.Spawns), tileref.GridIndices.ToEntityCoordinates(xform.GridUid.Value, _map));
+ Spawn(_random.Pick(entry.Spawns), _mapSystem.ToCenterCoordinates(tileref, grid));
}
}
}
{
if(_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound))
{
- var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager);
+ var coordinates = _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.GridIndices);
_audio.PlayPvs(SpaceWindSound, coordinates, AudioParams.Default.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100)));
}
}
gridAtmosphere.Comp.UpdateCounter,
tile.PressureDifference,
tile.PressureDirection, 0,
- tile.PressureSpecificTarget?.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager) ?? EntityCoordinates.Invalid,
+ tile.PressureSpecificTarget != null ? _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.PressureSpecificTarget.GridIndices) : EntityCoordinates.Invalid,
gridWorldRotation,
xforms.GetComponent(entity),
body);
{
public sealed partial class AtmosphereSystem
{
- [Dependency] private readonly EntityLookupSystem _lookup = default!;
-
private const int HotspotSoundCooldownCycles = 200;
private int _hotspotSoundCooldown = 0;
if (_hotspotSoundCooldown++ == 0 && !string.IsNullOrEmpty(HotspotSound))
{
- var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager);
+ var coordinates = _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.GridIndices);
+
// A few details on the audio parameters for fire.
// The greater the fire state, the lesser the pitch variation.
// The greater the fire state, the greater the volume.
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IAdminLogManager _adminLog = default!;
+ [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly InternalsSystem _internals = default!;
[Dependency] private readonly SharedContainerSystem _containers = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
- [Dependency] private readonly TransformSystem _transformSystem = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly TileSystem _tile = default!;
[Dependency] private readonly MapSystem _map = default!;
[Dependency] public readonly PuddleSystem Puddle = default!;
var physQuery = GetEntityQuery<PhysicsComponent>();
var resultList = new List<TileRef>();
- while (resultList.Count() < amount)
+ while (resultList.Count < amount)
{
- if (tilerefs.Count() == 0)
+ if (tilerefs.Count == 0)
break;
var tileref = _random.Pick(tilerefs);
continue;
}
}
+
resultList.Add(tileref);
}
return resultList;
}
var buildPos = _map.TileIndicesFor(grid, gridComp, xform.Coordinates);
- var intersecting = _entityLookup.GetEntitiesIntersecting(buildPos.ToEntityCoordinates(grid, _mapManager).Offset(new Vector2(0.5f, 0.5f))
- , LookupFlags.Dynamic | LookupFlags.Static);
+ var coords = _map.ToCenterCoordinates(grid, buildPos);
+
+ var intersecting = _entityLookup.GetEntitiesIntersecting(coords, LookupFlags.Dynamic | LookupFlags.Static);
// todo make this logic smarter.
// This should eventually allow for shit like building microwaves on tables and such.