@woosh/meep-engine 2.50.1 → 2.50.2

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 (51) hide show
  1. package/README.md +39 -0
  2. package/editor/Editor.js +5 -1
  3. package/editor/SelectionVisualizer.js +9 -3
  4. package/editor/tools/paint/TerrainTexturePaintTool.js +6 -1
  5. package/editor/view/EditorView.js +5 -1
  6. package/editor/view/ecs/EntityList.js +48 -37
  7. package/editor/view/makeEntityDecorators.js +125 -0
  8. package/package.json +7 -3
  9. package/samples/generation/README.md +6 -0
  10. package/{src/generation/example → samples/generation}/SampleGenerator0.js +60 -46
  11. package/{src/generation/example → samples/generation}/filters/SampleGroundMoistureFilter.js +14 -12
  12. package/samples/generation/filters/SampleNoise20_0.js +3 -0
  13. package/{src/generation/example → samples/generation}/generators/interactive/mir_generator_place_buff_objects.js +29 -23
  14. package/{src/generation/example → samples/generation}/generators/mir_generator_place_bases.js +33 -25
  15. package/{src/generation/example → samples/generation}/generators/mir_generator_place_road_decorators.js +16 -14
  16. package/samples/generation/generators/mir_generator_place_starting_point.js +60 -0
  17. package/{src/generation/example → samples/generation}/grid/configureMirGrid.js +2 -2
  18. package/{src/generation/example → samples/generation}/main.js +29 -28
  19. package/{src/generation/example → samples/generation}/rules/matcher_not_play_area.js +1 -1
  20. package/samples/generation/rules/matcher_play_area.js +5 -0
  21. package/{src/generation/example → samples/generation}/rules/matcher_tag_not_traversable.js +1 -1
  22. package/samples/generation/rules/matcher_tag_occupied.js +5 -0
  23. package/samples/generation/rules/matcher_tag_traversable.js +5 -0
  24. package/{src/generation/example → samples/generation}/rules/matcher_tag_traversable_unoccupied.js +1 -1
  25. package/{src/generation/example → samples/generation}/rules/matcher_tag_unoccupied.js +1 -1
  26. package/{src/generation/example → samples/generation}/rules/mir_matcher_attack_corridor.js +3 -3
  27. package/{src/generation/example → samples/generation}/themes/SampleTheme0.js +57 -47
  28. package/{src/generation/example → samples/generation}/themes/SampleTheme1.js +4 -4
  29. package/{src/generation/example → samples/generation}/themes/SampleTheme2.js +4 -4
  30. package/src/engine/ecs/{Blueprint.js → storage/json/Blueprint.js} +1 -1
  31. package/src/engine/ecs/{EntityFactory.js → storage/json/EntityFactory.js} +1 -1
  32. package/src/engine/ecs/storage/{JSONDeSerializer.js → json/JSONDeSerializer.js} +4 -4
  33. package/src/engine/ecs/storage/json/README.md +5 -0
  34. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +5 -0
  35. package/src/engine/intelligence/behavior/Behavior.d.ts +5 -0
  36. package/src/engine/intelligence/behavior/Behavior.js +19 -0
  37. package/src/engine/intelligence/behavior/SelectorBehavior.js +4 -2
  38. package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +2 -0
  39. package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +3 -1
  40. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +2 -3
  41. package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +2 -2
  42. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
  43. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
  44. package/src/view/common/VirtualListView.js +2 -0
  45. package/src/generation/example/filters/SampleNoise20_0.js +0 -3
  46. package/src/generation/example/generators/mir_generator_place_starting_point.js +0 -52
  47. package/src/generation/example/rules/matcher_play_area.js +0 -5
  48. package/src/generation/example/rules/matcher_tag_occupied.js +0 -5
  49. package/src/generation/example/rules/matcher_tag_traversable.js +0 -5
  50. /package/{src/generation/example → samples/generation}/grid/MirGridLayers.js +0 -0
  51. /package/src/engine/ecs/storage/{JSONSerializer.js → json/JSONSerializer.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { BehaviorStatus } from "./BehaviorStatus.js";
2
+ import Signal from "../../../core/events/signal/Signal.js";
2
3
 
3
4
  /**
4
5
  * Base class of behavior tree implementation
@@ -15,6 +16,20 @@ export class Behavior {
15
16
  */
16
17
  context = null;
17
18
 
19
+ /**
20
+ * Dispatched after initialization is complete
21
+ * @readonly
22
+ * @type {Signal<this,CTX>}
23
+ */
24
+ onInitialized = new Signal();
25
+
26
+ /**
27
+ * Dispatched after finalization is complete
28
+ * @readonly
29
+ * @type {Signal<this>}
30
+ */
31
+ onFinalized = new Signal();
32
+
18
33
  /**
19
34
  * Main update function. Every behavior executes some logic, some behaviors are long-running and some are instantaneous
20
35
  * @param {number} timeDelta time step in seconds
@@ -27,18 +42,22 @@ export class Behavior {
27
42
  /**
28
43
  * Called before behavior gets executed via {@link #tick} for the first time
29
44
  * Used to prepare the behavior for execution
45
+ * You can think of it as "start"
30
46
  * @param {CTX} [context]
31
47
  */
32
48
  initialize(context) {
33
49
  this.context = context;
50
+ this.onInitialized.send2(this, context);
34
51
  }
35
52
 
36
53
  /**
37
54
  * Called when behavior is finished, or interrupted
38
55
  * Used to clean up any resources
56
+ * You can think of it as "stop"
39
57
  */
40
58
  finalize() {
41
59
  // extend in subclasses as necessary
60
+ this.onFinalized.send1(this);
42
61
  }
43
62
  }
