@dcl/ecs 7.24.1-27293561585.commit-8c5b5ad → 7.24.1-27386133361.commit-558451f

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.
@@ -8,11 +8,13 @@ export interface AudioSourceComponentDefinitionExtended extends LastWriteWinElem
8
8
  /**
9
9
  * @public
10
10
  *
11
- * Set playing=true the sound `$name`
12
- * @param entity - entity with AudioSource component
11
+ * Play the sound `src` on the given entity. Creates the AudioSource component
12
+ * if it does not yet exist. Always emits a CRDT PUT, so repeated calls with
13
+ * identical parameters reliably retrigger playback.
14
+ * @param entity - target entity (AudioSource will be created if missing)
13
15
  * @param src - the path to the sound to play
14
16
  * @param resetCursor - the sound starts at 0 or continues from the current cursor position
15
- * @returns true in successful playing, false if it doesn't find the AudioSource component
17
+ * @returns always true; retained for backwards compatibility
16
18
  */
17
19
  playSound(entity: Entity, src: string, resetCursor?: boolean): boolean;
18
20
  /**
@@ -4,13 +4,13 @@ export function defineAudioSourceComponent(engine) {
4
4
  return {
5
5
  ...theComponent,
6
6
  playSound(entity, src, resetCursor = true) {
7
- // Get the mutable to modify
8
- const audioSource = theComponent.getMutableOrNull(entity);
9
- if (!audioSource)
10
- return false;
11
- audioSource.audioClipUrl = src;
12
- audioSource.playing = true;
13
- audioSource.currentTime = resetCursor ? 0 : audioSource.currentTime;
7
+ const existing = theComponent.getOrNull(entity);
8
+ theComponent.createOrReplace(entity, {
9
+ ...existing,
10
+ audioClipUrl: src,
11
+ playing: true,
12
+ currentTime: resetCursor ? 0 : existing?.currentTime ?? 0
13
+ });
14
14
  return true;
15
15
  },
16
16
  stopSound(entity, resetCursor = true) {
@@ -8,11 +8,13 @@ export interface AudioSourceComponentDefinitionExtended extends LastWriteWinElem
8
8
  /**
9
9
  * @public
10
10
  *
11
- * Set playing=true the sound `$name`
12
- * @param entity - entity with AudioSource component
11
+ * Play the sound `src` on the given entity. Creates the AudioSource component
12
+ * if it does not yet exist. Always emits a CRDT PUT, so repeated calls with
13
+ * identical parameters reliably retrigger playback.
14
+ * @param entity - target entity (AudioSource will be created if missing)
13
15
  * @param src - the path to the sound to play
14
16
  * @param resetCursor - the sound starts at 0 or continues from the current cursor position
15
- * @returns true in successful playing, false if it doesn't find the AudioSource component
17
+ * @returns always true; retained for backwards compatibility
16
18
  */
17
19
  playSound(entity: Entity, src: string, resetCursor?: boolean): boolean;
18
20
  /**
@@ -7,13 +7,13 @@ function defineAudioSourceComponent(engine) {
7
7
  return {
8
8
  ...theComponent,
9
9
  playSound(entity, src, resetCursor = true) {
10
- // Get the mutable to modify
11
- const audioSource = theComponent.getMutableOrNull(entity);
12
- if (!audioSource)
13
- return false;
14
- audioSource.audioClipUrl = src;
15
- audioSource.playing = true;
16
- audioSource.currentTime = resetCursor ? 0 : audioSource.currentTime;
10
+ const existing = theComponent.getOrNull(entity);
11
+ theComponent.createOrReplace(entity, {
12
+ ...existing,
13
+ audioClipUrl: src,
14
+ playing: true,
15
+ currentTime: resetCursor ? 0 : existing?.currentTime ?? 0
16
+ });
17
17
  return true;
18
18
  },
19
19
  stopSound(entity, resetCursor = true) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.24.1-27293561585.commit-8c5b5ad",
4
+ "version": "7.24.1-27386133361.commit-558451f",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/ecs/issues",
7
7
  "files": [
@@ -34,5 +34,5 @@
34
34
  "dependencies": {},
35
35
  "types": "./dist/index.d.ts",
36
36
  "typings": "./dist/index.d.ts",
37
- "commit": "8c5b5ad2e37f5977395ef59bd59b2be061c7a391"
37
+ "commit": "558451f7deaac1ece95b58a178ab8b291e524479"
38
38
  }