@dcl/ecs 7.27.1-33752500148.commit-5ae3ef7 → 7.27.1-33755622021.commit-da82bfb

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.
@@ -56,7 +56,9 @@ export function getComponentDefinition(engine, component) {
56
56
  */
57
57
  export function getEntityMapping(engine, compositeEntity, mappedEntities, { entityMapping }) {
58
58
  const existingEntity = mappedEntities.get(compositeEntity);
59
- if (existingEntity) {
59
+ // RootEntity is 0, so a mapping onto it is falsy. Testing the value here made
60
+ // an already-mapped entity look unmapped and allocated a second one.
61
+ if (existingEntity !== undefined) {
60
62
  return existingEntity;
61
63
  }
62
64
  if (entityMapping?.type === EntityMappingMode.EMM_DIRECT_MAPPING) {
@@ -93,7 +95,7 @@ export function instanceComposite(engine, compositeResource, compositeProvider,
93
95
  // First entity that I want to map, the root entity from the composite to the target entity in the engine
94
96
  // If there is no `rootEntity` passed, we assign one from `getNextAvailableEntity`
95
97
  const compositeRootEntity = rootEntity ?? getCompositeEntity(0);
96
- if (rootEntity) {
98
+ if (rootEntity !== undefined) {
97
99
  mappedEntities.set(0, rootEntity);
98
100
  }
99
101
  // ## 2 ##
@@ -4,7 +4,10 @@
4
4
  export const IOptional = (spec) => {
5
5
  return {
6
6
  serialize(value, builder) {
7
- if (value) {
7
+ // Only the absence of a value means absent. Testing the value itself made
8
+ // `false`, `0` and `''` indistinguishable from unset, so they could never
9
+ // be written and came back as undefined.
10
+ if (value !== undefined && value !== null) {
8
11
  builder.writeInt8(1);
9
12
  spec.serialize(value, builder);
10
13
  }
@@ -84,7 +84,9 @@ exports.getComponentDefinition = getComponentDefinition;
84
84
  */
85
85
  function getEntityMapping(engine, compositeEntity, mappedEntities, { entityMapping }) {
86
86
  const existingEntity = mappedEntities.get(compositeEntity);
87
- if (existingEntity) {
87
+ // RootEntity is 0, so a mapping onto it is falsy. Testing the value here made
88
+ // an already-mapped entity look unmapped and allocated a second one.
89
+ if (existingEntity !== undefined) {
88
90
  return existingEntity;
89
91
  }
90
92
  if (entityMapping?.type === EntityMappingMode.EMM_DIRECT_MAPPING) {
@@ -122,7 +124,7 @@ function instanceComposite(engine, compositeResource, compositeProvider, options
122
124
  // First entity that I want to map, the root entity from the composite to the target entity in the engine
123
125
  // If there is no `rootEntity` passed, we assign one from `getNextAvailableEntity`
124
126
  const compositeRootEntity = rootEntity ?? getCompositeEntity(0);
125
- if (rootEntity) {
127
+ if (rootEntity !== undefined) {
126
128
  mappedEntities.set(0, rootEntity);
127
129
  }
128
130
  // ## 2 ##
@@ -7,7 +7,10 @@ exports.IOptional = void 0;
7
7
  const IOptional = (spec) => {
8
8
  return {
9
9
  serialize(value, builder) {
10
- if (value) {
10
+ // Only the absence of a value means absent. Testing the value itself made
11
+ // `false`, `0` and `''` indistinguishable from unset, so they could never
12
+ // be written and came back as undefined.
13
+ if (value !== undefined && value !== null) {
11
14
  builder.writeInt8(1);
12
15
  spec.serialize(value, builder);
13
16
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.27.1-33752500148.commit-5ae3ef7",
4
+ "version": "7.27.1-33755622021.commit-da82bfb",
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": "5ae3ef7c921887bc7c78d88284f22fc91b1be4d4"
37
+ "commit": "da82bfb0c7b437a9410e353b085ed08ad81aeff4"
38
38
  }