@rpgjs/physic 5.0.0-alpha.25 → 5.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index7.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index7.js","sources":["../src/physics/Entity.ts"],"sourcesContent":["import { Vector2 } from '../core/math/Vector2';\nimport { UUID, EntityState } from '../core/types';\nimport { generateUUID } from '../utils/uuid';\nimport { CollisionInfo } from '../collision/Collider';\n\nconst MOVEMENT_EPSILON = 1e-3;\nconst MOVEMENT_EPSILON_SQ = MOVEMENT_EPSILON * MOVEMENT_EPSILON;\nconst DIRECTION_CHANGE_THRESHOLD = 1.0;\nconst DIRECTION_CHANGE_THRESHOLD_SQ = DIRECTION_CHANGE_THRESHOLD * DIRECTION_CHANGE_THRESHOLD;\n\nexport type CardinalDirection = 'idle' | 'up' | 'down' | 'left' | 'right';\n\n/**\n * Configuration options for creating an entity\n */\nexport interface EntityConfig {\n /** Initial position */\n position?: Vector2 | { x: number; y: number };\n /** Initial velocity */\n velocity?: Vector2 | { x: number; y: number };\n /** Initial rotation in radians */\n rotation?: number;\n /** Initial angular velocity in radians per second */\n angularVelocity?: number;\n /** Mass of the entity (0 or Infinity for static/immovable entities) */\n mass?: number;\n /** Radius for circular collider */\n radius?: number;\n /** Width for AABB collider */\n width?: number;\n /** Height for AABB collider */\n height?: number;\n /** Capsule collider configuration (if used) */\n capsule?: {\n radius: number;\n height: number;\n };\n /** Enable continuous collision detection (CCD) */\n continuous?: boolean;\n /** Entity state flags */\n state?: EntityState;\n /** Restitution (bounciness) coefficient (0-1) */\n restitution?: number;\n /** Friction coefficient */\n friction?: number;\n /** Linear damping (0-1, higher = more damping) */\n linearDamping?: number;\n /** Angular damping (0-1, higher = more damping) */\n angularDamping?: number;\n /** Maximum linear velocity */\n maxLinearVelocity?: number;\n /** Maximum angular velocity */\n maxAngularVelocity?: number;\n /** Custom UUID (auto-generated if not provided) */\n uuid?: UUID;\n /** Collision mask (bitmask for collision filtering) */\n collisionMask?: number;\n /** Collision category (bitmask) */\n collisionCategory?: number;\n}\n\n/**\n * Physical entity in the physics world\n * \n * Represents a dynamic or static object that can be affected by forces,\n * collisions, and other physical interactions.\n * \n * ## Creating Static Obstacles\n * \n * To create immovable obstacles (walls, decorations), set `mass` to `0` or `Infinity`.\n * This makes the entity static - it will block other entities but cannot be pushed.\n * \n * @example\n * ```typescript\n * // Dynamic entity (player, movable object)\n * const player = new Entity({\n * position: { x: 0, y: 0 },\n * radius: 10,\n * mass: 1,\n * velocity: { x: 5, y: 0 }\n * });\n * \n * // Static obstacle (wall, tree, decoration)\n * const wall = new Entity({\n * position: { x: 100, y: 0 },\n * width: 20,\n * height: 100,\n * mass: Infinity // or mass: 0\n * });\n * \n * player.applyForce(new Vector2(10, 0));\n * ```\n */\nexport class Entity {\n /**\n * Unique identifier (UUID)\n */\n public readonly uuid: UUID;\n\n /**\n * Position in world space\n */\n public position: Vector2;\n\n /**\n * Linear velocity\n */\n public velocity: Vector2;\n\n /**\n * Rotation in radians\n */\n public rotation: number;\n\n /**\n * Angular velocity in radians per second\n */\n public angularVelocity: number;\n\n /**\n * Mass (0 or Infinity means infinite mass / static)\n */\n public mass: number;\n\n /**\n * Inverse mass (cached for performance, 0 if mass is 0 or Infinity)\n */\n public invMass: number;\n\n /**\n * Radius for circular collider (if used)\n */\n public radius: number;\n\n /**\n * Width for AABB collider (if used)\n */\n public width: number;\n\n /**\n * Height for AABB collider (if used)\n */\n public height: number;\n\n /**\n * Capsule collider configuration (if used)\n */\n public capsule?: {\n radius: number;\n height: number;\n };\n\n /**\n * Enable continuous collision detection (CCD)\n */\n public continuous: boolean;\n\n /**\n * Entity state flags\n */\n public state: EntityState;\n\n /**\n * Restitution (bounciness) coefficient (0-1)\n */\n public restitution: number;\n\n /**\n * Friction coefficient\n */\n public friction: number;\n\n /**\n * Linear damping (0-1)\n */\n public linearDamping: number;\n\n /**\n * Angular damping (0-1)\n */\n public angularDamping: number;\n\n /**\n * Maximum linear velocity\n */\n public maxLinearVelocity: number;\n\n /**\n * Maximum angular velocity\n */\n public maxAngularVelocity: number;\n\n /**\n * Accumulated force for this frame\n */\n public force: Vector2;\n\n /**\n * Accumulated torque for this frame\n */\n public torque: number;\n\n /**\n * Collision mask (bitmask)\n */\n public collisionMask: number;\n\n /**\n * Collision category (bitmask)\n */\n public collisionCategory: number;\n\n /**\n * Time since last movement (for sleep detection)\n */\n public timeSinceMovement: number;\n\n /**\n * Threshold for sleep detection (seconds of inactivity)\n */\n public sleepThreshold: number;\n\n /**\n * Current tile coordinates (x, y)\n */\n public currentTile: Vector2;\n\n private collisionEnterHandlers: Set<EntityCollisionHandler>;\n private collisionExitHandlers: Set<EntityCollisionHandler>;\n private positionSyncHandlers: Set<EntityPositionSyncHandler>;\n private directionSyncHandlers: Set<EntityDirectionSyncHandler>;\n private movementChangeHandlers: Set<EntityMovementChangeHandler>;\n private enterTileHandlers: Set<EntityTileHandler>;\n private leaveTileHandlers: Set<EntityTileHandler>;\n private canEnterTileHandlers: Set<EntityCanEnterTileHandler>;\n private wasMoving: boolean;\n private lastCardinalDirection: CardinalDirection = 'idle';\n\n /**\n * Creates a new entity\n * \n * @param config - Entity configuration\n */\n constructor(config: EntityConfig = {}) {\n // Generate UUID if not provided\n this.uuid = config.uuid ?? generateUUID();\n\n // Position and velocity\n if (config.position instanceof Vector2) {\n this.position = config.position.clone();\n } else if (config.position) {\n this.position = new Vector2(config.position.x, config.position.y);\n } else {\n this.position = new Vector2(0, 0);\n }\n\n this.currentTile = new Vector2(0, 0); // Will be updated by World\n\n if (config.velocity instanceof Vector2) {\n this.velocity = config.velocity.clone();\n } else if (config.velocity) {\n this.velocity = new Vector2(config.velocity.x, config.velocity.y);\n } else {\n this.velocity = new Vector2(0, 0);\n }\n\n // Rotation\n this.rotation = config.rotation ?? 0;\n this.angularVelocity = config.angularVelocity ?? 0;\n\n // Mass\n this.mass = config.mass ?? 1;\n this.invMass = this.mass > 0 ? 1 / this.mass : 0;\n\n // Collider dimensions\n this.radius = config.radius ?? 0;\n this.width = config.width ?? 0;\n this.height = config.height ?? 0;\n if (config.capsule !== undefined) {\n this.capsule = config.capsule;\n }\n this.continuous = config.continuous ?? false;\n\n // State\n this.state = config.state ?? EntityState.Dynamic;\n\n // Material properties\n this.restitution = config.restitution ?? 0.2;\n this.friction = config.friction ?? 0.3;\n this.linearDamping = config.linearDamping ?? 0.01;\n this.angularDamping = config.angularDamping ?? 0.01;\n\n // Velocity limits\n this.maxLinearVelocity = config.maxLinearVelocity ?? Infinity;\n this.maxAngularVelocity = config.maxAngularVelocity ?? Infinity;\n\n // Forces\n this.force = new Vector2(0, 0);\n this.torque = 0;\n\n // Collision filtering\n this.collisionMask = config.collisionMask ?? 0xffffffff;\n this.collisionCategory = config.collisionCategory ?? 0x00000001;\n\n // Sleep detection\n this.timeSinceMovement = 0;\n this.sleepThreshold = 0.5; // 0.5 seconds of inactivity\n\n // Event handlers\n this.collisionEnterHandlers = new Set();\n this.collisionExitHandlers = new Set();\n this.positionSyncHandlers = new Set();\n this.directionSyncHandlers = new Set();\n this.positionSyncHandlers = new Set();\n this.directionSyncHandlers = new Set();\n this.movementChangeHandlers = new Set();\n this.enterTileHandlers = new Set();\n this.leaveTileHandlers = new Set();\n this.canEnterTileHandlers = new Set();\n\n // Initialize movement state\n this.wasMoving = this.velocity.lengthSquared() > MOVEMENT_EPSILON_SQ;\n }\n\n /**\n * Registers a handler fired when this entity starts colliding with another one.\n *\n * - **Purpose:** offer per-entity collision hooks without subscribing to the global event system.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n *\n * @param handler - Collision enter listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onCollisionEnter(({ other }) => {\n * console.log('Started colliding with', other.uuid);\n * });\n * ```\n */\n public onCollisionEnter(handler: EntityCollisionHandler): () => void {\n this.collisionEnterHandlers.add(handler);\n return () => this.collisionEnterHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when this entity stops colliding with another one.\n *\n * - **Purpose:** detect collision separation at the entity level for local gameplay reactions.\n * - **Design:** mirrors `onCollisionEnter` with identical lifecycle management semantics.\n *\n * @param handler - Collision exit listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onCollisionExit(({ other }) => {\n * console.log('Stopped colliding with', other.uuid);\n * });\n * ```\n */\n public onCollisionExit(handler: EntityCollisionHandler): () => void {\n this.collisionExitHandlers.add(handler);\n return () => this.collisionExitHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when the entity position changes (x, y).\n *\n * - **Purpose:** synchronize position changes for logging, rendering, network sync, etc.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n *\n * @param handler - Position change listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onPositionChange(({ x, y }) => {\n * console.log('Position changed to', x, y);\n * // Update rendering, sync network, etc.\n * });\n * ```\n */\n public onPositionChange(handler: EntityPositionSyncHandler): () => void {\n this.positionSyncHandlers.add(handler);\n return () => this.positionSyncHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when the entity direction changes.\n *\n * - **Purpose:** synchronize direction changes for logging, rendering, network sync, etc.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n *\n * @param handler - Direction change listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onDirectionChange(({ direction, cardinalDirection }) => {\n * console.log('Direction changed to', cardinalDirection);\n * // Update rendering, sync network, etc.\n * });\n * ```\n */\n public onDirectionChange(handler: EntityDirectionSyncHandler): () => void {\n this.directionSyncHandlers.add(handler);\n return () => this.directionSyncHandlers.delete(handler);\n }\n\n /**\n * Manually notifies that the position has changed.\n *\n * - **Purpose:** allow external code to trigger position sync hooks when position is modified directly.\n * - **Design:** can be called after direct position modifications (e.g., `entity.position.set()`).\n *\n * @example\n * ```typescript\n * entity.position.set(100, 200);\n * entity.notifyPositionChange(); // Trigger sync hooks\n * ```\n */\n public notifyPositionChange(): void {\n if (this.positionSyncHandlers.size === 0) {\n return;\n }\n\n const payload: EntityPositionSyncEvent = {\n entity: this,\n x: this.position.x,\n y: this.position.y,\n };\n\n for (const handler of this.positionSyncHandlers) {\n handler(payload);\n }\n }\n\n /**\n * Manually notifies that the direction has changed.\n *\n * - **Purpose:** allow external code to trigger direction sync hooks when direction is modified directly.\n * - **Design:** computes direction from velocity and cardinal direction.\n *\n * @example\n * ```typescript\n * entity.velocity.set(5, 0);\n * entity.notifyDirectionChange(); // Trigger sync hooks\n * ```\n */\n public notifyDirectionChange(): void {\n const isMoving = this.velocity.lengthSquared() > DIRECTION_CHANGE_THRESHOLD_SQ;\n const direction = isMoving ? this.velocity.clone().normalize() : new Vector2(0, 0);\n const cardinalDirection = this.computeCardinalDirection(direction);\n\n // Update state to support hysteresis\n if (cardinalDirection !== 'idle') {\n this.lastCardinalDirection = cardinalDirection;\n }\n\n if (this.directionSyncHandlers.size === 0) {\n return;\n }\n\n const payload: EntityDirectionSyncEvent = {\n entity: this,\n direction,\n cardinalDirection,\n };\n\n for (const handler of this.directionSyncHandlers) {\n handler(payload);\n }\n }\n\n /**\n * Gets the current cardinal direction.\n * \n * This value is updated whenever `notifyDirectionChange()` is called (e.g. by `setVelocity`).\n * It includes hysteresis logic to prevent rapid direction flipping during collisions.\n * \n * @returns The current cardinal direction ('up', 'down', 'left', 'right', 'idle')\n * \n * @example\n * ```typescript\n * const dir = entity.cardinalDirection;\n * if (dir === 'left') {\n * // Render left-facing sprite\n * }\n * ```\n */\n public get cardinalDirection(): CardinalDirection {\n return this.lastCardinalDirection;\n }\n\n /**\n * Registers a handler fired when the entity movement state changes (moving/stopped).\n *\n * - **Purpose:** detect when an entity starts or stops moving for gameplay reactions, animations, or network sync.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n * - **Movement detection:** uses `MOVEMENT_EPSILON` threshold to determine if entity is moving.\n * - **Intensity:** provides the movement speed magnitude to allow fine-grained animation control (e.g., walk vs run).\n *\n * @param handler - Movement state change listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onMovementChange(({ isMoving, intensity }) => {\n * console.log('Entity is', isMoving ? 'moving' : 'stopped', 'at speed', intensity);\n * // Update animations based on intensity\n * if (isMoving && intensity > 100) {\n * // Fast movement - use run animation\n * } else if (isMoving) {\n * // Slow movement - use walk animation\n * }\n * });\n * ```\n */\n public onMovementChange(handler: EntityMovementChangeHandler): () => void {\n this.movementChangeHandlers.add(handler);\n return () => this.movementChangeHandlers.delete(handler);\n }\n\n /**\n * Manually notifies that the movement state has changed.\n *\n * - **Purpose:** allow external code to trigger movement state sync hooks when velocity is modified directly.\n * - **Design:** checks if movement state (moving/stopped) has changed and notifies handlers with movement intensity.\n * - **Intensity:** calculated as the magnitude of the velocity vector (speed in pixels per second).\n *\n * @example\n * ```typescript\n * entity.velocity.set(5, 0);\n * entity.notifyMovementChange(); // Trigger sync hooks if state changed\n * ```\n */\n public notifyMovementChange(): void {\n const isMoving = this.velocity.lengthSquared() > MOVEMENT_EPSILON_SQ;\n const intensity = this.velocity.length(); // Movement speed magnitude\n\n if (this.movementChangeHandlers.size === 0) {\n // Still update wasMoving even if no handlers to track state correctly\n this.wasMoving = isMoving;\n return;\n }\n\n // Only notify if state actually changed\n if (isMoving !== this.wasMoving) {\n this.wasMoving = isMoving;\n\n const payload: EntityMovementChangeEvent = {\n entity: this,\n isMoving,\n intensity,\n };\n\n for (const handler of this.movementChangeHandlers) {\n handler(payload);\n }\n } else {\n // Update wasMoving even if state didn't change to keep it in sync\n this.wasMoving = isMoving;\n }\n }\n\n /**\n * Registers a handler fired when the entity enters a new tile.\n * \n * @param handler - Tile enter listener\n * @returns Unsubscribe closure\n */\n public onEnterTile(handler: EntityTileHandler): () => void {\n this.enterTileHandlers.add(handler);\n return () => this.enterTileHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when the entity leaves a tile.\n * \n * @param handler - Tile leave listener\n * @returns Unsubscribe closure\n */\n public onLeaveTile(handler: EntityTileHandler): () => void {\n this.leaveTileHandlers.add(handler);\n return () => this.leaveTileHandlers.delete(handler);\n }\n\n /**\n * Registers a handler to check if the entity can enter a tile.\n * If any handler returns false, the entity cannot enter.\n * \n * @param handler - Can enter tile listener\n * @returns Unsubscribe closure\n */\n public canEnterTile(handler: EntityCanEnterTileHandler): () => void {\n this.canEnterTileHandlers.add(handler);\n return () => this.canEnterTileHandlers.delete(handler);\n }\n\n /**\n * @internal\n * Notifies that the entity has entered a tile.\n */\n public notifyEnterTile(x: number, y: number): void {\n if (this.enterTileHandlers.size === 0) return;\n const event: EntityTileEvent = { entity: this, x, y };\n for (const handler of this.enterTileHandlers) {\n handler(event);\n }\n }\n\n /**\n * @internal\n * Notifies that the entity has left a tile.\n */\n public notifyLeaveTile(x: number, y: number): void {\n if (this.leaveTileHandlers.size === 0) return;\n const event: EntityTileEvent = { entity: this, x, y };\n for (const handler of this.leaveTileHandlers) {\n handler(event);\n }\n }\n\n /**\n * @internal\n * Checks if the entity can enter a tile.\n */\n public checkCanEnterTile(x: number, y: number): boolean {\n if (this.canEnterTileHandlers.size === 0) return true;\n const event: EntityTileEvent = { entity: this, x, y };\n for (const handler of this.canEnterTileHandlers) {\n if (handler(event) === false) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Applies a force to the entity\n * \n * Force is accumulated and applied during integration.\n * \n * @param force - Force vector to apply\n * @returns This entity for chaining\n * \n * @example\n * ```typescript\n * entity.applyForce(new Vector2(10, 0)); // Push right\n * ```\n */\n public applyForce(force: Vector2): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n this.force.addInPlace(force);\n return this;\n }\n\n /**\n * Applies a force at a specific point (creates torque)\n * \n * @param force - Force vector to apply\n * @param point - Point of application in world space\n * @returns This entity for chaining\n */\n public applyForceAtPoint(force: Vector2, point: Vector2): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n this.force.addInPlace(force);\n\n // Calculate torque: r × F\n const r = point.sub(this.position);\n this.torque += r.cross(force);\n\n return this;\n }\n\n /**\n * Applies an impulse (instantaneous change in velocity)\n * \n * @param impulse - Impulse vector\n * @returns This entity for chaining\n * \n * @example\n * ```typescript\n * entity.applyImpulse(new Vector2(5, 0)); // Instant push\n * ```\n */\n public applyImpulse(impulse: Vector2): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n this.velocity.addInPlace(impulse.mul(this.invMass));\n this.notifyMovementChange();\n this.notifyDirectionChange();\n return this;\n }\n\n /**\n * Applies an angular impulse (instantaneous change in angular velocity)\n * \n * @param impulse - Angular impulse value\n * @returns This entity for chaining\n */\n public applyAngularImpulse(impulse: number): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n // Simplified: assume moment of inertia = mass * radius^2\n const momentOfInertia = this.mass * this.radius * this.radius;\n if (momentOfInertia > 0) {\n this.angularVelocity += impulse / momentOfInertia;\n }\n return this;\n }\n\n /**\n * Teleports the entity to a new position\n * \n * @param position - New position\n * @returns This entity for chaining\n */\n public teleport(position: Vector2 | { x: number; y: number }): Entity {\n if (position instanceof Vector2) {\n this.position.copyFrom(position);\n } else {\n this.position.set(position.x, position.y);\n }\n this.wakeUp();\n this.notifyPositionChange();\n return this;\n }\n\n /**\n * Sets the velocity directly\n * \n * @param velocity - New velocity\n * @returns This entity for chaining\n */\n public setVelocity(velocity: Vector2 | { x: number; y: number }): Entity {\n const oldVelocity = this.velocity.clone();\n if (velocity instanceof Vector2) {\n this.velocity.copyFrom(velocity);\n } else {\n this.velocity.set(velocity.x, velocity.y);\n }\n this.wakeUp();\n\n // Check if direction changed\n const oldDirection = oldVelocity.lengthSquared() > MOVEMENT_EPSILON_SQ\n ? oldVelocity.clone().normalize()\n : new Vector2(0, 0);\n const newDirection = this.velocity.lengthSquared() > MOVEMENT_EPSILON_SQ\n ? this.velocity.clone().normalize()\n : new Vector2(0, 0);\n\n const oldCardinal = this.computeCardinalDirection(oldDirection);\n const newCardinal = this.computeCardinalDirection(newDirection);\n\n if (oldCardinal !== newCardinal || Math.abs(oldDirection.dot(newDirection) - 1) > 0.01) {\n this.notifyDirectionChange();\n }\n\n // Check if movement state changed\n this.notifyMovementChange();\n\n return this;\n }\n\n /**\n * Freezes the entity (makes it static)\n * \n * @returns This entity for chaining\n */\n public freeze(): Entity {\n this.state = EntityState.Static;\n this.velocity.set(0, 0);\n this.angularVelocity = 0;\n this.force.set(0, 0);\n this.torque = 0;\n this.notifyMovementChange();\n return this;\n }\n\n /**\n * Unfreezes the entity (makes it dynamic)\n * \n * @returns This entity for chaining\n */\n public unfreeze(): Entity {\n if (this.mass > 0) {\n this.state = EntityState.Dynamic;\n }\n return this;\n }\n\n /**\n * Puts the entity to sleep (stops updating)\n * \n * @returns This entity for chaining\n */\n public sleep(): Entity {\n if (!this.isStatic()) {\n this.state |= EntityState.Sleeping;\n this.velocity.set(0, 0);\n this.angularVelocity = 0;\n this.force.set(0, 0);\n this.torque = 0;\n this.notifyMovementChange();\n }\n return this;\n }\n\n /**\n * Wakes up the entity (resumes updating)\n * \n * @returns This entity for chaining\n */\n public wakeUp(): Entity {\n this.state &= ~EntityState.Sleeping;\n this.timeSinceMovement = 0;\n return this;\n }\n\n /**\n * Checks if the entity is static\n * \n * An entity is considered static if:\n * - It has the Static state flag, OR\n * - It has infinite mass (mass = Infinity), OR\n * - It has zero inverse mass (invMass = 0)\n * \n * @returns True if static\n */\n public isStatic(): boolean {\n return (this.state & EntityState.Static) !== 0 || this.invMass === 0;\n }\n\n /**\n * Checks if the entity is dynamic\n * \n * @returns True if dynamic\n */\n public isDynamic(): boolean {\n return (this.state & EntityState.Dynamic) !== 0 && this.mass > 0;\n }\n\n /**\n * Checks if the entity is sleeping\n * \n * @returns True if sleeping\n */\n public isSleeping(): boolean {\n return (this.state & EntityState.Sleeping) !== 0;\n }\n\n /**\n * Checks if the entity is kinematic\n * \n * @returns True if kinematic\n */\n public isKinematic(): boolean {\n return (this.state & EntityState.Kinematic) !== 0;\n }\n\n /**\n * Resets accumulated forces and torques\n * \n * Called at the start of each physics step.\n */\n public clearForces(): void {\n this.force.set(0, 0);\n this.torque = 0;\n }\n\n /**\n * Stops all movement immediately\n * \n * Completely stops the entity's movement by:\n * - Setting velocity to zero\n * - Setting angular velocity to zero\n * - Clearing accumulated forces and torques\n * - Waking up the entity if it was sleeping\n * - Notifying movement state change\n * \n * Unlike `freeze()`, this method keeps the entity dynamic and does not\n * change its state. It's useful for stopping movement when changing maps,\n * teleporting, or when you need to halt an entity without making it static.\n * \n * @returns This entity for chaining\n * \n * @example\n * ```ts\n * // Stop movement when changing maps\n * if (mapChanged) {\n * entity.stopMovement();\n * }\n * \n * // Stop movement after teleporting\n * entity.position.set(100, 200);\n * entity.stopMovement();\n * \n * // Stop movement when player dies\n * if (player.isDead()) {\n * playerEntity.stopMovement();\n * }\n * ```\n */\n public stopMovement(): Entity {\n this.velocity.set(0, 0);\n this.angularVelocity = 0;\n this.clearForces();\n this.wakeUp();\n this.notifyMovementChange();\n this.notifyDirectionChange();\n return this;\n }\n\n /**\n * Clamps velocities to maximum values\n */\n public clampVelocities(): void {\n const speed = this.velocity.length();\n if (speed > this.maxLinearVelocity) {\n this.velocity.normalizeInPlace().mulInPlace(this.maxLinearVelocity);\n }\n\n if (Math.abs(this.angularVelocity) > this.maxAngularVelocity) {\n this.angularVelocity = Math.sign(this.angularVelocity) * this.maxAngularVelocity;\n }\n }\n\n /**\n * Checks if this entity can collide with another entity\n * \n * @param other - Other entity to check\n * @returns True if collision is possible\n */\n public canCollideWith(other: Entity): boolean {\n // Check collision masks\n const categoryA = this.collisionCategory;\n const maskA = this.collisionMask;\n const categoryB = other.collisionCategory;\n const maskB = other.collisionMask;\n\n return (categoryA & maskB) !== 0 && (categoryB & maskA) !== 0;\n }\n\n /**\n * @internal\n *\n * Notifies the entity that a collision has started.\n *\n * @param collision - Collision information shared by the world\n * @param other - The counterpart entity\n */\n public notifyCollisionEnter(collision: CollisionInfo, other: Entity): void {\n if (this.collisionEnterHandlers.size === 0) {\n return;\n }\n\n const payload: EntityCollisionEvent = {\n entity: this,\n other,\n collision,\n };\n\n for (const handler of this.collisionEnterHandlers) {\n handler(payload);\n }\n }\n\n /**\n * @internal\n *\n * Notifies the entity that a collision has ended.\n *\n * @param collision - Collision information stored before separation\n * @param other - The counterpart entity\n */\n public notifyCollisionExit(collision: CollisionInfo, other: Entity): void {\n if (this.collisionExitHandlers.size === 0) {\n return;\n }\n\n const payload: EntityCollisionEvent = {\n entity: this,\n other,\n collision,\n };\n\n for (const handler of this.collisionExitHandlers) {\n handler(payload);\n }\n }\n\n\n private computeCardinalDirection(direction: Vector2): CardinalDirection {\n if (direction.lengthSquared() <= MOVEMENT_EPSILON_SQ) {\n return 'idle';\n }\n\n // If we were idle, just return the strongest direction without bias\n if (this.lastCardinalDirection === 'idle') {\n const absX = Math.abs(direction.x);\n const absY = Math.abs(direction.y);\n if (absX >= absY) {\n return direction.x >= 0 ? 'right' : 'left';\n }\n return direction.y >= 0 ? 'down' : 'up';\n }\n\n // Check for 180-degree flips (Bounce protection)\n // If the new direction is strictly opposite to the last one, we require a higher velocity\n // to accept the change. This filters out collision rebounds.\n const isOpposite =\n (this.lastCardinalDirection === 'left' && direction.x > 0.5) ||\n (this.lastCardinalDirection === 'right' && direction.x < -0.5) ||\n (this.lastCardinalDirection === 'up' && direction.y > 0.5) ||\n (this.lastCardinalDirection === 'down' && direction.y < -0.5);\n\n const speedSq = this.velocity.lengthSquared();\n\n // Threshold to accept a 180-degree turn (avoid jitter on bounce)\n // We expect a \"real\" turn to have some acceleration or accumulated velocity\n if (isOpposite && speedSq < 100.0) { // Speed < 10\n return this.lastCardinalDirection;\n }\n\n const absX = Math.abs(direction.x);\n const absY = Math.abs(direction.y);\n const bias = 2.0; // Strong bias to keep current direction\n\n // Hysteresis: favor current axis if we have a valid last direction\n if (['left', 'right'].includes(this.lastCardinalDirection)) {\n // Currently horizontal: stick to it unless vertical is significantly stronger\n // AND vertical component has meaningful speed (prevents slide when blocked)\n if (absY > absX * bias) {\n // Check if the \"new\" vertical movement is actually significant\n // e.g. if we are blocked Horizontally (x=0), absY will win even if it's 0.0001 without this check\n if (Math.abs(this.velocity.y) > 5.0) {\n return direction.y >= 0 ? 'down' : 'up';\n }\n }\n // Default: keep horizontal orientation, just update sign if needed (and not filtered by opposite check)\n // If we are here, it means we didn't switch axis, and we didn't trigger the \"Opposite\" guard above.\n // However, if we are \"blocked\" (velocity very low), we should probably not even flip sign.\n if (speedSq > 1.0) {\n return direction.x >= 0 ? 'right' : 'left';\n }\n return this.lastCardinalDirection;\n } else {\n // Currently vertical: stick to it unless horizontal is significantly stronger\n if (absX > absY * bias) {\n if (Math.abs(this.velocity.x) > 5.0) {\n return direction.x >= 0 ? 'right' : 'left';\n }\n }\n if (speedSq > 1.0) {\n return direction.y >= 0 ? 'down' : 'up';\n }\n return this.lastCardinalDirection;\n }\n }\n\n /**\n * Creates a copy of this entity\n * \n * @returns New entity with copied properties\n */\n public clone(): Entity {\n const entity = new Entity({\n position: this.position.clone(),\n velocity: this.velocity.clone(),\n rotation: this.rotation,\n angularVelocity: this.angularVelocity,\n mass: this.mass,\n radius: this.radius,\n width: this.width,\n height: this.height,\n state: this.state,\n restitution: this.restitution,\n friction: this.friction,\n linearDamping: this.linearDamping,\n angularDamping: this.angularDamping,\n maxLinearVelocity: this.maxLinearVelocity,\n maxAngularVelocity: this.maxAngularVelocity,\n collisionMask: this.collisionMask,\n collisionCategory: this.collisionCategory,\n uuid: this.uuid,\n });\n return entity;\n }\n}\n\nexport interface EntityCollisionEvent {\n entity: Entity;\n other: Entity;\n collision: CollisionInfo;\n}\n\nexport type EntityCollisionHandler = (event: EntityCollisionEvent) => void;\n\n\nexport interface EntityPositionSyncEvent {\n entity: Entity;\n x: number;\n y: number;\n}\n\nexport type EntityPositionSyncHandler = (event: EntityPositionSyncEvent) => void;\n\nexport interface EntityDirectionSyncEvent {\n entity: Entity;\n direction: Vector2;\n cardinalDirection: CardinalDirection;\n}\n\nexport type EntityDirectionSyncHandler = (event: EntityDirectionSyncEvent) => void;\n\nexport interface EntityMovementChangeEvent {\n entity: Entity;\n isMoving: boolean;\n /** Movement intensity (speed magnitude) */\n intensity: number;\n}\n\nexport type EntityMovementChangeHandler = (event: EntityMovementChangeEvent) => void;\n\nexport interface EntityTileEvent {\n entity: Entity;\n x: number;\n y: number;\n}\n\nexport type EntityTileHandler = (event: EntityTileEvent) => void;\nexport type EntityCanEnterTileHandler = (event: EntityTileEvent) => boolean;\n\n\n"],"names":["absX","absY"],"mappings":";;;AAKA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB,mBAAmB;AAC/C,MAAM,6BAA6B;AACnC,MAAM,gCAAgC,6BAA6B;AAqF5D,MAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsJlB,YAAY,SAAuB,IAAI;AAPvC,SAAQ,wBAA2C;AASjD,SAAK,OAAO,OAAO,QAAQ,aAAA;AAG3B,QAAI,OAAO,oBAAoB,SAAS;AACtC,WAAK,WAAW,OAAO,SAAS,MAAA;AAAA,IAClC,WAAW,OAAO,UAAU;AAC1B,WAAK,WAAW,IAAI,QAAQ,OAAO,SAAS,GAAG,OAAO,SAAS,CAAC;AAAA,IAClE,OAAO;AACL,WAAK,WAAW,IAAI,QAAQ,GAAG,CAAC;AAAA,IAClC;AAEA,SAAK,cAAc,IAAI,QAAQ,GAAG,CAAC;AAEnC,QAAI,OAAO,oBAAoB,SAAS;AACtC,WAAK,WAAW,OAAO,SAAS,MAAA;AAAA,IAClC,WAAW,OAAO,UAAU;AAC1B,WAAK,WAAW,IAAI,QAAQ,OAAO,SAAS,GAAG,OAAO,SAAS,CAAC;AAAA,IAClE,OAAO;AACL,WAAK,WAAW,IAAI,QAAQ,GAAG,CAAC;AAAA,IAClC;AAGA,SAAK,WAAW,OAAO,YAAY;AACnC,SAAK,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BAAiB,KAAK;AAAA,MACtB,MAAM,KAAK;AAAA,MACX,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,UAAU,KAAK;AAAA,MACf,eAAe,KAAK;AAAA,MACpB,gBAAgB,KAAK;AAAA,MACrB,mBAAmB,KAAK;AAAA,MACxB,oBAAoB,KAAK;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,mBAAmB,KAAK;AAAA,MACxB,MAAM,KAAK;AAAA,IAAA,CACZ;AACD,WAAO;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"index7.js","sources":["../src/physics/Entity.ts"],"sourcesContent":["import { Vector2 } from '../core/math/Vector2';\nimport { UUID, EntityState } from '../core/types';\nimport { generateUUID } from '../utils/uuid';\nimport { CollisionInfo } from '../collision/Collider';\n\nconst MOVEMENT_EPSILON = 1e-3;\nconst MOVEMENT_EPSILON_SQ = MOVEMENT_EPSILON * MOVEMENT_EPSILON;\nconst DIRECTION_CHANGE_THRESHOLD = 1.0;\nconst DIRECTION_CHANGE_THRESHOLD_SQ = DIRECTION_CHANGE_THRESHOLD * DIRECTION_CHANGE_THRESHOLD;\n\nexport type CardinalDirection = 'idle' | 'up' | 'down' | 'left' | 'right';\n\n/**\n * Configuration options for creating an entity\n */\nexport interface EntityConfig {\n /** Initial position */\n position?: Vector2 | { x: number; y: number };\n /** Initial velocity */\n velocity?: Vector2 | { x: number; y: number };\n /** Initial rotation in radians */\n rotation?: number;\n /** Initial angular velocity in radians per second */\n angularVelocity?: number;\n /** Mass of the entity (0 or Infinity for static/immovable entities) */\n mass?: number;\n /** Radius for circular collider */\n radius?: number;\n /** Width for AABB collider */\n width?: number;\n /** Height for AABB collider */\n height?: number;\n /** Capsule collider configuration (if used) */\n capsule?: {\n radius: number;\n height: number;\n };\n /** Enable continuous collision detection (CCD) */\n continuous?: boolean;\n /** Entity state flags */\n state?: EntityState;\n /** Restitution (bounciness) coefficient (0-1) */\n restitution?: number;\n /** Friction coefficient */\n friction?: number;\n /** Linear damping (0-1, higher = more damping) */\n linearDamping?: number;\n /** Angular damping (0-1, higher = more damping) */\n angularDamping?: number;\n /** Maximum linear velocity */\n maxLinearVelocity?: number;\n /** Maximum angular velocity */\n maxAngularVelocity?: number;\n /** Custom UUID (auto-generated if not provided) */\n uuid?: UUID;\n /** Collision mask (bitmask for collision filtering) */\n collisionMask?: number;\n /** Collision category (bitmask) */\n collisionCategory?: number;\n}\n\n/**\n * Physical entity in the physics world\n * \n * Represents a dynamic or static object that can be affected by forces,\n * collisions, and other physical interactions.\n * \n * ## Creating Static Obstacles\n * \n * To create immovable obstacles (walls, decorations), set `mass` to `0` or `Infinity`.\n * This makes the entity static - it will block other entities but cannot be pushed.\n * \n * @example\n * ```typescript\n * // Dynamic entity (player, movable object)\n * const player = new Entity({\n * position: { x: 0, y: 0 },\n * radius: 10,\n * mass: 1,\n * velocity: { x: 5, y: 0 }\n * });\n * \n * // Static obstacle (wall, tree, decoration)\n * const wall = new Entity({\n * position: { x: 100, y: 0 },\n * width: 20,\n * height: 100,\n * mass: Infinity // or mass: 0\n * });\n * \n * player.applyForce(new Vector2(10, 0));\n * ```\n */\nexport class Entity {\n /**\n * Unique identifier (UUID)\n */\n public readonly uuid: UUID;\n\n /**\n * Position in world space\n */\n public position: Vector2;\n\n /**\n * Linear velocity\n */\n public velocity: Vector2;\n\n /**\n * Rotation in radians\n */\n public rotation: number;\n\n /**\n * Angular velocity in radians per second\n */\n public angularVelocity: number;\n\n /**\n * Mass (0 or Infinity means infinite mass / static)\n */\n public mass: number;\n\n /**\n * Inverse mass (cached for performance, 0 if mass is 0 or Infinity)\n */\n public invMass: number;\n\n /**\n * Radius for circular collider (if used)\n */\n public radius: number;\n\n /**\n * Width for AABB collider (if used)\n */\n public width: number;\n\n /**\n * Height for AABB collider (if used)\n */\n public height: number;\n\n /**\n * Capsule collider configuration (if used)\n */\n public capsule?: {\n radius: number;\n height: number;\n };\n\n /**\n * Enable continuous collision detection (CCD)\n */\n public continuous: boolean;\n\n /**\n * Entity state flags\n */\n public state: EntityState;\n\n /**\n * Restitution (bounciness) coefficient (0-1)\n */\n public restitution: number;\n\n /**\n * Friction coefficient\n */\n public friction: number;\n\n /**\n * Linear damping (0-1)\n */\n public linearDamping: number;\n\n /**\n * Angular damping (0-1)\n */\n public angularDamping: number;\n\n /**\n * Maximum linear velocity\n */\n public maxLinearVelocity: number;\n\n /**\n * Maximum angular velocity\n */\n public maxAngularVelocity: number;\n\n /**\n * Accumulated force for this frame\n */\n public force: Vector2;\n\n /**\n * Accumulated torque for this frame\n */\n public torque: number;\n\n /**\n * Collision mask (bitmask)\n */\n public collisionMask: number;\n\n /**\n * Collision category (bitmask)\n */\n public collisionCategory: number;\n\n /**\n * Time since last movement (for sleep detection)\n */\n public timeSinceMovement: number;\n\n /**\n * Threshold for sleep detection (seconds of inactivity)\n */\n public sleepThreshold: number;\n\n /**\n * Current tile coordinates (x, y)\n */\n public currentTile: Vector2;\n\n private collisionEnterHandlers: Set<EntityCollisionHandler>;\n private collisionExitHandlers: Set<EntityCollisionHandler>;\n private positionSyncHandlers: Set<EntityPositionSyncHandler>;\n private directionSyncHandlers: Set<EntityDirectionSyncHandler>;\n private movementChangeHandlers: Set<EntityMovementChangeHandler>;\n private enterTileHandlers: Set<EntityTileHandler>;\n private leaveTileHandlers: Set<EntityTileHandler>;\n private canEnterTileHandlers: Set<EntityCanEnterTileHandler>;\n private wasMoving: boolean;\n private lastCardinalDirection: CardinalDirection = 'idle';\n\n /**\n * Creates a new entity\n * \n * @param config - Entity configuration\n */\n constructor(config: EntityConfig = {}) {\n // Generate UUID if not provided\n this.uuid = config.uuid ?? generateUUID();\n\n // Position and velocity\n if (config.position instanceof Vector2) {\n this.position = config.position.clone();\n } else if (config.position) {\n this.position = new Vector2(config.position.x, config.position.y);\n } else {\n this.position = new Vector2(0, 0);\n }\n\n this.currentTile = new Vector2(0, 0); // Will be updated by World\n\n if (config.velocity instanceof Vector2) {\n this.velocity = config.velocity.clone();\n } else if (config.velocity) {\n this.velocity = new Vector2(config.velocity.x, config.velocity.y);\n } else {\n this.velocity = new Vector2(0, 0);\n }\n\n // Rotation\n this.rotation = config.rotation ?? 0;\n this.angularVelocity = config.angularVelocity ?? 0;\n\n // Mass\n this.mass = config.mass ?? 1;\n this.invMass = this.mass > 0 ? 1 / this.mass : 0;\n\n // Collider dimensions\n this.radius = config.radius ?? 0;\n this.width = config.width ?? 0;\n this.height = config.height ?? 0;\n if (config.capsule !== undefined) {\n this.capsule = config.capsule;\n }\n this.continuous = config.continuous ?? false;\n\n // State\n this.state = config.state ?? EntityState.Dynamic;\n\n // Material properties\n this.restitution = config.restitution ?? 0.2;\n this.friction = config.friction ?? 0.3;\n this.linearDamping = config.linearDamping ?? 0.01;\n this.angularDamping = config.angularDamping ?? 0.01;\n\n // Velocity limits\n this.maxLinearVelocity = config.maxLinearVelocity ?? Infinity;\n this.maxAngularVelocity = config.maxAngularVelocity ?? Infinity;\n\n // Forces\n this.force = new Vector2(0, 0);\n this.torque = 0;\n\n // Collision filtering\n this.collisionMask = config.collisionMask ?? 0xffffffff;\n this.collisionCategory = config.collisionCategory ?? 0x00000001;\n\n // Sleep detection\n this.timeSinceMovement = 0;\n this.sleepThreshold = 0.5; // 0.5 seconds of inactivity\n\n // Event handlers\n this.collisionEnterHandlers = new Set();\n this.collisionExitHandlers = new Set();\n this.positionSyncHandlers = new Set();\n this.directionSyncHandlers = new Set();\n this.positionSyncHandlers = new Set();\n this.directionSyncHandlers = new Set();\n this.movementChangeHandlers = new Set();\n this.enterTileHandlers = new Set();\n this.leaveTileHandlers = new Set();\n this.canEnterTileHandlers = new Set();\n\n // Initialize movement state\n this.wasMoving = this.velocity.lengthSquared() > MOVEMENT_EPSILON_SQ;\n }\n\n /**\n * Registers a handler fired when this entity starts colliding with another one.\n *\n * - **Purpose:** offer per-entity collision hooks without subscribing to the global event system.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n *\n * @param handler - Collision enter listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onCollisionEnter(({ other }) => {\n * console.log('Started colliding with', other.uuid);\n * });\n * ```\n */\n public onCollisionEnter(handler: EntityCollisionHandler): () => void {\n this.collisionEnterHandlers.add(handler);\n return () => this.collisionEnterHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when this entity stops colliding with another one.\n *\n * - **Purpose:** detect collision separation at the entity level for local gameplay reactions.\n * - **Design:** mirrors `onCollisionEnter` with identical lifecycle management semantics.\n *\n * @param handler - Collision exit listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onCollisionExit(({ other }) => {\n * console.log('Stopped colliding with', other.uuid);\n * });\n * ```\n */\n public onCollisionExit(handler: EntityCollisionHandler): () => void {\n this.collisionExitHandlers.add(handler);\n return () => this.collisionExitHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when the entity position changes (x, y).\n *\n * - **Purpose:** synchronize position changes for logging, rendering, network sync, etc.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n *\n * @param handler - Position change listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onPositionChange(({ x, y }) => {\n * console.log('Position changed to', x, y);\n * // Update rendering, sync network, etc.\n * });\n * ```\n */\n public onPositionChange(handler: EntityPositionSyncHandler): () => void {\n this.positionSyncHandlers.add(handler);\n return () => this.positionSyncHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when the entity direction changes.\n *\n * - **Purpose:** synchronize direction changes for logging, rendering, network sync, etc.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n *\n * @param handler - Direction change listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onDirectionChange(({ direction, cardinalDirection }) => {\n * console.log('Direction changed to', cardinalDirection);\n * // Update rendering, sync network, etc.\n * });\n * ```\n */\n public onDirectionChange(handler: EntityDirectionSyncHandler): () => void {\n this.directionSyncHandlers.add(handler);\n return () => this.directionSyncHandlers.delete(handler);\n }\n\n /**\n * Manually notifies that the position has changed.\n *\n * - **Purpose:** allow external code to trigger position sync hooks when position is modified directly.\n * - **Design:** can be called after direct position modifications (e.g., `entity.position.set()`).\n *\n * @example\n * ```typescript\n * entity.position.set(100, 200);\n * entity.notifyPositionChange(); // Trigger sync hooks\n * ```\n */\n public notifyPositionChange(): void {\n if (this.positionSyncHandlers.size === 0) {\n return;\n }\n\n const payload: EntityPositionSyncEvent = {\n entity: this,\n x: this.position.x,\n y: this.position.y,\n };\n\n for (const handler of this.positionSyncHandlers) {\n handler(payload);\n }\n }\n\n /**\n * Manually notifies that the direction has changed.\n *\n * - **Purpose:** allow external code to trigger direction sync hooks when direction is modified directly.\n * - **Design:** computes direction from velocity and cardinal direction.\n *\n * @example\n * ```typescript\n * entity.velocity.set(5, 0);\n * entity.notifyDirectionChange(); // Trigger sync hooks\n * ```\n */\n public notifyDirectionChange(): void {\n const isMoving = this.velocity.lengthSquared() > DIRECTION_CHANGE_THRESHOLD_SQ;\n const direction = isMoving ? this.velocity.clone().normalize() : new Vector2(0, 0);\n const cardinalDirection = this.computeCardinalDirection(direction);\n\n // Update state to support hysteresis\n if (cardinalDirection !== 'idle') {\n this.lastCardinalDirection = cardinalDirection;\n }\n\n if (this.directionSyncHandlers.size === 0) {\n return;\n }\n\n const payload: EntityDirectionSyncEvent = {\n entity: this,\n direction,\n cardinalDirection,\n };\n\n for (const handler of this.directionSyncHandlers) {\n handler(payload);\n }\n }\n\n /**\n * Gets the current cardinal direction.\n * \n * This value is updated whenever `notifyDirectionChange()` is called (e.g. by `setVelocity`).\n * It includes hysteresis logic to prevent rapid direction flipping during collisions.\n * \n * @returns The current cardinal direction ('up', 'down', 'left', 'right', 'idle')\n * \n * @example\n * ```typescript\n * const dir = entity.cardinalDirection;\n * if (dir === 'left') {\n * // Render left-facing sprite\n * }\n * ```\n */\n public get cardinalDirection(): CardinalDirection {\n return this.lastCardinalDirection;\n }\n\n /**\n * Registers a handler fired when the entity movement state changes (moving/stopped).\n *\n * - **Purpose:** detect when an entity starts or stops moving for gameplay reactions, animations, or network sync.\n * - **Design:** lightweight Set-based listeners returning an unsubscribe closure to keep GC pressure low.\n * - **Movement detection:** uses `MOVEMENT_EPSILON` threshold to determine if entity is moving.\n * - **Intensity:** provides the movement speed magnitude to allow fine-grained animation control (e.g., walk vs run).\n *\n * @param handler - Movement state change listener\n * @returns Unsubscribe closure\n * @example\n * ```typescript\n * const unsubscribe = entity.onMovementChange(({ isMoving, intensity }) => {\n * console.log('Entity is', isMoving ? 'moving' : 'stopped', 'at speed', intensity);\n * // Update animations based on intensity\n * if (isMoving && intensity > 100) {\n * // Fast movement - use run animation\n * } else if (isMoving) {\n * // Slow movement - use walk animation\n * }\n * });\n * ```\n */\n public onMovementChange(handler: EntityMovementChangeHandler): () => void {\n this.movementChangeHandlers.add(handler);\n return () => this.movementChangeHandlers.delete(handler);\n }\n\n /**\n * Manually notifies that the movement state has changed.\n *\n * - **Purpose:** allow external code to trigger movement state sync hooks when velocity is modified directly.\n * - **Design:** checks if movement state (moving/stopped) has changed and notifies handlers with movement intensity.\n * - **Intensity:** calculated as the magnitude of the velocity vector (speed in pixels per second).\n *\n * @example\n * ```typescript\n * entity.velocity.set(5, 0);\n * entity.notifyMovementChange(); // Trigger sync hooks if state changed\n * ```\n */\n public notifyMovementChange(): void {\n const isMoving = this.velocity.lengthSquared() > MOVEMENT_EPSILON_SQ;\n const intensity = this.velocity.length(); // Movement speed magnitude\n\n if (this.movementChangeHandlers.size === 0) {\n // Still update wasMoving even if no handlers to track state correctly\n this.wasMoving = isMoving;\n return;\n }\n\n // Only notify if state actually changed\n if (isMoving !== this.wasMoving) {\n this.wasMoving = isMoving;\n\n const payload: EntityMovementChangeEvent = {\n entity: this,\n isMoving,\n intensity,\n };\n\n for (const handler of this.movementChangeHandlers) {\n handler(payload);\n }\n } else {\n // Update wasMoving even if state didn't change to keep it in sync\n this.wasMoving = isMoving;\n }\n }\n\n /**\n * Registers a handler fired when the entity enters a new tile.\n * \n * @param handler - Tile enter listener\n * @returns Unsubscribe closure\n */\n public onEnterTile(handler: EntityTileHandler): () => void {\n this.enterTileHandlers.add(handler);\n return () => this.enterTileHandlers.delete(handler);\n }\n\n /**\n * Registers a handler fired when the entity leaves a tile.\n * \n * @param handler - Tile leave listener\n * @returns Unsubscribe closure\n */\n public onLeaveTile(handler: EntityTileHandler): () => void {\n this.leaveTileHandlers.add(handler);\n return () => this.leaveTileHandlers.delete(handler);\n }\n\n /**\n * Registers a handler to check if the entity can enter a tile.\n * If any handler returns false, the entity cannot enter.\n * \n * @param handler - Can enter tile listener\n * @returns Unsubscribe closure\n */\n public canEnterTile(handler: EntityCanEnterTileHandler): () => void {\n this.canEnterTileHandlers.add(handler);\n return () => this.canEnterTileHandlers.delete(handler);\n }\n\n /**\n * @internal\n * Notifies that the entity has entered a tile.\n */\n public notifyEnterTile(x: number, y: number): void {\n if (this.enterTileHandlers.size === 0) return;\n const event: EntityTileEvent = { entity: this, x, y };\n for (const handler of this.enterTileHandlers) {\n handler(event);\n }\n }\n\n /**\n * @internal\n * Notifies that the entity has left a tile.\n */\n public notifyLeaveTile(x: number, y: number): void {\n if (this.leaveTileHandlers.size === 0) return;\n const event: EntityTileEvent = { entity: this, x, y };\n for (const handler of this.leaveTileHandlers) {\n handler(event);\n }\n }\n\n /**\n * @internal\n * Checks if the entity can enter a tile.\n */\n public checkCanEnterTile(x: number, y: number): boolean {\n if (this.canEnterTileHandlers.size === 0) return true;\n const event: EntityTileEvent = { entity: this, x, y };\n for (const handler of this.canEnterTileHandlers) {\n if (handler(event) === false) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Applies a force to the entity\n * \n * Force is accumulated and applied during integration.\n * \n * @param force - Force vector to apply\n * @returns This entity for chaining\n * \n * @example\n * ```typescript\n * entity.applyForce(new Vector2(10, 0)); // Push right\n * ```\n */\n public applyForce(force: Vector2): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n this.force.addInPlace(force);\n return this;\n }\n\n /**\n * Applies a force at a specific point (creates torque)\n * \n * @param force - Force vector to apply\n * @param point - Point of application in world space\n * @returns This entity for chaining\n */\n public applyForceAtPoint(force: Vector2, point: Vector2): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n this.force.addInPlace(force);\n\n // Calculate torque: r × F\n const r = point.sub(this.position);\n this.torque += r.cross(force);\n\n return this;\n }\n\n /**\n * Applies an impulse (instantaneous change in velocity)\n * \n * @param impulse - Impulse vector\n * @returns This entity for chaining\n * \n * @example\n * ```typescript\n * entity.applyImpulse(new Vector2(5, 0)); // Instant push\n * ```\n */\n public applyImpulse(impulse: Vector2): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n this.velocity.addInPlace(impulse.mul(this.invMass));\n this.notifyMovementChange();\n this.notifyDirectionChange();\n return this;\n }\n\n /**\n * Applies an angular impulse (instantaneous change in angular velocity)\n * \n * @param impulse - Angular impulse value\n * @returns This entity for chaining\n */\n public applyAngularImpulse(impulse: number): Entity {\n if (this.isStatic() || this.isSleeping()) {\n return this;\n }\n // Simplified: assume moment of inertia = mass * radius^2\n const momentOfInertia = this.mass * this.radius * this.radius;\n if (momentOfInertia > 0) {\n this.angularVelocity += impulse / momentOfInertia;\n }\n return this;\n }\n\n /**\n * Teleports the entity to a new position\n * \n * @param position - New position\n * @returns This entity for chaining\n */\n public teleport(position: Vector2 | { x: number; y: number }): Entity {\n if (position instanceof Vector2) {\n this.position.copyFrom(position);\n } else {\n this.position.set(position.x, position.y);\n }\n this.wakeUp();\n this.notifyPositionChange();\n return this;\n }\n\n /**\n * Sets the velocity directly\n * \n * @param velocity - New velocity\n * @returns This entity for chaining\n */\n public setVelocity(velocity: Vector2 | { x: number; y: number }): Entity {\n const oldVelocity = this.velocity.clone();\n\n if (velocity instanceof Vector2) {\n this.velocity.copyFrom(velocity);\n } else {\n this.velocity.set(velocity.x, velocity.y);\n }\n this.wakeUp();\n\n // Check if direction changed\n const oldDirection = oldVelocity.lengthSquared() > MOVEMENT_EPSILON_SQ\n ? oldVelocity.clone().normalize()\n : new Vector2(0, 0);\n const newDirection = this.velocity.lengthSquared() > MOVEMENT_EPSILON_SQ\n ? this.velocity.clone().normalize()\n : new Vector2(0, 0);\n\n const oldCardinal = this.computeCardinalDirection(oldDirection);\n const newCardinal = this.computeCardinalDirection(newDirection);\n\n if (oldCardinal !== newCardinal || Math.abs(oldDirection.dot(newDirection) - 1) > 0.01) {\n this.notifyDirectionChange();\n }\n\n // Check if movement state changed\n this.notifyMovementChange();\n\n return this;\n }\n\n /**\n * Freezes the entity (makes it static)\n * \n * @returns This entity for chaining\n */\n public freeze(): Entity {\n this.state = EntityState.Static;\n this.velocity.set(0, 0);\n this.angularVelocity = 0;\n this.force.set(0, 0);\n this.torque = 0;\n this.notifyMovementChange();\n return this;\n }\n\n /**\n * Unfreezes the entity (makes it dynamic)\n * \n * @returns This entity for chaining\n */\n public unfreeze(): Entity {\n if (this.mass > 0) {\n this.state = EntityState.Dynamic;\n }\n return this;\n }\n\n /**\n * Puts the entity to sleep (stops updating)\n * \n * @returns This entity for chaining\n */\n public sleep(): Entity {\n if (!this.isStatic()) {\n this.state |= EntityState.Sleeping;\n this.velocity.set(0, 0);\n this.angularVelocity = 0;\n this.force.set(0, 0);\n this.torque = 0;\n this.notifyMovementChange();\n }\n return this;\n }\n\n /**\n * Wakes up the entity (resumes updating)\n * \n * @returns This entity for chaining\n */\n public wakeUp(): Entity {\n this.state &= ~EntityState.Sleeping;\n this.timeSinceMovement = 0;\n return this;\n }\n\n /**\n * Checks if the entity is static\n * \n * An entity is considered static if:\n * - It has the Static state flag, OR\n * - It has infinite mass (mass = Infinity), OR\n * - It has zero inverse mass (invMass = 0)\n * \n * @returns True if static\n */\n public isStatic(): boolean {\n return (this.state & EntityState.Static) !== 0 || this.invMass === 0;\n }\n\n /**\n * Checks if the entity is dynamic\n * \n * @returns True if dynamic\n */\n public isDynamic(): boolean {\n return (this.state & EntityState.Dynamic) !== 0 && this.mass > 0;\n }\n\n /**\n * Checks if the entity is sleeping\n * \n * @returns True if sleeping\n */\n public isSleeping(): boolean {\n return (this.state & EntityState.Sleeping) !== 0;\n }\n\n /**\n * Checks if the entity is kinematic\n * \n * @returns True if kinematic\n */\n public isKinematic(): boolean {\n return (this.state & EntityState.Kinematic) !== 0;\n }\n\n /**\n * Resets accumulated forces and torques\n * \n * Called at the start of each physics step.\n */\n public clearForces(): void {\n this.force.set(0, 0);\n this.torque = 0;\n }\n\n /**\n * Stops all movement immediately\n * \n * Completely stops the entity's movement by:\n * - Setting velocity to zero\n * - Setting angular velocity to zero\n * - Clearing accumulated forces and torques\n * - Waking up the entity if it was sleeping\n * - Notifying movement state change\n * \n * Unlike `freeze()`, this method keeps the entity dynamic and does not\n * change its state. It's useful for stopping movement when changing maps,\n * teleporting, or when you need to halt an entity without making it static.\n * \n * @returns This entity for chaining\n * \n * @example\n * ```ts\n * // Stop movement when changing maps\n * if (mapChanged) {\n * entity.stopMovement();\n * }\n * \n * // Stop movement after teleporting\n * entity.position.set(100, 200);\n * entity.stopMovement();\n * \n * // Stop movement when player dies\n * if (player.isDead()) {\n * playerEntity.stopMovement();\n * }\n * ```\n */\n public stopMovement(): Entity {\n this.velocity.set(0, 0);\n this.angularVelocity = 0;\n this.clearForces();\n this.wakeUp();\n this.notifyMovementChange();\n this.notifyDirectionChange();\n return this;\n }\n\n /**\n * Clamps velocities to maximum values\n */\n public clampVelocities(): void {\n const speed = this.velocity.length();\n if (speed > this.maxLinearVelocity) {\n this.velocity.normalizeInPlace().mulInPlace(this.maxLinearVelocity);\n }\n\n if (Math.abs(this.angularVelocity) > this.maxAngularVelocity) {\n this.angularVelocity = Math.sign(this.angularVelocity) * this.maxAngularVelocity;\n }\n }\n\n /**\n * Checks if this entity can collide with another entity\n * \n * @param other - Other entity to check\n * @returns True if collision is possible\n */\n public canCollideWith(other: Entity): boolean {\n // Check collision masks\n const categoryA = this.collisionCategory;\n const maskA = this.collisionMask;\n const categoryB = other.collisionCategory;\n const maskB = other.collisionMask;\n\n return (categoryA & maskB) !== 0 && (categoryB & maskA) !== 0;\n }\n\n /**\n * @internal\n *\n * Notifies the entity that a collision has started.\n *\n * @param collision - Collision information shared by the world\n * @param other - The counterpart entity\n */\n public notifyCollisionEnter(collision: CollisionInfo, other: Entity): void {\n if (this.collisionEnterHandlers.size === 0) {\n return;\n }\n\n const payload: EntityCollisionEvent = {\n entity: this,\n other,\n collision,\n };\n\n for (const handler of this.collisionEnterHandlers) {\n handler(payload);\n }\n }\n\n /**\n * @internal\n *\n * Notifies the entity that a collision has ended.\n *\n * @param collision - Collision information stored before separation\n * @param other - The counterpart entity\n */\n public notifyCollisionExit(collision: CollisionInfo, other: Entity): void {\n if (this.collisionExitHandlers.size === 0) {\n return;\n }\n\n const payload: EntityCollisionEvent = {\n entity: this,\n other,\n collision,\n };\n\n for (const handler of this.collisionExitHandlers) {\n handler(payload);\n }\n }\n\n\n private computeCardinalDirection(direction: Vector2): CardinalDirection {\n if (direction.lengthSquared() <= MOVEMENT_EPSILON_SQ) {\n return 'idle';\n }\n\n // If we were idle, just return the strongest direction without bias\n if (this.lastCardinalDirection === 'idle') {\n const absX = Math.abs(direction.x);\n const absY = Math.abs(direction.y);\n if (absX >= absY) {\n return direction.x >= 0 ? 'right' : 'left';\n }\n return direction.y >= 0 ? 'down' : 'up';\n }\n\n // Check for 180-degree flips (Bounce protection)\n // If the new direction is strictly opposite to the last one, we require a higher velocity\n // to accept the change. This filters out collision rebounds.\n const isOpposite =\n (this.lastCardinalDirection === 'left' && direction.x > 0.5) ||\n (this.lastCardinalDirection === 'right' && direction.x < -0.5) ||\n (this.lastCardinalDirection === 'up' && direction.y > 0.5) ||\n (this.lastCardinalDirection === 'down' && direction.y < -0.5);\n\n const speedSq = this.velocity.lengthSquared();\n\n // Threshold to accept a 180-degree turn (avoid jitter on bounce)\n // We expect a \"real\" turn to have some acceleration or accumulated velocity\n if (isOpposite && speedSq < 100.0) { // Speed < 10\n return this.lastCardinalDirection;\n }\n\n const absX = Math.abs(direction.x);\n const absY = Math.abs(direction.y);\n const bias = 2.0; // Strong bias to keep current direction\n\n // Hysteresis: favor current axis if we have a valid last direction\n if (['left', 'right'].includes(this.lastCardinalDirection)) {\n // Currently horizontal: stick to it unless vertical is significantly stronger\n // AND vertical component has meaningful speed (prevents slide when blocked)\n if (absY > absX * bias) {\n // Check if the \"new\" vertical movement is actually significant\n // e.g. if we are blocked Horizontally (x=0), absY will win even if it's 0.0001 without this check\n if (Math.abs(this.velocity.y) > 5.0) {\n return direction.y >= 0 ? 'down' : 'up';\n }\n }\n // Default: keep horizontal orientation, just update sign if needed (and not filtered by opposite check)\n // If we are here, it means we didn't switch axis, and we didn't trigger the \"Opposite\" guard above.\n // However, if we are \"blocked\" (velocity very low), we should probably not even flip sign.\n if (speedSq > 1.0) {\n return direction.x >= 0 ? 'right' : 'left';\n }\n return this.lastCardinalDirection;\n } else {\n // Currently vertical: stick to it unless horizontal is significantly stronger\n if (absX > absY * bias) {\n if (Math.abs(this.velocity.x) > 5.0) {\n return direction.x >= 0 ? 'right' : 'left';\n }\n }\n if (speedSq > 1.0) {\n return direction.y >= 0 ? 'down' : 'up';\n }\n return this.lastCardinalDirection;\n }\n }\n\n /**\n * Creates a copy of this entity\n * \n * @returns New entity with copied properties\n */\n public clone(): Entity {\n const entity = new Entity({\n position: this.position.clone(),\n velocity: this.velocity.clone(),\n rotation: this.rotation,\n angularVelocity: this.angularVelocity,\n mass: this.mass,\n radius: this.radius,\n width: this.width,\n height: this.height,\n state: this.state,\n restitution: this.restitution,\n friction: this.friction,\n linearDamping: this.linearDamping,\n angularDamping: this.angularDamping,\n maxLinearVelocity: this.maxLinearVelocity,\n maxAngularVelocity: this.maxAngularVelocity,\n collisionMask: this.collisionMask,\n collisionCategory: this.collisionCategory,\n uuid: this.uuid,\n });\n return entity;\n }\n}\n\nexport interface EntityCollisionEvent {\n entity: Entity;\n other: Entity;\n collision: CollisionInfo;\n}\n\nexport type EntityCollisionHandler = (event: EntityCollisionEvent) => void;\n\n\nexport interface EntityPositionSyncEvent {\n entity: Entity;\n x: number;\n y: number;\n}\n\nexport type EntityPositionSyncHandler = (event: EntityPositionSyncEvent) => void;\n\nexport interface EntityDirectionSyncEvent {\n entity: Entity;\n direction: Vector2;\n cardinalDirection: CardinalDirection;\n}\n\nexport type EntityDirectionSyncHandler = (event: EntityDirectionSyncEvent) => void;\n\nexport interface EntityMovementChangeEvent {\n entity: Entity;\n isMoving: boolean;\n /** Movement intensity (speed magnitude) */\n intensity: number;\n}\n\nexport type EntityMovementChangeHandler = (event: EntityMovementChangeEvent) => void;\n\nexport interface EntityTileEvent {\n entity: Entity;\n x: number;\n y: number;\n}\n\nexport type EntityTileHandler = (event: EntityTileEvent) => void;\nexport type EntityCanEnterTileHandler = (event: EntityTileEvent) => boolean;\n\n\n"],"names":["absX","absY"],"mappings":";;;AAKA,MAAM,mBAAmB;AACzB,MAAM,sBAAsB,mBAAmB;AAC/C,MAAM,6BAA6B;AACnC,MAAM,gCAAgC,6BAA6B;AAqF5D,MAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsJlB,YAAY,SAAuB,IAAI;AAPvC,SAAQ,wBAA2C;AASjD,SAAK,OAAO,OAAO,QAAQ,aAAA;AAG3B,QAAI,OAAO,oBAAoB,SAAS;AACtC,WAAK,WAAW,OAAO,SAAS,MAAA;AAAA,IAClC,WAAW,OAAO,UAAU;AAC1B,WAAK,WAAW,IAAI,QAAQ,OAAO,SAAS,GAAG,OAAO,SAAS,CAAC;AAAA,IAClE,OAAO;AACL,WAAK,WAAW,IAAI,QAAQ,GAAG,CAAC;AAAA,IAClC;AAEA,SAAK,cAAc,IAAI,QAAQ,GAAG,CAAC;AAEnC,QAAI,OAAO,oBAAoB,SAAS;AACtC,WA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