hytopia 0.1.95 → 0.1.97
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/docs/server.md +66 -0
- package/docs/server.pathfindabortcallback.md +13 -0
- package/docs/server.pathfindcompletecallback.md +13 -0
- package/docs/server.pathfindingentitycontroller.debug.md +13 -0
- package/docs/server.pathfindingentitycontroller.maxfall.md +13 -0
- package/docs/server.pathfindingentitycontroller.maxjump.md +13 -0
- package/docs/server.pathfindingentitycontroller.maxopensetiterations.md +13 -0
- package/docs/server.pathfindingentitycontroller.md +287 -0
- package/docs/server.pathfindingentitycontroller.pathfind.md +87 -0
- package/docs/server.pathfindingentitycontroller.speed.md +13 -0
- package/docs/server.pathfindingentitycontroller.target.md +13 -0
- package/docs/server.pathfindingentitycontroller.verticalpenalty.md +13 -0
- package/docs/server.pathfindingentitycontroller.waypointnextindex.md +13 -0
- package/docs/server.pathfindingentitycontroller.waypoints.md +13 -0
- package/docs/server.pathfindingentitycontroller.waypointtimeoutms.md +13 -0
- package/docs/server.pathfindingoptions.md +26 -0
- package/docs/server.playerentitycontroller.autocancelmouseleftclick.md +13 -0
- package/docs/server.playerentitycontroller.idleloopedanimations.md +13 -0
- package/docs/server.playerentitycontroller.interactoneshotanimations.md +13 -0
- package/docs/server.playerentitycontroller.jumponeshotanimations.md +13 -0
- package/docs/server.playerentitycontroller.md +114 -0
- package/docs/server.playerentitycontroller.runloopedanimations.md +13 -0
- package/docs/server.playerentitycontroller.walkloopedanimations.md +13 -0
- package/docs/server.playerentitycontrolleroptions.autocancelmouseleftclick.md +13 -0
- package/docs/server.playerentitycontrolleroptions.idleloopedanimations.md +13 -0
- package/docs/server.playerentitycontrolleroptions.interactoneshotanimations.md +13 -0
- package/docs/server.playerentitycontrolleroptions.jumponeshotanimations.md +13 -0
- package/docs/server.playerentitycontrolleroptions.md +114 -0
- package/docs/server.playerentitycontrolleroptions.runloopedanimations.md +13 -0
- package/docs/server.playerentitycontrolleroptions.walkloopedanimations.md +13 -0
- package/docs/server.simpleentitycontroller.jump.md +53 -0
- package/docs/server.simpleentitycontroller.md +14 -0
- package/docs/server.waypointmovecompletecallback.md +15 -0
- package/docs/server.waypointmoveskippedcallback.md +15 -0
- package/examples/ai-agents/.env.example +2 -0
- package/examples/ai-agents/README.md +17 -0
- package/examples/ai-agents/bun.lockb +0 -0
- package/examples/big-world/bun.lockb +0 -0
- package/examples/block-entity/bun.lockb +0 -0
- package/examples/child-entity/bun.lockb +0 -0
- package/examples/child-entity/package-lock.json +30 -0
- package/examples/custom-ui/bun.lockb +0 -0
- package/examples/entity-controller/bun.lockb +0 -0
- package/examples/entity-spawn/bun.lockb +0 -0
- package/examples/hole-in-wall-game/bun.lockb +0 -0
- package/examples/lighting/bun.lockb +0 -0
- package/examples/pathfinding/README.md +3 -0
- package/examples/pathfinding/assets/map.json +25828 -0
- package/examples/pathfinding/bun.lockb +0 -0
- package/examples/pathfinding/index.ts +113 -0
- package/examples/pathfinding/package.json +16 -0
- package/examples/payload-game/bun.lockb +0 -0
- package/examples/wall-dodge-game/bun.lockb +0 -0
- package/examples/wall-dodge-game/package-lock.json +30 -0
- package/examples/zombies-fps/assets/audio/sfx/pistol-shoot-1.mp3 +0 -0
- package/examples/zombies-fps/assets/audio/sfx/pistol-shoot-2.mp3 +0 -0
- package/examples/zombies-fps/assets/audio/sfx/pistol-shoot.mp3 +0 -0
- package/examples/zombies-fps/assets/maps/terrain.json +0 -12
- package/examples/zombies-fps/assets/models/items/pistol.glb +0 -0
- package/examples/zombies-fps/assets/ui/index.html +35 -0
- package/examples/zombies-fps/bun.lockb +0 -0
- package/examples/zombies-fps/classes/GamePlayerEntity.ts +62 -5
- package/examples/zombies-fps/classes/GunEntity.ts +66 -0
- package/examples/zombies-fps/classes/PurchaseBarrierEntity.ts +1 -1
- package/examples/zombies-fps/classes/guns/BulletEntity.ts +0 -0
- package/examples/zombies-fps/classes/guns/PistolEntity.ts +49 -0
- package/examples/zombies-fps/gameConfig.ts +8 -9
- package/examples/zombies-fps/index.ts +5 -1
- package/package.json +1 -1
- package/server.api.json +1006 -8
- package/server.d.ts +156 -0
- package/server.js +87 -87
package/server.d.ts
CHANGED
@@ -2212,6 +2212,111 @@ export declare type MoveOptions = {
|
|
2212
2212
|
};
|
2213
2213
|
};
|
2214
2214
|
|
2215
|
+
/**
|
2216
|
+
* A callback function called when the pathfinding algorithm aborts.
|
2217
|
+
* @public
|
2218
|
+
*/
|
2219
|
+
export declare type PathfindAbortCallback = () => void;
|
2220
|
+
|
2221
|
+
/**
|
2222
|
+
* A callback function called when the entity associated with the
|
2223
|
+
* PathfindingEntityController finishes pathfinding and is now at the
|
2224
|
+
* target coordinate.
|
2225
|
+
* @public
|
2226
|
+
*/
|
2227
|
+
export declare type PathfindCompleteCallback = () => void;
|
2228
|
+
|
2229
|
+
/**
|
2230
|
+
* A pathfinding entity controller built on top of {@link SimpleEntityController}.
|
2231
|
+
*
|
2232
|
+
* @remarks
|
2233
|
+
* This class implements pathfinding using the A* algorithm. Pathfinding when frequently
|
2234
|
+
* called can cause performance issues, use it sparingly. The .pathfind() method should only need to
|
2235
|
+
* be called once in nearly all cases when attempting to move an entity to a target coordinate.
|
2236
|
+
*
|
2237
|
+
* @public
|
2238
|
+
*/
|
2239
|
+
export declare class PathfindingEntityController extends SimpleEntityController {
|
2240
|
+
|
2241
|
+
|
2242
|
+
|
2243
|
+
|
2244
|
+
|
2245
|
+
|
2246
|
+
|
2247
|
+
|
2248
|
+
|
2249
|
+
|
2250
|
+
|
2251
|
+
|
2252
|
+
|
2253
|
+
|
2254
|
+
|
2255
|
+
/** Whether to enable debug mode or not. When debug mode is enabled, the pathfinding algorithm will log debug information to the console. Defaults to false. */
|
2256
|
+
get debug(): boolean;
|
2257
|
+
/** The maximum fall distance the entity can fall. */
|
2258
|
+
get maxFall(): number;
|
2259
|
+
/** The maximum jump distance the entity can jump. */
|
2260
|
+
get maxJump(): number;
|
2261
|
+
/** The maximum number of open set iterations that can be processed before aborting pathfinding. Defaults to 200. */
|
2262
|
+
get maxOpenSetIterations(): number;
|
2263
|
+
/** The speed of the entity. */
|
2264
|
+
get speed(): number;
|
2265
|
+
/** The target coordinate to pathfind to. */
|
2266
|
+
get target(): Vector3Like | undefined;
|
2267
|
+
/** The vertical penalty for the pathfinding algorithm. A higher value will prefer paths with less vertical movement. */
|
2268
|
+
get verticalPenalty(): number;
|
2269
|
+
/** The current waypoints being followed. */
|
2270
|
+
get waypoints(): Vector3Like[];
|
2271
|
+
/** The index representing the next waypoint moving towards of the current set of waypoints being followed. */
|
2272
|
+
get waypointNextIndex(): number;
|
2273
|
+
/** The timeout in milliseconds for a waypoint to be considered reached. Defaults to 2000ms divided by the speed of the entity. */
|
2274
|
+
get waypointTimeoutMs(): number;
|
2275
|
+
/**
|
2276
|
+
* Calculate a path and move to the target if a path is found. Returns true if a path is found, false if no path is found.
|
2277
|
+
* @param target - The target coordinate to pathfind to.
|
2278
|
+
* @param speed - The speed of the entity.
|
2279
|
+
* @param options - The pathfinding options.
|
2280
|
+
* @returns Whether the path was found.
|
2281
|
+
*/
|
2282
|
+
pathfind(target: Vector3Like, speed: number, options?: PathfindingOptions): boolean;
|
2283
|
+
|
2284
|
+
|
2285
|
+
|
2286
|
+
|
2287
|
+
|
2288
|
+
|
2289
|
+
|
2290
|
+
|
2291
|
+
}
|
2292
|
+
|
2293
|
+
/**
|
2294
|
+
* Options for the {@link PathfindingEntityController.pathfind} method.
|
2295
|
+
* @public
|
2296
|
+
*/
|
2297
|
+
export declare type PathfindingOptions = {
|
2298
|
+
/** Whether to enable debug mode or not. When debug mode is enabled, the pathfinding algorithm will log debug information to the console. Defaults to false. */
|
2299
|
+
debug?: boolean;
|
2300
|
+
/** The maximum fall distance the entity can fall when considering a path. */
|
2301
|
+
maxFall?: number;
|
2302
|
+
/** The maximum height the entity will jump when considering a path. */
|
2303
|
+
maxJump?: number;
|
2304
|
+
/** The maximum number of open set iterations that can be processed before aborting pathfinding. Defaults to 200. */
|
2305
|
+
maxOpenSetIterations?: number;
|
2306
|
+
/** Callback called when the pathfinding algorithm aborts. */
|
2307
|
+
pathfindAbortCallback?: PathfindAbortCallback;
|
2308
|
+
/** Callback called when the entity associated with the PathfindingEntityController finishes pathfinding and is now at the target coordinate. */
|
2309
|
+
pathfindCompleteCallback?: PathfindCompleteCallback;
|
2310
|
+
/** The vertical penalty for the pathfinding algorithm. A higher value will prefer paths with less vertical movement. */
|
2311
|
+
verticalPenalty?: number;
|
2312
|
+
/** Callback called when the entity associated with the PathfindingEntityController finishes moving to a calculate waypoint of its current path. */
|
2313
|
+
waypointMoveCompleteCallback?: WaypointMoveCompleteCallback;
|
2314
|
+
/** Callback called when the entity associated with the PathfindingEntityController skips a waypoint because it took too long to reach. */
|
2315
|
+
waypointMoveSkippedCallback?: WaypointMoveSkippedCallback;
|
2316
|
+
/** The timeout in milliseconds for a waypoint to be considered reached. Defaults to 2000ms divided by the speed of the entity. */
|
2317
|
+
waypointTimeoutMs?: number;
|
2318
|
+
};
|
2319
|
+
|
2215
2320
|
/**
|
2216
2321
|
* A player in the game.
|
2217
2322
|
*
|
@@ -2557,6 +2662,8 @@ export declare class PlayerEntity extends Entity {
|
|
2557
2662
|
* @public
|
2558
2663
|
*/
|
2559
2664
|
export declare class PlayerEntityController extends BaseEntityController {
|
2665
|
+
/** Whether to automatically cancel left click input after first processed tick, defaults to true. */
|
2666
|
+
autoCancelMouseLeftClick: boolean;
|
2560
2667
|
/**
|
2561
2668
|
* A function allowing custom logic to determine if the entity can walk.
|
2562
2669
|
* @param playerEntityController - The entity controller instance.
|
@@ -2575,12 +2682,22 @@ export declare class PlayerEntityController extends BaseEntityController {
|
|
2575
2682
|
* @returns Whether the entity of the entity controller can jump.
|
2576
2683
|
*/
|
2577
2684
|
canJump: (playerEntityController: PlayerEntityController) => boolean;
|
2685
|
+
/** The looped animation(s) that will play when the entity is idle. */
|
2686
|
+
idleLoopedAnimations: string[];
|
2687
|
+
/** The oneshot animation(s) that will play when the entity interacts (left click) */
|
2688
|
+
interactOneshotAnimations: string[];
|
2689
|
+
/** The oneshot animation(s) that will play when the entity is jumping. */
|
2690
|
+
jumpOneshotAnimations: string[];
|
2578
2691
|
/** The upward velocity applied to the entity when it jumps. */
|
2579
2692
|
jumpVelocity: number;
|
2693
|
+
/** The looped animation(s) that will play when the entity is running. */
|
2694
|
+
runLoopedAnimations: string[];
|
2580
2695
|
/** The normalized horizontal velocity applied to the entity when it runs. */
|
2581
2696
|
runVelocity: number;
|
2582
2697
|
/** Whether the entity sticks to platforms. */
|
2583
2698
|
sticksToPlatforms: boolean;
|
2699
|
+
/** The looped animation(s) that will play when the entity is walking. */
|
2700
|
+
walkLoopedAnimations: string[];
|
2584
2701
|
/** The normalized horizontal velocity applied to the entity when it walks. */
|
2585
2702
|
walkVelocity: number;
|
2586
2703
|
|
@@ -2622,18 +2739,30 @@ export declare class PlayerEntityController extends BaseEntityController {
|
|
2622
2739
|
|
2623
2740
|
/** Options for creating a PlayerEntityController instance. @public */
|
2624
2741
|
export declare interface PlayerEntityControllerOptions {
|
2742
|
+
/** Whether to automatically cancel left click input after first processed tick, defaults to true. */
|
2743
|
+
autoCancelMouseLeftClick?: boolean;
|
2625
2744
|
/** A function allowing custom logic to determine if the entity can jump. */
|
2626
2745
|
canJump?: () => boolean;
|
2627
2746
|
/** A function allowing custom logic to determine if the entity can walk. */
|
2628
2747
|
canWalk?: () => boolean;
|
2629
2748
|
/** A function allowing custom logic to determine if the entity can run. */
|
2630
2749
|
canRun?: () => boolean;
|
2750
|
+
/** Overrides the animation(s) that will play when the entity is idle. */
|
2751
|
+
idleLoopedAnimations?: string[];
|
2752
|
+
/** Overrides the animation(s) that will play when the entity interacts (left click) */
|
2753
|
+
interactOneshotAnimations?: string[];
|
2754
|
+
/** Overrides the animation(s) that will play when the entity is jumping. */
|
2755
|
+
jumpOneshotAnimations?: string[];
|
2631
2756
|
/** The upward velocity applied to the entity when it jumps. */
|
2632
2757
|
jumpVelocity?: number;
|
2633
2758
|
/** The normalized horizontal velocity applied to the entity when it runs. */
|
2634
2759
|
runVelocity?: number;
|
2760
|
+
/** Overrides the animation(s) that will play when the entity is running. */
|
2761
|
+
runLoopedAnimations?: string[];
|
2635
2762
|
/** Whether the entity sticks to platforms, defaults to true. */
|
2636
2763
|
sticksToPlatforms?: boolean;
|
2764
|
+
/** Overrides the animation(s) that will play when the entity is walking. */
|
2765
|
+
walkLoopedAnimations?: string[];
|
2637
2766
|
/** The normalized horizontal velocity applied to the entity when it walks. */
|
2638
2767
|
walkVelocity?: number;
|
2639
2768
|
}
|
@@ -3600,6 +3729,7 @@ export declare class SimpleEntityController extends BaseEntityController {
|
|
3600
3729
|
|
3601
3730
|
|
3602
3731
|
|
3732
|
+
|
3603
3733
|
/**
|
3604
3734
|
* Rotates the entity at a given speed to face a target coordinate.
|
3605
3735
|
*
|
@@ -3613,6 +3743,13 @@ export declare class SimpleEntityController extends BaseEntityController {
|
|
3613
3743
|
* @param options - Additional options for the face operation, such as callbacks.
|
3614
3744
|
*/
|
3615
3745
|
face(target: Vector3Like, speed: number, options?: FaceOptions): void;
|
3746
|
+
/**
|
3747
|
+
* Applies an upwards impulse to the entity to simulate a jump, only supported
|
3748
|
+
* for entities with dynamic rigid body types.
|
3749
|
+
*
|
3750
|
+
* @param height - The height to jump to.
|
3751
|
+
*/
|
3752
|
+
jump(height: number): void;
|
3616
3753
|
/**
|
3617
3754
|
* Moves the entity at a given speed in a straight line to a target coordinate.
|
3618
3755
|
*
|
@@ -3950,6 +4087,25 @@ export declare interface Vector3Like {
|
|
3950
4087
|
z: number;
|
3951
4088
|
}
|
3952
4089
|
|
4090
|
+
/**
|
4091
|
+
* A callback function called when the entity associated with the
|
4092
|
+
* PathfindingEntityController finishes moving to a calculate waypoint
|
4093
|
+
* of its current path.
|
4094
|
+
* @param waypoint - The waypoint that the entity has finished moving to.
|
4095
|
+
* @param waypointIndex - The index of the waypoint that the entity has finished moving to.
|
4096
|
+
* @public
|
4097
|
+
*/
|
4098
|
+
export declare type WaypointMoveCompleteCallback = (waypoint: Vector3Like, waypointIndex: number) => void;
|
4099
|
+
|
4100
|
+
/**
|
4101
|
+
* A callback function called when the entity associated with the
|
4102
|
+
* PathfindingEntityController skips a waypoint because it took too long to reach.
|
4103
|
+
* @param waypoint - The waypoint that the entity skipped.
|
4104
|
+
* @param waypointIndex - The index of the waypoint that the entity skipped.
|
4105
|
+
* @public
|
4106
|
+
*/
|
4107
|
+
export declare type WaypointMoveSkippedCallback = (waypoint: Vector3Like, waypointIndex: number) => void;
|
4108
|
+
|
3953
4109
|
/**
|
3954
4110
|
* Represents a world in the game server.
|
3955
4111
|
*
|