@dcl/ecs 7.0.6-4087883663.commit-054d424 → 7.0.6-4106539347.commit-b417eb5

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.
@@ -43,12 +43,29 @@ export function createInputSystem(engine) {
43
43
  InternalInputStateComponent.getMutable(engine.RootEntity).timestampLastUpdate = state.currentTimestamp;
44
44
  }
45
45
  }
46
+ function* commandIterator() {
47
+ for (const [, value] of engine.getEntitiesWith(PointerEventsResult)) {
48
+ yield* value.commands;
49
+ }
50
+ }
51
+ function findLastAction(pointerEventType, inputAction, entity) {
52
+ let commandToReturn = undefined;
53
+ for (const command of commandIterator()) {
54
+ if (command.button === inputAction &&
55
+ command.state === pointerEventType &&
56
+ (!entity || (command.hit && entity === command.hit.entityId))) {
57
+ if (!commandToReturn || command.timestamp >= commandToReturn.timestamp)
58
+ commandToReturn = command;
59
+ }
60
+ }
61
+ return commandToReturn;
62
+ }
46
63
  function buttonStateUpdateSystem() {
47
64
  const component = PointerEventsResult.getOrNull(engine.RootEntity);
48
65
  if (!component)
49
66
  return;
50
67
  const state = InternalInputStateComponent.getMutable(engine.RootEntity);
51
- for (const command of component.commands) {
68
+ for (const command of commandIterator()) {
52
69
  if (command.timestamp > state.buttonState[command.button].ts) {
53
70
  if (command.state === 1 /* PointerEventType.PET_DOWN */) {
54
71
  state.buttonState[command.button].value = true;
@@ -73,16 +90,12 @@ export function createInputSystem(engine) {
73
90
  return null;
74
91
  }
75
92
  function findClick(inputAction, entity) {
76
- const component = PointerEventsResult.getOrNull(engine.RootEntity);
77
- if (!component)
78
- return null;
79
- const commands = component.commands;
80
93
  // We search the last DOWN command sorted by timestamp
81
- const down = findLastAction(commands, 1 /* PointerEventType.PET_DOWN */, inputAction, entity);
94
+ const down = findLastAction(1 /* PointerEventType.PET_DOWN */, inputAction, entity);
82
95
  // We search the last UP command sorted by timestamp
83
96
  if (!down)
84
97
  return null;
85
- const up = findLastAction(commands, 0 /* PointerEventType.PET_UP */, inputAction, entity);
98
+ const up = findLastAction(0 /* PointerEventType.PET_UP */, inputAction, entity);
86
99
  if (!up)
87
100
  return null;
88
101
  const state = InternalInputStateComponent.get(engine.RootEntity);
@@ -105,11 +118,8 @@ export function createInputSystem(engine) {
105
118
  return null;
106
119
  }
107
120
  function findInputCommand(inputAction, pointerEventType, entity) {
108
- const component = PointerEventsResult.getOrNull(engine.RootEntity);
109
- if (!component)
110
- return null;
111
121
  // We search the last pointer Event command sorted by timestamp
112
- const command = findLastAction(component.commands, pointerEventType, inputAction, entity);
122
+ const command = findLastAction(pointerEventType, inputAction, entity);
113
123
  if (!command)
114
124
  return null;
115
125
  const state = InternalInputStateComponent.get(engine.RootEntity);
@@ -143,15 +153,3 @@ export function createInputSystem(engine) {
143
153
  isTriggered
144
154
  };
145
155
  }
146
- function findLastAction(commands, pointerEventType, inputAction, entity) {
147
- let commandToReturn = undefined;
148
- for (const command of commands) {
149
- if (command.button === inputAction &&
150
- command.state === pointerEventType &&
151
- (!entity || (command.hit && entity === command.hit.entityId))) {
152
- if (!commandToReturn || command.timestamp >= commandToReturn.timestamp)
153
- commandToReturn = command;
154
- }
155
- }
156
- return commandToReturn;
157
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
- "version": "7.0.6-4087883663.commit-054d424",
3
+ "version": "7.0.6-4106539347.commit-b417eb5",
4
4
  "description": "Decentraland ECS",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "ts-proto": "^1.112.0"
28
28
  },
29
29
  "dependencies": {
30
- "@dcl/crdt": "7.0.6-4087883663.commit-054d424",
30
+ "@dcl/crdt": "7.0.6-4106539347.commit-b417eb5",
31
31
  "@dcl/js-runtime": "file:../js-runtime",
32
32
  "@dcl/protocol": "1.0.0-4085628047.commit-0f6384e"
33
33
  },
@@ -41,5 +41,5 @@
41
41
  "displayName": "ECS",
42
42
  "tsconfig": "./tsconfig.json"
43
43
  },
44
- "commit": "054d424646fc6082e7a29ebf4cc5903454205935"
44
+ "commit": "b417eb5c7747ce04f16562b96a64a5f76048d872"
45
45
  }