@rpgjs/common 4.3.0 → 5.0.0-alpha.1

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.
Files changed (148) hide show
  1. package/dist/Physic.d.ts +619 -0
  2. package/dist/Player.d.ts +198 -0
  3. package/{lib → dist}/Utils.d.ts +19 -2
  4. package/dist/database/Item.d.ts +10 -0
  5. package/dist/database/index.d.ts +1 -0
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.js +16741 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/modules.d.ts +92 -0
  10. package/dist/movement/MovementManager.d.ts +84 -0
  11. package/dist/movement/MovementStrategy.d.ts +39 -0
  12. package/dist/movement/index.d.ts +12 -0
  13. package/dist/movement/strategies/CompositeMovement.d.ts +76 -0
  14. package/dist/movement/strategies/Dash.d.ts +52 -0
  15. package/dist/movement/strategies/IceMovement.d.ts +87 -0
  16. package/dist/movement/strategies/Knockback.d.ts +50 -0
  17. package/dist/movement/strategies/LinearMove.d.ts +43 -0
  18. package/dist/movement/strategies/LinearRepulsion.d.ts +55 -0
  19. package/dist/movement/strategies/Oscillate.d.ts +60 -0
  20. package/dist/movement/strategies/PathFollow.d.ts +78 -0
  21. package/dist/movement/strategies/ProjectileMovement.d.ts +138 -0
  22. package/dist/movement/strategies/SeekAvoid.d.ts +27 -0
  23. package/dist/rooms/Map.d.ts +109 -0
  24. package/dist/services/updateMap.d.ts +7 -0
  25. package/package.json +17 -17
  26. package/src/Physic.ts +1644 -0
  27. package/src/Player.ts +262 -26
  28. package/src/{gui/PrebuiltGui.ts → PrebuiltGui.ts} +1 -1
  29. package/src/Utils.ts +184 -123
  30. package/src/database/Item.ts +19 -0
  31. package/src/database/index.ts +1 -0
  32. package/src/index.ts +9 -25
  33. package/src/modules.ts +230 -0
  34. package/src/movement/MovementManager.ts +142 -0
  35. package/src/movement/MovementStrategy.ts +42 -0
  36. package/src/movement/index.ts +15 -0
  37. package/src/movement/strategies/CompositeMovement.ts +173 -0
  38. package/src/movement/strategies/Dash.ts +82 -0
  39. package/src/movement/strategies/IceMovement.ts +158 -0
  40. package/src/movement/strategies/Knockback.ts +81 -0
  41. package/src/movement/strategies/LinearMove.ts +58 -0
  42. package/src/movement/strategies/LinearRepulsion.ts +128 -0
  43. package/src/movement/strategies/Oscillate.ts +144 -0
  44. package/src/movement/strategies/PathFollow.ts +156 -0
  45. package/src/movement/strategies/ProjectileMovement.ts +322 -0
  46. package/src/movement/strategies/SeekAvoid.ts +123 -0
  47. package/src/rooms/Map.ts +272 -0
  48. package/src/services/updateMap.ts +9 -0
  49. package/tests/physic.spec.ts +454 -0
  50. package/tsconfig.json +8 -3
  51. package/vite.config.ts +21 -0
  52. package/CHANGELOG.md +0 -160
  53. package/LICENSE +0 -19
  54. package/browser/manifest.json +0 -7
  55. package/browser/rpg.common.js +0 -11357
  56. package/browser/rpg.common.umd.cjs +0 -11358
  57. package/lib/AbstractObject.d.ts +0 -322
  58. package/lib/AbstractObject.js +0 -872
  59. package/lib/AbstractObject.js.map +0 -1
  60. package/lib/Color.d.ts +0 -1
  61. package/lib/Color.js +0 -25
  62. package/lib/Color.js.map +0 -1
  63. package/lib/DefaultInput.d.ts +0 -2
  64. package/lib/DefaultInput.js +0 -26
  65. package/lib/DefaultInput.js.map +0 -1
  66. package/lib/Event.d.ts +0 -3
  67. package/lib/Event.js +0 -4
  68. package/lib/Event.js.map +0 -1
  69. package/lib/EventEmitter.d.ts +0 -10
  70. package/lib/EventEmitter.js +0 -61
  71. package/lib/EventEmitter.js.map +0 -1
  72. package/lib/Game.d.ts +0 -28
  73. package/lib/Game.js +0 -127
  74. package/lib/Game.js.map +0 -1
  75. package/lib/Hit.d.ts +0 -16
  76. package/lib/Hit.js +0 -65
  77. package/lib/Hit.js.map +0 -1
  78. package/lib/Inject.d.ts +0 -9
  79. package/lib/Inject.js +0 -17
  80. package/lib/Inject.js.map +0 -1
  81. package/lib/Logger.d.ts +0 -2
  82. package/lib/Logger.js +0 -7
  83. package/lib/Logger.js.map +0 -1
  84. package/lib/Map.d.ts +0 -174
  85. package/lib/Map.js +0 -263
  86. package/lib/Map.js.map +0 -1
  87. package/lib/Module.d.ts +0 -16
  88. package/lib/Module.js +0 -139
  89. package/lib/Module.js.map +0 -1
  90. package/lib/Player.d.ts +0 -26
  91. package/lib/Player.js +0 -19
  92. package/lib/Player.js.map +0 -1
  93. package/lib/Plugin.d.ts +0 -67
  94. package/lib/Plugin.js +0 -92
  95. package/lib/Plugin.js.map +0 -1
  96. package/lib/Scheduler.d.ts +0 -26
  97. package/lib/Scheduler.js +0 -90
  98. package/lib/Scheduler.js.map +0 -1
  99. package/lib/Shape.d.ts +0 -127
  100. package/lib/Shape.js +0 -261
  101. package/lib/Shape.js.map +0 -1
  102. package/lib/Utils.js +0 -181
  103. package/lib/Utils.js.map +0 -1
  104. package/lib/Vector2d.d.ts +0 -20
  105. package/lib/Vector2d.js +0 -63
  106. package/lib/Vector2d.js.map +0 -1
  107. package/lib/VirtualGrid.d.ts +0 -26
  108. package/lib/VirtualGrid.js +0 -68
  109. package/lib/VirtualGrid.js.map +0 -1
  110. package/lib/Worker.d.ts +0 -7
  111. package/lib/Worker.js +0 -13
  112. package/lib/Worker.js.map +0 -1
  113. package/lib/WorldMaps.d.ts +0 -105
  114. package/lib/WorldMaps.js +0 -184
  115. package/lib/WorldMaps.js.map +0 -1
  116. package/lib/gui/PrebuiltGui.js +0 -29
  117. package/lib/gui/PrebuiltGui.js.map +0 -1
  118. package/lib/index.d.ts +0 -25
  119. package/lib/index.js +0 -26
  120. package/lib/index.js.map +0 -1
  121. package/lib/transports/io.d.ts +0 -22
  122. package/lib/transports/io.js +0 -82
  123. package/lib/transports/io.js.map +0 -1
  124. package/lib/workers/move.d.ts +0 -1
  125. package/lib/workers/move.js +0 -57
  126. package/lib/workers/move.js.map +0 -1
  127. package/rpg.toml +0 -11
  128. package/src/AbstractObject.ts +0 -973
  129. package/src/Color.ts +0 -29
  130. package/src/DefaultInput.ts +0 -26
  131. package/src/Event.ts +0 -3
  132. package/src/EventEmitter.ts +0 -65
  133. package/src/Game.ts +0 -159
  134. package/src/Hit.ts +0 -70
  135. package/src/Inject.ts +0 -22
  136. package/src/Logger.ts +0 -7
  137. package/src/Map.ts +0 -335
  138. package/src/Module.ts +0 -144
  139. package/src/Plugin.ts +0 -100
  140. package/src/Scheduler.ts +0 -95
  141. package/src/Shape.ts +0 -302
  142. package/src/Vector2d.ts +0 -70
  143. package/src/VirtualGrid.ts +0 -78
  144. package/src/Worker.ts +0 -17
  145. package/src/WorldMaps.ts +0 -204
  146. package/src/transports/io.ts +0 -91
  147. package/src/workers/move.ts +0 -61
  148. /package/{lib/gui → dist}/PrebuiltGui.d.ts +0 -0
