@dcl/ecs 7.3.40-7698451743.commit-c9c61fe → 7.3.40-7717066166.commit-ece036d
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/dist/components/generated/global.gen.d.ts +8 -0
- package/dist/components/generated/global.gen.js +4 -0
- package/dist/components/generated/index.gen.d.ts +16 -0
- package/dist/components/generated/index.gen.js +22 -0
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_emote_command.gen.d.ts +2 -13
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_emote_command.gen.js +14 -43
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_equipped_data.gen.d.ts +1 -1
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_equipped_data.gen.js +3 -3
- package/dist/engine/component.d.ts +6 -0
- package/dist/engine/entity.d.ts +8 -4
- package/dist/engine/entity.js +13 -48
- package/dist/engine/grow-only-value-set-component-definition.js +9 -1
- package/dist/engine/index.js +28 -9
- package/dist/engine/lww-element-set-component-definition.js +8 -1
- package/dist/engine/types.d.ts +2 -1
- package/dist/systems/crdt/index.js +1 -1
- package/dist-cjs/components/generated/global.gen.d.ts +8 -0
- package/dist-cjs/components/generated/global.gen.js +5 -1
- package/dist-cjs/components/generated/index.gen.d.ts +16 -0
- package/dist-cjs/components/generated/index.gen.js +27 -1
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_emote_command.gen.d.ts +2 -13
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_emote_command.gen.js +15 -44
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_equipped_data.gen.d.ts +1 -1
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_equipped_data.gen.js +3 -3
- package/dist-cjs/engine/component.d.ts +6 -0
- package/dist-cjs/engine/entity.d.ts +8 -4
- package/dist-cjs/engine/entity.js +15 -50
- package/dist-cjs/engine/grow-only-value-set-component-definition.js +9 -1
- package/dist-cjs/engine/index.js +27 -8
- package/dist-cjs/engine/lww-element-set-component-definition.js +8 -1
- package/dist-cjs/engine/types.d.ts +2 -1
- package/dist-cjs/systems/crdt/index.js +1 -1
- package/package.json +2 -2
|
@@ -170,6 +170,7 @@ export function createComponentDefinitionFromSchema(componentName, componentId,
|
|
|
170
170
|
const data = new Map();
|
|
171
171
|
const dirtyIterator = new Set();
|
|
172
172
|
const timestamps = new Map();
|
|
173
|
+
const onChangeCallbacks = new Map();
|
|
173
174
|
return {
|
|
174
175
|
get componentId() {
|
|
175
176
|
return componentId;
|
|
@@ -261,6 +262,12 @@ export function createComponentDefinitionFromSchema(componentName, componentId,
|
|
|
261
262
|
},
|
|
262
263
|
getCrdtUpdates: createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data),
|
|
263
264
|
updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data),
|
|
264
|
-
dumpCrdtStateToBuffer: createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data)
|
|
265
|
+
dumpCrdtStateToBuffer: createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data),
|
|
266
|
+
onChange(entity, cb) {
|
|
267
|
+
onChangeCallbacks.set(entity, cb);
|
|
268
|
+
},
|
|
269
|
+
__onChangeCallbacks(entity) {
|
|
270
|
+
return onChangeCallbacks.get(entity);
|
|
271
|
+
}
|
|
265
272
|
};
|
|
266
273
|
}
|
package/dist/engine/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { MapResult, Spec } from '../schemas/Map';
|
|
|
3
3
|
import { OnChangeFunction } from '../systems/crdt';
|
|
4
4
|
import { Transport } from '../systems/crdt/types';
|
|
5
5
|
import { ComponentDefinition, GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition } from './component';
|
|
6
|
-
import { Entity, EntityState } from './entity';
|
|
6
|
+
import { Entity, IEntityContainer, EntityState } from './entity';
|
|
7
7
|
import { ValueSetOptions } from './grow-only-value-set-component-definition';
|
|
8
8
|
import { ReadonlyComponentSchema } from './readonly';
|
|
9
9
|
import { SystemFn } from './systems';
|
|
@@ -38,6 +38,7 @@ export interface MapComponentDefinition<T> extends LastWriteWinElementSetCompone
|
|
|
38
38
|
*/
|
|
39
39
|
export interface IEngineOptions {
|
|
40
40
|
onChangeFunction: OnChangeFunction;
|
|
41
|
+
entityContainer?: IEntityContainer;
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* @public
|
|
@@ -139,7 +139,7 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
139
139
|
if (!conflictMessage) {
|
|
140
140
|
// Add message to transport queue to be processed by others transports
|
|
141
141
|
broadcastMessages.push(msg);
|
|
142
|
-
onProcessEntityComponentChange && onProcessEntityComponentChange(
|
|
142
|
+
onProcessEntityComponentChange && onProcessEntityComponentChange(entityId, msg.type, component, value);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
@@ -3,6 +3,9 @@ export * from './index.gen';
|
|
|
3
3
|
import { PBAudioSource } from './pb/decentraland/sdk/components/audio_source.gen';
|
|
4
4
|
import { PBAudioStream } from './pb/decentraland/sdk/components/audio_stream.gen';
|
|
5
5
|
import { PBAvatarAttach } from './pb/decentraland/sdk/components/avatar_attach.gen';
|
|
6
|
+
import { PBAvatarBase } from './pb/decentraland/sdk/components/avatar_base.gen';
|
|
7
|
+
import { PBAvatarEmoteCommand } from './pb/decentraland/sdk/components/avatar_emote_command.gen';
|
|
8
|
+
import { PBAvatarEquippedData } from './pb/decentraland/sdk/components/avatar_equipped_data.gen';
|
|
6
9
|
import { PBAvatarModifierArea } from './pb/decentraland/sdk/components/avatar_modifier_area.gen';
|
|
7
10
|
import { PBAvatarShape } from './pb/decentraland/sdk/components/avatar_shape.gen';
|
|
8
11
|
import { PBBillboard } from './pb/decentraland/sdk/components/billboard.gen';
|
|
@@ -12,6 +15,7 @@ import { PBEngineInfo } from './pb/decentraland/sdk/components/engine_info.gen';
|
|
|
12
15
|
import { PBGltfContainer } from './pb/decentraland/sdk/components/gltf_container.gen';
|
|
13
16
|
import { PBGltfContainerLoadingState } from './pb/decentraland/sdk/components/gltf_container_loading_state.gen';
|
|
14
17
|
import { PBNftShape } from './pb/decentraland/sdk/components/nft_shape.gen';
|
|
18
|
+
import { PBPlayerIdentityData } from './pb/decentraland/sdk/components/player_identity_data.gen';
|
|
15
19
|
import { PBPointerEvents } from './pb/decentraland/sdk/components/pointer_events.gen';
|
|
16
20
|
import { PBPointerEventsResult } from './pb/decentraland/sdk/components/pointer_events_result.gen';
|
|
17
21
|
import { PBPointerLock } from './pb/decentraland/sdk/components/pointer_lock.gen';
|
|
@@ -34,6 +38,9 @@ import { PBVisibilityComponent } from './pb/decentraland/sdk/components/visibili
|
|
|
34
38
|
/** @public */ export declare const AudioSource: LastWriteWinElementSetComponentDefinition<PBAudioSource>;
|
|
35
39
|
/** @public */ export declare const AudioStream: LastWriteWinElementSetComponentDefinition<PBAudioStream>;
|
|
36
40
|
/** @public */ export declare const AvatarAttach: LastWriteWinElementSetComponentDefinition<PBAvatarAttach>;
|
|
41
|
+
/** @public */ export declare const AvatarBase: LastWriteWinElementSetComponentDefinition<PBAvatarBase>;
|
|
42
|
+
/** @public */ export declare const AvatarEmoteCommand: GrowOnlyValueSetComponentDefinition<PBAvatarEmoteCommand>;
|
|
43
|
+
/** @public */ export declare const AvatarEquippedData: LastWriteWinElementSetComponentDefinition<PBAvatarEquippedData>;
|
|
37
44
|
/** @public */ export declare const AvatarModifierArea: LastWriteWinElementSetComponentDefinition<PBAvatarModifierArea>;
|
|
38
45
|
/** @public */ export declare const AvatarShape: LastWriteWinElementSetComponentDefinition<PBAvatarShape>;
|
|
39
46
|
/** @public */ export declare const Billboard: LastWriteWinElementSetComponentDefinition<PBBillboard>;
|
|
@@ -43,6 +50,7 @@ import { PBVisibilityComponent } from './pb/decentraland/sdk/components/visibili
|
|
|
43
50
|
/** @public */ export declare const GltfContainer: LastWriteWinElementSetComponentDefinition<PBGltfContainer>;
|
|
44
51
|
/** @public */ export declare const GltfContainerLoadingState: LastWriteWinElementSetComponentDefinition<PBGltfContainerLoadingState>;
|
|
45
52
|
/** @public */ export declare const NftShape: LastWriteWinElementSetComponentDefinition<PBNftShape>;
|
|
53
|
+
/** @public */ export declare const PlayerIdentityData: LastWriteWinElementSetComponentDefinition<PBPlayerIdentityData>;
|
|
46
54
|
/** @public */ export declare const PointerEvents: LastWriteWinElementSetComponentDefinition<PBPointerEvents>;
|
|
47
55
|
/** @public */ export declare const PointerEventsResult: GrowOnlyValueSetComponentDefinition<PBPointerEventsResult>;
|
|
48
56
|
/** @public */ export declare const PointerLock: LastWriteWinElementSetComponentDefinition<PBPointerLock>;
|
|
@@ -26,13 +26,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.VisibilityComponent = exports.VideoPlayer = exports.VideoEvent = exports.UiTransform = exports.UiText = exports.UiInputResult = exports.UiInput = exports.UiDropdownResult = exports.UiDropdown = exports.UiCanvasInformation = exports.UiBackground = exports.TweenState = exports.TweenSequence = exports.TextShape = exports.RaycastResult = exports.Raycast = exports.PointerLock = exports.PointerEventsResult = exports.PointerEvents = exports.NftShape = exports.GltfContainerLoadingState = exports.GltfContainer = exports.EngineInfo = exports.CameraModeArea = exports.CameraMode = exports.Billboard = exports.AvatarShape = exports.AvatarModifierArea = exports.AvatarAttach = exports.AudioStream = exports.AudioSource = void 0;
|
|
29
|
+
exports.VisibilityComponent = exports.VideoPlayer = exports.VideoEvent = exports.UiTransform = exports.UiText = exports.UiInputResult = exports.UiInput = exports.UiDropdownResult = exports.UiDropdown = exports.UiCanvasInformation = exports.UiBackground = exports.TweenState = exports.TweenSequence = exports.TextShape = exports.RaycastResult = exports.Raycast = exports.PointerLock = exports.PointerEventsResult = exports.PointerEvents = exports.PlayerIdentityData = exports.NftShape = exports.GltfContainerLoadingState = exports.GltfContainer = exports.EngineInfo = exports.CameraModeArea = exports.CameraMode = exports.Billboard = exports.AvatarShape = exports.AvatarModifierArea = exports.AvatarEquippedData = exports.AvatarEmoteCommand = exports.AvatarBase = exports.AvatarAttach = exports.AudioStream = exports.AudioSource = void 0;
|
|
30
30
|
const initialization_1 = require("../../runtime/initialization");
|
|
31
31
|
const components = __importStar(require("./index.gen"));
|
|
32
32
|
__exportStar(require("./index.gen"), exports);
|
|
33
33
|
/** @public */ exports.AudioSource = components.AudioSource(initialization_1.engine);
|
|
34
34
|
/** @public */ exports.AudioStream = components.AudioStream(initialization_1.engine);
|
|
35
35
|
/** @public */ exports.AvatarAttach = components.AvatarAttach(initialization_1.engine);
|
|
36
|
+
/** @public */ exports.AvatarBase = components.AvatarBase(initialization_1.engine);
|
|
37
|
+
/** @public */ exports.AvatarEmoteCommand = components.AvatarEmoteCommand(initialization_1.engine);
|
|
38
|
+
/** @public */ exports.AvatarEquippedData = components.AvatarEquippedData(initialization_1.engine);
|
|
36
39
|
/** @public */ exports.AvatarModifierArea = components.AvatarModifierArea(initialization_1.engine);
|
|
37
40
|
/** @public */ exports.AvatarShape = components.AvatarShape(initialization_1.engine);
|
|
38
41
|
/** @public */ exports.Billboard = components.Billboard(initialization_1.engine);
|
|
@@ -42,6 +45,7 @@ __exportStar(require("./index.gen"), exports);
|
|
|
42
45
|
/** @public */ exports.GltfContainer = components.GltfContainer(initialization_1.engine);
|
|
43
46
|
/** @public */ exports.GltfContainerLoadingState = components.GltfContainerLoadingState(initialization_1.engine);
|
|
44
47
|
/** @public */ exports.NftShape = components.NftShape(initialization_1.engine);
|
|
48
|
+
/** @public */ exports.PlayerIdentityData = components.PlayerIdentityData(initialization_1.engine);
|
|
45
49
|
/** @public */ exports.PointerEvents = components.PointerEvents(initialization_1.engine);
|
|
46
50
|
/** @public */ exports.PointerEventsResult = components.PointerEventsResult(initialization_1.engine);
|
|
47
51
|
/** @public */ exports.PointerLock = components.PointerLock(initialization_1.engine);
|
|
@@ -4,6 +4,9 @@ import { PBAnimator } from './pb/decentraland/sdk/components/animator.gen';
|
|
|
4
4
|
import { PBAudioSource } from './pb/decentraland/sdk/components/audio_source.gen';
|
|
5
5
|
import { PBAudioStream } from './pb/decentraland/sdk/components/audio_stream.gen';
|
|
6
6
|
import { PBAvatarAttach } from './pb/decentraland/sdk/components/avatar_attach.gen';
|
|
7
|
+
import { PBAvatarBase } from './pb/decentraland/sdk/components/avatar_base.gen';
|
|
8
|
+
import { PBAvatarEmoteCommand } from './pb/decentraland/sdk/components/avatar_emote_command.gen';
|
|
9
|
+
import { PBAvatarEquippedData } from './pb/decentraland/sdk/components/avatar_equipped_data.gen';
|
|
7
10
|
import { PBAvatarModifierArea } from './pb/decentraland/sdk/components/avatar_modifier_area.gen';
|
|
8
11
|
import { PBAvatarShape } from './pb/decentraland/sdk/components/avatar_shape.gen';
|
|
9
12
|
import { PBBillboard } from './pb/decentraland/sdk/components/billboard.gen';
|
|
@@ -16,6 +19,7 @@ import { PBMaterial } from './pb/decentraland/sdk/components/material.gen';
|
|
|
16
19
|
import { PBMeshCollider } from './pb/decentraland/sdk/components/mesh_collider.gen';
|
|
17
20
|
import { PBMeshRenderer } from './pb/decentraland/sdk/components/mesh_renderer.gen';
|
|
18
21
|
import { PBNftShape } from './pb/decentraland/sdk/components/nft_shape.gen';
|
|
22
|
+
import { PBPlayerIdentityData } from './pb/decentraland/sdk/components/player_identity_data.gen';
|
|
19
23
|
import { PBPointerEvents } from './pb/decentraland/sdk/components/pointer_events.gen';
|
|
20
24
|
import { PBPointerEventsResult } from './pb/decentraland/sdk/components/pointer_events_result.gen';
|
|
21
25
|
import { PBPointerLock } from './pb/decentraland/sdk/components/pointer_lock.gen';
|
|
@@ -40,6 +44,9 @@ export * from './pb/decentraland/sdk/components/animator.gen';
|
|
|
40
44
|
export * from './pb/decentraland/sdk/components/audio_source.gen';
|
|
41
45
|
export * from './pb/decentraland/sdk/components/audio_stream.gen';
|
|
42
46
|
export * from './pb/decentraland/sdk/components/avatar_attach.gen';
|
|
47
|
+
export * from './pb/decentraland/sdk/components/avatar_base.gen';
|
|
48
|
+
export * from './pb/decentraland/sdk/components/avatar_emote_command.gen';
|
|
49
|
+
export * from './pb/decentraland/sdk/components/avatar_equipped_data.gen';
|
|
43
50
|
export * from './pb/decentraland/sdk/components/avatar_modifier_area.gen';
|
|
44
51
|
export * from './pb/decentraland/sdk/components/avatar_shape.gen';
|
|
45
52
|
export * from './pb/decentraland/sdk/components/billboard.gen';
|
|
@@ -52,6 +59,7 @@ export * from './pb/decentraland/sdk/components/material.gen';
|
|
|
52
59
|
export * from './pb/decentraland/sdk/components/mesh_collider.gen';
|
|
53
60
|
export * from './pb/decentraland/sdk/components/mesh_renderer.gen';
|
|
54
61
|
export * from './pb/decentraland/sdk/components/nft_shape.gen';
|
|
62
|
+
export * from './pb/decentraland/sdk/components/player_identity_data.gen';
|
|
55
63
|
export * from './pb/decentraland/sdk/components/pointer_events.gen';
|
|
56
64
|
export * from './pb/decentraland/sdk/components/pointer_events_result.gen';
|
|
57
65
|
export * from './pb/decentraland/sdk/components/pointer_lock.gen';
|
|
@@ -78,6 +86,9 @@ export type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<an
|
|
|
78
86
|
/** @public */ export declare const AudioSource: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAudioSource>>;
|
|
79
87
|
/** @public */ export declare const AudioStream: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAudioStream>>;
|
|
80
88
|
/** @public */ export declare const AvatarAttach: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarAttach>>;
|
|
89
|
+
/** @public */ export declare const AvatarBase: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarBase>>;
|
|
90
|
+
/** @public */ export declare const AvatarEmoteCommand: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBAvatarEmoteCommand>>;
|
|
91
|
+
/** @public */ export declare const AvatarEquippedData: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarEquippedData>>;
|
|
81
92
|
/** @public */ export declare const AvatarModifierArea: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarModifierArea>>;
|
|
82
93
|
/** @public */ export declare const AvatarShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarShape>>;
|
|
83
94
|
/** @public */ export declare const Billboard: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBBillboard>>;
|
|
@@ -90,6 +101,7 @@ export type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<an
|
|
|
90
101
|
/** @public */ export declare const MeshCollider: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshCollider>>;
|
|
91
102
|
/** @public */ export declare const MeshRenderer: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshRenderer>>;
|
|
92
103
|
/** @public */ export declare const NftShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBNftShape>>;
|
|
104
|
+
/** @public */ export declare const PlayerIdentityData: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPlayerIdentityData>>;
|
|
93
105
|
/** @public */ export declare const PointerEvents: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerEvents>>;
|
|
94
106
|
/** @public */ export declare const PointerEventsResult: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBPointerEventsResult>>;
|
|
95
107
|
/** @public */ export declare const PointerLock: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerLock>>;
|
|
@@ -116,6 +128,9 @@ export declare const componentDefinitionByName: {
|
|
|
116
128
|
"core::AudioSource": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAudioSource>>;
|
|
117
129
|
"core::AudioStream": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAudioStream>>;
|
|
118
130
|
"core::AvatarAttach": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarAttach>>;
|
|
131
|
+
"core::AvatarBase": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarBase>>;
|
|
132
|
+
"core::AvatarEmoteCommand": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBAvatarEmoteCommand>>;
|
|
133
|
+
"core::AvatarEquippedData": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarEquippedData>>;
|
|
119
134
|
"core::AvatarModifierArea": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarModifierArea>>;
|
|
120
135
|
"core::AvatarShape": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarShape>>;
|
|
121
136
|
"core::Billboard": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBBillboard>>;
|
|
@@ -128,6 +143,7 @@ export declare const componentDefinitionByName: {
|
|
|
128
143
|
"core::MeshCollider": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshCollider>>;
|
|
129
144
|
"core::MeshRenderer": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshRenderer>>;
|
|
130
145
|
"core::NftShape": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBNftShape>>;
|
|
146
|
+
"core::PlayerIdentityData": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPlayerIdentityData>>;
|
|
131
147
|
"core::PointerEvents": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerEvents>>;
|
|
132
148
|
"core::PointerEventsResult": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBPointerEventsResult>>;
|
|
133
149
|
"core::PointerLock": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerLock>>;
|
|
@@ -14,11 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.componentDefinitionByName = exports.VisibilityComponent = exports.VideoPlayer = exports.VideoEvent = exports.UiTransform = exports.UiText = exports.UiInputResult = exports.UiInput = exports.UiDropdownResult = exports.UiDropdown = exports.UiCanvasInformation = exports.UiBackground = exports.TweenState = exports.TweenSequence = exports.Tween = exports.TextShape = exports.RaycastResult = exports.Raycast = exports.PointerLock = exports.PointerEventsResult = exports.PointerEvents = exports.NftShape = exports.MeshRenderer = exports.MeshCollider = exports.Material = exports.GltfContainerLoadingState = exports.GltfContainer = exports.EngineInfo = exports.CameraModeArea = exports.CameraMode = exports.Billboard = exports.AvatarShape = exports.AvatarModifierArea = exports.AvatarAttach = exports.AudioStream = exports.AudioSource = exports.Animator = void 0;
|
|
17
|
+
exports.componentDefinitionByName = exports.VisibilityComponent = exports.VideoPlayer = exports.VideoEvent = exports.UiTransform = exports.UiText = exports.UiInputResult = exports.UiInput = exports.UiDropdownResult = exports.UiDropdown = exports.UiCanvasInformation = exports.UiBackground = exports.TweenState = exports.TweenSequence = exports.Tween = exports.TextShape = exports.RaycastResult = exports.Raycast = exports.PointerLock = exports.PointerEventsResult = exports.PointerEvents = exports.PlayerIdentityData = exports.NftShape = exports.MeshRenderer = exports.MeshCollider = exports.Material = exports.GltfContainerLoadingState = exports.GltfContainer = exports.EngineInfo = exports.CameraModeArea = exports.CameraMode = exports.Billboard = exports.AvatarShape = exports.AvatarModifierArea = exports.AvatarEquippedData = exports.AvatarEmoteCommand = exports.AvatarBase = exports.AvatarAttach = exports.AudioStream = exports.AudioSource = exports.Animator = void 0;
|
|
18
18
|
const Animator_gen_1 = require("./Animator.gen");
|
|
19
19
|
const AudioSource_gen_1 = require("./AudioSource.gen");
|
|
20
20
|
const AudioStream_gen_1 = require("./AudioStream.gen");
|
|
21
21
|
const AvatarAttach_gen_1 = require("./AvatarAttach.gen");
|
|
22
|
+
const AvatarBase_gen_1 = require("./AvatarBase.gen");
|
|
23
|
+
const AvatarEmoteCommand_gen_1 = require("./AvatarEmoteCommand.gen");
|
|
24
|
+
const AvatarEquippedData_gen_1 = require("./AvatarEquippedData.gen");
|
|
22
25
|
const AvatarModifierArea_gen_1 = require("./AvatarModifierArea.gen");
|
|
23
26
|
const AvatarShape_gen_1 = require("./AvatarShape.gen");
|
|
24
27
|
const Billboard_gen_1 = require("./Billboard.gen");
|
|
@@ -31,6 +34,7 @@ const Material_gen_1 = require("./Material.gen");
|
|
|
31
34
|
const MeshCollider_gen_1 = require("./MeshCollider.gen");
|
|
32
35
|
const MeshRenderer_gen_1 = require("./MeshRenderer.gen");
|
|
33
36
|
const NftShape_gen_1 = require("./NftShape.gen");
|
|
37
|
+
const PlayerIdentityData_gen_1 = require("./PlayerIdentityData.gen");
|
|
34
38
|
const PointerEvents_gen_1 = require("./PointerEvents.gen");
|
|
35
39
|
const PointerEventsResult_gen_1 = require("./PointerEventsResult.gen");
|
|
36
40
|
const PointerLock_gen_1 = require("./PointerLock.gen");
|
|
@@ -55,6 +59,9 @@ __exportStar(require("./pb/decentraland/sdk/components/animator.gen"), exports);
|
|
|
55
59
|
__exportStar(require("./pb/decentraland/sdk/components/audio_source.gen"), exports);
|
|
56
60
|
__exportStar(require("./pb/decentraland/sdk/components/audio_stream.gen"), exports);
|
|
57
61
|
__exportStar(require("./pb/decentraland/sdk/components/avatar_attach.gen"), exports);
|
|
62
|
+
__exportStar(require("./pb/decentraland/sdk/components/avatar_base.gen"), exports);
|
|
63
|
+
__exportStar(require("./pb/decentraland/sdk/components/avatar_emote_command.gen"), exports);
|
|
64
|
+
__exportStar(require("./pb/decentraland/sdk/components/avatar_equipped_data.gen"), exports);
|
|
58
65
|
__exportStar(require("./pb/decentraland/sdk/components/avatar_modifier_area.gen"), exports);
|
|
59
66
|
__exportStar(require("./pb/decentraland/sdk/components/avatar_shape.gen"), exports);
|
|
60
67
|
__exportStar(require("./pb/decentraland/sdk/components/billboard.gen"), exports);
|
|
@@ -67,6 +74,7 @@ __exportStar(require("./pb/decentraland/sdk/components/material.gen"), exports);
|
|
|
67
74
|
__exportStar(require("./pb/decentraland/sdk/components/mesh_collider.gen"), exports);
|
|
68
75
|
__exportStar(require("./pb/decentraland/sdk/components/mesh_renderer.gen"), exports);
|
|
69
76
|
__exportStar(require("./pb/decentraland/sdk/components/nft_shape.gen"), exports);
|
|
77
|
+
__exportStar(require("./pb/decentraland/sdk/components/player_identity_data.gen"), exports);
|
|
70
78
|
__exportStar(require("./pb/decentraland/sdk/components/pointer_events.gen"), exports);
|
|
71
79
|
__exportStar(require("./pb/decentraland/sdk/components/pointer_events_result.gen"), exports);
|
|
72
80
|
__exportStar(require("./pb/decentraland/sdk/components/pointer_lock.gen"), exports);
|
|
@@ -99,6 +107,17 @@ exports.AudioStream = AudioStream;
|
|
|
99
107
|
/** @public */ const AvatarAttach = engine =>
|
|
100
108
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::AvatarAttach", AvatarAttach_gen_1.AvatarAttachSchema);
|
|
101
109
|
exports.AvatarAttach = AvatarAttach;
|
|
110
|
+
/** @public */ const AvatarBase = engine =>
|
|
111
|
+
/* @__PURE__ */ engine.defineComponentFromSchema("core::AvatarBase", AvatarBase_gen_1.AvatarBaseSchema);
|
|
112
|
+
exports.AvatarBase = AvatarBase;
|
|
113
|
+
/** @public */ const AvatarEmoteCommand = (engine) => /* @__PURE__ */ engine.defineValueSetComponentFromSchema("core::AvatarEmoteCommand", AvatarEmoteCommand_gen_1.AvatarEmoteCommandSchema, {
|
|
114
|
+
timestampFunction: (t) => t.timestamp,
|
|
115
|
+
maxElements: 100
|
|
116
|
+
});
|
|
117
|
+
exports.AvatarEmoteCommand = AvatarEmoteCommand;
|
|
118
|
+
/** @public */ const AvatarEquippedData = engine =>
|
|
119
|
+
/* @__PURE__ */ engine.defineComponentFromSchema("core::AvatarEquippedData", AvatarEquippedData_gen_1.AvatarEquippedDataSchema);
|
|
120
|
+
exports.AvatarEquippedData = AvatarEquippedData;
|
|
102
121
|
/** @public */ const AvatarModifierArea = engine =>
|
|
103
122
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::AvatarModifierArea", AvatarModifierArea_gen_1.AvatarModifierAreaSchema);
|
|
104
123
|
exports.AvatarModifierArea = AvatarModifierArea;
|
|
@@ -135,6 +154,9 @@ exports.MeshRenderer = MeshRenderer;
|
|
|
135
154
|
/** @public */ const NftShape = engine =>
|
|
136
155
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::NftShape", NftShape_gen_1.NftShapeSchema);
|
|
137
156
|
exports.NftShape = NftShape;
|
|
157
|
+
/** @public */ const PlayerIdentityData = engine =>
|
|
158
|
+
/* @__PURE__ */ engine.defineComponentFromSchema("core::PlayerIdentityData", PlayerIdentityData_gen_1.PlayerIdentityDataSchema);
|
|
159
|
+
exports.PlayerIdentityData = PlayerIdentityData;
|
|
138
160
|
/** @public */ const PointerEvents = engine =>
|
|
139
161
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::PointerEvents", PointerEvents_gen_1.PointerEventsSchema);
|
|
140
162
|
exports.PointerEvents = PointerEvents;
|
|
@@ -205,6 +227,9 @@ exports.componentDefinitionByName = {
|
|
|
205
227
|
"core::AudioSource": exports.AudioSource,
|
|
206
228
|
"core::AudioStream": exports.AudioStream,
|
|
207
229
|
"core::AvatarAttach": exports.AvatarAttach,
|
|
230
|
+
"core::AvatarBase": exports.AvatarBase,
|
|
231
|
+
"core::AvatarEmoteCommand": exports.AvatarEmoteCommand,
|
|
232
|
+
"core::AvatarEquippedData": exports.AvatarEquippedData,
|
|
208
233
|
"core::AvatarModifierArea": exports.AvatarModifierArea,
|
|
209
234
|
"core::AvatarShape": exports.AvatarShape,
|
|
210
235
|
"core::Billboard": exports.Billboard,
|
|
@@ -217,6 +242,7 @@ exports.componentDefinitionByName = {
|
|
|
217
242
|
"core::MeshCollider": exports.MeshCollider,
|
|
218
243
|
"core::MeshRenderer": exports.MeshRenderer,
|
|
219
244
|
"core::NftShape": exports.NftShape,
|
|
245
|
+
"core::PlayerIdentityData": exports.PlayerIdentityData,
|
|
220
246
|
"core::PointerEvents": exports.PointerEvents,
|
|
221
247
|
"core::PointerEventsResult": exports.PointerEventsResult,
|
|
222
248
|
"core::PointerLock": exports.PointerLock,
|
package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_emote_command.gen.d.ts
CHANGED
|
@@ -7,14 +7,10 @@ import _m0 from "protobufjs/minimal";
|
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
export interface PBAvatarEmoteCommand {
|
|
10
|
-
emoteCommand: PBAvatarEmoteCommand_EmoteCommand | undefined;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export interface PBAvatarEmoteCommand_EmoteCommand {
|
|
16
10
|
emoteUrn: string;
|
|
17
11
|
loop: boolean;
|
|
12
|
+
/** monotonic counter */
|
|
13
|
+
timestamp: number;
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
20
16
|
* @public
|
|
@@ -23,10 +19,3 @@ export declare namespace PBAvatarEmoteCommand {
|
|
|
23
19
|
function encode(message: PBAvatarEmoteCommand, writer?: _m0.Writer): _m0.Writer;
|
|
24
20
|
function decode(input: _m0.Reader | Uint8Array, length?: number): PBAvatarEmoteCommand;
|
|
25
21
|
}
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare namespace PBAvatarEmoteCommand_EmoteCommand {
|
|
30
|
-
function encode(message: PBAvatarEmoteCommand_EmoteCommand, writer?: _m0.Writer): _m0.Writer;
|
|
31
|
-
function decode(input: _m0.Reader | Uint8Array, length?: number): PBAvatarEmoteCommand_EmoteCommand;
|
|
32
|
-
}
|
package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_emote_command.gen.js
CHANGED
|
@@ -3,56 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.PBAvatarEmoteCommand = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
9
9
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
10
10
|
function createBasePBAvatarEmoteCommand() {
|
|
11
|
-
return {
|
|
11
|
+
return { emoteUrn: "", loop: false, timestamp: 0 };
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
16
|
var PBAvatarEmoteCommand;
|
|
17
17
|
(function (PBAvatarEmoteCommand) {
|
|
18
|
-
function encode(message, writer = minimal_1.default.Writer.create()) {
|
|
19
|
-
if (message.emoteCommand !== undefined) {
|
|
20
|
-
PBAvatarEmoteCommand_EmoteCommand.encode(message.emoteCommand, writer.uint32(10).fork()).ldelim();
|
|
21
|
-
}
|
|
22
|
-
return writer;
|
|
23
|
-
}
|
|
24
|
-
PBAvatarEmoteCommand.encode = encode;
|
|
25
|
-
function decode(input, length) {
|
|
26
|
-
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
27
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
28
|
-
const message = createBasePBAvatarEmoteCommand();
|
|
29
|
-
while (reader.pos < end) {
|
|
30
|
-
const tag = reader.uint32();
|
|
31
|
-
switch (tag >>> 3) {
|
|
32
|
-
case 1:
|
|
33
|
-
if (tag !== 10) {
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
message.emoteCommand = PBAvatarEmoteCommand_EmoteCommand.decode(reader, reader.uint32());
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
reader.skipType(tag & 7);
|
|
43
|
-
}
|
|
44
|
-
return message;
|
|
45
|
-
}
|
|
46
|
-
PBAvatarEmoteCommand.decode = decode;
|
|
47
|
-
})(PBAvatarEmoteCommand = exports.PBAvatarEmoteCommand || (exports.PBAvatarEmoteCommand = {}));
|
|
48
|
-
function createBasePBAvatarEmoteCommand_EmoteCommand() {
|
|
49
|
-
return { emoteUrn: "", loop: false };
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @public
|
|
53
|
-
*/
|
|
54
|
-
var PBAvatarEmoteCommand_EmoteCommand;
|
|
55
|
-
(function (PBAvatarEmoteCommand_EmoteCommand) {
|
|
56
18
|
function encode(message, writer = minimal_1.default.Writer.create()) {
|
|
57
19
|
if (message.emoteUrn !== "") {
|
|
58
20
|
writer.uint32(10).string(message.emoteUrn);
|
|
@@ -60,13 +22,16 @@ var PBAvatarEmoteCommand_EmoteCommand;
|
|
|
60
22
|
if (message.loop === true) {
|
|
61
23
|
writer.uint32(16).bool(message.loop);
|
|
62
24
|
}
|
|
25
|
+
if (message.timestamp !== 0) {
|
|
26
|
+
writer.uint32(24).uint32(message.timestamp);
|
|
27
|
+
}
|
|
63
28
|
return writer;
|
|
64
29
|
}
|
|
65
|
-
|
|
30
|
+
PBAvatarEmoteCommand.encode = encode;
|
|
66
31
|
function decode(input, length) {
|
|
67
32
|
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
68
33
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
69
|
-
const message =
|
|
34
|
+
const message = createBasePBAvatarEmoteCommand();
|
|
70
35
|
while (reader.pos < end) {
|
|
71
36
|
const tag = reader.uint32();
|
|
72
37
|
switch (tag >>> 3) {
|
|
@@ -82,6 +47,12 @@ var PBAvatarEmoteCommand_EmoteCommand;
|
|
|
82
47
|
}
|
|
83
48
|
message.loop = reader.bool();
|
|
84
49
|
continue;
|
|
50
|
+
case 3:
|
|
51
|
+
if (tag !== 24) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
message.timestamp = reader.uint32();
|
|
55
|
+
continue;
|
|
85
56
|
}
|
|
86
57
|
if ((tag & 7) === 4 || tag === 0) {
|
|
87
58
|
break;
|
|
@@ -90,5 +61,5 @@ var PBAvatarEmoteCommand_EmoteCommand;
|
|
|
90
61
|
}
|
|
91
62
|
return message;
|
|
92
63
|
}
|
|
93
|
-
|
|
94
|
-
})(
|
|
64
|
+
PBAvatarEmoteCommand.decode = decode;
|
|
65
|
+
})(PBAvatarEmoteCommand = exports.PBAvatarEmoteCommand || (exports.PBAvatarEmoteCommand = {}));
|
package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_equipped_data.gen.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.PBAvatarEquippedData = void 0;
|
|
|
8
8
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
9
9
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
10
10
|
function createBasePBAvatarEquippedData() {
|
|
11
|
-
return { wearableUrns: [],
|
|
11
|
+
return { wearableUrns: [], emoteUrns: [] };
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* @public
|
|
@@ -19,7 +19,7 @@ var PBAvatarEquippedData;
|
|
|
19
19
|
for (const v of message.wearableUrns) {
|
|
20
20
|
writer.uint32(10).string(v);
|
|
21
21
|
}
|
|
22
|
-
for (const v of message.
|
|
22
|
+
for (const v of message.emoteUrns) {
|
|
23
23
|
writer.uint32(18).string(v);
|
|
24
24
|
}
|
|
25
25
|
return writer;
|
|
@@ -42,7 +42,7 @@ var PBAvatarEquippedData;
|
|
|
42
42
|
if (tag !== 18) {
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
|
-
message.
|
|
45
|
+
message.emoteUrns.push(reader.string());
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
48
|
if ((tag & 7) === 4 || tag === 0) {
|
|
@@ -64,6 +64,12 @@ export interface BaseComponent<T> {
|
|
|
64
64
|
* @returns
|
|
65
65
|
*/
|
|
66
66
|
get(entity: Entity): any;
|
|
67
|
+
/**
|
|
68
|
+
* @public
|
|
69
|
+
* Triggers the callback if the entity has changed on the last tick.
|
|
70
|
+
* If the value is undefined, the component was deleted.
|
|
71
|
+
*/
|
|
72
|
+
onChange(entity: Entity, cb: (value: T | undefined) => void): void;
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
75
|
* @public
|
|
@@ -21,7 +21,6 @@ export type Entity = number & {
|
|
|
21
21
|
* This first 512 entities are reserved by the renderer
|
|
22
22
|
*/
|
|
23
23
|
export declare const RESERVED_STATIC_ENTITIES = 512;
|
|
24
|
-
export declare const RESERVED_LOCAL_ENTITIES = 65535;
|
|
25
24
|
/**
|
|
26
25
|
* @public
|
|
27
26
|
*/
|
|
@@ -54,9 +53,9 @@ export declare enum EntityState {
|
|
|
54
53
|
Reserved = 3
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
|
-
* @
|
|
56
|
+
* @public
|
|
58
57
|
*/
|
|
59
|
-
export type
|
|
58
|
+
export type IEntityContainer = {
|
|
60
59
|
generateEntity(networked?: boolean): Entity;
|
|
61
60
|
removeEntity(entity: Entity): boolean;
|
|
62
61
|
getEntityState(entity: Entity): EntityState;
|
|
@@ -64,5 +63,10 @@ export type EntityContainer = {
|
|
|
64
63
|
releaseRemovedEntities(): Entity[];
|
|
65
64
|
updateRemovedEntity(entity: Entity): boolean;
|
|
66
65
|
updateUsedEntity(entity: Entity): boolean;
|
|
67
|
-
setNetworkEntitiesRange(reservedLocalEntities: number, range: [number, number]): void;
|
|
68
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare function createEntityContainer(opts?: {
|
|
71
|
+
reservedStaticEntities: number;
|
|
72
|
+
}): IEntityContainer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createEntityContainer = exports.EntityState = exports.EntityUtils = exports.RESERVED_STATIC_ENTITIES = exports.MAX_ENTITY_NUMBER = exports.AMOUNT_VERSION_AVAILABLE = exports.MAX_U16 = void 0;
|
|
4
4
|
const gset_1 = require("../systems/crdt/gset");
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
@@ -20,8 +20,6 @@ exports.MAX_ENTITY_NUMBER = exports.MAX_U16;
|
|
|
20
20
|
* This first 512 entities are reserved by the renderer
|
|
21
21
|
*/
|
|
22
22
|
exports.RESERVED_STATIC_ENTITIES = 512;
|
|
23
|
-
// Max amount of local entities that can be created
|
|
24
|
-
exports.RESERVED_LOCAL_ENTITIES = exports.MAX_ENTITY_NUMBER;
|
|
25
23
|
/**
|
|
26
24
|
* @public
|
|
27
25
|
*/
|
|
@@ -62,35 +60,20 @@ var EntityState;
|
|
|
62
60
|
EntityState[EntityState["Reserved"] = 3] = "Reserved";
|
|
63
61
|
})(EntityState = exports.EntityState || (exports.EntityState = {}));
|
|
64
62
|
/**
|
|
65
|
-
* @
|
|
63
|
+
* @public
|
|
66
64
|
*/
|
|
67
|
-
function
|
|
65
|
+
function createEntityContainer(opts) {
|
|
66
|
+
const reservedStaticEntities = opts?.reservedStaticEntities ?? exports.RESERVED_STATIC_ENTITIES;
|
|
68
67
|
// Local entities counter
|
|
69
|
-
let entityCounter =
|
|
70
|
-
// Network entities counter
|
|
71
|
-
let networkEntityCounter;
|
|
72
|
-
// Network entities range that can be created by the user
|
|
73
|
-
let networkedEntitiesRange;
|
|
68
|
+
let entityCounter = reservedStaticEntities;
|
|
74
69
|
const usedEntities = new Set();
|
|
75
70
|
let toRemoveEntities = [];
|
|
76
71
|
const removedEntities = (0, gset_1.createVersionGSet)();
|
|
77
|
-
|
|
78
|
-
function setNetworkEntitiesRange(reservedLocalEntities, range) {
|
|
79
|
-
localEntitiesAvailable = reservedLocalEntities;
|
|
80
|
-
networkedEntitiesRange = range;
|
|
81
|
-
networkEntityCounter = range[0];
|
|
82
|
-
}
|
|
83
|
-
function generateNewEntity(networked) {
|
|
72
|
+
function generateNewEntity() {
|
|
84
73
|
if (entityCounter > exports.MAX_ENTITY_NUMBER - 1) {
|
|
85
74
|
throw new Error(`It fails trying to generate an entity out of range ${exports.MAX_ENTITY_NUMBER}.`);
|
|
86
75
|
}
|
|
87
|
-
|
|
88
|
-
throw new Error(`Max amount of network entities reached ${networkedEntitiesRange[1]} `);
|
|
89
|
-
}
|
|
90
|
-
if (!networked && entityCounter >= localEntitiesAvailable) {
|
|
91
|
-
throw new Error(`Max amount of local entities reached ${localEntitiesAvailable}`);
|
|
92
|
-
}
|
|
93
|
-
const entityNumber = networked ? networkEntityCounter++ : entityCounter++;
|
|
76
|
+
const entityNumber = entityCounter++;
|
|
94
77
|
const entityVersion = removedEntities.getMap().has(entityNumber)
|
|
95
78
|
? removedEntities.getMap().get(entityNumber) + 1
|
|
96
79
|
: 0;
|
|
@@ -101,31 +84,14 @@ function EntityContainer() {
|
|
|
101
84
|
usedEntities.add(entity);
|
|
102
85
|
return entity;
|
|
103
86
|
}
|
|
104
|
-
function generateEntity(
|
|
105
|
-
|
|
106
|
-
throw new Error('Network entities ranged not initialized. Connect to a CRDT Server');
|
|
107
|
-
}
|
|
108
|
-
const usedNetworkSize = (networkedEntitiesRange &&
|
|
109
|
-
[...usedEntities.values()].filter(($) => {
|
|
110
|
-
const [entityId] = EntityUtils.fromEntityId($);
|
|
111
|
-
return entityId >= networkedEntitiesRange[0] && entityId <= networkedEntitiesRange[1];
|
|
112
|
-
}).length) ??
|
|
113
|
-
0;
|
|
114
|
-
const usedSize = usedEntities.size - usedNetworkSize;
|
|
115
|
-
// If all entities until `entityCounter` are being used, we need to generate another one
|
|
116
|
-
if (!networked && usedSize + exports.RESERVED_STATIC_ENTITIES >= entityCounter) {
|
|
117
|
-
return generateNewEntity(networked);
|
|
118
|
-
}
|
|
87
|
+
function generateEntity() {
|
|
88
|
+
const usedSize = usedEntities.size;
|
|
119
89
|
// If all entities until `entityCounter` are being used, we need to generate another one
|
|
120
|
-
if (
|
|
121
|
-
return generateNewEntity(
|
|
90
|
+
if (usedSize + reservedStaticEntities >= entityCounter) {
|
|
91
|
+
return generateNewEntity();
|
|
122
92
|
}
|
|
123
93
|
for (const [number, version] of removedEntities.getMap()) {
|
|
124
94
|
if (version < exports.MAX_U16) {
|
|
125
|
-
if (networked && (number < networkedEntitiesRange[0] || number > networkedEntitiesRange[1]))
|
|
126
|
-
continue;
|
|
127
|
-
if (!networked && number >= localEntitiesAvailable)
|
|
128
|
-
continue;
|
|
129
95
|
const entity = EntityUtils.toEntityId(number, version + 1);
|
|
130
96
|
// If the entity is not being used, we can re-use it
|
|
131
97
|
// If the entity was removed in this tick, we're not counting for the usedEntities, but we have it in the toRemoveEntityArray
|
|
@@ -135,10 +101,10 @@ function EntityContainer() {
|
|
|
135
101
|
}
|
|
136
102
|
}
|
|
137
103
|
}
|
|
138
|
-
return generateNewEntity(
|
|
104
|
+
return generateNewEntity();
|
|
139
105
|
}
|
|
140
106
|
function removeEntity(entity) {
|
|
141
|
-
if (entity <
|
|
107
|
+
if (entity < reservedStaticEntities)
|
|
142
108
|
return false;
|
|
143
109
|
if (usedEntities.has(entity)) {
|
|
144
110
|
usedEntities.delete(entity);
|
|
@@ -187,7 +153,7 @@ function EntityContainer() {
|
|
|
187
153
|
}
|
|
188
154
|
function getEntityState(entity) {
|
|
189
155
|
const [n, v] = EntityUtils.fromEntityId(entity);
|
|
190
|
-
if (n <
|
|
156
|
+
if (n < reservedStaticEntities) {
|
|
191
157
|
return EntityState.Reserved;
|
|
192
158
|
}
|
|
193
159
|
if (usedEntities.has(entity)) {
|
|
@@ -200,7 +166,6 @@ function EntityContainer() {
|
|
|
200
166
|
return EntityState.Unknown;
|
|
201
167
|
}
|
|
202
168
|
return {
|
|
203
|
-
setNetworkEntitiesRange,
|
|
204
169
|
generateEntity,
|
|
205
170
|
removeEntity,
|
|
206
171
|
getExistingEntities() {
|
|
@@ -212,4 +177,4 @@ function EntityContainer() {
|
|
|
212
177
|
updateUsedEntity
|
|
213
178
|
};
|
|
214
179
|
}
|
|
215
|
-
exports.
|
|
180
|
+
exports.createEntityContainer = createEntityContainer;
|