hytopia 0.1.26 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/README.md +2 -1
  2. package/docs/server.basecharactercontroller.md +5 -5
  3. package/docs/server.basecharactercontroller.ontick.md +13 -0
  4. package/docs/server.basecharactercontroller.tick.md +53 -0
  5. package/docs/server.defaultcharactercontroller.md +0 -14
  6. package/docs/server.facecallback.md +15 -0
  7. package/docs/server.facecompletecallback.md +15 -0
  8. package/docs/server.faceoptions.md +18 -0
  9. package/docs/server.hytopia.basecharactercontroller.md +5 -5
  10. package/docs/server.hytopia.basecharactercontroller.ontick.md +13 -0
  11. package/docs/server.hytopia.basecharactercontroller.tick.md +53 -0
  12. package/docs/server.hytopia.defaultcharactercontroller.md +0 -14
  13. package/docs/server.hytopia.facecallback.md +15 -0
  14. package/docs/server.hytopia.facecompletecallback.md +15 -0
  15. package/docs/server.hytopia.faceoptions.md +18 -0
  16. package/docs/server.hytopia.md +99 -0
  17. package/docs/server.hytopia.movecallback.md +15 -0
  18. package/docs/server.hytopia.movecompletecallback.md +15 -0
  19. package/docs/server.hytopia.moveoptions.md +18 -0
  20. package/docs/server.hytopia.simplecharactercontroller.face.md +89 -0
  21. package/docs/server.hytopia.simplecharactercontroller.md +88 -0
  22. package/docs/server.hytopia.simplecharactercontroller.move.md +89 -0
  23. package/docs/server.hytopia.worldloopeventpayload.md +73 -0
  24. package/docs/server.hytopia.worldloopeventpayload.start.md +53 -0
  25. package/docs/server.hytopia.worldloopeventpayload.start.worldloop.md +11 -0
  26. package/docs/server.hytopia.worldloopeventpayload.stop.md +53 -0
  27. package/docs/server.hytopia.worldloopeventpayload.stop.worldloop.md +11 -0
  28. package/docs/server.hytopia.worldloopeventpayload.tickend.md +70 -0
  29. package/docs/server.hytopia.worldloopeventpayload.tickend.tickdurationms.md +11 -0
  30. package/docs/server.hytopia.worldloopeventpayload.tickend.worldloop.md +11 -0
  31. package/docs/server.hytopia.worldloopeventpayload.tickerror.error.md +11 -0
  32. package/docs/server.hytopia.worldloopeventpayload.tickerror.md +70 -0
  33. package/docs/server.hytopia.worldloopeventpayload.tickerror.worldloop.md +11 -0
  34. package/docs/server.hytopia.worldloopeventpayload.tickstart.md +70 -0
  35. package/docs/server.hytopia.worldloopeventpayload.tickstart.tickdeltams.md +11 -0
  36. package/docs/server.hytopia.worldloopeventpayload.tickstart.worldloop.md +11 -0
  37. package/docs/server.hytopia.worldloopeventtype.md +103 -0
  38. package/docs/server.md +99 -0
  39. package/docs/server.movecallback.md +15 -0
  40. package/docs/server.movecompletecallback.md +15 -0
  41. package/docs/server.moveoptions.md +18 -0
  42. package/docs/server.simplecharactercontroller.face.md +89 -0
  43. package/docs/server.simplecharactercontroller.md +88 -0
  44. package/docs/server.simplecharactercontroller.move.md +89 -0
  45. package/docs/server.worldloopeventpayload.md +73 -0
  46. package/docs/server.worldloopeventpayload.start.md +53 -0
  47. package/docs/server.worldloopeventpayload.start.worldloop.md +11 -0
  48. package/docs/server.worldloopeventpayload.stop.md +53 -0
  49. package/docs/server.worldloopeventpayload.stop.worldloop.md +11 -0
  50. package/docs/server.worldloopeventpayload.tickend.md +70 -0
  51. package/docs/server.worldloopeventpayload.tickend.tickdurationms.md +11 -0
  52. package/docs/server.worldloopeventpayload.tickend.worldloop.md +11 -0
  53. package/docs/server.worldloopeventpayload.tickerror.error.md +11 -0
  54. package/docs/server.worldloopeventpayload.tickerror.md +70 -0
  55. package/docs/server.worldloopeventpayload.tickerror.worldloop.md +11 -0
  56. package/docs/server.worldloopeventpayload.tickstart.md +70 -0
  57. package/docs/server.worldloopeventpayload.tickstart.tickdeltams.md +11 -0
  58. package/docs/server.worldloopeventpayload.tickstart.worldloop.md +11 -0
  59. package/docs/server.worldloopeventtype.md +103 -0
  60. package/package.json +1 -1
  61. package/server.api.json +1857 -263
  62. package/server.d.ts +175 -20
  63. package/server.js +60 -60
  64. package/docs/server.basecharactercontroller.ontickpathfindingmovement.md +0 -13
  65. package/docs/server.basecharactercontroller.tickpathfindingmovement.md +0 -69
  66. package/docs/server.defaultcharactercontroller.tickpathfindingmovement.md +0 -69
  67. package/docs/server.hytopia.basecharactercontroller.ontickpathfindingmovement.md +0 -13
  68. package/docs/server.hytopia.basecharactercontroller.tickpathfindingmovement.md +0 -69
  69. package/docs/server.hytopia.defaultcharactercontroller.tickpathfindingmovement.md +0 -69
