Deprecate entitylookupcomponent (#12159)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ public sealed class AccessOverlay : Overlay
|
||||
var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
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))
|
||||
|
||||
@@ -34,28 +34,30 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
var coordinates = testMap.GridCoords;
|
||||
var solutionSystem = server.ResolveDependency<IEntitySystemManager>()
|
||||
.GetEntitySystem<SolutionContainerSystem>();
|
||||
|
||||
foreach (var reactionPrototype in prototypeManager.EnumeratePrototypes<ReactionPrototype>())
|
||||
{
|
||||
//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<SolutionContainerSystem>()
|
||||
Assert.That(solutionSystem
|
||||
.TryGetSolution(beaker, "beaker", out component));
|
||||
foreach (var (id, reactant) in reactionPrototype.Reactants)
|
||||
{
|
||||
Assert.That(EntitySystem.Get<SolutionContainerSystem>()
|
||||
Assert.That(solutionSystem
|
||||
.TryAddReagent(beaker, component, id, reactant.Amount, out var quantity));
|
||||
Assert.That(reactant.Amount, Is.EqualTo(quantity));
|
||||
}
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().SetTemperature(beaker, component, reactionPrototype.MinimumTemperature);
|
||||
solutionSystem.SetTemperature(beaker, component, reactionPrototype.MinimumTemperature);
|
||||
});
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -145,9 +145,12 @@ namespace Content.Server.Chemistry.Components
|
||||
/// with the other area effects from the inception.</param>
|
||||
public void React(float averageExposures)
|
||||
{
|
||||
|
||||
if (!_entities.EntitySysManager.GetEntitySystem<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
if (!_entities.EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
|
||||
.TryGetSolution(Owner, SolutionName, out var solution) ||
|
||||
solution.Contents.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var xform = _entities.GetComponent<TransformComponent>(Owner);
|
||||
if (!MapManager.TryGetGrid(xform.GridUid, out var mapGrid))
|
||||
@@ -158,6 +161,7 @@ namespace Content.Server.Chemistry.Components
|
||||
var lookup = _entities.EntitySysManager.GetEntitySystem<EntityLookupSystem>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
/// </summary>
|
||||
/// <returns>True if the underlying tile can be uprooted, false if the tile is blocked by a dense entity</returns>
|
||||
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<TransformComponent> List, HashSet<EntityUid> Processed, EntityQuery<TransformComponent> XformQuery) state,
|
||||
in FixtureProxy proxy)
|
||||
{
|
||||
var owner = proxy.Fixture.Body.Owner;
|
||||
return GridQueryCallback(ref state, in owner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Same as <see cref="ExplodeTile"/>, but for SPAAAAAAACE.
|
||||
/// </summary>
|
||||
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<TransformComponent> List, HashSet<EntityUid> Processed, Matrix3 InvSpaceMatrix, EntityUid LookupOwner, EntityQuery<TransformComponent> XformQuery, Box2 GridBox) state,
|
||||
in FixtureProxy proxy)
|
||||
{
|
||||
var owner = proxy.Fixture.Body.Owner;
|
||||
return SpaceQueryCallback(ref state, in owner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function actually applies the explosion affects to an entity.
|
||||
/// </summary>
|
||||
@@ -460,7 +485,7 @@ sealed class Explosion
|
||||
/// <summary>
|
||||
/// Lookup component for this grid (or space/map).
|
||||
/// </summary>
|
||||
public EntityLookupComponent Lookup;
|
||||
public BroadphaseComponent Lookup;
|
||||
|
||||
/// <summary>
|
||||
/// 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<EntityLookupComponent>(mapUid),
|
||||
Lookup = entMan.GetComponent<BroadphaseComponent>(mapUid),
|
||||
MapGrid = null
|
||||
});
|
||||
|
||||
@@ -613,7 +638,7 @@ sealed class Explosion
|
||||
_explosionData.Add(new()
|
||||
{
|
||||
TileLists = grid.TileLists,
|
||||
Lookup = entMan.GetComponent<EntityLookupComponent>(grid.Grid.GridEntityId),
|
||||
Lookup = entMan.GetComponent<BroadphaseComponent>(grid.Grid.GridEntityId),
|
||||
MapGrid = grid.Grid
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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<ActiveConveyorComponent>(uid);
|
||||
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body))
|
||||
|
||||
@@ -47,7 +47,11 @@ public abstract class SharedFlyBySoundSystem : EntitySystem
|
||||
|
||||
private void OnShutdown(EntityUid uid, FlyBySoundComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body)) return;
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body) ||
|
||||
MetaData(uid).EntityLifeStage >= EntityLifeStage.Terminating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_fixtures.DestroyFixture(body, FlyByFixture);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -134,7 +134,6 @@ entities:
|
||||
- parent: null
|
||||
type: Transform
|
||||
- type: MapGrid
|
||||
- type: EntityLookup
|
||||
- type: Broadphase
|
||||
- id: centcomm
|
||||
type: BecomesStation
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user