@@ -0,0 +1,619 @@
1
+ import { Direction, RpgCommonPlayer } from './Player';
2
+ import * as Matter from 'matter-js';
3
+ export interface ZoneOptions {
4
+ /** World x‑coordinate (ignored if linkedTo) */
5
+ x?: number;
6
+ /** World y‑coordinate (ignored if linkedTo) */
7
+ y?: number;
8
+ /** Circle radius (px) */
9
+ radius: number;
10
+ /** Vision aperture. 360 = full circle, <360 = cone */
11
+ angle?: number;
12
+ /** Facing direction used when angle < 360 */
13
+ direction?: Direction;
14
+ /** If supplied, zone tracks this hitbox id */
15
+ linkedTo?: string;
16
+ /** If true, walls (static hitboxes) stop vision */
17
+ limitedByWalls?: boolean;
18
+ }
19
+ export interface SlidingOptions {
20
+ /** Enable collision sliding */
21
+ enabled?: boolean;
22
+ /** Sliding friction factor (0-1, where 0 = no sliding, 1 = perfect sliding) */
23
+ friction?: number;
24
+ /** Minimum velocity threshold for sliding to occur */
25
+ minVelocity?: number;
26
+ }
27
+ export interface ZoneData {
28
+ id: string;
29
+ /** 'static' if x/y provided, otherwise 'linked' */
30
+ type: 'static' | 'linked';
31
+ /** Underlying Matter sensor body */
32
+ body: Matter.Body;
33
+ /** Host hitbox id when type === 'linked' */
34
+ linkedTo?: string;
35
+ /** Aperture in radians (π*2 for full circle) */
36
+ aperture: number;
37
+ /** limitedByWalls flag */
38
+ limitedByWalls: boolean;
39
+ }
40
+ /**
41
+ * Class to manage physics in a 2D RPG world without gravity using MatterJS
42
+ *
43
+ * Provides management for:
44
+ * - Static hitboxes (map elements, obstacles)
45
+ * - Movable hitboxes (players, events)
46
+ * - Collision detection and tracking
47
+ * - Collision events (enter/exit)
48
+ * - Zones (sensor areas that detect entities without physical collision)
49
+ */
50
+ export declare class RpgCommonPhysic {
51
+ private engine;
52
+ private world;
53
+ private hitboxes;
54
+ private collisions;
55
+ private collisionEvents;
56
+ private movementEvents;
57
+ private zones;
58
+ private zoneCollisions;
59
+ private zoneEvents;
60
+ private collisionNormals;
61
+ private lastVelocities;
62
+ private intendedMovements;
63
+ private collisionData;
64
+ /**
65
+ * Initialize the physics engine with no gravity
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const physic = new RpgCommonPhysic();
70
+ * ```
71
+ */
72
+ constructor();
73
+ /**
74
+ * Updates the physics simulation
75
+ *
76
+ * @param delta - Time delta in milliseconds
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * // Update physics in game loop
81
+ * physic.update(16); // 16ms = ~60fps
82
+ * ```
83
+ */
84
+ update(delta: number): void;
85
+ /**
86
+ * Synchronize all physics bodies with their associated players
87
+ *
88
+ * Updates player positions based on their physics bodies after physics calculations
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * // Called automatically in update()
93
+ * physic.syncBodies();
94
+ * ```
95
+ */
96
+ private syncBodies;
97
+ /**
98
+ * Synchronize linked zones to follow their host hitboxes
99
+ *
100
+ * Updates zones that are linked to players or other movable hitboxes
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * // Called automatically in update()
105
+ * physic.syncLinkedZones();
106
+ * ```
107
+ */
108
+ private syncLinkedZones;
109
+ /**
110
+ * Convert a Direction enum value to radians
111
+ *
112
+ * @param dir - Direction enum value
113
+ * @returns Angle in radians
114
+ */
115
+ private directionToAngle;
116
+ /**
117
+ * Convert a movement vector to a Direction enum value
118
+ *
119
+ * Determines the primary direction based on the larger component
120
+ * of the movement vector. Returns null if no significant movement.
121
+ *
122
+ * @param dx - X displacement
123
+ * @param dy - Y displacement
124
+ * @returns Direction enum value or null if no movement
125
+ */
126
+ private vectorToDirection;
127
+ /**
128
+ * Add a static hitbox (immovable objects like walls, obstacles)
129
+ *
130
+ * @param id - Unique identifier for the hitbox
131
+ * @param x - X position
132
+ * @param y - Y position
133
+ * @param width - Width of hitbox
134
+ * @param height - Height of hitbox
135
+ * @returns The id of the created hitbox
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * // Add a wall
140
+ * physic.addStaticHitbox('wall1', 100, 50, 32, 128);
141
+ * ```
142
+ */
143
+ addStaticHitbox(id: string, x: number, y: number, width: number, height: number): string;
144
+ /**
145
+ * Add a movable hitbox (players, NPCs, dynamic objects)
146
+ *
147
+ * @param player - Player object that owns this hitbox
148
+ * @param x - X position
149
+ * @param y - Y position
150
+ * @param width - Width of hitbox
151
+ * @param height - Height of hitbox
152
+ * @param options - Additional body options
153
+ * @param slidingOptions - Collision sliding configuration
154
+ * @returns The id of the created hitbox
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * // Add a player with sliding enabled (only against walls)
159
+ * const player = new RpgCommonPlayer();
160
+ * player.id = 'player1';
161
+ * physic.addMovableHitbox(player, 200, 300, 24, 32, {}, {
162
+ * enabled: true,
163
+ * friction: 0.8,
164
+ * minVelocity: 0.5
165
+ * });
166
+ * ```
167
+ */
168
+ addMovableHitbox(player: RpgCommonPlayer, x: number, y: number, width: number, height: number, options?: {}, slidingOptions?: SlidingOptions): string;
169
+ /**
170
+ * Update a hitbox's position and size
171
+ *
172
+ * @param id - ID of the hitbox to update
173
+ * @param x - New X position
174
+ * @param y - New Y position
175
+ * @param width - New width (optional)
176
+ * @param height - New height (optional)
177
+ * @returns Boolean indicating success
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * // Update player position
182
+ * physic.updateHitbox('player1', newX, newY);
183
+ *
184
+ * // Update both position and size
185
+ * physic.updateHitbox('player1', newX, newY, newWidth, newHeight);
186
+ * ```
187
+ */
188
+ updateHitbox(id: string, x: number, y: number, width?: number, height?: number): boolean;
189
+ /**
190
+ * Remove a hitbox from the world
191
+ *
192
+ * @param id - ID of the hitbox to remove
193
+ * @returns Boolean indicating success
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * // Remove an enemy
198
+ * physic.removeHitbox('enemy1');
199
+ * ```
200
+ */
201
+ removeHitbox(id: string): boolean;
202
+ /**
203
+ * Register collision event callbacks for a hitbox
204
+ *
205
+ * @param id - ID of the hitbox
206
+ * @param onCollisionEnter - Callback when entering collision
207
+ * @param onCollisionExit - Callback when exiting collision
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * // Register collision events for player
212
+ * physic.registerCollisionEvents('player1',
213
+ * (hitboxIds) => console.log('Player hit:', hitboxIds),
214
+ * (hitboxIds) => console.log('Player no longer hitting:', hitboxIds)
215
+ * );
216
+ * ```
217
+ */
218
+ registerCollisionEvents(id: string, onCollisionEnter?: (collidedWith: string[]) => void, onCollisionExit?: (collidedWith: string[]) => void): void;
219
+ /**
220
+ * Get all hitbox IDs currently colliding with the specified hitbox
221
+ *
222
+ * @param id - ID of the hitbox to check collisions for
223
+ * @returns Array of hitbox IDs or empty array if none found
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * // Get all enemies colliding with player
228
+ * const collidingEnemies = physic.getCollisions('player1');
229
+ * ```
230
+ */
231
+ getCollisions(id: string): string[];
232
+ /**
233
+ * Check if two hitboxes are colliding
234
+ *
235
+ * @param id1 - First hitbox ID
236
+ * @param id2 - Second hitbox ID
237
+ * @returns Boolean indicating if they are colliding
238
+ *
239
+ * @example
240
+ * ```ts
241
+ * // Check if player is touching the door
242
+ * if (physic.areColliding('player1', 'door')) {
243
+ * // Open the door
244
+ * }
245
+ * ```
246
+ */
247
+ areColliding(id1: string, id2: string): boolean;
248
+ /**
249
+ * Handle collision start events from MatterJS
250
+ */
251
+ private handleCollisionStart;
252
+ /**
253
+ * Handle collision end events from MatterJS
254
+ */
255
+ private handleCollisionEnd;
256
+ /**
257
+ * Extract entity ID and zone status from a physics body
258
+ *
259
+ * @param body - Matter.js body
260
+ * @returns Object containing ID and isZone flag
261
+ */
262
+ private extractId;
263
+ /**
264
+ * Process a zone enter event
265
+ *
266
+ * @param zoneId - ID of the zone
267
+ * @param hitId - ID of the hitbox entering the zone
268
+ */
269
+ private processZoneEnter;
270
+ /**
271
+ * Process a zone exit event
272
+ *
273
+ * @param zoneId - ID of the zone
274
+ * @param hitId - ID of the hitbox exiting the zone
275
+ */
276
+ private processZoneExit;
277
+ /**
278
+ * Check if there is a clear line of sight between two points
279
+ *
280
+ * @param start - Starting point
281
+ * @param end - Ending point
282
+ * @returns True if no static hitbox blocks the line
283
+ */
284
+ private hasLineOfSight;
285
+ /**
286
+ * Record a collision between two hitboxes
287
+ */
288
+ private recordCollision;
289
+ /**
290
+ * Remove a collision record between two hitboxes
291
+ */
292
+ private removeCollision;
293
+ /**
294
+ * Move a body based on player movement data
295
+ *
296
+ * Applies velocity to a physics body based on the player's current speed
297
+ * and automatically updates the player's position and intended direction
298
+ *
299
+ * @param player - The player object containing movement data
300
+ * @param direction - The intended movement direction
301
+ * @returns Boolean indicating success
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * // Move a player's physics body
306
+ * physic.moveBody(player, Direction.Right);
307
+ * ```
308
+ */
309
+ moveBody(player: RpgCommonPlayer, direction: Direction): boolean;
310
+ /**
311
+ * Stop movement for a player
312
+ *
313
+ * Clears the intended direction and stops any ongoing movement.
314
+ * This should be called when the player releases movement keys.
315
+ *
316
+ * @param player - The player object to stop
317
+ * @returns Boolean indicating success
318
+ *
319
+ * @example
320
+ * ```ts
321
+ * // Player releases all movement keys
322
+ * physic.stopMovement(player);
323
+ * ```
324
+ */
325
+ stopMovement(player: RpgCommonPlayer): boolean;
326
+ /**
327
+ * Synchronize a player's position to its physics body
328
+ *
329
+ * Updates the physics body position based on the player's current position
330
+ * Useful when player position is changed outside of physics system
331
+ *
332
+ * @param playerId - ID of the player to synchronize
333
+ * @returns Boolean indicating success
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * // After teleporting a player
338
+ * player.x.set(newX);
339
+ * player.y.set(newY);
340
+ * physic.syncPlayerToBody(player.id);
341
+ * ```
342
+ */
343
+ syncPlayerToBody(playerId: string): boolean;
344
+ /**
345
+ * Get a physics body by entity ID
346
+ *
347
+ * Used by the MovementManager to apply movement strategies
348
+ *
349
+ * @param id - Entity ID
350
+ * @returns The Matter.js body or undefined if not found
351
+ *
352
+ * @example
353
+ * ```ts
354
+ * // Get a body to apply movement
355
+ * const body = physic.getBody('player1');
356
+ * if (body) Matter.Body.setVelocity(body, { x: 5, y: 0 });
357
+ * ```
358
+ */
359
+ getBody(id: string): Matter.Body | undefined;
360
+ /**
361
+ * Apply a translation to a body directly
362
+ *
363
+ * Used as a clean interface for the movement system.
364
+ * Automatically determines and sets the intended direction for players.
365
+ *
366
+ * @param id - Entity ID
367
+ * @param dx - X displacement in pixels
368
+ * @param dy - Y displacement in pixels
369
+ * @returns Boolean indicating success
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * // Move entity 5px right, 2px down
374
+ * physic.applyTranslation('player1', 5, 2);
375
+ * ```
376
+ */
377
+ applyTranslation(id: string, dx: number, dy: number): boolean;
378
+ /**
379
+ * Set the velocity of a body directly
380
+ *
381
+ * Used as a clean interface for the movement system
382
+ *
383
+ * @param id - Entity ID
384
+ * @param vx - X velocity component
385
+ * @param vy - Y velocity component
386
+ * @returns Boolean indicating success
387
+ *
388
+ * @example
389
+ * ```ts
390
+ * // Set entity velocity to 5px/s right
391
+ * physic.setVelocity('player1', 5, 0);
392
+ * ```
393
+ */
394
+ setVelocity(id: string, vx: number, vy: number): boolean;
395
+ /**
396
+ * Apply a force to a body
397
+ *
398
+ * Used as a clean interface for the movement system
399
+ *
400
+ * @param id - Entity ID
401
+ * @param forceX - X force component
402
+ * @param forceY - Y force component
403
+ * @param position - Application point (optional, default is body center)
404
+ * @returns Boolean indicating success
405
+ *
406
+ * @example
407
+ * ```ts
408
+ * // Apply force to push entity
409
+ * physic.applyForce('player1', 0.05, 0);
410
+ * ```
411
+ */
412
+ applyForce(id: string, forceX: number, forceY: number, position?: Matter.Vector): boolean;
413
+ /**
414
+ * Get the Matter.js world object
415
+ *
416
+ * Useful for advanced manipulation and querying of the physics world
417
+ *
418
+ * @returns Matter.js World object
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * // Query for all bodies in an area
423
+ * const world = physic.getWorld();
424
+ * const bodies = Matter.Query.region(world.bodies, area);
425
+ * ```
426
+ */
427
+ getWorld(): Matter.World;
428
+ /**
429
+ * Create a new Zone sensor. Never collides physically but triggers events.
430
+ *
431
+ * @param id - Unique identifier for the zone
432
+ * @param opts - Zone options
433
+ * @returns The id of the created zone
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * // 90° cone vision in front of guard1 (120px range)
438
+ * physic.addZone('guardVision', {
439
+ * linkedTo: 'guard1',
440
+ * radius: 120,
441
+ * angle: 90,
442
+ * direction: Direction.Right,
443
+ * limitedByWalls: true
444
+ * });
445
+ * ```
446
+ */
447
+ addZone(id: string, opts: ZoneOptions): string;
448
+ getZone(id: string): ZoneData | undefined;
449
+ /**
450
+ * Remove a zone from the world
451
+ *
452
+ * @param id - ID of the zone to remove
453
+ * @returns Boolean indicating success
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * // Remove a detection zone
458
+ * physic.removeZone('guardVision');
459
+ * ```
460
+ */
461
+ removeZone(id: string): boolean;
462
+ /**
463
+ * Register zone enter/exit callbacks
464
+ *
465
+ * @param id - ID of the zone
466
+ * @param onEnter - Callback when an entity enters the zone
467
+ * @param onExit - Callback when an entity exits the zone
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * // Register zone events
472
+ * physic.registerZoneEvents('guardVision',
473
+ * (hitIds) => console.log('Entities spotted:', hitIds),
474
+ * (hitIds) => console.log('Entities lost:', hitIds)
475
+ * );
476
+ * ```
477
+ */
478
+ registerZoneEvents(id: string, onEnter?: (hitIds: string[]) => void, onExit?: (hitIds: string[]) => void): void;
479
+ /**
480
+ * Get all entity IDs currently inside a zone
481
+ *
482
+ * @param id - ID of the zone to check
483
+ * @returns Array of entity IDs or empty array if none found
484
+ *
485
+ * @example
486
+ * ```ts
487
+ * // Check which entities are in guard's vision
488
+ * const spotted = physic.getEntitiesInZone('guardVision');
489
+ * if (spotted.includes('player1')) {
490
+ * // Guard saw the player!
491
+ * }
492
+ * ```
493
+ */
494
+ getEntitiesInZone(id: string): string[];
495
+ /**
496
+ * Check for movement state changes on all movable hitboxes
497
+ *
498
+ * Detects when objects start or stop moving and triggers appropriate events
499
+ *
500
+ * @example
501
+ * ```ts
502
+ * // Called automatically in update()
503
+ * physic.checkMovementChanges();
504
+ * ```
505
+ */
506
+ private checkMovementChanges;
507
+ /**
508
+ * Register movement event callbacks for a hitbox
509
+ *
510
+ * @param id - ID of the hitbox
511
+ * @param onStartMoving - Callback when object starts moving
512
+ * @param onStopMoving - Callback when object stops moving
513
+ *
514
+ * @example
515
+ * ```ts
516
+ * // Register movement events for player
517
+ * physic.registerMovementEvents('player1',
518
+ * () => console.log('Player started moving'),
519
+ * () => console.log('Player stopped moving')
520
+ * );
521
+ * ```
522
+ */
523
+ registerMovementEvents(id: string, onStartMoving?: () => void, onStopMoving?: () => void): void;
524
+ /**
525
+ * Check if a hitbox is currently moving
526
+ *
527
+ * @param id - ID of the hitbox to check
528
+ * @returns Boolean indicating if the object is in motion
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * // Check if player is moving
533
+ * if (physic.isMoving('player1')) {
534
+ * // Player is in motion
535
+ * }
536
+ * ```
537
+ */
538
+ isMoving(id: string): boolean;
539
+ /**
540
+ * Unregister movement events for a hitbox
541
+ *
542
+ * @param id - ID of the hitbox
543
+ * @returns Boolean indicating success
544
+ *
545
+ * @example
546
+ * ```ts
547
+ * // Remove movement event listeners
548
+ * physic.unregisterMovementEvents('player1');
549
+ * ```
550
+ */
551
+ unregisterMovementEvents(id: string): boolean;
552
+ /**
553
+ * Enable or disable collision sliding for a hitbox
554
+ *
555
+ * @param id - ID of the hitbox
556
+ * @param enabled - Whether to enable sliding
557
+ * @param options - Sliding configuration options
558
+ * @returns Boolean indicating success
559
+ *
560
+ * @example
561
+ * ```ts
562
+ * // Enable sliding for an existing player
563
+ * physic.setSliding('player1', true, {
564
+ * friction: 0.9,
565
+ * minVelocity: 1.0
566
+ * });
567
+ * ```
568
+ */
569
+ setSliding(id: string, enabled: boolean, options?: SlidingOptions): boolean;
570
+ /**
571
+ * Check if sliding is enabled for a hitbox
572
+ *
573
+ * @param id - ID of the hitbox
574
+ * @returns Boolean indicating if sliding is enabled
575
+ *
576
+ * @example
577
+ * ```ts
578
+ * // Check if player has sliding enabled
579
+ * if (physic.isSlidingEnabled('player1')) {
580
+ * // Player can slide along walls
581
+ * }
582
+ * ```
583
+ */
584
+ isSlidingEnabled(id: string): boolean;
585
+ /**
586
+ * Get sliding options for a hitbox
587
+ *
588
+ * @param id - ID of the hitbox
589
+ * @returns Sliding options or undefined if not found
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * // Get current sliding configuration
594
+ * const options = physic.getSlidingOptions('player1');
595
+ * console.log('Friction:', options?.friction);
596
+ * ```
597
+ */
598
+ getSlidingOptions(id: string): SlidingOptions | undefined;
599
+ private applySlidingCorrections;
600
+ private storeCollisionNormals;
601
+ /**
602
+ * Determine if a collision is partial (corner/edge) or full frontal
603
+ *
604
+ * @param bodyA - First collision body
605
+ * @param bodyB - Second collision body
606
+ * @param intendedMovement - The intended movement vector
607
+ * @returns Object with collision analysis
608
+ */
609
+ private analyzeCollision;
610
+ private resolveMovableCollisions;
611
+ /**
612
+ * Check if two bodies are actually touching/overlapping
613
+ */
614
+ private areBodiesTouching;
615
+ /**
616
+ * Check if a body is moving towards another body
617
+ */
618
+ private isMovingTowards;
619
+ }