@woosh/meep-engine 2.57.0 → 2.58.0
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/editor/Editor.js +4 -4
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +3 -3
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +3 -3
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +3 -3
- package/editor/tools/v2/prototypeTransformControls.js +3 -3
- package/editor/view/ecs/ComponentControlView.js +2 -1
- package/package.json +1 -1
- package/samples/generation/main.js +2 -2
- package/samples/terrain/from_image.js +2 -2
- package/samples/terrain/from_image_2.js +4 -4
- package/src/core/binary/byteArrayToString.js +28 -0
- package/src/core/binary/downloadAsFile.js +28 -0
- package/src/core/binary/downloadUrlAsFile.js +14 -0
- package/src/core/binary/jsonToStringToByteArray.js +27 -0
- package/src/core/binary/stringToByteArray.js +24 -0
- package/src/core/bvh2/BinaryNode.spec.js +2 -1
- package/src/core/color/Color.spec.js +27 -1
- package/src/core/color/parse_color.js +1 -1
- package/src/core/fsm/simple/SimpleStateMachine.spec.js +34 -2
- package/src/core/geom/3d/matrix/m4_multiply.js +2 -2
- package/src/core/geom/3d/matrix/m4_multiply.spec.js +11 -0
- package/src/core/geom/3d/matrix/m4_multiply_alphatensor.spec.js +11 -0
- package/src/core/geom/3d/morton/split_by_2.js +1 -1
- package/src/core/geom/3d/shape/util/shape_to_visual_entity.js +10 -10
- package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +2 -2
- package/src/core/geom/3d/topology/samples/sampleFloodFill.js +3 -3
- package/src/core/process/action/AsynchronousDelayAction.js +2 -2
- package/src/core/process/executor/profile/ConcurrentExecutorProfiler.js +1 -1
- package/src/engine/EngineHarness.js +7 -7
- package/src/engine/EntityCreator.js +5 -5
- package/src/engine/__module.js +1 -1
- package/src/engine/achievements/AchievementManager.js +2 -2
- package/src/engine/animation/AnimationUtils.js +4 -4
- package/src/engine/animation/behavior/animateProperty.js +2 -2
- package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +3 -3
- package/src/engine/animation/playAnimationTrack.js +3 -3
- package/src/engine/animation/playTrackRealTime.js +3 -3
- package/src/engine/animation/removeEntityWithMeshParticlesEffect.js +2 -2
- package/src/engine/control/ControlContext.js +7 -7
- package/src/engine/ecs/{EntityBuilder.d.ts → Entity.d.ts} +5 -5
- package/src/engine/ecs/{EntityBuilder.js → Entity.js} +29 -29
- package/src/engine/ecs/{EntityBuilder.spec.js → Entity.spec.js} +17 -17
- package/src/engine/ecs/EntityBlueprint.d.ts +2 -2
- package/src/engine/ecs/EntityBlueprint.js +3 -3
- package/src/engine/ecs/EntityBlueprint.spec.js +2 -2
- package/src/engine/ecs/{EntityBuilderFlags.js → EntityFlags.js} +1 -1
- package/src/engine/ecs/EntityObserver.spec.js +8 -8
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +5 -5
- package/src/engine/ecs/foliage/ecs/InstancedMeshUtils.js +3 -3
- package/src/engine/ecs/gui/menu/radial/RadialContextMenu.d.ts +2 -2
- package/src/engine/ecs/gui/menu/radial/RadialContextMenu.js +5 -5
- package/src/engine/ecs/parent/EntityNode.d.ts +3 -3
- package/src/engine/ecs/parent/EntityNode.js +5 -5
- package/src/engine/ecs/parent/testHuDPerf.js +2 -2
- package/src/engine/ecs/speaker/VoiceSystem.js +5 -5
- package/src/engine/ecs/tooltip/testTooltipComponentSystem.js +3 -3
- package/src/engine/graphics/camera/makeOrbitalCameraController.js +3 -3
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +3 -3
- package/src/engine/graphics/debug/createDebugLabel.js +3 -3
- package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.js +3 -3
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalEditor.js +3 -3
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +14 -14
- package/src/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +5 -5
- package/src/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +6 -6
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +3 -3
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +3 -3
- package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +3 -3
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +3 -3
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +2 -2
- package/src/engine/graphics/ecs/sprite/prototypeSpriteSystem.js +2 -2
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +4 -4
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +7 -7
- package/src/engine/graphics/particles/node-based/editor/ParticleSpecificationEditorView.js +1 -1
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +2 -2
- package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -2
- package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +3 -3
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +10 -10
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -2
- package/src/engine/graphics/render/buffer/simple-fx/taa/prototypeTAA.js +2 -2
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +11 -11
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +5 -5
- package/src/engine/graphics/sh3/LightProbeVolume.js +2 -2
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -3
- package/src/engine/graphics/sh3/visualise_probe.js +3 -3
- package/src/engine/graphics/shadows/testShadowMapRendering.js +3 -3
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +1 -1
- package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +2 -2
- package/src/engine/input/ecs/controllers/KeyboardCameraController.js +2 -2
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +2 -2
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +13 -12
- package/src/engine/physics/fluid/prototype.js +3 -3
- package/src/engine/save/storage/JsonStringCodec.js +1 -1
- package/src/engine/save/storage/LocalStorage.js +2 -1
- package/src/engine/ui/GUIEngine.js +4 -4
- package/src/engine/ui/notification/NotificationManager.js +3 -3
- package/src/generation/markers/debug/visualizeMarkers.js +2 -2
- package/src/generation/markers/prototypeGridCellActionPlaceMarker.js +2 -2
- package/src/core/binary/ByteArrayTools.js +0 -137
- package/src/core/binary/NaiveBitSet.js +0 -69
- package/src/core/binary/objects/StandardTypeBuilder.js +0 -126
- package/src/core/binary/serde/JsonSerializer.js +0 -113
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Entity from "../../../engine/ecs/Entity.js";
|
|
2
2
|
import { SequenceBehavior } from "../../../engine/intelligence/behavior/composite/SequenceBehavior.js";
|
|
3
3
|
import { BehaviorComponent } from "../../../engine/intelligence/behavior/ecs/BehaviorComponent.js";
|
|
4
4
|
import { DieBehavior } from "../../../engine/intelligence/behavior/ecs/DieBehavior.js";
|
|
@@ -23,7 +23,7 @@ export class AsynchronousDelayAction extends AsynchronousAction {
|
|
|
23
23
|
this.__ecd = ecd;
|
|
24
24
|
this.__time = time;
|
|
25
25
|
|
|
26
|
-
this.__entity = new
|
|
26
|
+
this.__entity = new Entity();
|
|
27
27
|
|
|
28
28
|
this.__entity.add(BehaviorComponent.fromOne(
|
|
29
29
|
SequenceBehavior.from([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { downloadAsFile } from "../../../binary/ByteArrayTools.js";
|
|
2
1
|
import { Profile } from "./Profile.js";
|
|
3
2
|
import { TraceEvent } from "./TraceEvent.js";
|
|
3
|
+
import {downloadAsFile} from "../../../binary/downloadAsFile.js";
|
|
4
4
|
|
|
5
5
|
export class ConcurrentExecutorProfiler {
|
|
6
6
|
constructor() {
|
|
@@ -3,7 +3,7 @@ import { MouseEvents } from "./input/devices/events/MouseEvents.js";
|
|
|
3
3
|
import { Transform } from "./ecs/transform/Transform.js";
|
|
4
4
|
import TopDownCameraController from "./graphics/ecs/camera/topdown/TopDownCameraController.js";
|
|
5
5
|
import { Camera } from "./graphics/ecs/camera/Camera.js";
|
|
6
|
-
import
|
|
6
|
+
import Entity from "./ecs/Entity.js";
|
|
7
7
|
import { Light } from "./graphics/ecs/light/Light.js";
|
|
8
8
|
import Vector3 from "../core/geom/Vector3.js";
|
|
9
9
|
import Terrain from "./ecs/terrain/ecs/Terrain.js";
|
|
@@ -162,7 +162,7 @@ export class EngineHarness {
|
|
|
162
162
|
* @param {number} [distanceMin]
|
|
163
163
|
* @param {number} [distanceMax]
|
|
164
164
|
* @param {number} [fieldOfView] in degrees
|
|
165
|
-
* @returns {
|
|
165
|
+
* @returns {Entity}
|
|
166
166
|
*/
|
|
167
167
|
static buildCamera(
|
|
168
168
|
{
|
|
@@ -212,7 +212,7 @@ export class EngineHarness {
|
|
|
212
212
|
camera.clip_far = distanceMax;
|
|
213
213
|
camera.fov.set(fieldOfView);
|
|
214
214
|
|
|
215
|
-
const entityBuilder = new
|
|
215
|
+
const entityBuilder = new Entity();
|
|
216
216
|
|
|
217
217
|
entityBuilder
|
|
218
218
|
.add(transform)
|
|
@@ -349,7 +349,7 @@ export class EngineHarness {
|
|
|
349
349
|
-0.3334313787830773
|
|
350
350
|
);
|
|
351
351
|
|
|
352
|
-
new
|
|
352
|
+
new Entity()
|
|
353
353
|
.add(key)
|
|
354
354
|
.add(transform)
|
|
355
355
|
.add(Tag.fromJSON(["Light", "Key"]))
|
|
@@ -362,7 +362,7 @@ export class EngineHarness {
|
|
|
362
362
|
fill.intensity.set(0.1);
|
|
363
363
|
|
|
364
364
|
|
|
365
|
-
new
|
|
365
|
+
new Entity()
|
|
366
366
|
.add(fill)
|
|
367
367
|
.add(new Transform())
|
|
368
368
|
.add(Tag.fromJSON(["Light", "Ambient"]))
|
|
@@ -375,7 +375,7 @@ export class EngineHarness {
|
|
|
375
375
|
* @param {Engine} engine
|
|
376
376
|
* @param {number} [sensitivity]
|
|
377
377
|
* @param {EntityComponentDataset} [ecd]
|
|
378
|
-
* @returns {
|
|
378
|
+
* @returns {Entity}
|
|
379
379
|
*/
|
|
380
380
|
static async buildOrbitalCameraController({
|
|
381
381
|
cameraEntity,
|
|
@@ -469,7 +469,7 @@ export class EngineHarness {
|
|
|
469
469
|
terrain.build(engine.assetManager);
|
|
470
470
|
|
|
471
471
|
|
|
472
|
-
const eb = new
|
|
472
|
+
const eb = new Entity();
|
|
473
473
|
|
|
474
474
|
eb.add(new Transform())
|
|
475
475
|
eb.add(terrain);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Transform } from './ecs/transform/Transform.js';
|
|
5
5
|
import { SoundEmitter } from './sound/ecs/emitter/SoundEmitter.js';
|
|
6
6
|
import Timer from './ecs/components/Timer.js';
|
|
7
|
-
import
|
|
7
|
+
import Entity from './ecs/Entity.js';
|
|
8
8
|
import Vector3 from "../core/geom/Vector3.js";
|
|
9
9
|
import { SoundEmitterChannels } from "./sound/ecs/emitter/SoundEmitterSystem.js";
|
|
10
10
|
import { BehaviorComponent } from "./intelligence/behavior/ecs/BehaviorComponent.js";
|
|
@@ -22,7 +22,7 @@ import { SerializationMetadata } from "./ecs/components/SerializationMetadata.js
|
|
|
22
22
|
* @param {boolean} [positioned]
|
|
23
23
|
* @param {String|SoundEmitterChannels} [channel]
|
|
24
24
|
* @param {number} [volume]
|
|
25
|
-
* @returns {
|
|
25
|
+
* @returns {Entity}
|
|
26
26
|
*/
|
|
27
27
|
function createSound(
|
|
28
28
|
{
|
|
@@ -37,7 +37,7 @@ function createSound(
|
|
|
37
37
|
}
|
|
38
38
|
) {
|
|
39
39
|
|
|
40
|
-
const builder = new
|
|
40
|
+
const builder = new Entity();
|
|
41
41
|
|
|
42
42
|
let trackJSON;
|
|
43
43
|
|
|
@@ -77,10 +77,10 @@ function createSound(
|
|
|
77
77
|
*
|
|
78
78
|
* @param timeout
|
|
79
79
|
* @param action
|
|
80
|
-
* @returns {
|
|
80
|
+
* @returns {Entity}
|
|
81
81
|
*/
|
|
82
82
|
export function createTimer({ timeout, action }) {
|
|
83
|
-
const builder = new
|
|
83
|
+
const builder = new Entity();
|
|
84
84
|
|
|
85
85
|
function suicide() {
|
|
86
86
|
builder.destroy();
|
package/src/engine/__module.js
CHANGED
|
@@ -14,6 +14,6 @@ export { EngineConfiguration } from "./EngineConfiguration.js";
|
|
|
14
14
|
export { Light } from "./graphics/ecs/light/Light.js";
|
|
15
15
|
export * from "./graphics/ecs/light/LightSystem.js";
|
|
16
16
|
export { ForwardPlusRenderingPlugin } from "./graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
17
|
-
export * from "./ecs/
|
|
17
|
+
export * from "./ecs/Entity.js";
|
|
18
18
|
|
|
19
19
|
export * from './intelligence/__module.js';
|
|
@@ -6,7 +6,7 @@ import ObservedBoolean from "../../core/model/ObservedBoolean.js";
|
|
|
6
6
|
import { AchievementNotificationView } from "../../view/game/achievements/AchievementNotificationView.js";
|
|
7
7
|
import ViewportPosition from "../ecs/gui/position/ViewportPosition.js";
|
|
8
8
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
9
|
-
import
|
|
9
|
+
import Entity from "../ecs/Entity.js";
|
|
10
10
|
import GUIElement from "../ecs/gui/GUIElement.js";
|
|
11
11
|
import AnimationTrack from "../animation/keyed2/AnimationTrack.js";
|
|
12
12
|
import TransitionFunctions from "../animation/TransitionFunctions.js";
|
|
@@ -313,7 +313,7 @@ export class AchievementManager extends EnginePlugin {
|
|
|
313
313
|
aExit.addKey(1, [1, 0, 1]);
|
|
314
314
|
aExit.addTransition(0, SLOW_CUBIC);
|
|
315
315
|
|
|
316
|
-
const builder = new
|
|
316
|
+
const builder = new Entity();
|
|
317
317
|
|
|
318
318
|
const sequenceBehavior = SequenceBehavior.from([
|
|
319
319
|
new AnimationBehavior(new AnimationTrackPlayback(aEntry, (scale, alpha, v) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
|
|
2
2
|
import Timer from "../ecs/components/Timer.js";
|
|
3
|
-
import
|
|
3
|
+
import Entity from "../ecs/Entity.js";
|
|
4
4
|
import { whenAllEntitiesDestroyed, whenEntityDestroyed } from "../ecs/EntityBuilderUtils.js";
|
|
5
5
|
import { Transform } from "../ecs/transform/Transform.js";
|
|
6
6
|
import { removeComponentsExcept } from "../ecs/util/removeComponentsExcept.js";
|
|
@@ -41,7 +41,7 @@ export function stopTrailAndNotifyOnceFinished(entity, ecd) {
|
|
|
41
41
|
|
|
42
42
|
trail.clearFlag(Trail2DFlags.Spawning);
|
|
43
43
|
|
|
44
|
-
new
|
|
44
|
+
new Entity()
|
|
45
45
|
.add(BehaviorComponent.fromOne(SequenceBehavior.from([
|
|
46
46
|
DelayBehavior.fromJSON({ value: trail.maxAge }),
|
|
47
47
|
new ActionBehavior(resolve)
|
|
@@ -85,7 +85,7 @@ export function stopEmitterAndNotifyOnceFinished(entity, ecd) {
|
|
|
85
85
|
//figure out how long the emitter should stay alive
|
|
86
86
|
const maxLife = emitter.computeMaxEmittingParticleLife();
|
|
87
87
|
|
|
88
|
-
const entityBuilder = new
|
|
88
|
+
const entityBuilder = new Entity();
|
|
89
89
|
//create a timer to remove emitter
|
|
90
90
|
const timer = new Timer();
|
|
91
91
|
timer.timeout = maxLife;
|
|
@@ -219,7 +219,7 @@ export function removeEntityWithEffect({ entity, ecd, emitter, soundEffect, time
|
|
|
219
219
|
const t = new Transform();
|
|
220
220
|
t.copy(transform);
|
|
221
221
|
|
|
222
|
-
const emitterBuilder = new
|
|
222
|
+
const emitterBuilder = new Entity();
|
|
223
223
|
emitterBuilder.add(t).add(emitter);
|
|
224
224
|
emitterBuilder.build(ecd);
|
|
225
225
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TransitionPropertyVectorXBehavior
|
|
3
3
|
} from "../../../../../model/game/story/behaviors/generic/TransitionPropertyVectorXBehavior.js";
|
|
4
|
-
import
|
|
4
|
+
import Entity from "../../ecs/Entity.js";
|
|
5
5
|
import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
6
6
|
import { SequenceBehavior } from "../../intelligence/behavior/composite/SequenceBehavior.js";
|
|
7
7
|
import { DieBehavior } from "../../intelligence/behavior/ecs/DieBehavior.js";
|
|
@@ -23,7 +23,7 @@ export async function animateProperty(ecd, entity, component, property, target,
|
|
|
23
23
|
|
|
24
24
|
assert.ok(ecd.entityExists(entity), `entity ${entity} doesn't exist`);
|
|
25
25
|
|
|
26
|
-
const builder = new
|
|
26
|
+
const builder = new Entity()
|
|
27
27
|
.add(SerializationMetadata.Transient)
|
|
28
28
|
.add(BehaviorComponent.fromOne(SequenceBehavior.from([
|
|
29
29
|
TransitionPropertyVectorXBehavior.from({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CanvasView } from "../../../../view/elements/CanvasView.js";
|
|
2
2
|
import { plot_data } from "./plot_data.js";
|
|
3
3
|
import { draw_label } from "./draw_label.js";
|
|
4
|
-
import
|
|
4
|
+
import Entity from "../../../ecs/Entity.js";
|
|
5
5
|
import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
|
|
6
6
|
import GUIElement from "../../../ecs/gui/GUIElement.js";
|
|
7
7
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
@@ -15,7 +15,7 @@ import Vector2 from "../../../../core/geom/Vector2.js";
|
|
|
15
15
|
* @param {number} [height]
|
|
16
16
|
* @param {Vector2} [margin]
|
|
17
17
|
* @param {string} [label]
|
|
18
|
-
* @return {
|
|
18
|
+
* @return {Entity}
|
|
19
19
|
*/
|
|
20
20
|
export function build_plot_entity_from_array({
|
|
21
21
|
data,
|
|
@@ -39,7 +39,7 @@ export function build_plot_entity_from_array({
|
|
|
39
39
|
draw_label(ctx, label, 0, 0)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
return new
|
|
42
|
+
return new Entity()
|
|
43
43
|
.add(ViewportPosition.fromJSON({
|
|
44
44
|
offset: { x, y }
|
|
45
45
|
}))
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Script from "../ecs/components/Script.js";
|
|
2
2
|
import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
|
|
3
|
-
import
|
|
3
|
+
import Entity from "../ecs/Entity.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param {AnimationTrackPlayback} track
|
|
8
8
|
* @param {EntityComponentDataset} ecd
|
|
9
|
-
* @returns {
|
|
9
|
+
* @returns {Entity}
|
|
10
10
|
*/
|
|
11
11
|
export function playAnimationTrack(track, ecd) {
|
|
12
12
|
const script = new Script();
|
|
@@ -15,7 +15,7 @@ export function playAnimationTrack(track, ecd) {
|
|
|
15
15
|
track.advance(timeDelta);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const entity = new
|
|
18
|
+
const entity = new Entity();
|
|
19
19
|
entity.add(script);
|
|
20
20
|
entity.add(SerializationMetadata.Transient);
|
|
21
21
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
|
|
2
|
-
import
|
|
2
|
+
import Entity from "../ecs/Entity.js";
|
|
3
3
|
import { BehaviorComponent } from "../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
4
4
|
import { ClockChannelType } from "../intelligence/behavior/ecs/ClockChannelType.js";
|
|
5
5
|
import { AnimationBehavior } from "./keyed2/behavior/AnimationBehavior.js";
|
|
@@ -9,11 +9,11 @@ import { AnimationBehavior } from "./keyed2/behavior/AnimationBehavior.js";
|
|
|
9
9
|
* @param {AnimationTrackPlayback} track
|
|
10
10
|
* @param {EntityComponentDataset} ecd
|
|
11
11
|
*
|
|
12
|
-
* @returns {
|
|
12
|
+
* @returns {Entity}
|
|
13
13
|
*/
|
|
14
14
|
export function playTrackRealTime(track, ecd) {
|
|
15
15
|
|
|
16
|
-
const entity = new
|
|
16
|
+
const entity = new Entity();
|
|
17
17
|
|
|
18
18
|
const behaviorComponent = BehaviorComponent.fromOne(new AnimationBehavior(track));
|
|
19
19
|
|
|
@@ -6,7 +6,7 @@ import { removeComponentsExcept } from "../ecs/util/removeComponentsExcept.js";
|
|
|
6
6
|
import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter/ParticleEmitter.js";
|
|
7
7
|
import Trail2D from "../graphics/ecs/trail2d/Trail2D.js";
|
|
8
8
|
import { Transform } from "../ecs/transform/Transform.js";
|
|
9
|
-
import
|
|
9
|
+
import Entity from "../ecs/Entity.js";
|
|
10
10
|
import { stopEntityAndNotifyWhenStopped } from "./AnimatedActions.js";
|
|
11
11
|
|
|
12
12
|
const lib = {
|
|
@@ -184,7 +184,7 @@ export function removeEntityWithMeshParticlesEffect(
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
//create particle emitter
|
|
187
|
-
const effectBuilder = new
|
|
187
|
+
const effectBuilder = new Entity();
|
|
188
188
|
const effectEntity = effectBuilder
|
|
189
189
|
.add(emitter)
|
|
190
190
|
.add(originalTransform.clone())
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Entity from "../ecs/Entity.js";
|
|
2
2
|
import { ControlContextState } from "./ControlContextState.js";
|
|
3
3
|
import { IllegalStateException } from "../../core/fsm/exceptions/IllegalStateException.js";
|
|
4
4
|
import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
|
|
5
|
-
import {
|
|
5
|
+
import { EntityFlags } from "../ecs/EntityFlags.js";
|
|
6
6
|
|
|
7
7
|
export class ControlContext {
|
|
8
8
|
constructor() {
|
|
@@ -14,7 +14,7 @@ export class ControlContext {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @private
|
|
17
|
-
* @type {
|
|
17
|
+
* @type {Entity[]}
|
|
18
18
|
*/
|
|
19
19
|
this.entities = [];
|
|
20
20
|
|
|
@@ -42,10 +42,10 @@ export class ControlContext {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Do not invoke "build" manually
|
|
45
|
-
* @returns {
|
|
45
|
+
* @returns {Entity}
|
|
46
46
|
*/
|
|
47
47
|
makeEntity() {
|
|
48
|
-
const eb = new
|
|
48
|
+
const eb = new Entity();
|
|
49
49
|
|
|
50
50
|
if (this.transientEntities) {
|
|
51
51
|
eb.add(SerializationMetadata.Transient);
|
|
@@ -124,7 +124,7 @@ export class ControlContext {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
for (const e of this.entities) {
|
|
127
|
-
if (e.getFlag(
|
|
127
|
+
if (e.getFlag(EntityFlags.Built)) {
|
|
128
128
|
throw new IllegalStateException(`Entity ${e.entity} is already built, this violates pre-condition of control context`);
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -149,7 +149,7 @@ export class ControlContext {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
for (const e of this.entities) {
|
|
152
|
-
if (!e.getFlag(
|
|
152
|
+
if (!e.getFlag(EntityFlags.Built)) {
|
|
153
153
|
//entity is not built, skip
|
|
154
154
|
continue;
|
|
155
155
|
}
|
|
@@ -4,10 +4,10 @@ interface Type<T> extends Function {
|
|
|
4
4
|
new(...args: any[]): T;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export default class
|
|
7
|
+
export default class Entity {
|
|
8
8
|
public entity: number;
|
|
9
9
|
|
|
10
|
-
add<T>(component: T):
|
|
10
|
+
add<T>(component: T): Entity
|
|
11
11
|
|
|
12
12
|
removeComponent<T>(componentType: Type<T>): T | null
|
|
13
13
|
|
|
@@ -27,11 +27,11 @@ export default class EntityBuilder {
|
|
|
27
27
|
|
|
28
28
|
sendEvent(eventName: string, event?: any): void
|
|
29
29
|
|
|
30
|
-
addEventListener(eventName: string, listener: (data?: any) => void, context?: any):
|
|
30
|
+
addEventListener(eventName: string, listener: (data?: any) => void, context?: any): Entity
|
|
31
31
|
|
|
32
|
-
removeEventListener(eventName: string, listener: (data?: any) => void, context?: any):
|
|
32
|
+
removeEventListener(eventName: string, listener: (data?: any) => void, context?: any): Entity
|
|
33
33
|
|
|
34
|
-
static readFromDataset(entity: number, dataset: EntityComponentDataset):
|
|
34
|
+
static readFromDataset(entity: number, dataset: EntityComponentDataset): Entity
|
|
35
35
|
|
|
36
36
|
getFlag(flag: number): boolean
|
|
37
37
|
|
|
@@ -2,22 +2,22 @@ import Signal from "../../core/events/signal/Signal.js";
|
|
|
2
2
|
import { assert } from "../../core/assert.js";
|
|
3
3
|
import { EventType } from "./EntityManager.js";
|
|
4
4
|
import { isDefined } from "../../core/process/matcher/Matchers.js";
|
|
5
|
-
import {
|
|
5
|
+
import { EntityFlags } from "./EntityFlags.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Set of default flags
|
|
9
9
|
* @type {number}
|
|
10
10
|
*/
|
|
11
11
|
const DEFAULT_FLAGS =
|
|
12
|
-
|
|
13
|
-
|
|
|
12
|
+
EntityFlags.RegisterComponents
|
|
13
|
+
| EntityFlags.WatchDestruction
|
|
14
14
|
;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Representation of an entity, helps build entities and keep track of them without having to access {@link EntityComponentDataset} directly
|
|
18
18
|
* @class
|
|
19
19
|
*/
|
|
20
|
-
class
|
|
20
|
+
class Entity {
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @type {number}
|
|
@@ -51,7 +51,7 @@ class EntityBuilder {
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
*
|
|
54
|
-
* @type {
|
|
54
|
+
* @type {EntityFlags|number}
|
|
55
55
|
*/
|
|
56
56
|
flags = DEFAULT_FLAGS;
|
|
57
57
|
|
|
@@ -73,12 +73,12 @@ class EntityBuilder {
|
|
|
73
73
|
* @private
|
|
74
74
|
*/
|
|
75
75
|
__handleEntityDestroyed() {
|
|
76
|
-
this.clearFlag(
|
|
76
|
+
this.clearFlag(EntityFlags.Built);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
*
|
|
81
|
-
* @param {number|
|
|
81
|
+
* @param {number|EntityFlags} value
|
|
82
82
|
*/
|
|
83
83
|
setFlag(value) {
|
|
84
84
|
this.flags |= value;
|
|
@@ -86,7 +86,7 @@ class EntityBuilder {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
*
|
|
89
|
-
* @param {number|
|
|
89
|
+
* @param {number|EntityFlags} flag
|
|
90
90
|
* @returns {boolean}
|
|
91
91
|
*/
|
|
92
92
|
getFlag(flag) {
|
|
@@ -97,7 +97,7 @@ class EntityBuilder {
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
*
|
|
100
|
-
* @param {number|
|
|
100
|
+
* @param {number|EntityFlags} flag
|
|
101
101
|
*/
|
|
102
102
|
clearFlag(flag) {
|
|
103
103
|
this.flags &= ~flag;
|
|
@@ -108,7 +108,7 @@ class EntityBuilder {
|
|
|
108
108
|
* @returns {boolean}
|
|
109
109
|
*/
|
|
110
110
|
get isBuilt() {
|
|
111
|
-
return this.getFlag(
|
|
111
|
+
return this.getFlag(EntityFlags.Built);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -135,7 +135,7 @@ class EntityBuilder {
|
|
|
135
135
|
/**
|
|
136
136
|
* @template T
|
|
137
137
|
* @param {T} componentInstance
|
|
138
|
-
* @returns {
|
|
138
|
+
* @returns {Entity}
|
|
139
139
|
*/
|
|
140
140
|
add(componentInstance) {
|
|
141
141
|
if (componentInstance === undefined) {
|
|
@@ -146,7 +146,7 @@ class EntityBuilder {
|
|
|
146
146
|
|
|
147
147
|
this.element.push(componentInstance);
|
|
148
148
|
|
|
149
|
-
if (this.getFlag(
|
|
149
|
+
if (this.getFlag(EntityFlags.Built)) {
|
|
150
150
|
//already built, add component to entity
|
|
151
151
|
this.dataset.addComponentToEntity(this.entity, componentInstance);
|
|
152
152
|
}
|
|
@@ -213,7 +213,7 @@ class EntityBuilder {
|
|
|
213
213
|
elements.splice(i, 1);
|
|
214
214
|
|
|
215
215
|
//see if entity is built
|
|
216
|
-
if (this.getFlag(
|
|
216
|
+
if (this.getFlag(EntityFlags.Built)) {
|
|
217
217
|
|
|
218
218
|
this.dataset.removeComponentFromEntity(this.entity, klass);
|
|
219
219
|
|
|
@@ -232,7 +232,7 @@ class EntityBuilder {
|
|
|
232
232
|
* @param {*} [event]
|
|
233
233
|
*/
|
|
234
234
|
sendEvent(eventName, event) {
|
|
235
|
-
if (this.getFlag(
|
|
235
|
+
if (this.getFlag(EntityFlags.Built)) {
|
|
236
236
|
this.dataset.sendEvent(this.entity, eventName, event);
|
|
237
237
|
} else {
|
|
238
238
|
console.warn("Entity doesn't exist. Event " + eventName + ":" + event + " was not sent.")
|
|
@@ -265,10 +265,10 @@ class EntityBuilder {
|
|
|
265
265
|
* @param {string} eventName
|
|
266
266
|
* @param {function} listener
|
|
267
267
|
* @param {*} [context]
|
|
268
|
-
* @returns {
|
|
268
|
+
* @returns {Entity}
|
|
269
269
|
*/
|
|
270
270
|
addEventListener(eventName, listener, context) {
|
|
271
|
-
if (this.getFlag(
|
|
271
|
+
if (this.getFlag(EntityFlags.Built)) {
|
|
272
272
|
this.dataset.addEntityEventListener(this.entity, eventName, listener, context);
|
|
273
273
|
} else {
|
|
274
274
|
this.deferredListeners.push({
|
|
@@ -285,10 +285,10 @@ class EntityBuilder {
|
|
|
285
285
|
* @param {string} eventName
|
|
286
286
|
* @param {function} listener
|
|
287
287
|
* @param {*} [context]
|
|
288
|
-
* @returns {
|
|
288
|
+
* @returns {Entity}
|
|
289
289
|
*/
|
|
290
290
|
removeEventListener(eventName, listener, context) {
|
|
291
|
-
if (this.getFlag(
|
|
291
|
+
if (this.getFlag(EntityFlags.Built)) {
|
|
292
292
|
this.dataset.removeEntityEventListener(this.entity, eventName, listener, context);
|
|
293
293
|
} else {
|
|
294
294
|
const listeners = this.deferredListeners;
|
|
@@ -317,7 +317,7 @@ class EntityBuilder {
|
|
|
317
317
|
* @returns {boolean}
|
|
318
318
|
*/
|
|
319
319
|
destroy() {
|
|
320
|
-
if (this.getFlag(
|
|
320
|
+
if (this.getFlag(EntityFlags.Built)) {
|
|
321
321
|
|
|
322
322
|
const dataset = this.dataset;
|
|
323
323
|
const entity = this.entity;
|
|
@@ -331,7 +331,7 @@ class EntityBuilder {
|
|
|
331
331
|
|
|
332
332
|
this.entity = void 0;
|
|
333
333
|
|
|
334
|
-
this.clearFlag(
|
|
334
|
+
this.clearFlag(EntityFlags.Built);
|
|
335
335
|
|
|
336
336
|
return true;
|
|
337
337
|
} else {
|
|
@@ -349,7 +349,7 @@ class EntityBuilder {
|
|
|
349
349
|
assert.notNull(dataset, "dataset");
|
|
350
350
|
|
|
351
351
|
if (
|
|
352
|
-
this.getFlag(
|
|
352
|
+
this.getFlag(EntityFlags.Built)
|
|
353
353
|
&& checkExistingComponents(this.entity, this.element, dataset)
|
|
354
354
|
) {
|
|
355
355
|
//already built
|
|
@@ -374,7 +374,7 @@ class EntityBuilder {
|
|
|
374
374
|
const element = this.element;
|
|
375
375
|
const element_count = element.length;
|
|
376
376
|
|
|
377
|
-
if (this.getFlag(
|
|
377
|
+
if (this.getFlag(EntityFlags.RegisterComponents)) {
|
|
378
378
|
for (i = 0; i < element_count; i++) {
|
|
379
379
|
const component = element[i];
|
|
380
380
|
|
|
@@ -388,9 +388,9 @@ class EntityBuilder {
|
|
|
388
388
|
dataset.addComponentToEntity(entity, component);
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
this.setFlag(
|
|
391
|
+
this.setFlag(EntityFlags.Built);
|
|
392
392
|
|
|
393
|
-
if (this.getFlag(
|
|
393
|
+
if (this.getFlag(EntityFlags.WatchDestruction)) {
|
|
394
394
|
dataset.addEntityEventListener(entity, EventType.EntityRemoved, this.__handleEntityDestroyed, this);
|
|
395
395
|
}
|
|
396
396
|
|
|
@@ -402,16 +402,16 @@ class EntityBuilder {
|
|
|
402
402
|
*
|
|
403
403
|
* @param {number} entity
|
|
404
404
|
* @param {EntityComponentDataset} dataset
|
|
405
|
-
* @returns {
|
|
405
|
+
* @returns {Entity}
|
|
406
406
|
*/
|
|
407
407
|
static readFromDataset(entity, dataset) {
|
|
408
|
-
const r = new
|
|
408
|
+
const r = new Entity();
|
|
409
409
|
|
|
410
410
|
dataset.getAllComponents(entity)
|
|
411
411
|
.filter(isDefined)
|
|
412
412
|
.forEach(r.add, r);
|
|
413
413
|
|
|
414
|
-
r.setFlag(
|
|
414
|
+
r.setFlag(EntityFlags.Built);
|
|
415
415
|
r.entity = entity;
|
|
416
416
|
r.dataset = dataset;
|
|
417
417
|
|
|
@@ -423,7 +423,7 @@ class EntityBuilder {
|
|
|
423
423
|
* @readonly
|
|
424
424
|
* @type {boolean}
|
|
425
425
|
*/
|
|
426
|
-
|
|
426
|
+
Entity.prototype.isEntityBuilder = true;
|
|
427
427
|
|
|
428
428
|
|
|
429
429
|
/**
|
|
@@ -452,4 +452,4 @@ function checkExistingComponents(entity, components, dataset) {
|
|
|
452
452
|
return true;
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
-
export default
|
|
455
|
+
export default Entity;
|