Skip to content

Commit

Permalink
updated Quadtree to also use late update
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Dec 21, 2024
1 parent 4f52fbe commit b118cd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Murder/Systems/Physics/QuadtreeCalculatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Murder.Systems;

[Filter(typeof(ColliderComponent), typeof(ITransformComponent))]
[Watch(typeof(ITransformComponent), typeof(ColliderComponent))]
public class QuadtreeCalculatorSystem : IReactiveSystem, IFixedUpdateSystem, IStartupSystem
public class QuadtreeCalculatorSystem : IReactiveSystem, IStartupSystem
{
private readonly HashSet<int> _entitiesOnWatch = new(516);

Expand Down Expand Up @@ -58,17 +58,17 @@ public void OnDeactivated(World world, ImmutableArray<Entity> entities)
}
}

public void FixedUpdate(Context context)
public void OnAfterTrigger(World world)
{
if (_entitiesOnWatch.Count == 0)
{
return;
}

Quadtree qt = Quadtree.GetOrCreateUnique(context.World);
Quadtree qt = Quadtree.GetOrCreateUnique(world);
foreach (int entityId in _entitiesOnWatch)
{
if (context.World.TryGetEntity(entityId) is Entity entity && entity.IsActive)
if (world.TryGetEntity(entityId) is Entity entity && entity.IsActive)
{
qt.RemoveFromCollisionQuadTree(entityId);
qt.AddToCollisionQuadTree(entity);
Expand Down
2 changes: 2 additions & 0 deletions src/Murder/Systems/Physics/TriggerPhysicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Murder.Services;
using Murder.Utilities;
using System.Collections.Immutable;
using System.Diagnostics;

namespace Murder.Systems.Physics
{
Expand All @@ -28,6 +29,7 @@ private void WatchEntities(ImmutableArray<Entity> entities, World world)
for (int i = 0; i < entities.Length; i++)
{
Entity entity = entities[i];

if (_entitiesOnWatch.ContainsKey(entity.EntityId))
{
continue;
Expand Down

0 comments on commit b118cd2

Please # to comment.