import { Component } from '../component'; import { Entity } from '../entity'; import { Vector2 } from '../types'; export declare enum COLLISION_TYPE { /** * No Collision, default value. E.g. particles not interacting with the world */ NEVER = 0, /** * Pushed by ACTIVE or FIXED entities */ LITE = 1, /** * Ignore other PASSIVE or LITE entities, mutual push vs ACTIVE */ PASSIVE = 2, /** * Mutual push vs ACTIVE or PASSIVE entities */ ACTIVE = 4, /** * Won't be pushed */ FIXED = 8 } /** * Enumation of collision groups */ export declare enum COLLISION_GROUP { NONE = 0, A = 1, B = 2, BOTH = 3 } /** * RigidBody component * * Manages the collisions vs the collisionMap and other Entities */ export declare class RigidBody extends Component { /** * The base value for gravity calculations. 0 = no gravity */ static baseGravityValue: number; /** * Used in entity-entity collision detection. You likely don't need to change that */ static cellSize: number; /** * Checks and resolves collisions between entities * TODO: need refactoring */ static checkCollisionsBetweenEntities(entities: Entity[]): void; /** * If this pair allows collision, solves it */ static checkPair(a: Entity, b: Entity): void; /** * Solves the collision between two entities. Depending on the `collisionType` value, * entities may collide and push each other. */ private static solveCollision; /** * Resolves entities colliding on the x axis * * @param {Entity} left * @param {Entity} right * @param {(Entity | null)} weak */ private static separateOnXAxis; /** * Resolves entities colliding on the y axis * * @param {Entity} top * @param {Entity} bottom * @param {(Entity | null)} weak */ private static separateOnYAxis; /** * Entity's velocity, in pixels per second */ vel: { x: number; y: number; }; /** * Entity's acceleration, in pixels per square second. * Is added to `vel`. */ accel: Vector2; /** * Entity's max velocity (while applying acceleration). * Will be ignored if you manually set the `vel` */ maxVel: Vector2; /** * Deceleration added to `vel`, when `accel` is 0. */ friction: Vector2; /** * Multiplier of `GlobalSettings.baseGravityValue` */ gravityFactor: number; /** * Bounciness on collision */ bounciness: number; /** * Minimal velocity to take bounciness into account */ minBounceVelocity: number; /** * How does this entity reacts when entity collision happens */ collisionType: COLLISION_TYPE; /** * The collision group of this entity (cannot be BOTH) */ collisionGroup: COLLISION_GROUP; /** * The collision group this entity will react against */ collidesAgainstGroup: COLLISION_GROUP; protected entity: Entity; /** * Determines if the entity is standing (not sliding) on the ground */ readonly standing: boolean; private _standing; /** * Previous coordinates */ private last; /** * The angle where an Entity stops is considered "standing" on ground */ private slopeStanding; destroy(): void; /** * Update method, called automatically */ update(delta: number): void; /** * Processes the collision result */ private handleMovementTrace; /** * Calculates the new velocity according to all physics parameters */ private getNewVelocity; }