@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
124 lines • 2.96 kB
TypeScript
import { World } from '../world/World';
import { Entity } from '../physics/Entity';
import { AABB } from '../core/math/AABB';
import { Vector2 } from '../core/math/Vector2';
/**
* Region configuration
*/
export interface RegionConfig {
/** Region bounds */
bounds: AABB;
/** Overlap size with neighboring regions (default: 0) */
overlap?: number;
/** Whether this region is active (default: true) */
active?: boolean;
}
/**
* Physical region in a distributed world
*
* Represents an independent simulation zone that can contain entities.
* Regions can overlap to allow smooth entity transitions.
*
* @example
* ```typescript
* const region = new Region({
* bounds: new AABB(0, 0, 100, 100),
* overlap: 10
* });
* ```
*/
export declare class Region {
private world;
private bounds;
private overlap;
private active;
private entities;
/**
* Creates a new region
*
* @param config - Region configuration
*/
constructor(config: RegionConfig);
/**
* Gets the region bounds
*
* @returns AABB bounds
*/
getBounds(): AABB;
/**
* Gets the expanded bounds including overlap
*
* @returns Expanded AABB
*/
getExpandedBounds(): AABB;
/**
* Checks if a point is inside this region
*
* @param point - Point to check
* @returns True if point is inside
*/
contains(point: Vector2): boolean;
/**
* Checks if an entity should belong to this region
*
* @param entity - Entity to check
* @returns True if entity should be in this region
*/
shouldContain(entity: Entity): boolean;
/**
* Adds an entity to this region
*
* @param entity - Entity to add
*/
addEntity(entity: Entity): void;
/**
* Removes an entity from this region
*
* @param entity - Entity to remove
*/
removeEntity(entity: Entity): void;
/**
* Gets all entities in this region
*
* @returns Array of entities
*/
getEntities(): Entity[];
/**
* Steps the region's physics simulation
*/
step(): void;
/**
* Activates this region
*/
activate(): void;
/**
* Deactivates this region
*/
deactivate(): void;
/**
* Checks if this region is active
*
* @returns True if active
*/
isActive(): boolean;
/**
* Gets the world instance for this region
*
* @returns World instance
*/
getWorld(): World;
/**
* Checks if this region overlaps with another region
*
* @param other - Other region to check
* @returns True if regions overlap
*/
overlaps(other: Region): boolean;
/**
* Gets entities that might need migration to neighboring regions
*
* @returns Array of entities near region boundaries
*/
getBoundaryEntities(): Entity[];
}
//# sourceMappingURL=Region.d.ts.map