@woosh/meep-engine 2.53.0 → 2.55.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.
Files changed (149) hide show
  1. package/package.json +1 -1
  2. package/src/core/__module.js +1 -1
  3. package/src/core/cache/Cache.js +1 -1
  4. package/src/core/collection/Stack.js +11 -14
  5. package/src/core/collection/array/array_contains_duplicates.js +5 -2
  6. package/src/core/collection/array/array_contains_duplicates.spec.js +14 -0
  7. package/src/core/collection/array/array_copy_entire.js +6 -11
  8. package/src/core/collection/array/array_get_index_in_range.js +5 -0
  9. package/src/core/collection/array/array_get_index_in_range.spec.js +16 -0
  10. package/src/core/collection/array/groupArrayBy.js +1 -1
  11. package/src/core/collection/array/isArrayEqual.js +4 -1
  12. package/src/core/collection/array/randomizeArrayElementOrder.js +1 -0
  13. package/src/core/collection/array/randomizeArrayElementOrder.spec.js +27 -0
  14. package/src/core/collection/heap/Uin32Heap.spec.js +64 -0
  15. package/src/core/collection/heap/Uint32Heap.js +6 -2
  16. package/src/core/collection/list/List.js +1 -0
  17. package/src/core/collection/{HashMap.js → map/HashMap.js} +10 -10
  18. package/src/core/collection/{HashMap.spec.js → map/HashMap.spec.js} +1 -1
  19. package/src/core/collection/{ObservedMap.js → map/ObservedMap.js} +1 -1
  20. package/src/core/collection/{HashSet.js → set/HashSet.js} +4 -3
  21. package/src/core/collection/{Set.d.ts → set/Set.d.ts} +1 -1
  22. package/src/core/collection/{Set.js → set/Set.js} +17 -14
  23. package/src/core/geom/2d/aabb/AABB2.js +1 -1
  24. package/src/core/geom/3d/aabb/AABB3.js +3 -1
  25. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_calc_edges.js +1 -1
  26. package/src/core/model/ObservedInteger.js +12 -7
  27. package/src/core/model/ObservedString.js +10 -8
  28. package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
  29. package/src/core/model/object/ImmutableObjectPool.js +1 -1
  30. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +1 -1
  31. package/src/engine/EngineConfiguration.js +24 -25
  32. package/src/engine/asset/AssetManager.js +3 -3
  33. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  34. package/src/engine/ecs/EntityBlueprint.js +10 -14
  35. package/src/engine/ecs/EntityComponentDataset.spec.js +77 -0
  36. package/src/engine/ecs/animation/AnimationSerializationAdapter.js +2 -5
  37. package/src/engine/ecs/components/Motion.js +0 -27
  38. package/src/engine/ecs/components/MotionSerializationAdapter.js +26 -0
  39. package/src/engine/ecs/components/PropertySet.js +0 -29
  40. package/src/engine/ecs/components/PropertySetSerializationAdapter.js +29 -0
  41. package/src/engine/ecs/components/SerializationMetadata.js +0 -28
  42. package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.js +26 -0
  43. package/src/engine/ecs/components/Steering.js +0 -35
  44. package/src/engine/ecs/components/SteeringSerializationAdapter.js +34 -0
  45. package/src/engine/ecs/components/Tag.js +6 -102
  46. package/src/engine/ecs/components/TagSerializationAdapter.js +44 -0
  47. package/src/engine/ecs/components/TagSerializationUpgrader_0_1.js +18 -0
  48. package/src/engine/ecs/components/Timer.js +1 -1
  49. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -1
  50. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleCooldownDescription.js +10 -14
  51. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +31 -39
  52. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.js +1 -1
  53. package/src/engine/ecs/dynamic_actions/{DynamicRuleDescriptionTable.spec.js → rules/DynamicRuleDescriptionTable.spec.js} +12 -12
  54. package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +2 -5
  55. package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.js +2 -5
  56. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +5 -8
  57. package/src/engine/ecs/gui/GUIElementSerializationAdapter.js +2 -5
  58. package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.js +3 -6
  59. package/src/engine/ecs/gui/position/ViewportPosition.js +2 -5
  60. package/src/engine/ecs/ik/IKConstraint.js +95 -0
  61. package/src/engine/ecs/ik/InverseKinematics.js +10 -169
  62. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js +72 -0
  63. package/src/engine/ecs/speaker/Voice.js +5 -8
  64. package/src/engine/ecs/speaker/VoiceSystem.js +15 -19
  65. package/src/engine/ecs/speaker/lines/LineDescription.js +20 -25
  66. package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +15 -19
  67. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +7 -0
  68. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
  69. package/src/engine/ecs/storage/binary/object/ObjectBasedClassSerializationAdapter.js +6 -9
  70. package/src/engine/ecs/team/TeamSerializationAdapter.js +2 -5
  71. package/src/engine/ecs/terrain/ecs/Terrain.spec.js +5 -0
  72. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +23 -21
  73. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +2 -5
  74. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -40
  75. package/src/engine/ecs/terrain/overlay/TerrainOverlay.spec.js +6 -0
  76. package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.js +7 -10
  77. package/src/engine/ecs/terrain/tiles/TerrainTile.js +79 -76
  78. package/src/engine/ecs/terrain/tiles/TerrainTile.spec.js +25 -0
  79. package/src/engine/ecs/tooltip/TooltipComponent.spec.js +47 -0
  80. package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.js +2 -5
  81. package/src/engine/ecs/transform/Transform.spec.js +52 -0
  82. package/src/engine/ecs/transform/TransformSerializationAdapter.js +2 -5
  83. package/src/engine/ecs/transform-attachment/TransformAttachment.js +18 -19
  84. package/src/engine/graphics/ecs/animation/AnimationController.js +20 -129
  85. package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.js +27 -0
  86. package/src/engine/graphics/ecs/animation/AnimationRule.js +79 -0
  87. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.js +9 -11
  88. package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.js +3 -5
  89. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +2 -5
  90. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.js +2 -6
  91. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.js +3 -15
  92. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +2 -4
  93. package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.js +2 -5
  94. package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +1 -1
  95. package/src/engine/graphics/ecs/light/LightSerializationAdapter.js +2 -5
  96. package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.js +2 -5
  97. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +3 -0
  98. package/src/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +1 -1
  99. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.js +2 -5
  100. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  101. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
  102. package/src/engine/graphics/material/manager/MaterialManager.js +1 -1
  103. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  104. package/src/engine/graphics/particles/node-based/codegen/CodeContext.js +1 -1
  105. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +2 -5
  106. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.js +2 -5
  107. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +1 -1
  108. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +1 -1
  109. package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.js +2 -5
  110. package/src/engine/grid/grid2transform/GridPosition2Transform.js +11 -13
  111. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +3 -5
  112. package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.js +2 -5
  113. package/src/engine/grid/position/GridPositionSerializationAdapter.js +2 -5
  114. package/src/engine/grid/transform2grid/Transform2GridPosition.js +10 -13
  115. package/src/engine/input/devices/KeyboardDevice.js +5 -2
  116. package/src/engine/input/devices/KeyboardDevice.spec.js +12 -0
  117. package/src/engine/input/devices/PointerDevice.js +5 -1
  118. package/src/engine/input/ecs/components/Input.js +37 -11
  119. package/src/engine/input/ecs/ism/InputBinding.js +30 -12
  120. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +7 -10
  121. package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +2 -5
  122. package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +2 -6
  123. package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.js +2 -5
  124. package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.js +2 -5
  125. package/src/engine/knowledge/database/StaticKnowledgeDatabase.js +12 -13
  126. package/src/engine/knowledge/database/StaticKnowledgeDatabase.spec.js +23 -0
  127. package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +2 -5
  128. package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +2 -5
  129. package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +25 -0
  130. package/src/engine/options/OptionAbstract.js +6 -5
  131. package/src/engine/options/OptionGroup.js +13 -25
  132. package/src/engine/options/OptionGroup.spec.js +61 -0
  133. package/src/engine/platform/EnginePlatform.js +0 -4
  134. package/src/engine/save/storage/InMemoryStorage.js +3 -2
  135. package/src/engine/sound/ecs/SoundController.js +2 -6
  136. package/src/engine/sound/ecs/SoundListener.js +3 -21
  137. package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.js +2 -6
  138. package/src/generation/theme/ThemeEngine.js +1 -1
  139. package/src/core/collection/LazyStream.js +0 -23
  140. package/src/core/collection/LazyStream.spec.js +0 -13
  141. package/src/core/collection/heap/BinaryHeap.js +0 -153
  142. package/src/engine/InputEngine.js +0 -94
  143. package/src/engine/PointerLock.js +0 -60
  144. package/src/engine/ecs/components/GeometryBVH.js +0 -44
  145. package/src/engine/ecs/systems/GeometryBVHSystem.js +0 -36
  146. package/src/engine/ecs/terrain/ecs/layers/loadLegacyTerrainLayers.js +0 -99
  147. package/src/engine/ecs/terrain/ecs/splat/loadLegacyTerrainSplats.js +0 -73
  148. /package/src/core/collection/{HashMap.d.ts → map/HashMap.d.ts} +0 -0
  149. /package/src/core/collection/{HashSet.d.ts → set/HashSet.d.ts} +0 -0
