hytopia 0.3.12 → 0.3.14
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/boilerplate/assets/map.json +42 -190
- package/boilerplate/assets/ui/index.html +102 -0
- package/boilerplate/index.ts +3 -0
- package/docs/server.baseentityoptions.controller.md +13 -0
- package/docs/server.baseentityoptions.md +190 -0
- package/docs/server.baseentityoptions.name.md +13 -0
- package/docs/{server.entityoptions.opacity.md → server.baseentityoptions.opacity.md} +2 -2
- package/docs/{server.entityoptions.parent.md → server.baseentityoptions.parent.md} +2 -2
- package/docs/{server.entityoptions.parentnodename.md → server.baseentityoptions.parentnodename.md} +2 -2
- package/docs/server.baseentityoptions.rigidbodyoptions.md +13 -0
- package/docs/{server.entityoptions.tag.md → server.baseentityoptions.tag.md} +2 -2
- package/docs/server.baseentityoptions.tintcolor.md +13 -0
- package/docs/{server.entityoptions.blockhalfextents.md → server.blockentityoptions.blockhalfextents.md} +2 -2
- package/docs/{server.entityoptions.blocktextureuri.md → server.blockentityoptions.blocktextureuri.md} +2 -2
- package/docs/server.blockentityoptions.md +77 -0
- package/docs/server.entityoptions.md +4 -312
- package/docs/server.md +52 -19
- package/docs/server.modelentityoptions.md +134 -0
- package/docs/server.modelentityoptions.modelanimationsplaybackrate.md +13 -0
- package/docs/server.modelentityoptions.modelhiddennodes.md +13 -0
- package/docs/server.modelentityoptions.modelloopedanimations.md +13 -0
- package/docs/server.modelentityoptions.modelscale.md +13 -0
- package/docs/server.modelentityoptions.modeluri.md +13 -0
- package/docs/server.playerentityoptions.md +5 -46
- package/docs/server.playerui.lockpointer.md +1 -1
- package/docs/server.playerui.md +1 -1
- package/examples/entity-spawn/index.ts +4 -3
- package/examples/hygrounds/classes/ChestEntity.ts +2 -2
- package/examples/hygrounds/classes/GunEntity.ts +3 -3
- package/examples/hygrounds/classes/ItemEntity.ts +13 -9
- package/examples/hygrounds/classes/MeleeWeaponEntity.ts +3 -3
- package/examples/mobile-controls/README.md +3 -0
- package/examples/mobile-controls/assets/map.json +2624 -0
- package/examples/mobile-controls/assets/ui/index.html +102 -0
- package/examples/mobile-controls/bun.lock +503 -0
- package/examples/mobile-controls/index.ts +32 -0
- package/examples/mobile-controls/package.json +15 -0
- package/examples/zombies-fps/classes/EnemyEntity.ts +2 -2
- package/examples/zombies-fps/classes/GunEntity.ts +3 -3
- package/package.json +1 -1
- package/server.api.json +614 -534
- package/server.d.ts +51 -36
- package/server.js +1 -1
- package/docs/server.entityoptions.controller.md +0 -13
- package/docs/server.entityoptions.modelanimationsplaybackrate.md +0 -13
- package/docs/server.entityoptions.modelhiddennodes.md +0 -13
- package/docs/server.entityoptions.modelloopedanimations.md +0 -13
- package/docs/server.entityoptions.modelscale.md +0 -13
- package/docs/server.entityoptions.modeluri.md +0 -13
- package/docs/server.entityoptions.name.md +0 -13
- package/docs/server.entityoptions.rigidbodyoptions.md +0 -13
- package/docs/server.entityoptions.tintcolor.md +0 -13
- package/docs/server.playerentityoptions.player.md +0 -13
@@ -0,0 +1,134 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ModelEntityOptions](./server.modelentityoptions.md)
|
4
|
+
|
5
|
+
## ModelEntityOptions interface
|
6
|
+
|
7
|
+
The options for creating a model entity.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
export interface ModelEntityOptions extends BaseEntityOptions
|
13
|
+
```
|
14
|
+
**Extends:** [BaseEntityOptions](./server.baseentityoptions.md)
|
15
|
+
|
16
|
+
## Properties
|
17
|
+
|
18
|
+
<table><thead><tr><th>
|
19
|
+
|
20
|
+
Property
|
21
|
+
|
22
|
+
|
23
|
+
</th><th>
|
24
|
+
|
25
|
+
Modifiers
|
26
|
+
|
27
|
+
|
28
|
+
</th><th>
|
29
|
+
|
30
|
+
Type
|
31
|
+
|
32
|
+
|
33
|
+
</th><th>
|
34
|
+
|
35
|
+
Description
|
36
|
+
|
37
|
+
|
38
|
+
</th></tr></thead>
|
39
|
+
<tbody><tr><td>
|
40
|
+
|
41
|
+
[modelAnimationsPlaybackRate?](./server.modelentityoptions.modelanimationsplaybackrate.md)
|
42
|
+
|
43
|
+
|
44
|
+
</td><td>
|
45
|
+
|
46
|
+
|
47
|
+
</td><td>
|
48
|
+
|
49
|
+
number
|
50
|
+
|
51
|
+
|
52
|
+
</td><td>
|
53
|
+
|
54
|
+
_(Optional)_ The playback rate of the entity's model animations.
|
55
|
+
|
56
|
+
|
57
|
+
</td></tr>
|
58
|
+
<tr><td>
|
59
|
+
|
60
|
+
[modelHiddenNodes?](./server.modelentityoptions.modelhiddennodes.md)
|
61
|
+
|
62
|
+
|
63
|
+
</td><td>
|
64
|
+
|
65
|
+
|
66
|
+
</td><td>
|
67
|
+
|
68
|
+
string\[\]
|
69
|
+
|
70
|
+
|
71
|
+
</td><td>
|
72
|
+
|
73
|
+
_(Optional)_ The nodes to hide on the entity's model.
|
74
|
+
|
75
|
+
|
76
|
+
</td></tr>
|
77
|
+
<tr><td>
|
78
|
+
|
79
|
+
[modelLoopedAnimations?](./server.modelentityoptions.modelloopedanimations.md)
|
80
|
+
|
81
|
+
|
82
|
+
</td><td>
|
83
|
+
|
84
|
+
|
85
|
+
</td><td>
|
86
|
+
|
87
|
+
string\[\]
|
88
|
+
|
89
|
+
|
90
|
+
</td><td>
|
91
|
+
|
92
|
+
_(Optional)_ The looped animations to start when the entity is spawned.
|
93
|
+
|
94
|
+
|
95
|
+
</td></tr>
|
96
|
+
<tr><td>
|
97
|
+
|
98
|
+
[modelScale?](./server.modelentityoptions.modelscale.md)
|
99
|
+
|
100
|
+
|
101
|
+
</td><td>
|
102
|
+
|
103
|
+
|
104
|
+
</td><td>
|
105
|
+
|
106
|
+
number
|
107
|
+
|
108
|
+
|
109
|
+
</td><td>
|
110
|
+
|
111
|
+
_(Optional)_ The scale of the entity's model.
|
112
|
+
|
113
|
+
|
114
|
+
</td></tr>
|
115
|
+
<tr><td>
|
116
|
+
|
117
|
+
[modelUri?](./server.modelentityoptions.modeluri.md)
|
118
|
+
|
119
|
+
|
120
|
+
</td><td>
|
121
|
+
|
122
|
+
|
123
|
+
</td><td>
|
124
|
+
|
125
|
+
string
|
126
|
+
|
127
|
+
|
128
|
+
</td><td>
|
129
|
+
|
130
|
+
_(Optional)_ The URI or path to the .gltf model asset to be used for the entity.
|
131
|
+
|
132
|
+
|
133
|
+
</td></tr>
|
134
|
+
</tbody></table>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ModelEntityOptions](./server.modelentityoptions.md) > [modelAnimationsPlaybackRate](./server.modelentityoptions.modelanimationsplaybackrate.md)
|
4
|
+
|
5
|
+
## ModelEntityOptions.modelAnimationsPlaybackRate property
|
6
|
+
|
7
|
+
The playback rate of the entity's model animations.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
modelAnimationsPlaybackRate?: number;
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ModelEntityOptions](./server.modelentityoptions.md) > [modelHiddenNodes](./server.modelentityoptions.modelhiddennodes.md)
|
4
|
+
|
5
|
+
## ModelEntityOptions.modelHiddenNodes property
|
6
|
+
|
7
|
+
The nodes to hide on the entity's model.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
modelHiddenNodes?: string[];
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ModelEntityOptions](./server.modelentityoptions.md) > [modelLoopedAnimations](./server.modelentityoptions.modelloopedanimations.md)
|
4
|
+
|
5
|
+
## ModelEntityOptions.modelLoopedAnimations property
|
6
|
+
|
7
|
+
The looped animations to start when the entity is spawned.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
modelLoopedAnimations?: string[];
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ModelEntityOptions](./server.modelentityoptions.md) > [modelScale](./server.modelentityoptions.modelscale.md)
|
4
|
+
|
5
|
+
## ModelEntityOptions.modelScale property
|
6
|
+
|
7
|
+
The scale of the entity's model.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
modelScale?: number;
|
13
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
2
|
+
|
3
|
+
[Home](./index.md) > [server](./server.md) > [ModelEntityOptions](./server.modelentityoptions.md) > [modelUri](./server.modelentityoptions.modeluri.md)
|
4
|
+
|
5
|
+
## ModelEntityOptions.modelUri property
|
6
|
+
|
7
|
+
The URI or path to the .gltf model asset to be used for the entity.
|
8
|
+
|
9
|
+
**Signature:**
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
modelUri?: string;
|
13
|
+
```
|
@@ -2,57 +2,16 @@
|
|
2
2
|
|
3
3
|
[Home](./index.md) > [server](./server.md) > [PlayerEntityOptions](./server.playerentityoptions.md)
|
4
4
|
|
5
|
-
## PlayerEntityOptions
|
5
|
+
## PlayerEntityOptions type
|
6
6
|
|
7
7
|
Options for creating a PlayerEntity instance.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
11
11
|
```typescript
|
12
|
-
export
|
12
|
+
export type PlayerEntityOptions = {
|
13
|
+
player: Player;
|
14
|
+
} & EntityOptions;
|
13
15
|
```
|
14
|
-
**
|
16
|
+
**References:** [Player](./server.player.md)<!-- -->, [EntityOptions](./server.entityoptions.md)
|
15
17
|
|
16
|
-
## Properties
|
17
|
-
|
18
|
-
<table><thead><tr><th>
|
19
|
-
|
20
|
-
Property
|
21
|
-
|
22
|
-
|
23
|
-
</th><th>
|
24
|
-
|
25
|
-
Modifiers
|
26
|
-
|
27
|
-
|
28
|
-
</th><th>
|
29
|
-
|
30
|
-
Type
|
31
|
-
|
32
|
-
|
33
|
-
</th><th>
|
34
|
-
|
35
|
-
Description
|
36
|
-
|
37
|
-
|
38
|
-
</th></tr></thead>
|
39
|
-
<tbody><tr><td>
|
40
|
-
|
41
|
-
[player](./server.playerentityoptions.player.md)
|
42
|
-
|
43
|
-
|
44
|
-
</td><td>
|
45
|
-
|
46
|
-
|
47
|
-
</td><td>
|
48
|
-
|
49
|
-
[Player](./server.player.md)
|
50
|
-
|
51
|
-
|
52
|
-
</td><td>
|
53
|
-
|
54
|
-
The player the player entity is assigned to.
|
55
|
-
|
56
|
-
|
57
|
-
</td></tr>
|
58
|
-
</tbody></table>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## PlayerUI.lockPointer() method
|
6
6
|
|
7
|
-
Locks or unlocks the player's mouse pointer.
|
7
|
+
Locks or unlocks the player's mouse pointer. If the pointer is unlocked with lockPointer(false), the player will not be able to use in-game inputs or camera controls from the mouse pointer until `player.ui.lockPointer(true)`<!-- -->, or in your game's client UI html with `hytopia.lockPointer(true)`<!-- -->.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
package/docs/server.playerui.md
CHANGED
@@ -111,7 +111,7 @@ Loads client UI for the player.
|
|
111
111
|
|
112
112
|
</td><td>
|
113
113
|
|
114
|
-
Locks or unlocks the player's mouse pointer.
|
114
|
+
Locks or unlocks the player's mouse pointer. If the pointer is unlocked with lockPointer(false), the player will not be able to use in-game inputs or camera controls from the mouse pointer until `player.ui.lockPointer(true)`<!-- -->, or in your game's client UI html with `hytopia.lockPointer(true)`<!-- -->.
|
115
115
|
|
116
116
|
|
117
117
|
</td></tr>
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
startServer,
|
3
|
+
BlockType,
|
4
|
+
Collider,
|
3
5
|
ColliderShape,
|
4
6
|
Entity,
|
5
7
|
EntityEvent,
|
@@ -7,7 +9,6 @@ import {
|
|
7
9
|
PlayerEvent,
|
8
10
|
RigidBodyType,
|
9
11
|
World,
|
10
|
-
Collider,
|
11
12
|
} from 'hytopia';
|
12
13
|
|
13
14
|
import worldMap from './assets/map.json';
|
@@ -41,8 +42,8 @@ startServer(world => {
|
|
41
42
|
radius: 9,
|
42
43
|
isSensor: true, // Sensors are colliders that do not react with physics, but can still trigger collision events.
|
43
44
|
tag: 'aggro-sensor',
|
44
|
-
onCollision: (
|
45
|
-
console.log('spider aggro-sensor colliding with',
|
45
|
+
onCollision: (other: Entity | BlockType, started: boolean) => {
|
46
|
+
console.log('spider aggro-sensor colliding with', other.name, started);
|
46
47
|
},
|
47
48
|
},
|
48
49
|
],
|
@@ -3,7 +3,7 @@ import {
|
|
3
3
|
BallColliderOptions,
|
4
4
|
Collider,
|
5
5
|
Entity,
|
6
|
-
|
6
|
+
ModelEntityOptions,
|
7
7
|
QuaternionLike,
|
8
8
|
SceneUI,
|
9
9
|
Vector3Like,
|
@@ -18,7 +18,7 @@ export default class ChestEntity extends Entity {
|
|
18
18
|
private _openAudio: Audio;
|
19
19
|
private _opened: boolean = false;
|
20
20
|
|
21
|
-
public constructor(options:
|
21
|
+
public constructor(options: Partial<ModelEntityOptions> = {}) {
|
22
22
|
super({
|
23
23
|
modelUri: 'models/environment/chest.gltf',
|
24
24
|
modelScale: 1,
|
@@ -14,7 +14,7 @@ import type { ItemEntityOptions } from './ItemEntity';
|
|
14
14
|
|
15
15
|
export type GunHand = 'left' | 'right' | 'both';
|
16
16
|
|
17
|
-
export
|
17
|
+
export type GunEntityOptions = {
|
18
18
|
ammo: number; // The amount of ammo in the clip.
|
19
19
|
damage: number; // The damage of the gun.
|
20
20
|
fireRate: number; // Bullets shot per second.
|
@@ -25,7 +25,7 @@ export interface GunEntityOptions extends ItemEntityOptions {
|
|
25
25
|
reloadTimeMs: number; // Seconds to reload.
|
26
26
|
shootAudioUri: string; // The audio played when shooting
|
27
27
|
scopeZoom?: number; // The zoom level when scoped in.
|
28
|
-
}
|
28
|
+
} & ItemEntityOptions;
|
29
29
|
|
30
30
|
export default abstract class GunEntity extends ItemEntity {
|
31
31
|
protected readonly damage: number;
|
@@ -44,7 +44,7 @@ export default abstract class GunEntity extends ItemEntity {
|
|
44
44
|
private _shootAudio: Audio;
|
45
45
|
|
46
46
|
public constructor(options: GunEntityOptions) {
|
47
|
-
if (!options
|
47
|
+
if (!('modelUri' in options)) {
|
48
48
|
throw new Error('GunEntity requires modelUri');
|
49
49
|
}
|
50
50
|
|
@@ -4,11 +4,14 @@ import {
|
|
4
4
|
CollisionGroup,
|
5
5
|
Entity,
|
6
6
|
EntityOptions,
|
7
|
+
BlockEntityOptions,
|
8
|
+
ModelEntityOptions,
|
7
9
|
PlayerEntityController,
|
8
10
|
QuaternionLike,
|
9
11
|
SceneUI,
|
10
12
|
Vector3Like,
|
11
13
|
World,
|
14
|
+
ErrorHandler,
|
12
15
|
} from 'hytopia';
|
13
16
|
|
14
17
|
import GamePlayerEntity from './GamePlayerEntity';
|
@@ -18,7 +21,7 @@ const INVENTORIED_POSITION = { x: 0, y: -300, z: 0 };
|
|
18
21
|
|
19
22
|
export type HeldHand = 'left' | 'right' | 'both';
|
20
23
|
|
21
|
-
export
|
24
|
+
export type ItemEntityOptions = {
|
22
25
|
heldHand: HeldHand; // The hand the item is held in.
|
23
26
|
iconImageUri: string; // The image uri of the weapon icon.
|
24
27
|
idleAnimation: string; // The animation played when the player holding it is idle.
|
@@ -27,7 +30,7 @@ export interface ItemEntityOptions extends EntityOptions {
|
|
27
30
|
consumable?: boolean;
|
28
31
|
consumeAudioUri?: string;
|
29
32
|
consumeTimeMs?: number;
|
30
|
-
}
|
33
|
+
} & EntityOptions;
|
31
34
|
|
32
35
|
export default class ItemEntity extends Entity {
|
33
36
|
public readonly consumable: boolean;
|
@@ -42,19 +45,20 @@ export default class ItemEntity extends Entity {
|
|
42
45
|
private readonly _labelSceneUI: SceneUI;
|
43
46
|
|
44
47
|
public constructor(options: ItemEntityOptions) {
|
45
|
-
|
46
|
-
throw new Error('ItemEntity requires either modelUri or blockHalfExtents');
|
47
|
-
}
|
48
|
-
|
49
|
-
const colliderOptions = options.modelUri
|
48
|
+
const colliderOptions = 'modelUri' in options && options.modelUri
|
50
49
|
? Collider.optionsFromModelUri(options.modelUri)
|
51
|
-
:
|
50
|
+
: 'blockHalfExtents' in options && options.blockHalfExtents
|
51
|
+
? Collider.optionsFromBlockHalfExtents(options.blockHalfExtents)
|
52
|
+
: undefined;
|
52
53
|
|
54
|
+
if (!colliderOptions) {
|
55
|
+
ErrorHandler.fatalError('ItemEntity.constructor(): Item must be a model or block entity!');
|
56
|
+
}
|
53
57
|
|
54
58
|
super({
|
55
59
|
...options,
|
56
60
|
parentNodeName: ItemEntity._getHandAnchorNode(options.heldHand),
|
57
|
-
rigidBodyOptions: ItemEntity._createRigidBodyOptions(colliderOptions, options.modelScale ?? 1),
|
61
|
+
rigidBodyOptions: ItemEntity._createRigidBodyOptions(colliderOptions, 'modelScale' in options ? options.modelScale ?? 1 : 1),
|
58
62
|
});
|
59
63
|
|
60
64
|
this.consumable = options.consumable ?? false;
|
@@ -11,14 +11,14 @@ import ItemEntity from './ItemEntity';
|
|
11
11
|
import TerrainDamageManager from './TerrainDamageManager';
|
12
12
|
import type { ItemEntityOptions } from './ItemEntity';
|
13
13
|
|
14
|
-
export
|
14
|
+
export type MeleeWeaponEntityOptions = {
|
15
15
|
damage: number; // The damage dealt by the weapon
|
16
16
|
attackRate: number; // Attacks per second
|
17
17
|
range: number; // The range of the melee attack
|
18
18
|
attackAudioUri: string; // The audio played when attacking
|
19
19
|
hitAudioUri: string; // The audio played when hitting an entity or block
|
20
|
-
minesMaterials: boolean;
|
21
|
-
}
|
20
|
+
minesMaterials: boolean; // Whether the weapon mines materials when it hits a block
|
21
|
+
} & ItemEntityOptions;
|
22
22
|
|
23
23
|
export default abstract class MeleeWeaponEntity extends ItemEntity {
|
24
24
|
protected readonly damage: number;
|