Make large explosions use approximate lookups (#9296)
This commit is contained in:
@@ -182,7 +182,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
string id,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<DamageableComponent> damageQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery)
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
LookupFlags flags)
|
||||
{
|
||||
var gridBox = new Box2(tile * grid.TileSize, (tile + 1) * grid.TileSize);
|
||||
|
||||
@@ -192,7 +193,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
void AddIntersecting(List<(EntityUid, TransformComponent?)> listy)
|
||||
{
|
||||
foreach (var uid in _entityLookup.GetLocalEntitiesIntersecting(lookup, ref gridBox, LookupFlags.None))
|
||||
// TODO directly query lookup.Tree
|
||||
foreach (var uid in _entityLookup.GetLocalEntitiesIntersecting(lookup, ref gridBox, flags))
|
||||
{
|
||||
if (processed.Contains(uid))
|
||||
continue;
|
||||
@@ -272,7 +274,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
string id,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<DamageableComponent> damageQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery)
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
LookupFlags flags)
|
||||
{
|
||||
var gridBox = new Box2(tile * DefaultTileSize, (DefaultTileSize, DefaultTileSize));
|
||||
var worldBox = spaceMatrix.TransformBox(gridBox);
|
||||
@@ -280,7 +283,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
void AddIntersecting(List<(EntityUid, TransformComponent)> listy)
|
||||
{
|
||||
foreach (var uid in _entityLookup.GetEntitiesIntersecting(lookup, ref worldBox, LookupFlags.None))
|
||||
// TODO directly query lookup.Tree
|
||||
foreach (var uid in _entityLookup.GetEntitiesIntersecting(lookup, ref worldBox, flags))
|
||||
{
|
||||
if (processed.Contains(uid))
|
||||
return;
|
||||
@@ -517,6 +521,8 @@ sealed class Explosion
|
||||
/// </summary>
|
||||
public readonly int Area;
|
||||
|
||||
private readonly LookupFlags _flags = LookupFlags.None;
|
||||
|
||||
/// <summary>
|
||||
/// factor used to scale the tile break chances.
|
||||
/// </summary>
|
||||
@@ -563,6 +569,11 @@ sealed class Explosion
|
||||
_canCreateVacuum = canCreateVacuum;
|
||||
_entMan = entMan;
|
||||
|
||||
// yeah this should be a cvar, but this is only temporary anyways
|
||||
// see lookup todo
|
||||
if (Area > 100)
|
||||
_flags |= LookupFlags.Approximate;
|
||||
|
||||
_xformQuery = entMan.GetEntityQuery<TransformComponent>();
|
||||
_physicsQuery = entMan.GetEntityQuery<PhysicsComponent>();
|
||||
_damageQuery = entMan.GetEntityQuery<DamageableComponent>();
|
||||
@@ -705,7 +716,8 @@ sealed class Explosion
|
||||
ExplosionType.ID,
|
||||
_xformQuery,
|
||||
_damageQuery,
|
||||
_physicsQuery);
|
||||
_physicsQuery,
|
||||
_flags);
|
||||
|
||||
// If the floor is not blocked by some dense object, damage the floor tiles.
|
||||
if (canDamageFloor)
|
||||
@@ -725,7 +737,8 @@ sealed class Explosion
|
||||
ExplosionType.ID,
|
||||
_xformQuery,
|
||||
_damageQuery,
|
||||
_physicsQuery);
|
||||
_physicsQuery,
|
||||
_flags);
|
||||
}
|
||||
|
||||
if (!MoveNext())
|
||||
|
||||
Reference in New Issue
Block a user