CollisionDetection<T extends Hitbox<T>, B extends Broadphase<T>> class abstract

CollisionDetection is the foundation of the collision detection system in Flame.

If the HasCollisionDetection mixin is added to the game, run is called every tick to check for collisions.

Implementers

Constructors

CollisionDetection({required B broadphase})

Properties

broadphase → B
final
collisionsCompletedNotifier CollisionDetectionCompletionNotifier
final
hashCode int
The hash code for this object.
no setterinherited
items List<T>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(T item) → void
addAll(Iterable<T> items) → void
handleCollision(Set<Vector2> intersectionPoints, T itemA, T itemB) → void
handleCollisionEnd(T itemA, T itemB) → void
handleCollisionStart(Set<Vector2> intersectionPoints, T itemA, T itemB) → void
intersections(T itemA, T itemB) Set<Vector2>
Check what the intersection points of two items are, returns an empty list if there are no intersections.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
raycast(Ray2 ray, {double? maxDistance, bool hitboxFilter(T candidate)?, List<T>? ignoreHitboxes, RaycastResult<T>? out}) RaycastResult<T>?
Returns the first hitbox that the given ray hits and the associated intersection information; or null if the ray doesn't hit any hitbox.
raycastAll(Vector2 origin, {required int numberOfRays, double startAngle = 0, double sweepAngle = tau, double? maxDistance, List<Ray2>? rays, bool hitboxFilter(T candidate)?, List<T>? ignoreHitboxes, List<RaycastResult<T>>? out}) List<RaycastResult<T>>
Casts rays uniformly between startAngle to startAngle+sweepAngle from the given origin and returns all hitboxes and intersection points the rays hit. numberOfRays is the number of rays that should be casted.
raytrace(Ray2 ray, {int maxDepth = 10, bool hitboxFilter(T candidate)?, List<T>? ignoreHitboxes, List<RaycastResult<T>>? out}) Iterable<RaycastResult<T>>
Follows the ray and its reflections until maxDepth is reached and then returns all hitboxes, intersection points, normals and reflection rays (bundled in a list of RaycastResults) from where the ray hits.
remove(T item) → void
Removes the item from the collision detection, if you just want to temporarily inactivate it you can set collisionType = CollisionType.inactive; instead.
removeAll(Iterable<T> items) → void
Removes all items from the collision detection, see remove.
run() → void
Run collision detection for the current state of items.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited