@woosh/meep-engine 2.127.1 → 2.128.1

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 (84) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/packing/miniball/Miniball.d.ts +12 -10
  3. package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
  4. package/src/core/geom/packing/miniball/Miniball.js +76 -54
  5. package/src/engine/Clock.d.ts +2 -1
  6. package/src/engine/Clock.d.ts.map +1 -1
  7. package/src/engine/Clock.js +1 -0
  8. package/src/engine/ecs/Entity.d.ts.map +1 -1
  9. package/src/engine/ecs/Entity.js +14 -5
  10. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  11. package/src/engine/ecs/EntityComponentDataset.js +48 -2
  12. package/src/engine/ecs/EntityManager.d.ts +5 -6
  13. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  14. package/src/engine/ecs/EntityManager.js +85 -39
  15. package/src/engine/ecs/EntityReference.d.ts.map +1 -1
  16. package/src/engine/ecs/EntityReference.js +2 -0
  17. package/src/engine/ecs/System.d.ts +2 -2
  18. package/src/engine/ecs/System.d.ts.map +1 -1
  19. package/src/engine/ecs/System.js +44 -47
  20. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.d.ts +1 -1
  21. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.d.ts.map +1 -1
  22. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -4
  23. package/src/engine/ecs/fow/FogOfWarSystem.d.ts +2 -4
  24. package/src/engine/ecs/fow/FogOfWarSystem.d.ts.map +1 -1
  25. package/src/engine/ecs/fow/FogOfWarSystem.js +15 -21
  26. package/src/engine/ecs/gui/GUIElementSystem.d.ts.map +1 -1
  27. package/src/engine/ecs/gui/GUIElementSystem.js +7 -18
  28. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.d.ts.map +1 -1
  29. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +3 -10
  30. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts +2 -2
  31. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts.map +1 -1
  32. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +2 -6
  33. package/src/engine/ecs/renderable/RenderSystem.d.ts.map +1 -1
  34. package/src/engine/ecs/renderable/RenderSystem.js +3 -7
  35. package/src/engine/ecs/speaker/VoiceSystem.d.ts +1 -1
  36. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  37. package/src/engine/ecs/speaker/VoiceSystem.js +2 -4
  38. package/src/engine/ecs/{validateSystem.d.ts → system_validate_class.d.ts} +2 -2
  39. package/src/engine/ecs/system_validate_class.d.ts.map +1 -0
  40. package/src/engine/ecs/{validateSystem.js → system_validate_class.js} +12 -3
  41. package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
  42. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -5
  43. package/src/engine/ecs/tooltip/TooltipComponentSystem.d.ts +2 -2
  44. package/src/engine/ecs/tooltip/TooltipComponentSystem.d.ts.map +1 -1
  45. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +10 -12
  46. package/src/engine/graphics/ecs/camera/CameraSystem.d.ts.map +1 -1
  47. package/src/engine/graphics/ecs/camera/CameraSystem.js +5 -8
  48. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts.map +1 -1
  49. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -6
  50. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts.map +1 -1
  51. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.js +14 -27
  52. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  53. package/src/engine/graphics/ecs/light/LightSystem.js +2 -6
  54. package/src/engine/graphics/ecs/mesh/MeshSystem.d.ts.map +1 -1
  55. package/src/engine/graphics/ecs/mesh/MeshSystem.js +2 -6
  56. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
  57. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -5
  58. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.d.ts.map +1 -1
  59. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +1 -2
  60. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  61. package/src/engine/graphics/ecs/path/PathDisplaySystem.js +13 -17
  62. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts.map +1 -1
  63. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +2 -6
  64. package/src/engine/graphics/ecs/water/WaterSystem.d.ts +2 -2
  65. package/src/engine/graphics/ecs/water/WaterSystem.d.ts.map +1 -1
  66. package/src/engine/graphics/ecs/water/WaterSystem.js +5 -11
  67. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts.map +1 -1
  68. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +2 -6
  69. package/src/engine/graphics/render/frame_graph/RenderGraph.d.ts +2 -1
  70. package/src/engine/graphics/render/frame_graph/RenderGraph.d.ts.map +1 -1
  71. package/src/engine/graphics/render/frame_graph/RenderGraph.js +2 -1
  72. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.d.ts +1 -0
  73. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.d.ts.map +1 -1
  74. package/src/engine/graphics/render/frame_graph/resource/ResourceDescriptor.js +3 -0
  75. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
  76. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -2
  77. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts +2 -2
  78. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts.map +1 -1
  79. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.js +3 -5
  80. package/src/engine/scene/SceneManager.js +3 -3
  81. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts +2 -2
  82. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
  83. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +2 -6
  84. package/src/engine/ecs/validateSystem.d.ts.map +0 -1
@@ -10,7 +10,7 @@ import { EntityComponentDataset } from "./EntityComponentDataset.js";
10
10
  import { EntityObserver } from "./EntityObserver.js";
11
11
  import { System, SystemState } from "./System.js";
12
12
  import { computeSystemComponentDependencyGraph } from "./system/computeSystemComponentDependencyGraph.js";
13
- import { validateSystem } from "./validateSystem.js";
13
+ import { system_validate_class } from "./system_validate_class.js";
14
14
 
15
15
  /**
16
16
  * @readonly
@@ -25,6 +25,12 @@ export const EntityManagerState = {
25
25
  Stopped: 5
26
26
  };
27
27
 
28
+ /**
29
+ * In seconds
30
+ * @type {number}
31
+ */
32
+ const DEFAULT_SYSTEM_STARTUP_TIMEOUT_CHECK = 5;
33
+
28
34
  /**
29
35
  * Brings together {@link System}s and an {@link EntityComponentDataset}
30
36
  * Main entry point into the simulation process
@@ -261,7 +267,7 @@ export class EntityManager {
261
267
 
262
268
  const localComponentTypeMap = this.getComponentTypeMap();
263
269
 
264
- //ensure compatibility with system-used component map
270
+ // ensure compatibility with system-used component map
265
271
  dataset.registerManyComponentTypes(localComponentTypeMap);
266
272
 
267
273
  this.dataset = dataset;
@@ -450,7 +456,7 @@ export class EntityManager {
450
456
  /**
451
457
  * If the {@link EntityManager} is already started, the system will be started automatically before being added
452
458
  * @param {System} system
453
- * @returns {Promise}
459
+ * @returns {Promise} resolution depends on {@link EntityManager}'s state, if running - promise resolves after system startup. Otherwise, the promise will be resolved immediately.
454
460
  * @throws {IllegalStateException}
455
461
  */
456
462
  addSystem(system) {
@@ -470,19 +476,19 @@ export class EntityManager {
470
476
 
471
477
 
472
478
  try {
473
- validateSystem(system);
479
+ system_validate_class(system);
474
480
  } catch (e) {
475
- console.error(`System validation failed '${computeSystemName(system)}' : `, e, system);
481
+ console.error(`Validation of '${computeSystemName(system)}' failed : `, e, system);
476
482
  }
477
483
 
478
484
  //check system state
479
485
  const systemState = system.state.getValue();
480
486
 
481
- const legalStates = [SystemState.INITIAL, SystemState.STOPPED];
487
+ const valid_states = [SystemState.INITIAL, SystemState.STOPPED];
482
488
 
483
- if (legalStates.indexOf(systemState) === -1) {
489
+ if (valid_states.indexOf(systemState) === -1) {
484
490
  //illegal state
485
- throw new IllegalStateException(`System must be in one of these states: [${legalStates.join(",")}], instead was ${systemState}`);
491
+ throw new IllegalStateException(`System must be in one of these states: [${valid_states.join(",")}], instead was ${systemState}`);
486
492
  }
487
493
 
488
494
  const systems = this.systems;
@@ -495,22 +501,16 @@ export class EntityManager {
495
501
  const entityObserver = new EntityObserver(system.dependencies, system.link, system.unlink, system);
496
502
  this.systemObservers.set(system, entityObserver);
497
503
 
498
- let startup_promise;
504
+ let result_promise;
499
505
  if (this.state === EntityManagerState.Running) {
500
506
  //initialize the system
501
- startup_promise = new Promise((resolve, reject) => {
507
+ result_promise = new Promise((resolve, reject) => {
502
508
  this.startSystem(system, resolve, reject);
503
509
  });
504
510
  } else {
505
- startup_promise = Promise.resolve();
511
+ result_promise = Promise.resolve();
506
512
  }
507
513
 
508
- // Link EntityManager
509
- if (system.entityManager === null) {
510
- system.entityManager = this;
511
- } else if (system.entityManager !== this) {
512
- throw new Error(`System is bound to another EntityManager`);
513
- }
514
514
 
515
515
  // link dependency components
516
516
  this.dataset?.registerManyComponentTypes(system.referenced_components);
@@ -519,8 +519,7 @@ export class EntityManager {
519
519
 
520
520
  this.on.systemAdded.send1(system);
521
521
 
522
-
523
- return startup_promise;
522
+ return result_promise;
524
523
  }
525
524
 
526
525
  /**
@@ -601,7 +600,13 @@ export class EntityManager {
601
600
  }
602
601
 
603
602
  try {
604
- system.shutdown(self, systemReady, systemFailed);
603
+ const promise = system.shutdown(self);
604
+
605
+ assert.defined(promise, "promise");
606
+ assert.notNull(promise, "promise");
607
+ assert.isFunction(promise.then, "promise.then");
608
+
609
+ promise.then(systemReady, systemFailed);
605
610
  } catch (e) {
606
611
  console.error(`Failed to execute system shutdown`, e);
607
612
  errorCallback(e);
@@ -662,25 +667,53 @@ export class EntityManager {
662
667
  successCallback(system);
663
668
  }
664
669
 
665
- function systemFailed(reason) {
666
- errorCallback(reason);
667
- }
668
-
669
670
  try {
670
- system.startup(self, systemReady, systemFailed);
671
+
672
+ const deprecation_check = () => {
673
+ throw new Error("'success' callback was deprecated in meep 2.128.0, please use `async` instead.");
674
+ };
675
+
676
+ // Link EntityManager
677
+ if (system.entityManager === null || system.entityManager === undefined) {
678
+ system.entityManager = this;
679
+ } else if (system.entityManager !== this) {
680
+ throw new Error(`System is bound to another EntityManager`);
681
+ }
682
+
683
+ const promise = system.startup(self, deprecation_check);
684
+
685
+
686
+ assert.defined(promise, "promise");
687
+ assert.notNull(promise, "promise");
688
+ assert.isFunction(promise.then, "promise.then");
689
+
690
+ const startup_check_timeout = setTimeout(
691
+ () => {
692
+ console.warn(`System '${computeSystemName(system)}' failed to complete startup process in ${DEFAULT_SYSTEM_STARTUP_TIMEOUT_CHECK}s, check your code for potential deadlocks.`);
693
+ },
694
+ DEFAULT_SYSTEM_STARTUP_TIMEOUT_CHECK * 1000,
695
+ );
696
+
697
+ promise.finally(() => {
698
+ clearTimeout(startup_check_timeout);
699
+ });
700
+
701
+ promise.then(systemReady, errorCallback);
702
+
671
703
  } catch (e) {
672
704
  console.error(`Failed to execute system startup`, e);
673
- systemFailed(e);
705
+ errorCallback(e);
674
706
  }
675
707
  }
676
708
 
677
709
  /**
678
- * This method is asynchronous by nature, it has to wait for each individual system to finish its own statup.
679
- * Make sure to register callback in order to be notified when the startup has finished
710
+ * This method is asynchronous by nature, it has to wait for each system to finish its own startup.
711
+ * Make sure to register callback to be notified when the startup has finished
680
712
  * @param {function} [readyCallback] executed once entity manager successfully completes startup
681
713
  * @param {function} [errorCallback] executed if entity manager encounters an error during startup
682
714
  */
683
715
  startup(readyCallback = noop, errorCallback = console.error) {
716
+
684
717
  if (this.state === EntityManagerState.Starting) {
685
718
  throw new IllegalStateException(`System is currently in starting state`);
686
719
  }
@@ -743,15 +776,15 @@ export class EntityManager {
743
776
  return;
744
777
  }
745
778
 
746
- systems.forEach(function (system) {
779
+ for (const system of systems) {
747
780
  //ensure eventManager are there
748
781
  //start the system
749
782
  const cbOK = systemReady.bind(null, system);
750
783
  const cbError = systemError.bind(null, system);
751
784
 
752
- self.startSystem(system, cbOK, cbError);
785
+ this.startSystem(system, cbOK, cbError);
753
786
 
754
- });
787
+ }
755
788
  }
756
789
 
757
790
  /**
@@ -786,7 +819,6 @@ export class EntityManager {
786
819
  }
787
820
 
788
821
  /**
789
- *
790
822
  * @param {Class} systemClass
791
823
  * @param {SystemState} state
792
824
  * @returns {Promise.<System>}
@@ -814,21 +846,24 @@ export class EntityManager {
814
846
  }
815
847
 
816
848
  /**
817
- * This method is asynchronous by nature, it will not be done until each individual system has finished its shutdown
849
+ * This method is asynchronous by nature, it will not be done until each system has finished its shutdown
818
850
  * Make sure to use callback to be notified when the shutdown has completed
819
851
  * @param {function} [readyCallback] Called when shutdown finishes successfully. defaults to no-operation
820
- * @param {function} [errorCallback] Called when an error occurs during shutdown process. defaults to console error output
852
+ * @param {function} [errorCallback] Called when an error occurs during the shutdown process. defaults to console error output
821
853
  */
822
854
  shutdown(readyCallback = noop, errorCallback = console.error) {
823
855
  if (this.state !== EntityManagerState.Running) {
824
856
  throw new IllegalStateException(`System is wrong state, expected '${EntityManagerState.Running}'`);
825
857
  }
826
858
 
859
+ assert.isFunction(readyCallback, 'readyCallback');
860
+ assert.isFunction(errorCallback, 'errorCallback');
861
+
827
862
  this.state = EntityManagerState.Stopping;
828
863
 
829
864
  if (this.dataset !== null) {
830
865
  // a dataset is still attached, to properly dispose of all the component-bound resources, we first detach the dataset
831
- this.detachDataSet();
866
+ this.detachDataset();
832
867
  }
833
868
 
834
869
  const self = this;
@@ -877,18 +912,29 @@ export class EntityManager {
877
912
  finalizeShutdown();
878
913
  }
879
914
 
880
- systems.forEach(function (system) {
915
+ for (const system of systems) {
916
+
881
917
  system.state.set(SystemState.STOPPING);
882
- //start the system
918
+
883
919
  const cbOK = systemReady.bind(null, system);
884
920
  const cbError = systemError.bind(null, system);
921
+
885
922
  try {
886
- system.shutdown(self, cbOK, cbError);
923
+ const promise = system.shutdown(this);
924
+
925
+ assert.defined(promise, 'promise');
926
+ assert.notNull(promise, 'promise');
927
+ assert.isFunction(promise.then, 'promise.then');
928
+
929
+ // TODO add timeout
930
+
931
+ promise.then(cbOK, cbError);
887
932
  } catch (e) {
888
933
  //failure in shutdown function
889
934
  cbError(e);
890
935
  }
891
- });
936
+
937
+ }
892
938
  }
893
939
  }
894
940
 
@@ -1 +1 @@
1
- {"version":3,"file":"EntityReference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityReference.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAsHI;;;;;OAKG;IACH,gBAJW,MAAM,cACN,MAAM,GACL,eAAe,CAQ1B;IAED;;;;;OAKG;IACH,6CAHW,MAAM,GACJ,eAAe,CAQ3B;IA9ID;;;;OAIG;IACH,IAFU,MAAM,CAET;IAEP;;;;;OAKG;IACH,YAFU,MAAM,CAED;IAEf;;;OAGG;IACH,YAFW,eAAe,QAKzB;IAED;;;OAGG;IACH,SAFa,eAAe,CAQ3B;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,eAAe,GACd,OAAO,CAMlB;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAYnB;IAED;;;;;OAKG;IACH,sCAFa,OAAO,CASnB;IAED;;;;OAIG;IACH,0CAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,SAHW,MAAM,cACN,MAAM,QAUhB;IA+BL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;;cAWS,eAAe"}
1
+ {"version":3,"file":"EntityReference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityReference.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAwHI;;;;;OAKG;IACH,gBAJW,MAAM,cACN,MAAM,GACL,eAAe,CAQ1B;IAED;;;;;OAKG;IACH,6CAHW,MAAM,GACJ,eAAe,CAQ3B;IAhJD;;;;OAIG;IACH,IAFU,MAAM,CAET;IAEP;;;;;OAKG;IACH,YAFU,MAAM,CAED;IAEf;;;OAGG;IACH,YAFW,eAAe,QAOzB;IAED;;;OAGG;IACH,SAFa,eAAe,CAQ3B;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,eAAe,GACd,OAAO,CAMlB;IAED;;;;OAIG;IACH,qCAFa,OAAO,CAYnB;IAED;;;;;OAKG;IACH,sCAFa,OAAO,CASnB;IAED;;;;OAIG;IACH,0CAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,SAHW,MAAM,cACN,MAAM,QAUhB;IA+BL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;;cAWS,eAAe"}
@@ -42,6 +42,8 @@ export class EntityReference {
42
42
  * @param {EntityReference} other
43
43
  */
44
44
  copy(other) {
45
+ assert.defined(other, 'other');
46
+
45
47
  this.id = other.id;
46
48
  this.generation = other.generation;
47
49
  }
@@ -11,9 +11,9 @@ export class System<A, B = any, C = any, D = any, E = any> {
11
11
 
12
12
  protected readonly entityManager: EntityManager
13
13
 
14
- startup(em: EntityManager, ready_callback: () => void, error_callback: () => void): void
14
+ startup(em: EntityManager): Promise<void>
15
15
 
16
- shutdown(em: EntityManager, ready_callback: () => void, error_callback: () => void): void
16
+ shutdown(em: EntityManager): Promise<void>
17
17
 
18
18
  link(a: A, entity: number): void
19
19
  link(a: A, b: B, entity: number): void
@@ -1 +1 @@
1
- {"version":3,"file":"System.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/System.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAEI;;;;;OAKG;IACH,uCAAqB;IAErB;;;;OAIG;IACH,oBAA+C;IAE/C;;;;;OAKG;IACH,oBAAkB;IAElB;;;;;;;;;OASG;IACH,iBAFU,6BAA6B,CAElB;IAGrB;;OAEG;IACH,mCAcC;IAED;;;;OAIG;IACH,oCAFY,MAAM,CA8BjB;IAED;;;;;;OAMG;IACH,8FAGC;IAED;;;;;;;OAOG;IACH,+FAEC;IAGD;;;;OAIG;IACH,wCAEC;IAED;;;;OAIG;IACH,0CAEC;IAED;;;;;;;;OAQG;IACH,6DAEC;IAED;;;;;;;;OAQG;IACH,6DAEC;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;IAEzB;;;;OAIG;IACH,yBAA4B;IAG5B;;;;;;OAMG;IACH,oBAAuB;CAvBtB;;;;0BA8CS,MAAM;;;;;;;;qBAjPK,6BAA6B"}
1
+ {"version":3,"file":"System.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/System.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAEI;;;;;OAKG;IACH,uCAAqB;IAErB;;;;OAIG;IACH,oBAA+C;IAE/C;;;;;;;OAOG;IACH,6BAAkB;IAElB;;;;;;;;;;OAUG;IACH,0BAFU,6BAA6B,CAElB;IAGrB;;OAEG;IACH,mCAcC;IAED;;;;;OAKG;IACH,oCAFY,MAAM,CA8BjB;IAED;;;;;;OAMG;IACH,uCAHa,QAAQ,IAAI,CAAC,CAKzB;IAED;;;;;;;OAOG;IACH,wCAHa,QAAQ,IAAI,CAAC,CAKzB;IAGD;;;;OAIG;IACH,wCAEC;IAED;;;;OAIG;IACH,0CAEC;IAED;;;;;;;;;;OAUG;IACH,6DAEC;IAED;;;;;;;;;;OAUG;IACH,6DAEC;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;IAEzB;;;;OAIG;IACH,yBAA4B;IAG5B;;;;;;OAMG;IACH,oBAAuB;CAvBtB;0BA2BS,MAAM;;;;;;;;qBArOK,6BAA6B"}
@@ -54,7 +54,9 @@ export class System {
54
54
  /**
55
55
  * Component classes which have to be present before the system links an entity.
56
56
  * NOTE: do not modify this while the system is running.
57
- * see {@link link} and {@link unlink} methods.
57
+ * @see link
58
+ * @see unlink
59
+ * @readonly
58
60
  * @type {Array}
59
61
  */
60
62
  dependencies = [];
@@ -67,6 +69,7 @@ export class System {
67
69
  *
68
70
  * NOTE: specifying this is optional. The engine will still work.
69
71
  * NOTE: do not modify this while the system is running
72
+ * @readonly
70
73
  * @type {ResourceAccessSpecification[]}
71
74
  */
72
75
  components_used = [];
@@ -92,9 +95,10 @@ export class System {
92
95
  }
93
96
 
94
97
  /**
98
+ * Does not check if the component is present, will return 0 if not present.
95
99
  * @template T
96
100
  * @param {T} Klass
97
- * @return {number}
101
+ * @return {number} bitmask of {@link ResourceAccessKind}
98
102
  */
99
103
  getAccessForComponent(Klass) {
100
104
  let result = 0;
@@ -127,27 +131,26 @@ export class System {
127
131
  }
128
132
 
129
133
  /**
130
- * Invoked before system is used
131
- * Managed by {@EntityManager}'s lifecycle. Do not call this manually.
134
+ * Invoked before {@link System} is used for the first time.
135
+ * Managed by {@link EntityManager}'s lifecycle. Do not call this manually.
132
136
  * @param {EntityManager} entityManager
133
- * @param {function} readyCallback must be called by the system when the startup process is finished
134
- * @param {function} errorCallback must be called by the system if any issues occur during startup process that prevent completion
137
+ * @returns {Promise<void>}
138
+ * @see shutdown
135
139
  */
136
- startup(entityManager, readyCallback, errorCallback) {
137
- this.entityManager = entityManager;
138
- readyCallback();
140
+ async startup(entityManager) {
141
+ // override as necessary
139
142
  }
140
143
 
141
144
  /**
142
- * Invoked when system is no longer needed.
145
+ * Invoked when {@link System} is no longer needed.
143
146
  * Good place to clean up any held resourced and terminate owned processes.
144
- * Managed by {@EntityManager}'s lifecycle. Do not call this manually.
147
+ * Managed by {@link EntityManager}'s lifecycle. Do not call this manually.
145
148
  * @param {EntityManager} entityManager
146
- * @param {function} readyCallback
147
- * @param {function} errorCallback
149
+ * @returns {Promise<void>}
150
+ * @see startup
148
151
  */
149
- shutdown(entityManager, readyCallback, errorCallback) {
150
- readyCallback();
152
+ async shutdown(entityManager) {
153
+ // override as necessary
151
154
  }
152
155
 
153
156
 
@@ -171,10 +174,12 @@ export class System {
171
174
 
172
175
  /**
173
176
  * Invoked when a dataset is attached to the system, this happens before any entities are linked.
174
- * Happens as a result of {@link EntityManager.attachDataSet}.
177
+ * Happens as a result of {@link EntityManager.attachDataset}.
175
178
  * It is generally advised *NOT* to modify the dataset here.
176
- * Managed by {@EntityManager}'s lifecycle. Do not call this manually.
177
- * Entirely optional, provides advanced functionality for situations where datasets are being switched on the fly.
179
+ * Managed by {@link EntityManager}'s lifecycle. Do not call this manually.
180
+ *
181
+ * This method is entirely optional, it provides advanced functionality for situations where datasets are being switched on the fly.
182
+ *
178
183
  * see {@link handleDatasetDetached} for the reverse.
179
184
  * @param {EntityComponentDataset} dataset
180
185
  */
@@ -184,10 +189,12 @@ export class System {
184
189
 
185
190
  /**
186
191
  * Invoked when dataset is about to be detached from the system, this happens after all entities have been unlinked.
187
- * Happens as a result of {@link EntityManager.detachDataSet}.
192
+ * Happens as a result of {@link EntityManager.detachDataset}.
188
193
  * It is generally advised *NOT* to modify the dataset here.
189
- * Managed by {@EntityManager}'s lifecycle. Do not call this manually.
190
- * Entirely optional, provides advanced functionality for situations where datasets are being switched on the fly.
194
+ * Managed by {@link EntityManager}'s lifecycle. Do not call this manually.
195
+ *
196
+ * This method is entirely optional, it provides advanced functionality for situations where datasets are being switched on the fly.
197
+ *
191
198
  * see {@link handleDatasetAttached} for the reverse.
192
199
  * @param {EntityComponentDataset} dataset
193
200
  */
@@ -216,44 +223,34 @@ System.prototype.fixedUpdate = noop; // by assigning NO-OP we enable a simple ch
216
223
  * Note that this time step can vary depending on system conditions and hardware we are running on.
217
224
  * It is generally safe to assume that this update will happen once per frame, but it is not guaranteed.
218
225
  * Also, note that when the application window/tab is suspended, the next update step can have a very large value.
219
- * @param {number} timeDelta Time in seconds
226
+ * @param {number} timeDelta in seconds
220
227
  */
221
228
  System.prototype.update = noop; // by assigning NO-OP we enable a simple check, whether running the update would be useful
222
229
 
223
- Object.defineProperties(System.prototype, {
224
- /**
225
- * @deprecated
226
- */
227
- componentClass: {
228
- configurable: true,
229
- /**
230
- * @deprecated
231
- * @returns {Class<C>}
232
- */
233
- get() {
234
- console.warn(`componentClass property is deprecated and should not be used`);
235
- return null;
236
- }
237
-
238
- }
239
-
240
- });
241
-
242
230
  /**
243
231
  * @readonly
244
232
  * @enum {number}
245
233
  */
246
234
  export const SystemState = {
247
235
  INITIAL: 0,
236
+ /**
237
+ * System is currently in the process of starting up.
238
+ * @see System.startup
239
+ */
248
240
  STARTING: 1,
241
+ /**
242
+ * System is in the main running state, after startup has successfully finished.
243
+ */
249
244
  RUNNING: 2,
245
+ /**
246
+ * System is currently in the process of shutting down.
247
+ * @see System.shutdown
248
+ */
250
249
  STOPPING: 3,
250
+ /**
251
+ * System has finished shutting down.
252
+ * @see System.shutdown
253
+ */
251
254
  STOPPED: 4
252
255
  }
253
256
 
254
- /**
255
- * @readonly
256
- * @deprecated use {@link SystemState} directly instead
257
- */
258
- System.State = SystemState;
259
-
@@ -109,7 +109,7 @@ export class DynamicActorSystem extends AbstractContextSystem<any> {
109
109
  * @returns {DynamicRuleDescription|undefined}
110
110
  */
111
111
  match(entity: number, event: string, context: any): DynamicRuleDescription | undefined;
112
- startup(entityManager: any, readyCallback: any, errorCallback: any): Promise<void>;
112
+ startup(entityManager: any): Promise<void>;
113
113
  /**
114
114
  *
115
115
  * @param {DynamicActor} actor
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicActorSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/dynamic_actions/DynamicActorSystem.js"],"names":[],"mappings":"AA6FA;IA4DI;;;OAGG;IACH,4BASC;IAxED,sCAA8B;IAE9B,kEAEE;IAEF;;;OAGG;IACH,sCAAgB;IAEhB;;;OAGG;IACH,OAFU,SAAS,CAEK;IAExB;;;;OAIG;IACH,iCAOG;IAEH;;;;OAIG;IACH,gCAAoC;IAEpC;;;OAGG;IACH,mCAAiB;IAEjB;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,gBAAgB;IASZ;;;OAGG;IACH,eAAoB;IAIxB;;;OAGG;IACH,kBAFY,MAAM,CAIjB;IAED;;;;;OAKG;IACH,6BAJW,MAAM,uDAyBhB;IAED;;;OAGG;IACH,iCAFW,MAAM,QAehB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,oDA4DhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,SACN,SAAS,QAsDnB;IAED;;;;OAIG;IACH,yBAFY,yBAAuB,SAAS,CA6E3C;IAED;;;;;;;;;OASG;IACH,yFAHW,MAAM,GACJ;QAAC,MAAM,EAAC,MAAM,CAAC;QAAA,IAAI,yBAAwB;QAAC,KAAK,EAAE,SAAS,CAAA;KAAC,EAAE,CA4E3E;IAED;;;;;;OAMG;IACH,cALW,MAAM,SACN,MAAM,iBAEJ,yBAAuB,SAAS,CAiC5C;IAED,mFAWC;IAED;;;;;OAKG;IACH,mCAiBC;IAED,6BAYC;CACJ;sCAzkBqC,oCAAoC;6BAG7C,mBAAmB;2BATrB,6CAA6C;4CAP5B,oDAAoD;0BAetE,gBAAgB;2BAnBf,sCAAsC"}
1
+ {"version":3,"file":"DynamicActorSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/dynamic_actions/DynamicActorSystem.js"],"names":[],"mappings":"AA6FA;IA4DI;;;OAGG;IACH,4BASC;IAxED,sCAA8B;IAE9B,kEAEE;IAEF;;;OAGG;IACH,sCAAgB;IAEhB;;;OAGG;IACH,OAFU,SAAS,CAEK;IAExB;;;;OAIG;IACH,iCAOG;IAEH;;;;OAIG;IACH,gCAAoC;IAEpC;;;OAGG;IACH,mCAAiB;IAEjB;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,gBAAgB;IASZ;;;OAGG;IACH,eAAoB;IAIxB;;;OAGG;IACH,kBAFY,MAAM,CAIjB;IAED;;;;;OAKG;IACH,6BAJW,MAAM,uDAyBhB;IAED;;;OAGG;IACH,iCAFW,MAAM,QAehB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,oDA4DhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,SACN,SAAS,QAsDnB;IAED;;;;OAIG;IACH,yBAFY,yBAAuB,SAAS,CA6E3C;IAED;;;;;;;;;OASG;IACH,yFAHW,MAAM,GACJ;QAAC,MAAM,EAAC,MAAM,CAAC;QAAA,IAAI,yBAAwB;QAAC,KAAK,EAAE,SAAS,CAAA;KAAC,EAAE,CA4E3E;IAED;;;;;;OAMG;IACH,cALW,MAAM,SACN,MAAM,iBAEJ,yBAAuB,SAAS,CAiC5C;IAED,2CAQC;IAED;;;;;OAKG;IACH,mCAiBC;IAED,6BAYC;CACJ;sCAtkBqC,oCAAoC;6BAG7C,mBAAmB;2BATrB,6CAA6C;4CAP5B,oDAAoD;0BAetE,gBAAgB;2BAnBf,sCAAsC"}
@@ -553,17 +553,14 @@ export class DynamicActorSystem extends AbstractContextSystem {
553
553
  return description;
554
554
  }
555
555
 
556
- async startup(entityManager, readyCallback, errorCallback) {
556
+ async startup(entityManager) {
557
557
  const staticKnowledge = this.engine.staticKnowledge;
558
558
 
559
-
560
559
  await staticKnowledge.promise();
561
560
 
562
561
  this.database = staticKnowledge.getTable('dynamic-actions');
563
562
 
564
563
  this.evaluator = this.database.buildEvaluator();
565
-
566
- super.startup(entityManager, readyCallback, errorCallback);
567
564
  }
568
565
 
569
566
  /**
@@ -26,12 +26,10 @@ export class FogOfWarSystem extends System<any, any, any, any, any> {
26
26
  /**
27
27
  *
28
28
  * @param {EntityManager} entityManager
29
- * @param readyCallback
30
- * @param errorCallback
31
29
  */
32
- startup(entityManager: EntityManager, readyCallback: any, errorCallback: any): void;
30
+ startup(entityManager: EntityManager): Promise<void>;
33
31
  renderTarget: any;
34
- shutdown(entityManager: any, readyCallback: any, errorCallback: any): void;
32
+ shutdown(entityManager: any): Promise<void>;
35
33
  /**
36
34
  *
37
35
  * @param {FogOfWar} fow
@@ -1 +1 @@
1
- {"version":3,"file":"FogOfWarSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/fow/FogOfWarSystem.js"],"names":[],"mappings":"AAwBA;IACI;;;OAGG;IACH,sCA0BC;IAvBG;;;OAGG;IACH,yBAAwB;IAExB,mDAAuC;IAEvC,gEAEC;IAED,mCAAoD;IAIpD;;;OAGG;IACH,eAFU,aAAa,CAEE;IAEzB,uBAAuB;IAG3B;;;OAGG;IACH,yBAFa,gBAAgB,CAuE5B;IAED;;;;;OAKG;IACH,oFA+EC;IA/DG,kBAAgC;IAiEpC,2EAIC;IAED;;;;;OAKG;IACH,UAJW,QAAQ,WACR,OAAO,UACP,MAAM,QAmBhB;IAED,kDAQC;IAED,6BAUC;CACJ;uBA/QsB,cAAc;oBAEjB,2BAA2B;yBADtB,eAAe;4CAiBI,oDAAoD;iCAd/D,sDAAsD;8BAQzD,0CAA0C"}
1
+ {"version":3,"file":"FogOfWarSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/fow/FogOfWarSystem.js"],"names":[],"mappings":"AAwBA;IACI;;;OAGG;IACH,sCA0BC;IAvBG;;;OAGG;IACH,yBAAwB;IAExB,mDAAuC;IAEvC,gEAEC;IAED,mCAAoD;IAIpD;;;OAGG;IACH,eAFU,aAAa,CAEE;IAEzB,uBAAuB;IAG3B;;;OAGG;IACH,yBAFa,gBAAgB,CAuE5B;IAED;;;OAGG;IACH,qDA6EC;IA7DG,kBAAgC;IA+DpC,4CAEC;IAED;;;;;OAKG;IACH,UAJW,QAAQ,WACR,OAAO,UACP,MAAM,QAmBhB;IAED,kDAQC;IAED,6BAUC;CACJ;uBAzPsB,cAAc;oBACjB,2BAA2B;yBACtB,eAAe;4CAdI,oDAAoD;iCAS/D,sDAAsD;8BAPzD,0CAA0C"}
@@ -1,23 +1,23 @@
1
- import { System } from "../System.js";
2
- import { FogOfWar } from "./FogOfWar.js";
3
- import Terrain from "../terrain/ecs/Terrain.js";
4
1
  import { Frustum } from "three";
5
- import { VisibilityFilter } from "../../graphics/render/visibility/VisibilityFilter.js";
6
- import Vector4 from "../../../core/geom/Vector4.js";
7
- import { Camera } from "../../graphics/ecs/camera/Camera.js";
8
- import WaterSystem from "../../graphics/ecs/water/WaterSystem.js";
9
2
  import Vector3 from "../../../core/geom/Vector3.js";
10
- import { BlendingType } from "../../graphics/texture/sampler/BlendingType.js";
11
- import { FogOfWarRenderer } from "./shader/FogOfWarRenderer.js";
12
- import { StandardFrameBuffers } from "../../graphics/StandardFrameBuffers.js";
13
- import { CompositLayer } from "../../graphics/composit/CompositLayer.js";
3
+ import Vector4 from "../../../core/geom/Vector4.js";
4
+ import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
5
+ import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
14
6
  import { CompositingStages } from "../../graphics/composit/CompositingStages.js";
7
+ import { CompositLayer } from "../../graphics/composit/CompositLayer.js";
8
+ import { Camera } from "../../graphics/ecs/camera/Camera.js";
15
9
  import {
16
10
  compute_perspective_camera_focal_position
17
11
  } from "../../graphics/ecs/camera/compute_perspective_camera_focal_position.js";
18
12
  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";
13
+ import WaterSystem from "../../graphics/ecs/water/WaterSystem.js";
14
+ import { VisibilityFilter } from "../../graphics/render/visibility/VisibilityFilter.js";
15
+ import { StandardFrameBuffers } from "../../graphics/StandardFrameBuffers.js";
16
+ import { BlendingType } from "../../graphics/texture/sampler/BlendingType.js";
17
+ import { System } from "../System.js";
18
+ import Terrain from "../terrain/ecs/Terrain.js";
19
+ import { FogOfWar } from "./FogOfWar.js";
20
+ import { FogOfWarRenderer } from "./shader/FogOfWarRenderer.js";
21
21
 
22
22
 
23
23
  const frustum = new Frustum();
@@ -133,10 +133,8 @@ export class FogOfWarSystem extends System {
133
133
  /**
134
134
  *
135
135
  * @param {EntityManager} entityManager
136
- * @param readyCallback
137
- * @param errorCallback
138
136
  */
139
- startup(entityManager, readyCallback, errorCallback) {
137
+ async startup(entityManager) {
140
138
  this.entityManager = entityManager;
141
139
 
142
140
  const graphics = this.graphics;
@@ -213,14 +211,10 @@ export class FogOfWarSystem extends System {
213
211
  }
214
212
  });
215
213
 
216
-
217
- readyCallback();
218
214
  }
219
215
 
220
- shutdown(entityManager, readyCallback, errorCallback) {
216
+ async shutdown(entityManager) {
221
217
  this.graphics.layerComposer.remove(this.compositLayer);
222
-
223
- super.shutdown(entityManager, readyCallback, errorCallback);
224
218
  }
225
219
 
226
220
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"GUIElementSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/gui/GUIElementSystem.js"],"names":[],"mappings":"AAgCA,gFAAiF;;AAEjF;IAyBI;;;;;OAKG;IACH,2BAJW,IAAI,kBAqCd;IA9DD,gBAaG;IAEH,oCAA4B;IAE5B;;;OAGG;IACH,YAAY;IA2BR,iCAAkC;IAGlC;;OAEG;IACH,8BAA0C;IAE1C;;;OAGG;IACH,eAAoB;IAIxB,mDAQC;IAED,kDAQC;IAED;;;;OAIG;IACH,2BAHW,UAAU,UACV,MAAM,QA6DhB;IAED;;;;OAIG;IACH,2BAHW,UAAU,UACV,MAAM,QAoBhB;IAED;;;;OAIG;IACH,gBAHW,UAAU,qBAiDpB;IAED;;;;OAIG;IACH,kBAHW,UAAU,qBAiBpB;CACJ;uBA1RsB,cAAc;sBAFf,qCAAqC;uBAGhB,iBAAiB;iBAF3C,uBAAuB"}
1
+ {"version":3,"file":"GUIElementSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/gui/GUIElementSystem.js"],"names":[],"mappings":"AAgCA,gFAAiF;;AAEjF;IAyBI;;;;;OAKG;IACH,2BAJW,IAAI,kBAqCd;IA9DD,gBAaG;IAEH,oCAA4B;IAE5B;;;OAGG;IACH,YAAY;IA2BR,iCAAkC;IAGlC;;OAEG;IACH,8BAA0C;IAE1C;;;OAGG;IACH,eAAoB;IAIxB,gCAGC;IAED,iCAEC;IAED;;;;OAIG;IACH,2BAHW,UAAU,UACV,MAAM,QA6DhB;IAED;;;;OAIG;IACH,2BAHW,UAAU,UACV,MAAM,QAoBhB;IAED;;;;OAIG;IACH,gBAHW,UAAU,qBAiDpB;IAED;;;;OAIG;IACH,kBAHW,UAAU,qBAiBpB;CACJ;uBA/QsB,cAAc;sBAFf,qCAAqC;uBAGhB,iBAAiB;iBAF3C,uBAAuB"}
@@ -65,11 +65,11 @@ class GUIElementSystem extends System {
65
65
  */
66
66
  constructor(containerView, engine) {
67
67
  if (containerView === undefined) {
68
- throw new Error(`mandatory parameter containerView is undefined`);
68
+ throw new Error(`mandatory parameter containerView is undefined`);
69
69
  }
70
70
 
71
71
  if (containerView === null) {
72
- throw new Error(`mandatory parameter containerView is null`);
72
+ throw new Error(`mandatory parameter containerView is null`);
73
73
  }
74
74
 
75
75
  if (!(containerView instanceof View)) {
@@ -98,24 +98,13 @@ class GUIElementSystem extends System {
98
98
 
99
99
  }
100
100
 
101
- shutdown(em, cmOk, cbFailure) {
102
- try {
103
- this.containerView.removeChild(this.view);
104
- cmOk();
105
- } catch (e) {
106
- cbFailure(e);
107
- }
108
-
101
+ async startup(em) {
102
+ this.entityManager = em;
103
+ this.containerView.addChild(this.view);
109
104
  }
110
105
 
111
- startup(em, cbOK, cbFailure) {
112
- this.entityManager = em;
113
- try {
114
- this.containerView.addChild(this.view);
115
- cbOK();
116
- } catch (e) {
117
- cbFailure(e);
118
- }
106
+ async shutdown(em) {
107
+ this.containerView.removeChild(this.view);
119
108
  }
120
109
 
121
110
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"HeadsUpDisplaySystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js"],"names":[],"mappings":";AAeA;;;;;GAKG;AACH;IASI;;;OAGG;IACH,4BAFW,cAAc,EAqBxB;IA/BD,wCAAgC;IAGhC,2HAGE;IAaE,yBAA8B;IAM9B;;;;OAIG;IACH,+BAAiD;IAGrD,mDAQC;IAED,kDAMC;IAED;;;;;;;OAOG;IACH,sCAwGC;IAED,6BAsBC;CACJ;uBA7MsB,iBAAiB;2BAIb,qBAAqB;uBAFzB,kBAAkB;4CALG,uDAAuD;6BAMtE,iCAAiC;+BAL/B,qCAAqC"}
1
+ {"version":3,"file":"HeadsUpDisplaySystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js"],"names":[],"mappings":";AAeA;;;;;GAKG;AACH;IASI;;;OAGG;IACH,4BAFW,cAAc,EAqBxB;IA/BD,wCAAgC;IAGhC,2HAGE;IAaE,yBAA8B;IAM9B;;;;OAIG;IACH,+BAAiD;IAGrD,iCAGC;IAED,gCAIC;IAED;;;;;;;OAOG;IACH,sCAwGC;IAED,6BAsBC;CACJ;uBAtMsB,iBAAiB;2BAIb,qBAAqB;uBAFzB,kBAAkB;4CALG,uDAAuD;6BAMtE,iCAAiC;+BAL/B,qCAAqC"}