@@ -20,7 +20,7 @@ import { CrossOriginKind } from "../CORS/CrossOriginKind.js";
20
20
  import { computeObjectBoundingSphere } from "./gltf/computeObjectBoundingSphere.js";
21
21
  import { isMesh } from "./gltf/isMesh.js";
22
22
  import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
23
- import { HashSet } from "../../../core/collection/HashSet.js";
23
+ import { HashSet } from "../../../core/collection/set/HashSet.js";
24
24
  import { computeGeometryHash } from "../../graphics/geometry/buffered/computeGeometryHash.js";
25
25
  import { computeGeometryEquality } from "../../graphics/geometry/buffered/computeGeometryEquality.js";
26
26
  import { traverseThreeObject } from "../../graphics/ecs/highlight/renderer/traverseThreeObject.js";
@@ -3,7 +3,7 @@ import EntityBuilder from "./EntityBuilder.js";
3
3
  /**
4
4
  *
5
5
  * @param {Object} template
6
- * @param {Object} seed
6
+ * @param {Object} [seed]
7
7
  */
8
8
  function populateJsonTemplate(template, seed) {
9
9
  if (seed === undefined) {
@@ -41,9 +41,7 @@ function populateJsonTemplate(template, seed) {
41
41
  for (const propertyName in template) {
42
42
  const templateValue = template[propertyName];
43
43
 
44
- const seededValue = populateJsonTemplate(templateValue, seed);
45
-
46
- result[propertyName] = seededValue;
44
+ result[propertyName] = populateJsonTemplate(templateValue, seed);
47
45
  }
48
46
 
49
47
  return result;
@@ -61,13 +59,11 @@ function populateJsonTemplate(template, seed) {
61
59
  * @class
62
60
  */
63
61
  export class EntityBlueprint {
64
- constructor() {
65
- /**
66
- *
67
- * @type {Map<Class, Object>}
68
- */
69
- this.componentnts = new Map();
70
- }
62
+ /**
63
+ * @private
64
+ * @type {Map<Class, Object>}
65
+ */
66
+ #components = new Map();
71
67
 
72
68
  /**
73
69
  *
@@ -97,7 +93,7 @@ export class EntityBlueprint {
97
93
  }
98
94
 
99
95
  clear() {
100
- this.componentnts.clear();
96
+ this.#components.clear();
101
97
  }
102
98
 
103
99
  /**
@@ -106,7 +102,7 @@ export class EntityBlueprint {
106
102
  * @param {Object} json
107
103
  */
108
104
  addJSON(klass, json) {
109
- this.componentnts.set(klass, json);
105
+ this.#components.set(klass, json);
110
106
  }
111
107
 
112
108
  /**
@@ -150,7 +146,7 @@ export class EntityBlueprint {
150
146
  build(templateSeed) {
151
147
  const eb = new EntityBuilder();
152
148
 
153
- this.componentnts.forEach((template, ComponentClass) => {
149
+ this.#components.forEach((template, ComponentClass) => {
154
150
  const component = new ComponentClass();
155
151
 
156
152
  const json = populateJsonTemplate(template, templateSeed);
@@ -442,6 +442,30 @@ test('getComponent with 1 entity and 1 component', () => {
442
442
  expect(visitor_1).not.toHaveBeenCalled();
443
443
  });
444
444
 
445
+ test("getComponent on unregistered component class", () => {
446
+
447
+ const ecd = new EntityComponentDataset();
448
+
449
+ const entity = ecd.createEntity();
450
+
451
+ expect(ecd.getComponent(entity, DummyComponentA)).toBe(undefined);
452
+ });
453
+
454
+ test("getComponentSafe", () => {
455
+
456
+ const ecd = new EntityComponentDataset();
457
+ ecd.registerComponentType(DummyComponentA);
458
+
459
+ const entity = ecd.createEntity();
460
+
461
+ expect(() => ecd.getComponentSafe(entity, DummyComponentA)).toThrow();
462
+
463
+ const component = new DummyComponentA();
464
+
465
+ ecd.addComponentToEntity(entity, component);
466
+
467
+ expect(ecd.getComponentSafe(entity, DummyComponentA)).toBe(component);
468
+ });
445
469
 
446
470
  test('isComponentTypeRegistered', () => {
447
471
  const ecd = new EntityComponentDataset();
@@ -594,6 +618,59 @@ test('entityHasComponents', () => {
594
618
  expect(ecd.entityHasComponents(a)).toBe(true);
595
619
  });
596
620
 
621
+ test("getAnyComponent", () => {
622
+
623
+ const ecd = new EntityComponentDataset();
624
+
625
+ ecd.registerManyComponentTypes([
626
+ DummyComponentA,
627
+ DummyComponentB
628
+ ]);
629
+
630
+ const a = ecd.createEntity();
631
+
632
+ expect(ecd.getAnyComponent(DummyComponentA)).toEqual({
633
+ entity: -1,
634
+ component: null
635
+ });
636
+
637
+ const component_a = new DummyComponentA();
638
+ ecd.addComponentToEntity(a, component_a);
639
+ ecd.addComponentToEntity(a, new DummyComponentB());
640
+
641
+ expect(ecd.getAnyComponent(DummyComponentA)).toEqual({
642
+ entity: a,
643
+ component: component_a
644
+ });
645
+
646
+ });
647
+
648
+ test("hasComponent", () => {
649
+
650
+
651
+ const ecd = new EntityComponentDataset();
652
+
653
+ ecd.registerManyComponentTypes([
654
+ DummyComponentA,
655
+ DummyComponentB
656
+ ]);
657
+
658
+ const a = ecd.createEntity();
659
+
660
+ expect(ecd.hasComponent(a, DummyComponentA)).toBe(false);
661
+ expect(ecd.hasComponent(a, DummyComponentB)).toBe(false);
662
+
663
+ ecd.addComponentToEntity(a, new DummyComponentA());
664
+
665
+ expect(ecd.hasComponent(a, DummyComponentA)).toBe(true);
666
+ expect(ecd.hasComponent(a, DummyComponentB)).toBe(false);
667
+
668
+ ecd.addComponentToEntity(a, new DummyComponentB());
669
+
670
+ expect(ecd.hasComponent(a, DummyComponentA)).toBe(true);
671
+ expect(ecd.hasComponent(a, DummyComponentB)).toBe(true);
672
+ });
673
+
597
674
  describe('event management', () => {
598
675
 
599
676
  test("shouldn't be able to add event listener to non-existent entity", () => {
@@ -3,12 +3,9 @@ import { AnimationClip } from "./AnimationClip.js";
3
3
  import { Animation } from "./Animation.js";
4
4
 
5
5
  export class AnimationSerializationAdapter extends BinaryClassSerializationAdapter {
6
- constructor() {
7
- super();
8
6
 
9
- this.klass = Animation;
10
- this.version = 0;
11
- }
7
+ klass = Animation;
8
+ version = 0;
12
9
 
13
10
  /**
14
11
  *
@@ -4,7 +4,6 @@
4
4
  * Time: 20:41
5
5
  */
6
6
  import Vector3 from '../../../core/geom/Vector3.js';
7
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
8
7
 
9
8
 
10
9
  class Motion {
@@ -33,29 +32,3 @@ Motion.typeName = "Motion";
33
32
  export default Motion;
34
33
 
35
34
 
36
- export class MotionSerializationAdapter extends BinaryClassSerializationAdapter {
37
- constructor() {
38
- super();
39
-
40
- this.klass = Motion;
41
- this.version = 0;
42
- }
43
-
44
- /**
45
- *
46
- * @param {BinaryBuffer} buffer
47
- * @param {Motion} value
48
- */
49
- serialize(buffer, value) {
50
- value.velocity.toBinaryBufferFloat32(buffer);
51
- }
52
-
53
- /**
54
- *
55
- * @param {BinaryBuffer} buffer
56
- * @param {Motion} value
57
- */
58
- deserialize(buffer, value) {
59
- value.velocity.fromBinaryBufferFloat32(buffer);
60
- }
61
- }
@@ -0,0 +1,26 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import Motion from "./Motion.js";
3
+
4
+ export class MotionSerializationAdapter extends BinaryClassSerializationAdapter {
5
+
6
+ klass = Motion;
7
+ version = 0;
8
+
9
+ /**
10
+ *
11
+ * @param {BinaryBuffer} buffer
12
+ * @param {Motion} value
13
+ */
14
+ serialize(buffer, value) {
15
+ value.velocity.toBinaryBufferFloat32(buffer);
16
+ }
17
+
18
+ /**
19
+ *
20
+ * @param {BinaryBuffer} buffer
21
+ * @param {Motion} value
22
+ */
23
+ deserialize(buffer, value) {
24
+ value.velocity.fromBinaryBufferFloat32(buffer);
25
+ }
26
+ }
@@ -4,7 +4,6 @@
4
4
 
5
5
 
6
6
  import { resolvePath } from "../../../core/json/resolvePath.js";
7
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
8
7
 
9
8
  function PropertySet(options) {
10
9
  this.data = {};
@@ -110,31 +109,3 @@ PropertySet.prototype.fromBinaryBuffer = function (buffer) {
110
109
 
111
110
  export default PropertySet;
112
111
 
113
- export class PropertySetSerializationAdapter extends BinaryClassSerializationAdapter {
114
- constructor() {
115
- super();
116
-
117
- this.klass = PropertySet;
118
- this.version = 0;
119
- }
120
-
121
- /**
122
- *
123
- * @param {BinaryBuffer} buffer
124
- * @param {PropertySet} value
125
- */
126
- serialize(buffer, value) {
127
- buffer.writeUTF8String(JSON.stringify(value.data));
128
- }
129
-
130
- /**
131
- *
132
- * @param {BinaryBuffer} buffer
133
- * @param {PropertySet} value
134
- */
135
- deserialize(buffer, value) {
136
- const string = buffer.readUTF8String();
137
-
138
- value.data = JSON.parse(string);
139
- }
140
- }
@@ -0,0 +1,29 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import PropertySet from "./PropertySet.js";
3
+
4
+ export class PropertySetSerializationAdapter extends BinaryClassSerializationAdapter {
5
+
6
+
7
+ klass = PropertySet;
8
+ version = 0;
9
+
10
+ /**
11
+ *
12
+ * @param {BinaryBuffer} buffer
13
+ * @param {PropertySet} value
14
+ */
15
+ serialize(buffer, value) {
16
+ buffer.writeUTF8String(JSON.stringify(value.data));
17
+ }
18
+
19
+ /**
20
+ *
21
+ * @param {BinaryBuffer} buffer
22
+ * @param {PropertySet} value
23
+ */
24
+ deserialize(buffer, value) {
25
+ const string = buffer.readUTF8String();
26
+
27
+ value.data = JSON.parse(string);
28
+ }
29
+ }
@@ -1,5 +1,3 @@
1
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
-
3
1
  export const SerializationFlags = {
4
2
  Transient: 1
5
3
  };
@@ -69,29 +67,3 @@ SerializationMetadata.Transient = Object.freeze(transient);
69
67
  SerializationMetadata.typeName = "SerializationMetadata";
70
68
 
71
69
 
72
- export class SerializationMetadataSerializationAdapter extends BinaryClassSerializationAdapter {
73
- constructor() {
74
- super();
75
-
76
- this.klass = SerializationMetadata;
77
- this.version = 0;
78
- }
79
-
80
- /**
81
- *
82
- * @param {BinaryBuffer} buffer
83
- * @param {SerializationMetadata} value
84
- */
85
- serialize(buffer, value) {
86
- buffer.writeUint8(value.flags);
87
- }
88
-
89
- /**
90
- *
91
- * @param {BinaryBuffer} buffer
92
- * @param {SerializationMetadata} value
93
- */
94
- deserialize(buffer, value) {
95
- value.flags = buffer.readUint8();
96
- }
97
- }
@@ -0,0 +1,26 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import { SerializationMetadata } from "./SerializationMetadata.js";
3
+
4
+ export class SerializationMetadataSerializationAdapter extends BinaryClassSerializationAdapter {
5
+
6
+ klass = SerializationMetadata;
7
+ version = 0;
8
+
9
+ /**
10
+ *
11
+ * @param {BinaryBuffer} buffer
12
+ * @param {SerializationMetadata} value
13
+ */
14
+ serialize(buffer, value) {
15
+ buffer.writeUint8(value.flags);
16
+ }
17
+
18
+ /**
19
+ *
20
+ * @param {BinaryBuffer} buffer
21
+ * @param {SerializationMetadata} value
22
+ */
23
+ deserialize(buffer, value) {
24
+ value.flags = buffer.readUint8();
25
+ }
26
+ }
@@ -6,7 +6,6 @@
6
6
 
7
7
 
8
8
  import Vector3 from '../../../core/geom/Vector3.js';
9
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
10
9
 
11
10
  /**
12
11
  * @readonly
@@ -110,37 +109,3 @@ Steering.typeName = "Steering";
110
109
 
111
110
  export default Steering;
112
111
 
113
- export class SteeringSerializationAdapter extends BinaryClassSerializationAdapter {
114
- constructor() {
115
- super();
116
-
117
- this.klass = Steering;
118
- this.version = 0;
119
- }
120
-
121
- /**
122
- *
123
- * @param {BinaryBuffer} buffer
124
- * @param {Steering} value
125
- */
126
- serialize(buffer, value) {
127
- buffer.writeFloat32(value.maxSpeed);
128
- buffer.writeFloat32(value.rotationSpeed);
129
-
130
- value.destination.toBinaryBufferFloat32(buffer);
131
- value.targetMargin.toBinaryBufferFloat32_EqualityEncoded(buffer);
132
- }
133
-
134
- /**
135
- *
136
- * @param {BinaryBuffer} buffer
137
- * @param {Steering} value
138
- */
139
- deserialize(buffer, value) {
140
- value.maxSpeed = buffer.readFloat32();
141
- value.rotationSpeed = buffer.readFloat32();
142
-
143
- value.destination.fromBinaryBufferFloat32(buffer);
144
- value.targetMargin.fromBinaryBufferFloat32_EqualityEncoded(buffer);
145
- }
146
- }
@@ -0,0 +1,34 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import Steering from "./Steering.js";
3
+
4
+ export class SteeringSerializationAdapter extends BinaryClassSerializationAdapter {
5
+
6
+ klass = Steering;
7
+ version = 0;
8
+
9
+ /**
10
+ *
11
+ * @param {BinaryBuffer} buffer
12
+ * @param {Steering} value
13
+ */
14
+ serialize(buffer, value) {
15
+ buffer.writeFloat32(value.maxSpeed);
16
+ buffer.writeFloat32(value.rotationSpeed);
17
+
18
+ value.destination.toBinaryBufferFloat32(buffer);
19
+ value.targetMargin.toBinaryBufferFloat32_EqualityEncoded(buffer);
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @param {BinaryBuffer} buffer
25
+ * @param {Steering} value
26
+ */
27
+ deserialize(buffer, value) {
28
+ value.maxSpeed = buffer.readFloat32();
29
+ value.rotationSpeed = buffer.readFloat32();
30
+
31
+ value.destination.fromBinaryBufferFloat32(buffer);
32
+ value.targetMargin.fromBinaryBufferFloat32_EqualityEncoded(buffer);
33
+ }
34
+ }
@@ -3,32 +3,18 @@
3
3
  */
4
4
 
5
5
 
6
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
7
- import { BinaryClassUpgrader } from "../storage/binary/BinaryClassUpgrader.js";
8
6
  import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
9
7
  import { assert } from "../../../core/assert.js";
10
8
 
9
+ /**
10
+ * Stores textual tags, useful for marking entities
11
+ */
11
12
  export class Tag {
12
13
  /**
13
- *
14
- * @param {string} [name]
15
- * @constructor
14
+ * @private
15
+ * @type {String[]}
16
16
  */
17
- constructor(name) {
18
-
19
- /**
20
- * @private
21
- * @type {String[]}
22
- */
23
- this.values = [];
24
-
25
-
26
- if (name !== undefined) {
27
- this.add(name);
28
-
29
- console.warn('constructor arguments are deprecated');
30
- }
31
- }
17
+ values = [];
32
18
 
33
19
  /**
34
20
  *
@@ -49,27 +35,6 @@ export class Tag {
49
35
  return this.values[i];
50
36
  }
51
37
 
52
- /**
53
- *
54
- * @param {String} v
55
- */
56
- set name(v) {
57
- console.warn('name property is deprecated');
58
-
59
- this.clear();
60
- this.add(v);
61
- }
62
-
63
- /**
64
- *
65
- * @returns {String}
66
- */
67
- get name() {
68
- console.warn('name property is deprecated');
69
-
70
- return this.getFirst();
71
- }
72
-
73
38
  clear() {
74
39
  this.values.splice(0, this.values.length);
75
40
  }
@@ -327,65 +292,4 @@ Tag.typeName = "Tag";
327
292
 
328
293
  export default Tag;
329
294
 
330
- export class TagSerializationAdapter extends BinaryClassSerializationAdapter {
331
- constructor() {
332
- super();
333
-
334
- this.klass = Tag;
335
- this.version = 1;
336
- }
337
-
338
- /**
339
- *
340
- * @param {BinaryBuffer} buffer
341
- * @param {Tag} value
342
- */
343
- serialize(buffer, value) {
344
- const values = value.getValues();
345
-
346
- const n = values.length;
347
-
348
- buffer.writeUintVar(n);
349
-
350
- for (let i = 0; i < n; i++) {
351
- const v = values[i];
352
-
353
- buffer.writeUTF8String(v);
354
- }
355
- }
356
-
357
- /**
358
- *
359
- * @param {BinaryBuffer} buffer
360
- * @param {Tag} value
361
- */
362
- deserialize(buffer, value) {
363
- value.clear();
364
-
365
- const tagCount = buffer.readUintVar();
366
-
367
- for (let i = 0; i < tagCount; i++) {
368
- const v = buffer.readUTF8String();
369
-
370
- value.add(v);
371
- }
372
- }
373
- }
374
-
375
-
376
- export class TagSerializationUpgrader_0_1 extends BinaryClassUpgrader {
377
- constructor() {
378
- super();
379
-
380
- this.__startVersion = 0;
381
- this.__targetVersion = 1;
382
- }
383
295
 
384
- upgrade(source, target) {
385
- const tag = source.readUTF8String();
386
-
387
- //write tag count
388
- target.writeUintVar(1);
389
- target.writeUTF8String(tag);
390
- }
391
- }
@@ -0,0 +1,44 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import Tag from "./Tag.js";
3
+
4
+ export class TagSerializationAdapter extends BinaryClassSerializationAdapter {
5
+
6
+ klass = Tag;
7
+ version = 1;
8
+
9
+ /**
10
+ *
11
+ * @param {BinaryBuffer} buffer
12
+ * @param {Tag} value
13
+ */
14
+ serialize(buffer, value) {
15
+ const values = value.getValues();
16
+
17
+ const n = values.length;
18
+
19
+ buffer.writeUintVar(n);
20
+
21
+ for (let i = 0; i < n; i++) {
22
+ const v = values[i];
23
+
24
+ buffer.writeUTF8String(v);
25
+ }
26
+ }
27
+
28
+ /**
29
+ *
30
+ * @param {BinaryBuffer} buffer
31
+ * @param {Tag} value
32
+ */
33
+ deserialize(buffer, value) {
34
+ value.clear();
35
+
36
+ const tagCount = buffer.readUintVar();
37
+
38
+ for (let i = 0; i < tagCount; i++) {
39
+ const v = buffer.readUTF8String();
40
+
41
+ value.add(v);
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,18 @@
1
+ import { BinaryClassUpgrader } from "../storage/binary/BinaryClassUpgrader.js";
2
+
3
+ export class TagSerializationUpgrader_0_1 extends BinaryClassUpgrader {
4
+ constructor() {
5
+ super();
6
+
7
+ this.__startVersion = 0;
8
+ this.__targetVersion = 1;
9
+ }
10
+
11
+ upgrade(source, target) {
12
+ const tag = source.readUTF8String();
13
+
14
+ //write tag count
15
+ target.writeUintVar(1);
16
+ target.writeUTF8String(tag);
17
+ }
18
+ }
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
  /**
9
- * @deprecated entirely superseded by the {@link BehaviorSystem}, prefer using a timer behavior instead
9
+ * @deprecated entirely superseded by the {@link BehaviorSystem}, prefer using a {@link DelayBehavior} instead
10
10
  */
11
11
  class Timer {
12
12
  /**
@@ -12,7 +12,7 @@ import { DieBehavior } from "../../intelligence/behavior/ecs/DieBehavior.js";
12
12
  import { SerializationMetadata } from "../components/SerializationMetadata.js";
13
13
  import Tag from "../components/Tag.js";
14
14
  import { OverrideContextBehavior } from "../../../../../model/game/util/behavior/OverrideContextBehavior.js";
15
- import { HashMap } from "../../../core/collection/HashMap.js";
15
+ import { HashMap } from "../../../core/collection/map/HashMap.js";
16
16
  import { assert } from "../../../core/assert.js";
17
17
  import { RuleExecution } from "./RuleExecution.js";
18
18
  import { computeContextualDynamicRuleDebugString } from "./rules/computeContextualDynamicRuleDebugString.js";