@woosh/meep-engine 2.50.1 → 2.50.3
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/README.md +42 -0
- package/editor/Editor.js +5 -1
- package/editor/SelectionVisualizer.js +9 -3
- package/editor/tools/paint/TerrainTexturePaintTool.js +6 -1
- package/editor/view/EditorView.js +5 -1
- package/editor/view/ecs/EntityList.js +48 -37
- package/editor/view/makeEntityDecorators.js +125 -0
- package/package.json +7 -3
- package/samples/generation/README.md +6 -0
- package/{src/generation/example → samples/generation}/SampleGenerator0.js +60 -46
- package/{src/generation/example → samples/generation}/filters/SampleGroundMoistureFilter.js +14 -12
- package/samples/generation/filters/SampleNoise20_0.js +3 -0
- package/{src/generation/example → samples/generation}/generators/interactive/mir_generator_place_buff_objects.js +29 -23
- package/{src/generation/example → samples/generation}/generators/mir_generator_place_bases.js +33 -25
- package/{src/generation/example → samples/generation}/generators/mir_generator_place_road_decorators.js +16 -14
- package/samples/generation/generators/mir_generator_place_starting_point.js +60 -0
- package/{src/generation/example → samples/generation}/grid/configureMirGrid.js +2 -2
- package/{src/generation/example → samples/generation}/main.js +29 -28
- package/{src/generation/example → samples/generation}/rules/matcher_not_play_area.js +1 -1
- package/samples/generation/rules/matcher_play_area.js +5 -0
- package/{src/generation/example → samples/generation}/rules/matcher_tag_not_traversable.js +1 -1
- package/samples/generation/rules/matcher_tag_occupied.js +5 -0
- package/samples/generation/rules/matcher_tag_traversable.js +5 -0
- package/{src/generation/example → samples/generation}/rules/matcher_tag_traversable_unoccupied.js +1 -1
- package/{src/generation/example → samples/generation}/rules/matcher_tag_unoccupied.js +1 -1
- package/{src/generation/example → samples/generation}/rules/mir_matcher_attack_corridor.js +3 -3
- package/{src/generation/example → samples/generation}/themes/SampleTheme0.js +57 -47
- package/{src/generation/example → samples/generation}/themes/SampleTheme1.js +4 -4
- package/{src/generation/example → samples/generation}/themes/SampleTheme2.js +4 -4
- package/src/core/cache/Cache.d.ts +4 -0
- package/src/core/cache/Cache.js +31 -15
- package/src/core/cache/Cache.spec.js +33 -0
- package/src/core/cache/FrequencySketch.js +26 -23
- package/src/core/cache/FrequencySketch.spec.js +5 -0
- package/src/core/cache/LoadingCache.d.ts +2 -0
- package/src/core/cache/LoadingCache.js +16 -7
- package/src/core/cache/LoadingCache.spec.js +24 -0
- package/src/core/collection/HashMap.d.ts +2 -0
- package/src/core/collection/HashMap.spec.js +51 -2
- package/src/core/collection/list/List.d.ts +13 -1
- package/src/core/collection/list/List.js +702 -684
- package/src/core/collection/list/List.spec.js +93 -0
- package/src/core/collection/map/AsyncLoadingCache.js +1 -0
- package/src/core/fsm/simple/SimpleStateMachine.js +23 -22
- package/src/core/function/extractFunctionBody.spec.js +15 -0
- package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +69 -33
- package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.spec.js +33 -0
- package/src/core/geom/2d/convex-hull/orientation3.js +55 -10
- package/src/core/process/matcher/Matchers.js +1 -1
- package/src/engine/asset/loaders/image/png/PNG.spec.js +5 -0
- package/src/engine/asset/loaders/image/png/PNGReader.spec.js +5 -0
- package/src/engine/asset/loaders/image/png/crc.spec.js +15 -0
- package/src/engine/ecs/EntityBlueprint.js +4 -0
- package/src/engine/ecs/EntityBuilder.js +48 -49
- package/src/engine/ecs/EntityBuilderFlags.js +2 -2
- package/src/engine/ecs/guid/GUID.js +1 -0
- package/src/engine/ecs/{Blueprint.js → storage/json/Blueprint.js} +1 -1
- package/src/engine/ecs/{EntityFactory.js → storage/json/EntityFactory.js} +1 -1
- package/src/engine/ecs/storage/{JSONDeSerializer.js → json/JSONDeSerializer.js} +4 -4
- package/src/engine/ecs/storage/json/README.md +5 -0
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +5 -0
- package/src/engine/intelligence/behavior/Behavior.d.ts +5 -0
- package/src/engine/intelligence/behavior/Behavior.js +19 -0
- package/src/engine/intelligence/behavior/SelectorBehavior.js +4 -2
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +2 -0
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +3 -1
- package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +2 -3
- package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +2 -2
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
- package/src/view/common/VirtualListView.js +2 -0
- package/src/generation/example/filters/SampleNoise20_0.js +0 -3
- package/src/generation/example/generators/mir_generator_place_starting_point.js +0 -52
- package/src/generation/example/rules/matcher_play_area.js +0 -5
- package/src/generation/example/rules/matcher_tag_occupied.js +0 -5
- package/src/generation/example/rules/matcher_tag_traversable.js +0 -5
- /package/{src/generation/example → samples/generation}/grid/MirGridLayers.js +0 -0
- /package/src/engine/ecs/storage/{JSONSerializer.js → json/JSONSerializer.js} +0 -0
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import Blueprint from '
|
|
7
|
-
import { assert } from "
|
|
8
|
-
import { countTask } from "
|
|
9
|
-
import { emptyTask } from "
|
|
6
|
+
import Blueprint from './Blueprint.js';
|
|
7
|
+
import { assert } from "../../../../core/assert.js";
|
|
8
|
+
import { countTask } from "../../../../core/process/task/util/countTask.js";
|
|
9
|
+
import { emptyTask } from "../../../../core/process/task/util/emptyTask.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import {BehaviorStatus} from "./BehaviorStatus";
|
|
2
|
+
import Signal from "../../../core/events/signal/Signal";
|
|
2
3
|
|
|
3
4
|
export class Behavior<CTX> {
|
|
4
5
|
context: CTX | null
|
|
5
6
|
|
|
7
|
+
readonly onInitialized: Signal<this, CTX>
|
|
8
|
+
|
|
9
|
+
readonly onFinalized: Signal<this>
|
|
10
|
+
|
|
6
11
|
tick(timeDeltaSeconds: number): BehaviorStatus
|
|
7
12
|
|
|
8
13
|
initialize(context: CTX): void
|
|
@@ -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
|
}
|
|
@@ -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
|
|
|
@@ -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 "
|
|
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 "
|
|
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 "
|
|
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";
|
|
@@ -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);
|
|
File without changes
|
|
File without changes
|