@hytopia.com/examples 1.0.32 → 1.0.34

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.
@@ -0,0 +1,36 @@
1
+ {
2
+ "health": 94,
3
+ "currentRegionId": "hearthwilds",
4
+ "currentRegionSpawnFacingAngle": 90,
5
+ "currentRegionSpawnPoint": {
6
+ "x": 249,
7
+ "y": 22,
8
+ "z": -89
9
+ },
10
+ "skillExperience": [
11
+ [
12
+ "agility",
13
+ 8
14
+ ]
15
+ ],
16
+ "backpack": {
17
+ "items": []
18
+ },
19
+ "hotbar": {
20
+ "items": [
21
+ {
22
+ "position": 0,
23
+ "itemId": "toy_sword"
24
+ }
25
+ ]
26
+ },
27
+ "questLog": {
28
+ "quests": []
29
+ },
30
+ "storage": {
31
+ "items": []
32
+ },
33
+ "wearables": {
34
+ "items": []
35
+ }
36
+ }
@@ -216,6 +216,11 @@ export default class GamePlayerEntity extends DefaultPlayerEntity implements IDa
216
216
 
217
217
  public override spawn(world: World, position: Vector3Like, rotation?: QuaternionLike) {
218
218
  super.spawn(world, position, rotation);
219
+
220
+ this.setCollisionGroupsForSolidColliders({
221
+ belongsTo: [ CollisionGroup.PLAYER ],
222
+ collidesWith: [ CollisionGroup.ALL ],
223
+ })
219
224
 
220
225
  this._gamePlayer.onEntitySpawned(this);
221
226
 
@@ -2,6 +2,7 @@ import {
2
2
  Audio,
3
3
  Collider,
4
4
  ColliderShape,
5
+ CollisionGroup,
5
6
  BlockType,
6
7
  Entity,
7
8
  ErrorHandler,
@@ -121,6 +122,10 @@ export default class GameRegion {
121
122
 
122
123
  new Collider({ // Out of world collider
123
124
  shape: ColliderShape.BLOCK,
125
+ collisionGroups: {
126
+ belongsTo: [ CollisionGroup.ALL ],
127
+ collidesWith: [ CollisionGroup.ENTITY, CollisionGroup.PLAYER ],
128
+ },
124
129
  halfExtents: { x: 500, y : 32, z: 500 },
125
130
  isSensor: true,
126
131
  relativePosition: { x: 0, y: -64, z: 0 },
@@ -223,13 +223,17 @@ export default class BaseCombatEntity extends BaseEntity {
223
223
  public override spawn(world: World, position: Vector3Like, rotation?: QuaternionLike): void {
224
224
  super.spawn(world, position, rotation);
225
225
 
226
+ // This is an optimization to reduce the amount of work the physics engien needs
227
+ // to do in the narrow phase for checking collisions with the aggro sensor collider.
228
+ const playerAggroOnly = this._aggroPotentialTargetTypes.length === 1 && this._aggroPotentialTargetTypes[0] === GamePlayerEntity;
229
+
226
230
  // Create the aggro sensor collider
227
231
  this.createAndAddChildCollider({
228
232
  shape: ColliderShape.BALL,
229
233
  radius: this._aggroRadius,
230
234
  collisionGroups: {
231
235
  belongsTo: [ CollisionGroup.ENTITY_SENSOR ],
232
- collidesWith: [ CollisionGroup.ENTITY ],
236
+ collidesWith: playerAggroOnly ? [ CollisionGroup.PLAYER ] : [ CollisionGroup.ENTITY, CollisionGroup.PLAYER ],
233
237
  },
234
238
  isSensor: true,
235
239
  tag: 'aggroSensor',
@@ -2,6 +2,7 @@ import {
2
2
  BlockColliderOptions,
3
3
  Collider,
4
4
  ColliderShape,
5
+ CollisionGroup,
5
6
  Entity,
6
7
  ErrorHandler,
7
8
  ModelEntityOptions,
@@ -40,6 +41,10 @@ export default class PortalEntity extends Entity {
40
41
  colliders: [
41
42
  {
42
43
  ...colliderOptions,
44
+ collisionGroups: {
45
+ belongsTo: [ CollisionGroup.ALL ],
46
+ collidesWith: [ CollisionGroup.PLAYER ],
47
+ },
43
48
  isSensor: true,
44
49
  onCollision: (other, started) => {
45
50
  if (!(other instanceof GamePlayerEntity)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/examples",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -45,6 +45,7 @@ startServer(world => {
45
45
  velocityVariance: { x: 4, y: 2, z: 4 }, // Variates the base velocity +/- this value
46
46
  });
47
47
  dirtParticleEmitter.spawn(world);
48
+ dirtParticleEmitter.stop();
48
49
 
49
50
  // Start/stop the emitter every 3 seconds
50
51
  setInterval(() => {
@@ -55,6 +56,11 @@ startServer(world => {
55
56
  }
56
57
  }, 5000);
57
58
 
59
+ // Burst every 1 second, regardless of pause state
60
+ setInterval(() => {
61
+ dirtParticleEmitter.burst(500);
62
+ }, 3000);
63
+
58
64
 
59
65
  // Falling sparkles emitter
60
66
  const fallingSparklesEmitter = new ParticleEmitter({