package/server.d.ts CHANGED
@@ -290,6 +290,11 @@ export declare interface AudioOptions {
290
290
  export declare abstract class BaseCharacterController {
291
291
  /** The entity the controller is for. */
292
292
  readonly entity: Entity;
293
+ /**
294
+ * A callback function for when the controller ticks.
295
+ * @param deltaTimeMs - The delta time in milliseconds since the last tick.
296
+ */
297
+ onTick?: (deltaTimeMs: number) => void;
293
298
  /**
294
299
  * A callback function for when the controller ticks
295
300
  * player movement.
@@ -298,13 +303,6 @@ export declare abstract class BaseCharacterController {
298
303
  * @param deltaTimeMs - The delta time in milliseconds since the last tick.
299
304
  */
300
305
  onTickPlayerMovement?: (inputState: PlayerInputState, orientationState: PlayerOrientationState, deltaTimeMs: number) => void;
301
- /**
302
- * A callback function for when the controller ticks
303
- * pathfinding movement.
304
- * @param destination - The destination to move to.
305
- * @param deltaTimeMs - The delta time in milliseconds since the last tick.
306
- */
307
- onTickPathfindingMovement?: (destination: Vector3, deltaTimeMs: number) => void;
308
306
  /**
309
307
  * @param entity - The entity the controller is for.
310
308
  * @param _options - Arbitrary options you may provide or omit for your controller implementation.
@@ -325,13 +323,11 @@ export declare abstract class BaseCharacterController {
325
323
  */
326
324
  tickPlayerMovement(inputState: PlayerInputState, orientationState: PlayerOrientationState, deltaTimeMs: number): void;
327
325
  /**
328
- * Override this method to implement pathfinding
329
- * movement logic for your character controller.
330
- * NOTE: This method is not fully supported yet.
331
- * @param destination - The destination target to move to.
326
+ * Override this method to handle entity movements
327
+ * based on your character controller.
332
328
  * @param deltaTimeMs - The delta time in milliseconds since the last tick.
333
329
  */
334
- tickPathfindingMovement(destination: Vector3, deltaTimeMs: number): void;
330
+ tick(deltaTimeMs: number): void;
335
331
  }
336
332
 
337
333
  /**
@@ -1148,13 +1144,6 @@ export declare class DefaultCharacterController extends BaseCharacterController
1148
1144
  * @param deltaTimeMs - The delta time in milliseconds since the last tick.
1149
1145
  */
1150
1146
  tickPlayerMovement(inputState: PlayerInputState, orientationState: PlayerOrientationState, deltaTimeMs: number): void;
1151
- /**
1152
- * Ticks the pathfinding movement for the character controller,
1153
- * overriding the default implementation.
1154
- * @param destination - The destination to move to.
1155
- * @param deltaTimeMs - The delta time in milliseconds since the last tick.
1156
- */
1157
- tickPathfindingMovement(destination: Vector3, deltaTimeMs: number): void;
1158
1147
  }
