hytopia 0.1.55 → 0.1.56
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.basecharactercontroller.attach.md +53 -0
- package/docs/server.basecharactercontroller.despawn.md +53 -0
- package/docs/server.basecharactercontroller.detach.md +53 -0
- package/docs/server.basecharactercontroller.md +91 -28
- package/docs/server.basecharactercontroller.onattach.md +13 -0
- package/docs/server.basecharactercontroller.ondespawn.md +13 -0
- package/docs/server.basecharactercontroller.ondetach.md +13 -0
- package/docs/server.basecharactercontroller.onspawn.md +13 -0
- package/docs/server.basecharactercontroller.ontick.md +2 -2
- package/docs/server.basecharactercontroller.ontickwithplayerinput.md +2 -2
- package/docs/server.basecharactercontroller.spawn.md +53 -0
- package/docs/server.basecharactercontroller.tick.md +15 -1
- package/docs/server.basecharactercontroller.tickwithplayerinput.md +17 -1
- package/docs/server.defaultcharactercontroller._constructor_.md +1 -17
- package/docs/server.defaultcharactercontroller.attach.md +53 -0
- package/docs/server.defaultcharactercontroller.md +18 -4
- package/docs/server.defaultcharactercontroller.spawn.md +53 -0
- package/docs/server.defaultcharactercontroller.tickwithplayerinput.md +17 -1
- package/docs/server.entity.md +0 -19
- package/docs/server.entity.setcharactercontroller.md +2 -2
- package/docs/server.entityoptions.charactercontroller.md +13 -0
- package/docs/server.entityoptions.md +3 -3
- package/examples/block-entity/index.ts +1 -1
- package/examples/character-controller/MyCharacterController.ts +190 -119
- package/examples/character-controller/index.ts +5 -10
- package/examples/custom-ui/index.ts +1 -1
- package/examples/payload-game/index.ts +6 -7
- package/package.json +1 -1
- package/server.api.json +468 -176
- package/server.d.ts +71 -40
- package/server.js +81 -81
- package/docs/server.basecharactercontroller._constructor_.md +0 -65
- package/docs/server.basecharactercontroller.createcolliders.md +0 -19
- package/docs/server.basecharactercontroller.entity.md +0 -13
- package/docs/server.defaultcharactercontroller.createcolliders.md +0 -19
- package/docs/server.entity.createcustomcharactercontroller.md +0 -13
- package/docs/server.entityoptions.createcustomcharactercontroller.md +0 -13
package/server.d.ts
CHANGED
@@ -287,48 +287,82 @@ export declare interface AudioOptions {
|
|
287
287
|
* @public
|
288
288
|
*/
|
289
289
|
export declare abstract class BaseCharacterController {
|
290
|
-
/** The entity the controller is for. */
|
291
|
-
readonly entity: Entity;
|
292
290
|
/**
|
293
|
-
* A
|
294
|
-
*
|
291
|
+
* A function that is called every tick. Useful for implementing
|
292
|
+
* tick logic without writing a new character controller class.
|
295
293
|
*/
|
296
|
-
onTick?: (deltaTimeMs: number) => void;
|
294
|
+
onTick?: (entity: Entity, deltaTimeMs: number) => void;
|
297
295
|
/**
|
298
|
-
* A
|
299
|
-
*
|
300
|
-
*
|
301
|
-
|
302
|
-
|
296
|
+
* A function that is called every tick with player input by a
|
297
|
+
* PlayerEntity with this controller attached. Useful for implementing
|
298
|
+
* tick logic without writing a new character controller class.
|
299
|
+
*/
|
300
|
+
onTickWithPlayerInput?: (entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number) => void;
|
301
|
+
/**
|
302
|
+
* A function that is called when the controller is attached to an entity.
|
303
|
+
* Useful for implementing attach logic without writing a
|
304
|
+
* new character controller class.
|
305
|
+
*/
|
306
|
+
onAttach?: (entity: Entity) => void;
|
307
|
+
/**
|
308
|
+
* A function that is called when the controlled entity is despawned.
|
309
|
+
* Useful for implementing despawn logic without writing a
|
310
|
+
* new character controller class.
|
311
|
+
*/
|
312
|
+
onDespawn?: (entity: Entity) => void;
|
313
|
+
/**
|
314
|
+
* A function that is called when the controller is detached from an entity.
|
315
|
+
* Useful for implementing detach logic without writing a
|
316
|
+
* new character controller class.
|
317
|
+
*/
|
318
|
+
onDetach?: (entity: Entity) => void;
|
319
|
+
/**
|
320
|
+
* A function that is called when the controlled entity is spawned.
|
321
|
+
* Useful for implementing spawn logic without writing a
|
322
|
+
* new character controller class.
|
303
323
|
*/
|
304
|
-
|
324
|
+
onSpawn?: (entity: Entity) => void;
|
325
|
+
/**
|
326
|
+
* Override this method to handle the attachment of an entity
|
327
|
+
* to your character controller.
|
328
|
+
* @param entity - The entity to attach the controller to.
|
329
|
+
*/
|
330
|
+
attach(entity: Entity): void;
|
305
331
|
/**
|
306
|
-
*
|
307
|
-
*
|
332
|
+
* Override this method to handle the despawn of an entity
|
333
|
+
* from your character controller.
|
334
|
+
* @param entity - The entity to despawn.
|
308
335
|
*/
|
309
|
-
|
336
|
+
despawn(entity: Entity): void;
|
310
337
|
/**
|
311
|
-
* Override this method to
|
312
|
-
*
|
313
|
-
* @
|
338
|
+
* Override this method to handle the detachment of an entity
|
339
|
+
* from your character controller.
|
340
|
+
* @param entity - The entity to detach.
|
314
341
|
*/
|
315
|
-
|
342
|
+
detach(entity: Entity): void;
|
343
|
+
/**
|
344
|
+
* Override this method to handle the spawning of an entity
|
345
|
+
* to your character controller.
|
346
|
+
* @param entity - The entity to spawn.
|
347
|
+
*/
|
348
|
+
spawn(entity: Entity): void;
|
316
349
|
/**
|
317
350
|
* Override this method to handle entity movements
|
318
351
|
* based on player input for your character controller.
|
319
352
|
* This is called every tick by a PlayerEntity with a
|
320
353
|
* character controller.
|
354
|
+
* @param entity - The entity to tick.
|
321
355
|
* @param input - The current input state of the player.
|
322
356
|
* @param cameraOrientation - The current camera orientation state of the player.
|
323
357
|
* @param deltaTimeMs - The delta time in milliseconds since the last tick.
|
324
358
|
*/
|
325
|
-
tickWithPlayerInput(input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
|
359
|
+
tickWithPlayerInput(entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
|
326
360
|
/**
|
327
361
|
* Override this method to handle entity movements
|
328
362
|
* based on your character controller.
|
329
363
|
* @param deltaTimeMs - The delta time in milliseconds since the last tick.
|
330
364
|
*/
|
331
|
-
tick(deltaTimeMs: number): void;
|
365
|
+
tick(entity: Entity, deltaTimeMs: number): void;
|
332
366
|
}
|
333
367
|
|
334
368
|
/**
|
@@ -1198,10 +1232,9 @@ export declare class DefaultCharacterController extends BaseCharacterController
|
|
1198
1232
|
|
1199
1233
|
|
1200
1234
|
/**
|
1201
|
-
* @param entity - The entity the controller is for.
|
1202
1235
|
* @param options - Options for the controller.
|
1203
1236
|
*/
|
1204
|
-
constructor(
|
1237
|
+
constructor(options?: DefaultCharacterControllerOptions);
|
1205
1238
|
/** Whether the entity is grounded. */
|
1206
1239
|
get isGrounded(): boolean;
|
1207
1240
|
/** Whether the entity is on a platform, a platform is any entity with a kinematic rigid body. */
|
@@ -1209,19 +1242,27 @@ export declare class DefaultCharacterController extends BaseCharacterController
|
|
1209
1242
|
/** The platform the entity is on, if any. */
|
1210
1243
|
get platform(): Entity | undefined;
|
1211
1244
|
/**
|
1212
|
-
*
|
1213
|
-
*
|
1214
|
-
* @returns An array of colliders.
|
1245
|
+
* Called when the controller is attached to an entity.
|
1246
|
+
* @param entity - The entity to attach the controller to.
|
1215
1247
|
*/
|
1216
|
-
|
1248
|
+
attach(entity: Entity): void;
|
1249
|
+
/**
|
1250
|
+
* Called when the controlled entity is spawned.
|
1251
|
+
* In DefaultCharacterController, this function is used to create
|
1252
|
+
* the colliders for the entity for wall and ground detection.
|
1253
|
+
* @param entity - The entity that is spawned.
|
1254
|
+
*/
|
1255
|
+
spawn(entity: Entity): void;
|
1217
1256
|
/**
|
1218
1257
|
* Ticks the player movement for the character controller,
|
1219
1258
|
* overriding the default implementation.
|
1259
|
+
*
|
1260
|
+
* @param entity - The entity to tick.
|
1220
1261
|
* @param input - The current input state of the player.
|
1221
1262
|
* @param cameraOrientation - The current camera orientation state of the player.
|
1222
1263
|
* @param deltaTimeMs - The delta time in milliseconds since the last tick.
|
1223
1264
|
*/
|
1224
|
-
tickWithPlayerInput(input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
|
1265
|
+
tickWithPlayerInput(entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
|
1225
1266
|
}
|
1226
1267
|
|
1227
1268
|
/** Options for creating a DefaultCharacterController instance. @public */
|
@@ -1276,12 +1317,6 @@ export declare interface DefaultCharacterControllerOptions {
|
|
1276
1317
|
* @public
|
1277
1318
|
*/
|
1278
1319
|
export declare class Entity extends RigidBody implements protocol.Serializable {
|
1279
|
-
/**
|
1280
|
-
* A function that creates a custom character controller for the entity when it spawns.
|
1281
|
-
* @param entity - The Entity instance the character controller is created for.
|
1282
|
-
* @returns A character controller that extends {@link BaseCharacterController}.
|
1283
|
-
*/
|
1284
|
-
createCustomCharacterController?: (entity: Entity) => BaseCharacterController;
|
1285
1320
|
/**
|
1286
1321
|
* A function that is called when the entity collides with a block.
|
1287
1322
|
*
|
@@ -1405,7 +1440,7 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
|
|
1405
1440
|
* Sets the character controller for the entity.
|
1406
1441
|
* @param characterController - The character controller to set.
|
1407
1442
|
*/
|
1408
|
-
setCharacterController(characterController: BaseCharacterController): void;
|
1443
|
+
setCharacterController(characterController: BaseCharacterController | undefined): void;
|
1409
1444
|
/**
|
1410
1445
|
* Sets the nodes to hide on the entity's model. Matched nodes
|
1411
1446
|
* will be hidden for all players. Uses case insensitive
|
@@ -1575,12 +1610,8 @@ export declare interface EntityOptions {
|
|
1575
1610
|
blockHalfExtents?: Vector3Like;
|
1576
1611
|
/** The texture uri of a entity if the entity is a block entity, if set rigidBodyOptions collider shape [0] must be a block */
|
1577
1612
|
blockTextureUri?: string;
|
1578
|
-
/**
|
1579
|
-
|
1580
|
-
* @param entity - The Entity instance.
|
1581
|
-
* @returns A character controller that extends {@link BaseCharacterController}.
|
1582
|
-
*/
|
1583
|
-
createCustomCharacterController?: (entity: Entity) => BaseCharacterController;
|
1613
|
+
/** The character controller to use for the entity. */
|
1614
|
+
characterController?: BaseCharacterController;
|
1584
1615
|
/** The URI or path to the .gltf model asset to be used for the entity. */
|
1585
1616
|
modelUri?: string;
|
1586
1617
|
/** The nodes to hide on the entity's model. */
|