hytopia 0.1.96 → 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.md +19 -0
- package/docs/server.playerentitycontrolleroptions.autocancelmouseleftclick.md +13 -0
- package/docs/server.playerentitycontrolleroptions.md +19 -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/ui/index.html +35 -0
- package/examples/zombies-fps/bun.lockb +0 -0
- package/examples/zombies-fps/classes/GamePlayerEntity.ts +49 -16
- package/examples/zombies-fps/classes/GunEntity.ts +66 -0
- package/examples/zombies-fps/classes/guns/BulletEntity.ts +0 -0
- package/examples/zombies-fps/classes/guns/PistolEntity.ts +49 -0
- package/examples/zombies-fps/index.ts +5 -1
- package/package.json +1 -1
- package/server.api.json +713 -0
- package/server.d.ts +136 -0
- package/server.js +87 -87
- package/examples/zombies-fps/classes/WeaponEntity.ts +0 -32
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.
|
@@ -2632,6 +2739,8 @@ export declare class PlayerEntityController extends BaseEntityController {
|
|
2632
2739
|
|
2633
2740
|
/** Options for creating a PlayerEntityController instance. @public */
|
2634
2741
|
export declare interface PlayerEntityControllerOptions {
|
2742
|
+
/** Whether to automatically cancel left click input after first processed tick, defaults to true. */
|
2743
|
+
autoCancelMouseLeftClick?: boolean;
|
2635
2744
|
/** A function allowing custom logic to determine if the entity can jump. */
|
2636
2745
|
canJump?: () => boolean;
|
2637
2746
|
/** A function allowing custom logic to determine if the entity can walk. */
|
@@ -3620,6 +3729,7 @@ export declare class SimpleEntityController extends BaseEntityController {
|
|
3620
3729
|
|
3621
3730
|
|
3622
3731
|
|
3732
|
+
|
3623
3733
|
/**
|
3624
3734
|
* Rotates the entity at a given speed to face a target coordinate.
|
3625
3735
|
*
|
@@ -3633,6 +3743,13 @@ export declare class SimpleEntityController extends BaseEntityController {
|
|
3633
3743
|
* @param options - Additional options for the face operation, such as callbacks.
|
3634
3744
|
*/
|
3635
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;
|
3636
3753
|
/**
|
3637
3754
|
* Moves the entity at a given speed in a straight line to a target coordinate.
|
3638
3755
|
*
|
@@ -3970,6 +4087,25 @@ export declare interface Vector3Like {
|
|
3970
4087
|
z: number;
|
3971
4088
|
}
|
3972
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
|
+
|
3973
4109
|
/**
|
3974
4110
|
* Represents a world in the game server.
|
3975
4111
|
*
|