remove entity queries (#642)
This commit is contained in:
@@ -190,19 +190,20 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
|
|||||||
var epicenter = mapPos.Position;
|
var epicenter = mapPos.Position;
|
||||||
var minRange2 = MathF.Max(minRange * minRange, MinGravPulseRange); // Cache square value for speed. Also apply a sane minimum value to the minimum value so that div/0s don't happen.
|
var minRange2 = MathF.Max(minRange * minRange, MinGravPulseRange); // Cache square value for speed. Also apply a sane minimum value to the minimum value so that div/0s don't happen.
|
||||||
|
|
||||||
var bodyQuery = GetEntityQuery<PhysicsComponent>();
|
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
|
||||||
|
|
||||||
foreach(var entity in _lookup.GetEntitiesInRange(mapPos.MapId, epicenter, maxRange, flags: LookupFlags.Dynamic | LookupFlags.Static | LookupFlags.Sundries))
|
foreach(var entity in _lookup.GetEntitiesInRange(mapPos.MapId, epicenter, maxRange, flags: LookupFlags.Dynamic | LookupFlags.Static | LookupFlags.Sundries))
|
||||||
{
|
{
|
||||||
|
if (!entity.Valid)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (ignore?.Contains(entity) is true)
|
if (ignore?.Contains(entity) is true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!bodyQuery.TryGetComponent(entity, out var physics)) // WD edit
|
// WD added start
|
||||||
|
if (!TryComp<PhysicsComponent>(entity, out var physics)) // WD edit
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// WD added start
|
if (!TryComp(entity, out TransformComponent? xform))
|
||||||
var xform = Transform(entity);
|
continue;
|
||||||
|
|
||||||
if (HasComp<ContainmentFieldGeneratorComponent>(entity))
|
if (HasComp<ContainmentFieldGeneratorComponent>(entity))
|
||||||
continue;
|
continue;
|
||||||
@@ -220,7 +221,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
|
|||||||
if (xform.Anchored) // WD added
|
if (xform.Anchored) // WD added
|
||||||
_transform.Unanchor(entity, xform);
|
_transform.Unanchor(entity, xform);
|
||||||
|
|
||||||
var displacement = epicenter - _transform.GetWorldPosition(entity, xformQuery);
|
var displacement = epicenter - _transform.GetWorldPosition(entity);
|
||||||
var distance2 = displacement.LengthSquared();
|
var distance2 = displacement.LengthSquared();
|
||||||
|
|
||||||
if (distance2 < minRange2)
|
if (distance2 < minRange2)
|
||||||
|
|||||||
Reference in New Issue
Block a user