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