@woosh/meep-engine 2.48.1 → 2.48.5
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/package.json +1 -1
- package/src/core/binary/32BitEncoder.js +11 -3
- package/src/core/binary/BinaryBuffer.js +80 -59
- package/src/core/binary/int32_to_binary_string.js +32 -7
- package/src/core/binary/to_half_float_uint16.js +6 -4
- package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +1 -1
- package/src/core/collection/list/List.js +3 -0
- package/src/core/geom/3d/CircleMath.js +13 -2
- package/src/core/geom/3d/matrix/m4_make_translation.js +15 -0
- package/src/core/geom/3d/triangle/computeTrianglePlaneSide.js +4 -13
- package/src/core/geom/Vector3.spec.js +10 -0
- package/src/core/graph/convertGraphToDotString.js +13 -3
- package/src/core/graph/v2/Graph.js +17 -1
- package/src/core/graph/v2/NodeContainer.js +58 -0
- package/src/core/model/ModuleRegistry.js +44 -10
- package/src/core/model/ResourceAccessKind.js +11 -0
- package/src/core/model/ResourceAccessSpecification.js +41 -0
- package/src/engine/Engine.js +1 -1
- package/src/engine/ecs/EntityEventBinding.js +74 -0
- package/src/engine/ecs/EntityManager.js +143 -0
- package/src/engine/ecs/System.js +53 -5
- package/src/engine/ecs/animation/InverseKinematicsSystem.js +6 -0
- package/src/engine/ecs/attachment/AttachmentSystem.js +8 -0
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +5 -0
- package/src/engine/ecs/fow/FogOfWarRevealerSystem.js +7 -3
- package/src/engine/ecs/fow/FogOfWarSystem.js +6 -0
- package/src/engine/ecs/gui/GUIElementSystem.js +1 -1
- package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +8 -0
- package/src/engine/ecs/gui/position/ViewportPositionSystem.js +6 -0
- package/src/engine/ecs/speaker/VoiceSystem.js +13 -0
- package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.js +451 -12
- package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.spec.js +123 -0
- package/src/engine/ecs/system/computeSystemComponentDependencyGraph.js +71 -0
- package/src/engine/ecs/systems/RenderSystem.js +6 -0
- package/src/engine/ecs/terrain/ecs/Terrain.js +26 -44
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +9 -0
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +5 -0
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +26 -6
- package/src/engine/ecs/tooltip/TooltipComponentSystem.js +7 -0
- package/src/engine/graphics/ecs/animation/animator/AnimationGraphSystem.js +6 -0
- package/src/engine/graphics/ecs/camera/CameraSystem.js +6 -0
- package/src/engine/graphics/ecs/camera/pp/PerfectPanner.js +4 -0
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +5 -0
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +6 -0
- package/src/engine/graphics/ecs/light/LightSystem.js +8 -0
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +8 -1
- package/src/engine/graphics/ecs/path/PathDisplaySystem.js +7 -1
- package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +7 -0
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +34 -7
- package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +6 -0
- package/src/engine/grid/systems/GridPosition2TransformSystem.js +6 -0
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +6 -0
- package/src/engine/intelligence/behavior/Behavior.js +11 -0
- package/src/engine/intelligence/behavior/composite/CompositeBehavior.js +10 -4
- package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +1 -0
- package/src/engine/intelligence/behavior/util/behavior_traverse_tree.js +8 -0
- package/src/engine/navigation/ecs/path_following/PathFollowingSystem.js +8 -0
- package/src/engine/network/RemoteController.js +60 -84
- package/src/engine/network/remoteEditor.js +108 -2
- package/src/engine/sound/SoundEngine.js +81 -79
- package/src/engine/sound/ecs/SoundControllerSystem.js +8 -0
- package/src/engine/sound/ecs/SoundListenerSystem.js +7 -0
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.js +42 -46
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +15 -2
- package/src/engine/sound/ecs/emitter/SoundTrack.js +137 -35
- package/src/engine/sound/ecs/emitter/SoundTrackFlags.js +17 -1
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.js +2 -4
- package/src/engine/sound/ecs/emitter/loadSoundTrackAsset.js +1 -2
- package/src/generation/theme/ThemeEngine.js +20 -3
- package/src/view/{elements/image → common}/HTMLElementCacheKey.js +5 -5
- package/src/view/elements/button/ButtonView.js +10 -2
- package/src/view/elements/image/ImageView.js +1 -1
- package/src/view/elements/video/VideoView.js +1 -1
- package/src/view/interaction/CommandButtonView.js +16 -153
- package/src/view/interaction/createInterfaceCommandButton.js +124 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ResourceAccessKind } from "./ResourceAccessKind.js";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_ACCESS = ResourceAccessKind.Read | ResourceAccessKind.Write;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @template R
|
|
7
|
+
*/
|
|
8
|
+
export class ResourceAccessSpecification {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {number|ResourceAccessKind}
|
|
12
|
+
*/
|
|
13
|
+
access = DEFAULT_ACCESS
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @type {R|null}
|
|
18
|
+
*/
|
|
19
|
+
resource = null
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @template R
|
|
23
|
+
* @param {R} resource
|
|
24
|
+
* @param {number|ResourceAccessKind} access
|
|
25
|
+
* @returns {ResourceAccessSpecification<R>}
|
|
26
|
+
*/
|
|
27
|
+
static from(resource, access = DEFAULT_ACCESS){
|
|
28
|
+
const r = new ResourceAccessSpecification();
|
|
29
|
+
|
|
30
|
+
r.access = access;
|
|
31
|
+
r.resource = resource;
|
|
32
|
+
|
|
33
|
+
return r;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @readonly
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
*/
|
|
41
|
+
ResourceAccessSpecification.prototype.isResourceAccessSpecification = true;
|
package/src/engine/Engine.js
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { assert } from "../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
export class EntityEventBinding {
|
|
4
|
+
entity = -1
|
|
5
|
+
event = ""
|
|
6
|
+
handler = null
|
|
7
|
+
context = null
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @type {EntityComponentDataset|null}
|
|
11
|
+
*/
|
|
12
|
+
ecd = null
|
|
13
|
+
|
|
14
|
+
#linked = false
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {number} entity
|
|
19
|
+
* @param {string} event
|
|
20
|
+
* @param {function} handler
|
|
21
|
+
* @param {*} [context]
|
|
22
|
+
* @returns {EntityEventBinding}
|
|
23
|
+
*/
|
|
24
|
+
static from(
|
|
25
|
+
entity, event, handler, context
|
|
26
|
+
) {
|
|
27
|
+
assert.isNonNegativeInteger(entity, 'entity');
|
|
28
|
+
assert.isString(event, 'event');
|
|
29
|
+
assert.isFunction(handler, 'handler');
|
|
30
|
+
|
|
31
|
+
const r = new EntityEventBinding();
|
|
32
|
+
|
|
33
|
+
r.entity = entity;
|
|
34
|
+
r.event = event;
|
|
35
|
+
r.handler = handler;
|
|
36
|
+
r.context = context;
|
|
37
|
+
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {EntityComponentDataset} ecd
|
|
44
|
+
*/
|
|
45
|
+
link(ecd) {
|
|
46
|
+
if (this.#linked) {
|
|
47
|
+
if (this.ecd === ecd) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.unlink();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.#linked = true;
|
|
55
|
+
this.ecd = ecd;
|
|
56
|
+
|
|
57
|
+
ecd.addEntityEventListener(this.entity, this.event, this.handler, this.context);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
unlink() {
|
|
61
|
+
if (!this.#linked) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const ecd = this.ecd;
|
|
66
|
+
|
|
67
|
+
if (ecd.entityExists(this.entity)) {
|
|
68
|
+
ecd.removeEntityEventListener(this.entity, this.event, this.handler, this.context);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.#linked = false;
|
|
72
|
+
this.ecd = null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -9,6 +9,8 @@ import { assert } from "../../core/assert.js";
|
|
|
9
9
|
import { EntityObserver } from "./EntityObserver.js";
|
|
10
10
|
import { IllegalStateException } from "../../core/fsm/exceptions/IllegalStateException.js";
|
|
11
11
|
import { noop } from "../../core/function/Functions.js";
|
|
12
|
+
import { ResourceAccessKind } from "../../core/model/ResourceAccessKind.js";
|
|
13
|
+
import { computeSystemComponentDependencyGraph } from "./system/computeSystemComponentDependencyGraph.js";
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
*
|
|
@@ -45,6 +47,12 @@ function EntityManager() {
|
|
|
45
47
|
*/
|
|
46
48
|
this.systems = [];
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @readonly
|
|
52
|
+
* @type {System[]}
|
|
53
|
+
*/
|
|
54
|
+
this.systemsExecutionOrder = [];
|
|
55
|
+
|
|
48
56
|
/**
|
|
49
57
|
* @readonly
|
|
50
58
|
* @type {EntityObserver[]}
|
|
@@ -85,8 +93,98 @@ function EntityManager() {
|
|
|
85
93
|
* @type {EntityComponentDataset}
|
|
86
94
|
*/
|
|
87
95
|
this.dataset = null;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @type {boolean}
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
this.__execution_order_needs_update = true;
|
|
88
103
|
}
|
|
89
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Rebuild execution order
|
|
107
|
+
*/
|
|
108
|
+
EntityManager.prototype.updateExecutionOrder = function () {
|
|
109
|
+
// console.time('updateExecutionOrder')
|
|
110
|
+
|
|
111
|
+
const order = this.systemsExecutionOrder;
|
|
112
|
+
|
|
113
|
+
order.splice(0, order.length);
|
|
114
|
+
|
|
115
|
+
const systems = this.systems;
|
|
116
|
+
const system_count = systems.length;
|
|
117
|
+
|
|
118
|
+
let executable_system_count = 0;
|
|
119
|
+
|
|
120
|
+
for (let i = 0; i < system_count; i++) {
|
|
121
|
+
const system = systems[i];
|
|
122
|
+
|
|
123
|
+
if (system.update === noop && system.fixedUpdate === noop) {
|
|
124
|
+
// not a simulation system
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
order[executable_system_count++] = system;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// build dependency graphs amongst components
|
|
132
|
+
const dependency_graph = computeSystemComponentDependencyGraph(executable_system_count, order);
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @param {System} system
|
|
138
|
+
* @returns {number} higher values means it should be scheduled before others
|
|
139
|
+
*/
|
|
140
|
+
function scoreSystem(system) {
|
|
141
|
+
let result = 0;
|
|
142
|
+
|
|
143
|
+
const components = system.referenced_components;
|
|
144
|
+
const component_count = components.length;
|
|
145
|
+
|
|
146
|
+
for (let i = 0; i < component_count; i++) {
|
|
147
|
+
const component = components[i];
|
|
148
|
+
|
|
149
|
+
result += 0.0001;
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
// count number of incoming edges
|
|
153
|
+
const attached_edge_count = dependency_graph.getNodeContainer(component).getIncomingEdgeCount();
|
|
154
|
+
|
|
155
|
+
const access = system.getAccessForComponent(component);
|
|
156
|
+
|
|
157
|
+
if ((access & ResourceAccessKind.Create) !== 0) {
|
|
158
|
+
result += attached_edge_count * 4
|
|
159
|
+
} else if ((access & ResourceAccessKind.Write) !== 0) {
|
|
160
|
+
result += attached_edge_count * 2
|
|
161
|
+
} else {
|
|
162
|
+
result += attached_edge_count;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// pre-score systems for faster sorting
|
|
171
|
+
const scores = new Map();
|
|
172
|
+
|
|
173
|
+
for (let i = 0; i < executable_system_count; i++) {
|
|
174
|
+
const system = order[i];
|
|
175
|
+
|
|
176
|
+
scores.set(system, scoreSystem(system));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
order.sort((a, b) => {
|
|
180
|
+
return scores.get(b) - scores.get(a);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// clear update flag
|
|
184
|
+
this.__execution_order_needs_update = false;
|
|
185
|
+
// console.timeEnd('updateExecutionOrder')
|
|
186
|
+
};
|
|
187
|
+
|
|
90
188
|
EntityManager.prototype.detachDataSet = function () {
|
|
91
189
|
const dataset = this.dataset;
|
|
92
190
|
|
|
@@ -215,6 +313,11 @@ EntityManager.prototype.simulate = function (timeDelta) {
|
|
|
215
313
|
assert.notNaN(timeDelta, 'timeDelta');
|
|
216
314
|
assert.greaterThanOrEqual(timeDelta, 0, 'timeDelta must be >= 0');
|
|
217
315
|
|
|
316
|
+
if (this.__execution_order_needs_update) {
|
|
317
|
+
this.updateExecutionOrder();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
218
321
|
/**
|
|
219
322
|
*
|
|
220
323
|
* @type {System[]}
|
|
@@ -263,6 +366,11 @@ EntityManager.prototype.simulate = function (timeDelta) {
|
|
|
263
366
|
}
|
|
264
367
|
};
|
|
265
368
|
|
|
369
|
+
/**
|
|
370
|
+
*
|
|
371
|
+
* @param {System} system
|
|
372
|
+
* @throws if system fails validation
|
|
373
|
+
*/
|
|
266
374
|
function validateSystem(system) {
|
|
267
375
|
if (system === undefined) {
|
|
268
376
|
throw new Error("System is undefined");
|
|
@@ -284,6 +392,35 @@ function validateSystem(system) {
|
|
|
284
392
|
throw new Error(`uses deprecated 'remove' method, should use 'unlink' instead`);
|
|
285
393
|
}
|
|
286
394
|
|
|
395
|
+
// validate 'components_used' section
|
|
396
|
+
const components_used = system.components_used;
|
|
397
|
+
const components_used_count = components_used.length;
|
|
398
|
+
|
|
399
|
+
for (let i = 0; i < components_used_count; i++) {
|
|
400
|
+
const spec = components_used[i];
|
|
401
|
+
|
|
402
|
+
if (spec === undefined || spec === null || spec.isResourceAccessSpecification !== true) {
|
|
403
|
+
throw new Error(`Invalid access specification[${i}], expected an instance of ResourceAccessSpecification, but got something else`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (spec.resource === null) {
|
|
407
|
+
throw new Error(`No component specified for element [${i}]`);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (spec.access === 0) {
|
|
411
|
+
throw new Error('No access modifiers specified, must have at least one (such as Read, Write, Create)');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// backtrace to make sure there are no duplicates
|
|
415
|
+
for (let j = 0; j < i - 1; j++) {
|
|
416
|
+
const spec_other = components_used[j];
|
|
417
|
+
|
|
418
|
+
if (spec_other.resource === spec.resource) {
|
|
419
|
+
throw new Error(`Duplicate specification of component [${j}] and [${i}]`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
287
424
|
//validate dependencies
|
|
288
425
|
const dependencies = system.dependencies;
|
|
289
426
|
|
|
@@ -305,6 +442,7 @@ function validateSystem(system) {
|
|
|
305
442
|
}
|
|
306
443
|
}
|
|
307
444
|
|
|
445
|
+
|
|
308
446
|
const linkArgumentCount = numDependencies + 1;
|
|
309
447
|
|
|
310
448
|
if (system.link !== System.prototype.link && system.link.length !== linkArgumentCount && system.__validation_ignore_link_argument_count !== true) {
|
|
@@ -359,6 +497,8 @@ EntityManager.prototype.addSystem = async function (system) {
|
|
|
359
497
|
|
|
360
498
|
systems[systemIndex] = system;
|
|
361
499
|
|
|
500
|
+
// request exec order update
|
|
501
|
+
this.__execution_order_needs_update = true;
|
|
362
502
|
|
|
363
503
|
//build observer
|
|
364
504
|
const linkObserver = new EntityObserver(system.dependencies, system.link, system.unlink, system);
|
|
@@ -416,6 +556,9 @@ EntityManager.prototype.removeSystem = async function (system) {
|
|
|
416
556
|
//shutdown system
|
|
417
557
|
this.systems.splice(systemIndex, 1);
|
|
418
558
|
|
|
559
|
+
// request exec order update
|
|
560
|
+
this.__execution_order_needs_update = true;
|
|
561
|
+
|
|
419
562
|
if (this.dataset !== null) {
|
|
420
563
|
this.dataset.removeObserver(systemObserver);
|
|
421
564
|
}
|
package/src/engine/ecs/System.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { array_copy_unique } from "../../core/collection/array/array_copy_unique.js";
|
|
7
7
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
8
8
|
import { noop } from "../../core/function/Functions.js";
|
|
9
|
+
import { array_push_if_unique } from "../../core/collection/array/array_push_if_unique.js";
|
|
10
|
+
import { ResourceAccessKind } from "../../core/model/ResourceAccessKind.js";
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
*
|
|
@@ -32,21 +34,67 @@ class System {
|
|
|
32
34
|
dependencies = [];
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
|
-
* Component types that are used internally by the system
|
|
36
|
-
*
|
|
37
|
-
*
|
|
37
|
+
* Component types that are used internally by the system and how they are used
|
|
38
|
+
* Main benefit of doing so is twofold:
|
|
39
|
+
* - Helps the engine figure out the best execution order for system to make sure that updates propagate as quickly as possible
|
|
40
|
+
* - Declaring this helps EntityManager to ensure that all relevant component types are properly registered for the system
|
|
41
|
+
*
|
|
42
|
+
* NOTE: specifying this is optional. The engine will still work.
|
|
43
|
+
* @type {ResourceAccessSpecification[]}
|
|
38
44
|
*/
|
|
39
45
|
components_used = [];
|
|
40
46
|
|
|
41
47
|
|
|
42
48
|
/**
|
|
43
|
-
* @returns {[]}
|
|
49
|
+
* @returns {[]} Component classes
|
|
44
50
|
*/
|
|
45
51
|
get referenced_components() {
|
|
46
52
|
const result = [];
|
|
47
53
|
|
|
48
54
|
array_copy_unique(this.dependencies, 0, result, result.length, this.dependencies.length);
|
|
49
|
-
|
|
55
|
+
|
|
56
|
+
const used = this.components_used;
|
|
57
|
+
const use_count = used.length;
|
|
58
|
+
for (let i = 0; i < use_count; i++) {
|
|
59
|
+
const ref = used[i];
|
|
60
|
+
|
|
61
|
+
array_push_if_unique(result, ref.resource);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @template T
|
|
69
|
+
* @param {T} Klass
|
|
70
|
+
* @return {number}
|
|
71
|
+
*/
|
|
72
|
+
getAccessForComponent(Klass) {
|
|
73
|
+
let result = 0;
|
|
74
|
+
|
|
75
|
+
const used = this.components_used;
|
|
76
|
+
const use_count = used.length;
|
|
77
|
+
for (let i = 0; i < use_count; i++) {
|
|
78
|
+
const ref = used[i];
|
|
79
|
+
|
|
80
|
+
if (ref.resource === Klass) {
|
|
81
|
+
result |= ref.access;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const dependencies = this.dependencies;
|
|
87
|
+
const dependency_count = dependencies.length;
|
|
88
|
+
|
|
89
|
+
for (let i = 0; i < dependency_count; i++) {
|
|
90
|
+
const dependency = dependencies[i];
|
|
91
|
+
|
|
92
|
+
if (dependency === Klass) {
|
|
93
|
+
// at the very least it's going to read
|
|
94
|
+
result |= ResourceAccessKind.Read;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
50
98
|
|
|
51
99
|
return result;
|
|
52
100
|
}
|
|
@@ -6,6 +6,8 @@ import { extractSkeletonFromMeshComponent } from "../../graphics/ecs/mesh/Skelet
|
|
|
6
6
|
import { OneBoneSurfaceAlignmentSolver } from "./OneBoneSurfaceAlignmentSolver.js";
|
|
7
7
|
import { IKProblem } from "./IKProblem.js";
|
|
8
8
|
import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
|
|
9
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
10
|
+
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
export class InverseKinematicsSystem extends System {
|
|
@@ -14,6 +16,10 @@ export class InverseKinematicsSystem extends System {
|
|
|
14
16
|
|
|
15
17
|
this.dependencies = [InverseKinematics, Mesh];
|
|
16
18
|
|
|
19
|
+
this.components_used = [
|
|
20
|
+
ResourceAccessSpecification.from(Mesh,ResourceAccessKind.Read|ResourceAccessSpecification.Write)
|
|
21
|
+
];
|
|
22
|
+
|
|
17
23
|
/**
|
|
18
24
|
*
|
|
19
25
|
* @type {{"2BIK": TwoBoneInverseKinematicsSolver}}
|
|
@@ -6,6 +6,8 @@ import { assert } from "../../../core/assert.js";
|
|
|
6
6
|
import Mesh from "../../graphics/ecs/mesh/Mesh.js";
|
|
7
7
|
import { BoneAttachmentBinding } from "./BoneAttachmentBinding.js";
|
|
8
8
|
import { TransformAttachmentBinding } from "./TransformAttachmentBinding.js";
|
|
9
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
10
|
+
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
9
11
|
|
|
10
12
|
export class AttachmentSystem extends System {
|
|
11
13
|
constructor() {
|
|
@@ -13,6 +15,12 @@ export class AttachmentSystem extends System {
|
|
|
13
15
|
|
|
14
16
|
this.dependencies = [Attachment, Transform];
|
|
15
17
|
|
|
18
|
+
this.components_used = [
|
|
19
|
+
ResourceAccessSpecification.from(AttachmentSockets, ResourceAccessKind.Read),
|
|
20
|
+
ResourceAccessSpecification.from(Mesh, ResourceAccessKind.Read),
|
|
21
|
+
ResourceAccessSpecification.from(Transform, ResourceAccessKind.Write)
|
|
22
|
+
];
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
*
|
|
18
26
|
* @type {number[]}
|
|
@@ -20,6 +20,8 @@ import { computeStringHash } from "../../../core/primitives/strings/computeStrin
|
|
|
20
20
|
import { randomFromArray } from "../../../core/math/random/randomFromArray.js";
|
|
21
21
|
import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
|
|
22
22
|
import { randomMultipleFromArray } from "../../../core/collection/array/randomMultipleFromArray.js";
|
|
23
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
24
|
+
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* In seconds
|
|
@@ -104,6 +106,9 @@ export class DynamicActorSystem extends AbstractContextSystem {
|
|
|
104
106
|
|
|
105
107
|
this.dependencies = [DynamicActor];
|
|
106
108
|
|
|
109
|
+
this.components_used = [
|
|
110
|
+
ResourceAccessSpecification.from(Blackboard, ResourceAccessKind.Read)
|
|
111
|
+
];
|
|
107
112
|
|
|
108
113
|
/**
|
|
109
114
|
*
|
|
@@ -6,6 +6,8 @@ import Team from "../team/Team.js";
|
|
|
6
6
|
import { Transform } from "../transform/Transform.js";
|
|
7
7
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
8
8
|
import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
|
|
9
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
10
|
+
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
9
11
|
|
|
10
12
|
const v2 = new Vector2();
|
|
11
13
|
|
|
@@ -17,9 +19,11 @@ export class FogOfWarRevealerSystem extends System {
|
|
|
17
19
|
constructor(team) {
|
|
18
20
|
super();
|
|
19
21
|
|
|
20
|
-
this.dependencies
|
|
21
|
-
|
|
22
|
-
this.
|
|
22
|
+
this.dependencies = [FogOfWarRevealer, Transform, Team];
|
|
23
|
+
|
|
24
|
+
this.components_used = [
|
|
25
|
+
ResourceAccessSpecification.from(FogOfWar, ResourceAccessKind.Write)
|
|
26
|
+
];
|
|
23
27
|
|
|
24
28
|
this.data = [];
|
|
25
29
|
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
compute_perspective_camera_focal_position
|
|
17
17
|
} from "../../graphics/ecs/camera/compute_perspective_camera_focal_position.js";
|
|
18
18
|
import { frustum_from_camera } from "../../graphics/ecs/camera/frustum_from_camera.js";
|
|
19
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
20
|
+
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
const frustum = new Frustum();
|
|
@@ -36,6 +38,10 @@ export class FogOfWarSystem extends System {
|
|
|
36
38
|
|
|
37
39
|
this.dependencies = [FogOfWar, Terrain];
|
|
38
40
|
|
|
41
|
+
this.components_used = [
|
|
42
|
+
ResourceAccessSpecification.from(FogOfWar, ResourceAccessKind.Read | ResourceAccessKind.Write)
|
|
43
|
+
];
|
|
44
|
+
|
|
39
45
|
this.visibilityFilter = this.buildVisibilityFilter();
|
|
40
46
|
//turn off by default
|
|
41
47
|
this.visibilityFilter.enabled = false;
|
|
@@ -12,6 +12,8 @@ import ViewportPosition from "../position/ViewportPosition.js";
|
|
|
12
12
|
import GUIElement from "../GUIElement.js";
|
|
13
13
|
import { HeadsUpDisplayFlag } from "./HeadsUpDisplayFlag.js";
|
|
14
14
|
import { mat4 } from "gl-matrix";
|
|
15
|
+
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
16
|
+
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
15
17
|
|
|
16
18
|
const projection = new Float32Array(16);
|
|
17
19
|
|
|
@@ -32,6 +34,12 @@ class HeadsUpDisplaySystem extends System {
|
|
|
32
34
|
|
|
33
35
|
this.dependencies = [HeadsUpDisplay];
|
|
34
36
|
|
|
37
|
+
|
|
38
|
+
this.components_used = [
|
|
39
|
+
ResourceAccessSpecification.from(GUIElement, ResourceAccessKind.Read | ResourceAccessKind.Write),
|
|
40
|
+
ResourceAccessSpecification.from(ViewportPosition, ResourceAccessKind.Read | ResourceAccessKind.Write),
|
|
41
|
+
];
|
|
42
|
+
|
|
35
43
|
if (!(graphicsEngine instanceof GraphicsEngine)) {
|
|
36
44
|
throw new TypeError(`graphicsEngine is not an instance of GraphicsEngine`);
|
|
37
45
|
}
|
|
@@ -9,6 +9,8 @@ import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
|
|
|
9
9
|
import AABB2 from "../../../../core/geom/AABB2.js";
|
|
10
10
|
import { GUIElementEvent } from "../GUIElementEvent.js";
|
|
11
11
|
import { EPSILON } from "../../../../core/math/EPSILON.js";
|
|
12
|
+
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
13
|
+
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
12
14
|
|
|
13
15
|
const CSS_CLASS = 'ecs-viewport-position-component';
|
|
14
16
|
|
|
@@ -27,6 +29,10 @@ class ViewportPositionSystem extends System {
|
|
|
27
29
|
|
|
28
30
|
this.dependencies = [ViewportPosition, GUIElement];
|
|
29
31
|
|
|
32
|
+
this.components_used = [
|
|
33
|
+
ResourceAccessSpecification.from(GUIElement, ResourceAccessKind.Read | ResourceAccessKind.Write),
|
|
34
|
+
];
|
|
35
|
+
|
|
30
36
|
this.viewportSize = viewportSize;
|
|
31
37
|
|
|
32
38
|
this.viewportSizeChangeReactor = new SignalBinding(viewportSize.onChanged, () => {
|
|
@@ -30,6 +30,8 @@ import TransitionFunctions from "../../animation/TransitionFunctions.js";
|
|
|
30
30
|
import AnimationTrackPlayback from "../../animation/keyed2/AnimationTrackPlayback.js";
|
|
31
31
|
import { globalMetrics } from "../../metrics/GlobalMetrics.js";
|
|
32
32
|
import { MetricsCategory } from "../../metrics/MetricsCategory.js";
|
|
33
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
34
|
+
import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* Delay before the user notices the text and begins to read
|
|
@@ -170,6 +172,17 @@ export class VoiceSystem extends AbstractContextSystem {
|
|
|
170
172
|
|
|
171
173
|
this.dependencies = [Voice];
|
|
172
174
|
|
|
175
|
+
this.components_used = [
|
|
176
|
+
ResourceAccessSpecification.from(GUIElement, ResourceAccessKind.Create),
|
|
177
|
+
ResourceAccessSpecification.from(ViewportPosition, ResourceAccessKind.Create),
|
|
178
|
+
ResourceAccessSpecification.from(HeadsUpDisplay, ResourceAccessKind.Create),
|
|
179
|
+
ResourceAccessSpecification.from(Transform, ResourceAccessKind.Create),
|
|
180
|
+
ResourceAccessSpecification.from(Attachment, ResourceAccessKind.Create),
|
|
181
|
+
ResourceAccessSpecification.from(SerializationMetadata, ResourceAccessKind.Create),
|
|
182
|
+
ResourceAccessSpecification.from(BehaviorComponent, ResourceAccessKind.Create),
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
|
|
173
186
|
/**
|
|
174
187
|
*
|
|
175
188
|
* @type {Localization}
|