Pool NPC entitylookup fields (#21806)
This commit is contained in:
@@ -469,12 +469,13 @@ public sealed partial class NPCSteeringSystem
|
||||
{
|
||||
var objectRadius = 0.15f;
|
||||
var detectionRadius = MathF.Max(0.35f, agentRadius + objectRadius);
|
||||
var ents = _entSetPool.Get();
|
||||
_lookup.GetEntitiesInRange(uid, detectionRadius, ents, LookupFlags.Static);
|
||||
|
||||
foreach (var ent in _lookup.GetEntitiesInRange(uid, detectionRadius, LookupFlags.Static))
|
||||
foreach (var ent in ents)
|
||||
{
|
||||
// TODO: If we can access the door or smth.
|
||||
if (ent == uid ||
|
||||
!_physicsQuery.TryGetComponent(ent, out var otherBody) ||
|
||||
if (!_physicsQuery.TryGetComponent(ent, out var otherBody) ||
|
||||
!otherBody.Hard ||
|
||||
!otherBody.CanCollide ||
|
||||
(mask & otherBody.CollisionLayer) == 0x0 &&
|
||||
@@ -521,6 +522,7 @@ public sealed partial class NPCSteeringSystem
|
||||
}
|
||||
}
|
||||
|
||||
_entSetPool.Return(ents);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -545,12 +547,13 @@ public sealed partial class NPCSteeringSystem
|
||||
var detectionRadius = MathF.Max(0.35f, agentRadius + objectRadius);
|
||||
var ourVelocity = body.LinearVelocity;
|
||||
_factionQuery.TryGetComponent(uid, out var ourFaction);
|
||||
var ents = _entSetPool.Get();
|
||||
_lookup.GetEntitiesInRange(uid, detectionRadius, ents, LookupFlags.Dynamic);
|
||||
|
||||
foreach (var ent in _lookup.GetEntitiesInRange(uid, detectionRadius, LookupFlags.Dynamic))
|
||||
foreach (var ent in ents)
|
||||
{
|
||||
// TODO: If we can access the door or smth.
|
||||
if (ent == uid ||
|
||||
!_physicsQuery.TryGetComponent(ent, out var otherBody) ||
|
||||
if (!_physicsQuery.TryGetComponent(ent, out var otherBody) ||
|
||||
!otherBody.Hard ||
|
||||
!otherBody.CanCollide ||
|
||||
(mask & otherBody.CollisionLayer) == 0x0 &&
|
||||
@@ -602,6 +605,8 @@ public sealed partial class NPCSteeringSystem
|
||||
danger[i] = MathF.Max(dot * weight, danger[i]);
|
||||
}
|
||||
}
|
||||
|
||||
_entSetPool.Return(ents);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user