1159
1148
 
1160
1149
  /** Options for creating a DefaultCharacterController instance. @public */
@@ -1507,6 +1496,34 @@ export declare class EventRouter {
1507
1496
  emit<TPayload>(event: Event_2<TPayload>): boolean;
1508
1497
  }
1509
1498
 
1499
+ /**
1500
+ * A callback function called when the entity associated with the
1501
+ * SimpleCharacterController updates its rotation as it is
1502
+ * attempting to face a target coordinate.
1503
+ * @param currentRotation - The current rotation of the entity.
1504
+ * @param targetRotation - The target rotation of the entity.
1505
+ * @public
1506
+ */
1507
+ export declare type FaceCallback = (currentRotation: Rotation, targetRotation: Rotation) => void;
1508
+
1509
+ /**
1510
+ * A callback function called when the entity associated with the
1511
+ * SimpleCharacterController finishes rotating and is now facing
1512
+ * a target coordinate.
1513
+ * @param endRotation - The rotation of the entity after it has finished rotating.
1514
+ * @public
1515
+ */
1516
+ export declare type FaceCompleteCallback = (endRotation: Rotation) => void;
1517
+
1518
+ /**
1519
+ * Options for the {@link SimpleCharacterController.face} method.
1520
+ * @public
1521
+ */
1522
+ export declare type FaceOptions = {
1523
+ faceCallback?: FaceCallback;
1524
+ faceCompleteCallback?: FaceCompleteCallback;
1525
+ };
1526
+
1510
1527
  /**
1511
1528
  * Manages the game and associated worlds and systems.
1512
1529
  *
@@ -1616,17 +1633,54 @@ declare namespace HYTOPIA {
1616
1633
  RigidBodyType,
1617
1634
  RigidBodyAdditionalMassProperties,
1618
1635
  RigidBodyOptions,
1636
+ SimpleCharacterController,
1637
+ FaceCallback,
1638
+ FaceCompleteCallback,
1639
+ FaceOptions,
1640
+ MoveCallback,
1641
+ MoveCompleteCallback,
1642
+ MoveOptions,
1619
1643
  Simulation,
1620
1644
  WebServer,
1621
1645
  PORT,
1622
1646
  World,
1623
1647
  WorldMap,
1624
1648
  WorldOptions,
1625
- WorldLoop
1649
+ WorldLoop,
1650
+ WorldLoopEventType,
1651
+ WorldLoopEventPayload
1626
1652
  }
1627
1653
  }
1628
1654
  export default HYTOPIA;
1629
1655
 
1656
+ /**
1657
+ * A callback function called when the entity associated with the
1658
+ * SimpleCharacterController updates its translation as it is
1659
+ * attempting to move to a target coordinate.
1660
+ * @param currentTranslation - The current translation of the entity.
1661
+ * @param targetTranslation - The target translation of the entity.
1662
+ * @public
1663
+ */
1664
+ export declare type MoveCallback = (currentTranslation: Vector3, targetTranslation: Vector3) => void;
1665
+
1666
+ /**
1667
+ * A callback function called when the entity associated with the
1668
+ * SimpleCharacterController reaches the target coordinate. An entity
1669
+ * must reach the x,y,z coordinate for the callback to be called.
1670
+ * @param endTranslation - The translation of the entity after it has finished moving.
1671
+ * @public
1672
+ */
1673
+ export declare type MoveCompleteCallback = (endTranslation: Vector3) => void;
1674
+
1675
+ /**
1676
+ * Options for the {@link SimpleCharacterController.move} method.
1677
+ * @public
1678
+ */
1679
+ export declare type MoveOptions = {
1680
+ moveCallback?: MoveCallback;
1681
+ moveCompleteCallback?: MoveCompleteCallback;
1682
+ };
1683
+
1630
1684
  /**
1631
1685
  * A player in the game.
1632
1686
  *
@@ -2292,6 +2346,76 @@ export declare interface Rotation {
2292
2346
  w: number;
2293
2347
  }
2294
2348
 
2349
+ /**
2350
+ * A simple character controller with basic movement functions.
2351
+ *
2352
+ * @remarks
2353
+ * This class implements simple movement methods that serve
2354
+ * as a way to add realistic movement and rotational facing
2355
+ * functionality to an entity. This is also a great base to
2356
+ * extend for your own more complex character controller
2357
+ * that implements things like pathfinding.
2358
+ *
2359
+ * @example
2360
+ * ```typescript
2361
+ * // Create a custom character controller for myEntity, prior to spawning it.
2362
+ * myEntity.createCustomCharacterController = () => {
2363
+ * return new SimpleCharacterController(myEntity);
2364
+ * };
2365
+ *
2366
+ * // Spawn the entity in the world.
2367
+ * myEntity.spawn(world, { x: 53, y: 10, z: 23 });
2368
+ *
2369
+ * // Move the entity at a speed of 4 blocks
2370
+ * // per second to the coordinate (10, 1, 10).
2371
+ * // console.log when we reach the target.
2372
+ * myEntity.characterController.move({ x: 10, y: 1, z: 10 }, 4, {
2373
+ * moveCompleteCallback: endPosition => {
2374
+ * console.log('Finished moving to', endPosition);
2375
+ * },
2376
+ * });
2377
+ * ```
2378
+ *
2379
+ * @public
2380
+ */
2381
+ export declare class SimpleCharacterController extends BaseCharacterController {
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+ /**
2391
+ * Rotates the entity at a given speed to face a target coordinate.
2392
+ *
2393
+ * @remarks
2394
+ * If this method is called while the entity is already attempting
2395
+ * to face another target, the previous target will be ignored and
2396
+ * the entity will start attempting to face the new target.
2397
+ *
2398
+ * @param target - The target coordinate to face.
2399
+ * @param speed - The speed at which to rotate to the target coordinate.
2400
+ * @param options - Additional options for the face operation, such as callbacks.
2401
+ */
2402
+ face(target: Vector3, speed: number, options?: FaceOptions): void;
2403
+ /**
2404
+ * Moves the entity at a given speed in a straight line to a target coordinate.
2405
+ *
2406
+ * @remarks
2407
+ * If this method is called while the entity is already attempting
2408
+ * to move to another target, the previous target will be ignored and
2409
+ * the entity will start attempting to move to the new target.
2410
+ *
2411
+ * @param target - The target coordinate to move to.
2412
+ * @param speed - The speed at which to move to the target coordinate.
2413
+ * @param options - Additional options for the move operation, such as callbacks.
2414
+ */
2415
+ move(target: Vector3, speed: number, options?: MoveOptions): void;
2416
+
2417
+ }
2418
+
2295
2419
  /**
2296
2420
  * Represents the physics simulation for a world.
2297
2421
  *
@@ -2539,6 +2663,37 @@ export declare class WorldLoop {
2539
2663
 
2540
2664
 
2541
2665
 
2666
+ }
2667
+
2668
+ /** Payloads for events emitted by a WorldLoop instance. @public */
2669
+ export declare namespace WorldLoopEventPayload {
2670
+ export interface Start {
2671
+ worldLoop: WorldLoop;
2672
+ }
2673
+ export interface Stop {
2674
+ worldLoop: WorldLoop;
2675
+ }
2676
+ export interface TickStart {
2677
+ worldLoop: WorldLoop;
2678
+ tickDeltaMs: number;
2679
+ }
2680
+ export interface TickEnd {
2681
+ worldLoop: WorldLoop;
2682
+ tickDurationMs: number;
2683
+ }
2684
+ export interface TickError {
2685
+ worldLoop: WorldLoop;
2686
+ error: Error;
2687
+ }
2688
+ }
2689
+
2690
+ /** Event types a WorldLoop instance can emit. @public */
2691
+ export declare enum WorldLoopEventType {
2692
+ START = "WORLD_LOOP.START",
2693
+ STOP = "WORLD_LOOP.STOP",
2694
+ TICK_START = "WORLD_LOOP.TICK_START",
2695
+ TICK_END = "WORLD_LOOP.TICK_END",
2696
+ TICK_ERROR = "WORLD_LOOP.TICK_ERROR"
2542
2697
  }
2543
2698
 
2544
2699
  /** A map representation for a world. @public */