Optimise high pressure movements slightly (#6287)
This commit is contained in:
@@ -110,18 +110,4 @@ namespace Content.Server.Atmos.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MovedByPressureExtensions
|
|
||||||
{
|
|
||||||
public static bool IsMovedByPressure(this EntityUid entity)
|
|
||||||
{
|
|
||||||
return entity.IsMovedByPressure(out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsMovedByPressure(this EntityUid entity, [NotNullWhen(true)] out MovedByPressureComponent? moved)
|
|
||||||
{
|
|
||||||
return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out moved) &&
|
|
||||||
moved.Enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ using Content.Server.Atmos.Components;
|
|||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Containers;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -22,7 +19,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string? SpaceWindSound { get; private set; } = "/Audio/Effects/space_wind.ogg";
|
public string? SpaceWindSound { get; private set; } = "/Audio/Effects/space_wind.ogg";
|
||||||
|
|
||||||
private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile)
|
private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, EntityQuery<PhysicsComponent> bodies, EntityQuery<TransformComponent> xforms, EntityQuery<MovedByPressureComponent> pressureQuery)
|
||||||
{
|
{
|
||||||
// TODO ATMOS finish this
|
// TODO ATMOS finish this
|
||||||
|
|
||||||
@@ -39,9 +36,10 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
foreach (var entity in _lookup.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices))
|
foreach (var entity in _lookup.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices))
|
||||||
{
|
{
|
||||||
if (!HasComp<IPhysBody>(entity)
|
// Ideally containers would have their own EntityQuery internally or something given recursively it may need to slam GetComp<T> anyway.
|
||||||
|| !entity.IsMovedByPressure(out var pressure)
|
if (!bodies.HasComponent(entity)
|
||||||
|| entity.IsInContainer())
|
|| !pressureQuery.TryGetComponent(entity, out var pressure) || !pressure.Enabled
|
||||||
|
|| _containers.IsEntityInContainer(entity, xforms.GetComponent(entity)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var pressureMovements = EnsureComp<MovedByPressureComponent>(entity);
|
var pressureMovements = EnsureComp<MovedByPressureComponent>(entity);
|
||||||
|
|||||||
@@ -220,9 +220,13 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.HighPressureDelta);
|
atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.HighPressureDelta);
|
||||||
|
|
||||||
var number = 0;
|
var number = 0;
|
||||||
|
var bodies = EntityManager.GetEntityQuery<PhysicsComponent>();
|
||||||
|
var xforms = EntityManager.GetEntityQuery<TransformComponent>();
|
||||||
|
var pressureQuery = EntityManager.GetEntityQuery<MovedByPressureComponent>();
|
||||||
|
|
||||||
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
|
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
|
||||||
{
|
{
|
||||||
HighPressureMovements(atmosphere, tile);
|
HighPressureMovements(atmosphere, tile, bodies, xforms, pressureQuery);
|
||||||
tile.PressureDifference = 0f;
|
tile.PressureDifference = 0f;
|
||||||
tile.PressureSpecificTarget = null;
|
tile.PressureSpecificTarget = null;
|
||||||
atmosphere.HighPressureDelta.Remove(tile);
|
atmosphere.HighPressureDelta.Remove(tile);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Content.Shared.Atmos.EntitySystems;
|
|||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
@@ -24,6 +25,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly AdminLogSystem _adminLog = default!;
|
[Dependency] private readonly AdminLogSystem _adminLog = default!;
|
||||||
|
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
||||||
|
|
||||||
private const float ExposedUpdateDelay = 1f;
|
private const float ExposedUpdateDelay = 1f;
|
||||||
private float _exposedTimer = 0f;
|
private float _exposedTimer = 0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user