UNPKG

blaze-2d

Version:

A fast and simple WebGL 2 2D game engine written in TypeScript

66 lines (65 loc) 2.3 kB
import CollisionObject from "./collisionObject"; import Manifold from "./manifold"; /** * Represents a 2 layered {@link Map} containing {@link Manifold}s for {@link CollisionObject} pairs. */ export default class ManifoldMap { map: Map<CollisionObject, Map<CollisionObject, Manifold>>; /** * Gets all the manifolds in the map and returns them as a contiguous array. * * @returns All the manifolds in the map as an array */ getAllManifolds(): Manifold[]; /** * Finds a manifold in the {@link ManifoldMap}. * * @param a The first collision object * @param b The second collision object * @returns The manifold for the collision between **a** and **b** or undefined. */ getManifold(a: CollisionObject, b: CollisionObject): Manifold | undefined; /** * Finds the correct key in the map for objects `a` and `b`. * * @param a An object in the key * @param b An object in the key * @returns The manifold key or undefined */ getManifoldKey(a: CollisionObject, b: CollisionObject): { top: CollisionObject; key: CollisionObject; } | undefined; /** * Adds a manifold to the map with the top level key being `a` and inner key being `b`. * * If a manifold is already in the map with key [b, a] then that manifold will be updated instead. * * @param a The first object for the key * @param b The second object for the key * @param m The manifold to insert */ addManifold(a: CollisionObject, b: CollisionObject, m: Manifold): void; /** * Removes the manifold involving objects `a` and `b`. * * @param a An object in the manifold * @param b Another object in the manifold * @returns Wether or not a manifold was removed */ removeManifold(a: CollisionObject, b: CollisionObject): boolean; /** * Removes all manifolds involving the given object. * * @param obj The obj to remove manifolds of */ removeManifoldsInvolving(obj: CollisionObject): void; /** * Removes all manifolds in the map which have `isDead` set to true. */ removeDeadManifolds(): void; /** * Sets `isDead` to true for every manifold in the map. */ killAllManifolds(): void; }