44
63
 
@@ -78,11 +78,11 @@ export class SelectorBehavior extends CompositeBehavior {
78
78
  this.__currentBehaviour.finalize();
79
79
  this.__currentBehaviour = null;
80
80
  }
81
+
82
+ super.finalize();
81
83
  }
82
84
 
83
85
  initialize(context) {
84
- super.initialize(context);
85
-
86
86
  const children = this.__children;
87
87
 
88
88
  if (children.length > 0) {
@@ -99,5 +99,7 @@ export class SelectorBehavior extends CompositeBehavior {
99
99
  this.__currentBehaviour = null;
100
100
 
101
101
  }
102
+
103
+ super.initialize(context);
102
104
  }
103
105
  }
@@ -218,6 +218,8 @@ export class ParallelBehavior extends CompositeBehavior {
218
218
  //finalize remaining active behaviours
219
219
 
220
220
  this.__finalizeActiveChildren();
221
+
222
+ super.finalize();
221
223
  }
222
224
 
223
225
  /**
@@ -34,7 +34,6 @@ export class SequenceBehavior extends CompositeBehavior {
34
34
 
35
35
  initialize(context) {
36
36
  // console.log('+ SequenceBehavior');
37
- super.initialize(context);
38
37
 
39
38
  this.__currentBehaviourIndex = 0;
40
39
  this.__currentBehaviour = this.__children[0];
@@ -43,6 +42,8 @@ export class SequenceBehavior extends CompositeBehavior {
43
42
  this.__currentBehaviour.initialize(context);
44
43
 
45
44
  this.__currentBehaviourState = BehaviorStatus.Running;
45
+
46
+ super.initialize(context);
46
47
  }
47
48
 
48
49
 
@@ -100,6 +101,7 @@ export class SequenceBehavior extends CompositeBehavior {
100
101
  this.__currentBehaviourIndex = child_count;
101
102
 
102
103
  // console.warn('- SequenceBehavior');
104
+ super.finalize();
103
105
  }
104
106
 
105
107
  /**
@@ -35,14 +35,13 @@ export class AbstractDecoratorBehavior extends Behavior {
35
35
  }
36
36
 
37
37
  initialize(context) {
38
- super.initialize(context);
39
38
  this.__source.initialize(context);
39
+ super.initialize(context);
40
40
  }
41
41
 
42
42
  finalize() {
43
- super.finalize();
44
-
45
43
  this.__source.finalize();
44
+ super.finalize();
46
45
  }
47
46
  }
48
47
 
@@ -59,10 +59,10 @@ export class RepeatBehavior extends AbstractDecoratorBehavior {
59
59
  }
60
60
 
61
61
  initialize(context) {
62
- super.initialize(context);
63
-
64
62
  // reset iterator
65
63
  this.__iterator = 0;
64
+
65
+ super.initialize(context);
66
66
  }
67
67
 
68
68
  tick(timeDelta) {
@@ -10,7 +10,7 @@ import TaskGroup from "../../../../core/process/task/TaskGroup.js";
10
10
  import { Sampler2D } from "../../../../engine/graphics/texture/sampler/Sampler2D.js";
11
11
  import { bitSet2Sampler2D } from "../../../../engine/graphics/texture/sampler/util/bitSet2Sampler2D.js";
12
12
  import { drawSamplerHTML } from "../../../../engine/graphics/texture/sampler/util/drawSamplerHTML.js";
13
- import { matcher_tag_unoccupied } from "../../../example/rules/matcher_tag_unoccupied.js";
13
+ import { matcher_tag_unoccupied } from "../../../../../samples/generation/rules/matcher_tag_unoccupied.js";
14
14
  import { buildDistanceMapToObjective } from "../util/buildDistanceMapToObjective.js";
15
15
  import { buildPathFromDistanceMap } from "../util/buildPathFromDistanceMap.js";
16
16
  import { assert } from "../../../../core/assert.js";
@@ -6,7 +6,7 @@ import TaskGroup from "../../../../core/process/task/TaskGroup.js";
6
6
  import Graph from "../../../../core/graph/Graph.js";
7
7
  import BinaryHeap from "../../../../core/collection/heap/FastBinaryHeap.js";
8
8
  import { BitSet } from "../../../../core/binary/BitSet.js";
9
- import { matcher_tag_traversable } from "../../../example/rules/matcher_tag_traversable.js";
9
+ import { matcher_tag_traversable } from "../../../../../samples/generation/rules/matcher_tag_traversable.js";
10
10
  import { buildPathFromDistanceMap } from "../util/buildPathFromDistanceMap.js";
11
11
  import { GridCellActionPlaceTags } from "../../../placement/action/GridCellActionPlaceTags.js";
12
12
  import { GridTags } from "../../../GridTags.js";
@@ -20,7 +20,7 @@ import { readMarkerNodeGroupId } from "./readMarkerNodeGroupId.js";
20
20
  import { buildUnsignedDistanceField } from "../util/buildUnsignedDistanceField.js";
21
21
  import { CellMatcherNot } from "../../../rules/logic/CellMatcherNot.js";
22
22
  import { RoadConnectionNetwork } from "./RoadConnectionNetwork.js";
23
- import { MirGridLayers } from "../../../example/grid/MirGridLayers.js";
23
+ import { MirGridLayers } from "../../../../../samples/generation/grid/MirGridLayers.js";
24
24
  import { actionTask } from "../../../../core/process/task/util/actionTask.js";
25
25
  import { countTask } from "../../../../core/process/task/util/countTask.js";
26
26
  import { groupArrayBy } from "../../../../core/collection/array/groupArrayBy.js";
@@ -16,6 +16,8 @@ export const AlignmentOption = {
16
16
  End: 'end'
17
17
  };
18
18
 
19
+ const update_scratch = [];
20
+
19
21
  class VirtualListView extends View {
20
22
  /**
21
23
  * @template T
@@ -1,3 +0,0 @@
1
- import { CellFilterSimplexNoise } from "../../filtering/numeric/complex/CellFilterSimplexNoise.js";
2
-
3
- export const SampleNoise20_0 = CellFilterSimplexNoise.from(20, 20);
@@ -1,52 +0,0 @@
1
- import { GridCellPlacementRule } from "../../placement/GridCellPlacementRule.js";
2
- import { matcher_tag_traversable_unoccupied } from "../rules/matcher_tag_traversable_unoccupied.js";
3
- import { CellMatcherNot } from "../../rules/logic/CellMatcherNot.js";
4
- import { GridCellActionPlaceTags } from "../../placement/action/GridCellActionPlaceTags.js";
5
- import { GridTags } from "../../GridTags.js";
6
- import { GridCellActionPlaceMarker } from "../../markers/GridCellActionPlaceMarker.js";
7
- import { GridTaskExecuteRuleTimes } from "../../grid/generation/GridTaskExecuteRuleTimes.js";
8
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
9
- import { CellMatcherGridPattern } from "../../rules/cell/CellMatcherGridPattern.js";
10
- import { MirGridLayers } from "../grid/MirGridLayers.js";
11
- import { GridCellActionTransformNearbyMarkers } from "../../placement/GridCellActionTransformNearbyMarkers.js";
12
- import { MarkerNodeMatcherByType } from "../../markers/matcher/MarkerNodeMatcherByType.js";
13
- import { MarkerNodeTransformerRecordProperty } from "../../markers/transform/MarkerNodeTransformerRecordProperty.js";
14
- import { CellFilterLiteralFloat } from "../../filtering/numeric/CellFilterLiteralFloat.js";
15
- import { MirMarkerTypes } from "../../../../../generator/MirMarkerTypes.js";
16
- import { MarkerNodeTransformerRemoveTag } from "../../markers/transform/MarkerNodeTransformerRemoveTag.js";
17
- import { MirMarkerTags } from "../../../../../generator/MirMarkerTags.js";
18
- import { MarkerNodeTransformerSequence } from "../../markers/transform/MarkerNodeTransformerSequence.js";
19
- import { GridCellActionSequence } from "../../placement/action/util/GridCellActionSequence.js";
20
-
21
- const MATCH_STARTING_POINT = CellMatcherLayerBitMaskTest.from(GridTags.StartingPoint, MirGridLayers.Tags);
22
-
23
-
24
- const pattern = new CellMatcherGridPattern();
25
-
26
- pattern.addRule(0, 0, matcher_tag_traversable_unoccupied);
27
- pattern.addRule(0, 0, CellMatcherNot.from(MATCH_STARTING_POINT));
28
- // NEXT TO A BASE
29
- pattern.addRule(0, -1, CellMatcherLayerBitMaskTest.from(GridTags.Base, MirGridLayers.Tags));
30
-
31
- const rule = GridCellPlacementRule.from(
32
- {
33
- matcher: pattern,
34
- action: GridCellActionSequence.from([
35
- GridCellActionPlaceTags.from(GridTags.StartingPoint | GridTags.Occupied, MirGridLayers.Tags),
36
- GridCellActionPlaceMarker.from({ type: MirMarkerTypes.StartingPoint }),
37
- // transfer ownership of any base within some distance to the player
38
- GridCellActionTransformNearbyMarkers.from(
39
- 5,
40
- MarkerNodeMatcherByType.from(MirMarkerTypes.Base),
41
- MarkerNodeTransformerSequence.from([
42
- MarkerNodeTransformerRecordProperty.from('team', CellFilterLiteralFloat.from(0)),
43
- MarkerNodeTransformerRemoveTag.from(MirMarkerTags.Encounter)
44
- ])
45
- )
46
- ])
47
- }
48
- );
49
-
50
- rule.allowRotation = true;
51
-
52
- export const mir_generator_place_starting_point = () => GridTaskExecuteRuleTimes.from(rule, 1);
@@ -1,5 +0,0 @@
1
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../GridTags.js";
3
- import { MirGridLayers } from "../grid/MirGridLayers.js";
4
-
5
- export const matcher_play_area = CellMatcherLayerBitMaskTest.from(GridTags.PlayArea, MirGridLayers.Tags);
@@ -1,5 +0,0 @@
1
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../GridTags.js";
3
- import { MirGridLayers } from "../grid/MirGridLayers.js";
4
-
5
- export const matcher_tag_occupied = CellMatcherLayerBitMaskTest.from(GridTags.Occupied, MirGridLayers.Tags);
@@ -1,5 +0,0 @@
1
- import { CellMatcherLayerBitMaskTest } from "../../rules/CellMatcherLayerBitMaskTest.js";
2
- import { GridTags } from "../../GridTags.js";
3
- import { MirGridLayers } from "../grid/MirGridLayers.js";
4
-
5
- export const matcher_tag_traversable = CellMatcherLayerBitMaskTest.from(GridTags.Traversable, MirGridLayers.Tags);