diff --git a/Content.Client/Access/AccessOverlay.cs b/Content.Client/Access/AccessOverlay.cs index 74273d4102..1ba2dc613f 100644 --- a/Content.Client/Access/AccessOverlay.cs +++ b/Content.Client/Access/AccessOverlay.cs @@ -32,7 +32,7 @@ public sealed class AccessOverlay : Overlay var xformQuery = _entityManager.GetEntityQuery(); foreach (var ent in _lookup.GetEntitiesIntersecting(args.MapId, args.WorldAABB, - LookupFlags.Anchored | LookupFlags.Approximate)) + LookupFlags.Static | LookupFlags.Approximate)) { if (!readerQuery.TryGetComponent(ent, out var reader) || !xformQuery.TryGetComponent(ent, out var xform)) diff --git a/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs b/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs index 2bbbcd6ee9..065067eef0 100644 --- a/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs +++ b/Content.IntegrationTests/Tests/Chemistry/TryAllReactionsTest.cs @@ -34,28 +34,30 @@ namespace Content.IntegrationTests.Tests.Chemistry var prototypeManager = server.ResolveDependency(); var testMap = await PoolManager.CreateTestMap(pairTracker); var coordinates = testMap.GridCoords; + var solutionSystem = server.ResolveDependency() + .GetEntitySystem(); foreach (var reactionPrototype in prototypeManager.EnumeratePrototypes()) { //since i have no clue how to isolate each loop assert-wise im just gonna throw this one in for good measure Console.WriteLine($"Testing {reactionPrototype.ID}"); - EntityUid beaker; + EntityUid beaker = default; Solution component = null; await server.WaitAssertion(() => { beaker = entityManager.SpawnEntity("TestSolutionContainer", coordinates); - Assert.That(EntitySystem.Get() + Assert.That(solutionSystem .TryGetSolution(beaker, "beaker", out component)); foreach (var (id, reactant) in reactionPrototype.Reactants) { - Assert.That(EntitySystem.Get() + Assert.That(solutionSystem .TryAddReagent(beaker, component, id, reactant.Amount, out var quantity)); Assert.That(reactant.Amount, Is.EqualTo(quantity)); } - EntitySystem.Get().SetTemperature(beaker, component, reactionPrototype.MinimumTemperature); + solutionSystem.SetTemperature(beaker, component, reactionPrototype.MinimumTemperature); }); await server.WaitIdleAsync(); diff --git a/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs index ab231d5418..d670000edc 100644 --- a/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs @@ -145,9 +145,12 @@ namespace Content.Server.Chemistry.Components /// with the other area effects from the inception. public void React(float averageExposures) { - - if (!_entities.EntitySysManager.GetEntitySystem().TryGetSolution(Owner, SolutionName, out var solution)) + if (!_entities.EntitySysManager.GetEntitySystem() + .TryGetSolution(Owner, SolutionName, out var solution) || + solution.Contents.Count == 0) + { return; + } var xform = _entities.GetComponent(Owner); if (!MapManager.TryGetGrid(xform.GridUid, out var mapGrid)) @@ -158,6 +161,7 @@ namespace Content.Server.Chemistry.Components var lookup = _entities.EntitySysManager.GetEntitySystem(); var solutionFraction = 1 / Math.Floor(averageExposures); + var ents = lookup.GetEntitiesIntersecting(tile, LookupFlags.Uncontained).ToArray(); foreach (var reagentQuantity in solution.Contents.ToArray()) { @@ -173,14 +177,14 @@ namespace Content.Server.Chemistry.Components } // Touch every entity on the tile - foreach (var entity in lookup.GetEntitiesIntersecting(tile).ToArray()) + foreach (var entity in ents) { chemistry.ReactionEntity(entity, ReactionMethod.Touch, reagent, reagentQuantity.Quantity * solutionFraction, solution); } } - foreach (var entity in lookup.GetEntitiesIntersecting(tile).ToArray()) + foreach (var entity in ents) { ReactWithEntity(entity, solutionFraction); } diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs index 078633ed52..ec6305a1e2 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs @@ -6,6 +6,7 @@ using Content.Shared.Physics; using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; +using Robust.Shared.Physics.Dynamics; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -188,7 +189,7 @@ public sealed partial class ExplosionSystem : EntitySystem /// Find entities on a grid tile using the EntityLookupComponent and apply explosion effects. /// /// True if the underlying tile can be uprooted, false if the tile is blocked by a dense entity - internal bool ExplodeTile(EntityLookupComponent lookup, + internal bool ExplodeTile(BroadphaseComponent lookup, IMapGrid grid, Vector2i tile, float throwForce, @@ -209,7 +210,9 @@ public sealed partial class ExplosionSystem : EntitySystem var state = (list, processed, xformQuery); // get entities: - lookup.Tree.QueryAabb(ref state, GridQueryCallback, gridBox, true); + lookup.DynamicTree.QueryAabb(ref state, GridQueryCallback, gridBox, true); + lookup.StaticTree.QueryAabb(ref state, GridQueryCallback, gridBox, true); + lookup.SundriesTree.QueryAabb(ref state, GridQueryCallback, gridBox, true); // process those entities foreach (var xform in list) @@ -250,7 +253,9 @@ public sealed partial class ExplosionSystem : EntitySystem return !tileBlocked; list.Clear(); - lookup.Tree.QueryAabb(ref state, GridQueryCallback, gridBox, true); + lookup.DynamicTree.QueryAabb(ref state, GridQueryCallback, gridBox, true); + lookup.StaticTree.QueryAabb(ref state, GridQueryCallback, gridBox, true); + lookup.SundriesTree.QueryAabb(ref state, GridQueryCallback, gridBox, true); foreach (var xform in list) { @@ -272,10 +277,18 @@ public sealed partial class ExplosionSystem : EntitySystem return true; } + private bool GridQueryCallback( + ref (List List, HashSet Processed, EntityQuery XformQuery) state, + in FixtureProxy proxy) + { + var owner = proxy.Fixture.Body.Owner; + return GridQueryCallback(ref state, in owner); + } + /// /// Same as , but for SPAAAAAAACE. /// - internal void ExplodeSpace(EntityLookupComponent lookup, + internal void ExplodeSpace(BroadphaseComponent lookup, Matrix3 spaceMatrix, Matrix3 invSpaceMatrix, Vector2i tile, @@ -295,7 +308,9 @@ public sealed partial class ExplosionSystem : EntitySystem var state = (list, processed, invSpaceMatrix, lookup.Owner, xformQuery, gridBox); // get entities: - lookup.Tree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); + lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); + lookup.StaticTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); + lookup.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); foreach (var xform in state.Item1) { @@ -309,7 +324,9 @@ public sealed partial class ExplosionSystem : EntitySystem // Also, throw any entities that were spawned as shrapnel. Compared to entity spawning & destruction, this extra // lookup is relatively minor computational cost, and throwing is disabled for nukes anyways. list.Clear(); - lookup.Tree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); + lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); + lookup.StaticTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); + lookup.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true); foreach (var xform in list) { @@ -342,6 +359,14 @@ public sealed partial class ExplosionSystem : EntitySystem return true; } + private bool SpaceQueryCallback( + ref (List List, HashSet Processed, Matrix3 InvSpaceMatrix, EntityUid LookupOwner, EntityQuery XformQuery, Box2 GridBox) state, + in FixtureProxy proxy) + { + var owner = proxy.Fixture.Body.Owner; + return SpaceQueryCallback(ref state, in owner); + } + /// /// This function actually applies the explosion affects to an entity. /// @@ -460,7 +485,7 @@ sealed class Explosion /// /// Lookup component for this grid (or space/map). /// - public EntityLookupComponent Lookup; + public BroadphaseComponent Lookup; /// /// The actual grid that this corresponds to. If null, this implies space. @@ -513,7 +538,7 @@ sealed class Explosion // Variables used for enumerating over tiles, grids, etc private DamageSpecifier _currentDamage = default!; - private EntityLookupComponent _currentLookup = default!; + private BroadphaseComponent _currentLookup = default!; private IMapGrid? _currentGrid; private float _currentIntensity; private float _currentThrowForce; @@ -600,7 +625,7 @@ sealed class Explosion _explosionData.Add(new() { TileLists = spaceData.TileLists, - Lookup = entMan.GetComponent(mapUid), + Lookup = entMan.GetComponent(mapUid), MapGrid = null }); @@ -613,7 +638,7 @@ sealed class Explosion _explosionData.Add(new() { TileLists = grid.TileLists, - Lookup = entMan.GetComponent(grid.Grid.GridEntityId), + Lookup = entMan.GetComponent(grid.Grid.GridEntityId), MapGrid = grid.Grid }); } diff --git a/Content.Server/Physics/Controllers/ConveyorController.cs b/Content.Server/Physics/Controllers/ConveyorController.cs index ee8bd4f410..5b282c024c 100644 --- a/Content.Server/Physics/Controllers/ConveyorController.cs +++ b/Content.Server/Physics/Controllers/ConveyorController.cs @@ -168,6 +168,9 @@ namespace Content.Server.Physics.Controllers private void OnConveyorShutdown(EntityUid uid, ConveyorComponent component, ComponentShutdown args) { + if (MetaData(uid).EntityLifeStage >= EntityLifeStage.Terminating) + return; + RemComp(uid); if (!TryComp(uid, out var body)) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedFlyBySoundSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedFlyBySoundSystem.cs index 6919f46426..40e67656b1 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedFlyBySoundSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedFlyBySoundSystem.cs @@ -47,7 +47,11 @@ public abstract class SharedFlyBySoundSystem : EntitySystem private void OnShutdown(EntityUid uid, FlyBySoundComponent component, ComponentShutdown args) { - if (!TryComp(uid, out var body)) return; + if (!TryComp(uid, out var body) || + MetaData(uid).EntityLifeStage >= EntityLifeStage.Terminating) + { + return; + } _fixtures.DestroyFixture(body, FlyByFixture); } diff --git a/Resources/Maps/bagel.yml b/Resources/Maps/bagel.yml index b1e7cb501b..a4dcfa8a30 100644 --- a/Resources/Maps/bagel.yml +++ b/Resources/Maps/bagel.yml @@ -663,7 +663,6 @@ entities: parent: 943 type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - id: Bagel type: BecomesStation @@ -31751,7 +31750,6 @@ entities: - type: Transform - index: 4 type: Map - - type: EntityLookup - type: Broadphase - type: PhysicsMap - type: OccluderTree diff --git a/Resources/Maps/box.yml b/Resources/Maps/box.yml index 7ed8dcc409..72e975bc29 100644 --- a/Resources/Maps/box.yml +++ b/Resources/Maps/box.yml @@ -5535,7 +5535,6 @@ entities: - type: Transform - index: 5 type: Map - - type: EntityLookup - type: Broadphase - type: PhysicsMap - type: OccluderTree @@ -56709,7 +56708,6 @@ entities: parent: 780 type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - id: Boxstation type: BecomesStation @@ -113447,7 +113445,6 @@ entities: type: Transform - index: 1 type: MapGrid - - type: EntityLookup - type: Broadphase - angularDamping: 0.05 linearDamping: 0.05 diff --git a/Resources/Maps/centcomm.yml b/Resources/Maps/centcomm.yml index cdbd32fc2c..77d35f75f1 100644 --- a/Resources/Maps/centcomm.yml +++ b/Resources/Maps/centcomm.yml @@ -134,7 +134,6 @@ entities: - parent: null type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - id: centcomm type: BecomesStation diff --git a/Resources/Maps/cluster.yml b/Resources/Maps/cluster.yml index 402bd048a5..b6ec6e27f1 100644 --- a/Resources/Maps/cluster.yml +++ b/Resources/Maps/cluster.yml @@ -918,7 +918,6 @@ entities: - type: Transform - index: 7 type: Map - - type: EntityLookup - type: Broadphase - type: PhysicsMap - type: OccluderTree @@ -953,7 +952,6 @@ entities: parent: 122 type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - angularDamping: 0.05 linearDamping: 0.05 diff --git a/Resources/Maps/dart.yml b/Resources/Maps/dart.yml index 7fcb4033c4..07c619d14a 100644 --- a/Resources/Maps/dart.yml +++ b/Resources/Maps/dart.yml @@ -118,7 +118,6 @@ entities: - type: Transform - index: 15 type: Map - - type: EntityLookup - type: Broadphase - type: PhysicsMap - type: OccluderTree @@ -129,7 +128,6 @@ entities: parent: 0 type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - angularDamping: 0.05 linearDamping: 0.05 diff --git a/Resources/Maps/kettle.yml b/Resources/Maps/kettle.yml index 27f9b28570..f3670653b9 100644 --- a/Resources/Maps/kettle.yml +++ b/Resources/Maps/kettle.yml @@ -896,7 +896,6 @@ entities: parent: 84 type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - id: Kettle type: BecomesStation @@ -40407,7 +40406,6 @@ entities: - type: Transform - index: 4 type: Map - - type: EntityLookup - type: Broadphase - type: PhysicsMap - type: OccluderTree diff --git a/Resources/Maps/marathon.yml b/Resources/Maps/marathon.yml index b2e1ba5ec3..f54b93337d 100644 --- a/Resources/Maps/marathon.yml +++ b/Resources/Maps/marathon.yml @@ -466,7 +466,6 @@ entities: parent: 5350 type: Transform - type: MapGrid - - type: EntityLookup - type: Broadphase - angularDamping: 0.05 linearDamping: 0.05 @@ -61444,7 +61443,6 @@ entities: - type: Transform - index: 4 type: Map - - type: EntityLookup - type: Broadphase - type: PhysicsMap - type: OccluderTree