24 List<ColliderInstance> results,
28 var layer = SceneLayer;
29 var periodic = layer is not
null && (layer.WrapHorizontally || layer.WrapVertically);
30 var period = periodic ? layer!.GetPeriod() :
default;
32 var query =
new System.Drawing.RectangleF(
38 foreach (var collider
in _static.Concat(_dynamic))
40 if (ReferenceEquals(collider, ignore) || (collider.CollisionGroup & collidesWithMask) == 0 ||
41 (layerMask & collider.CollidesWith) == 0)
44 var bounds = collider.BoundsWorldPx;
48 if (area.Intersects(bounds))
49 results.Add(
new(collider, bounds));
54 foreach (var offset
in period.Offsets(
65 bounds.MinX + offset.X,
66 bounds.MinY + offset.Y,
67 bounds.MaxX + offset.X,
68 bounds.MaxY + offset.Y)));
72 private readonly HashSet<ICollider> _static =
new();
73 private readonly HashSet<ICollider> _dynamic =
new();
94 throw new ArgumentNullException(nameof(collider));
97 _static.Add(collider);
99 _dynamic.Add(collider);
109 if (collider is
null)
113 _static.Remove(collider);
115 _dynamic.Remove(collider);
132 int collidesWithMask,
133 List<ICollider> results,
136 var instances =
new List<ColliderInstance>();
147 foreach (var instance
in instances)
148 if (!results.Contains(instance.Collider))
149 results.Add(instance.Collider);
Manages registration and querying of colliders, separating them into static and dynamic collections f...
void QueryInstances(in Aabb area, int layerMask, int collidesWithMask, List< ColliderInstance > results, ICollider? ignore=null)
Queries canonical colliders with translated bounds for every overlapping wrapped instance....
void Unregister(ICollider collider)
Unregisters a collider from the registry, removing it from either the static or dynamic collection ba...
IEnumerable< ICollider > DynamicColliders
Gets the collection of dynamic colliders registered in this registry.
void QueryAabb(in Aabb area, int layerMask, int collidesWithMask, List< ICollider > results, ICollider? ignore=null)
Broad-phase query: returns colliders overlapping the given AABB that also match the provided layer ma...
void Register(ICollider collider)
Registers a collider with the registry. The collider is added to either the static or dynamic collect...
IEnumerable< ICollider > StaticColliders
Gets the collection of static colliders registered in this registry.
Represents a single layer within a Scene, containing a grid of tiles and supporting various coordinat...
World-space axis-aligned collider used by the collision system.
bool IsStatic
True for static, non-moving colliders (walls, tiles, etc.). False for dynamic objects (player,...
Represents an axis-aligned bounding box (AABB) defined by its minimum and maximum coordinates along t...