@woosh/meep-engine 2.47.31 → 2.47.33
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/build/meep.cjs +149 -38
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +149 -38
- package/package.json +1 -1
- package/src/core/cache/Cache.js +12 -0
- package/src/core/collection/HashMap.js +33 -5
- package/src/core/collection/HashMap.spec.js +30 -4
- package/src/engine/asset/loaders/material/StaticMaterialCache.js +18 -0
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +30 -34
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.js +59 -0
- package/src/engine/intelligence/behavior/util/syncExecuteBehaviorToCompletion.js +34 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
2
|
+
import { assert } from "../../../../core/assert.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Synchronously executes behavior from start to finish, or throws if could not be completed within set number of ticks
|
|
6
|
+
* @template CTX
|
|
7
|
+
* @param {Behavior<CTX>} behavior
|
|
8
|
+
* @param {CTX} context behavior context, will be passed into behavior initialization
|
|
9
|
+
* @param {number} [tick_limit]
|
|
10
|
+
* @returns {BehaviorStatus} completion status
|
|
11
|
+
* @throws {Error} if can't complete within tick limit
|
|
12
|
+
*/
|
|
13
|
+
export function syncExecuteBehaviorToCompletion({ behavior, context, tick_limit = 10000 }) {
|
|
14
|
+
assert.isNumber(tick_limit, 'tick_limit');
|
|
15
|
+
assert.notNaN(tick_limit, 'tick_limit');
|
|
16
|
+
assert.isNonNegativeInteger(tick_limit, 'tick_limit');
|
|
17
|
+
|
|
18
|
+
behavior.initialize(context);
|
|
19
|
+
|
|
20
|
+
let tick_count = 0;
|
|
21
|
+
let state;
|
|
22
|
+
|
|
23
|
+
do {
|
|
24
|
+
if (tick_count++ > tick_limit) {
|
|
25
|
+
throw new Error(`Failed to complete behavior, tick limit(${tick_limit}) reached. Behavior not finalized`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
state = behavior.tick(0);
|
|
29
|
+
} while (state === BehaviorStatus.Running);
|
|
30
|
+
|
|
31
|
+
behavior.finalize();
|
|
32
|
+
|
|
33
|
+
return state;
|
|
34
|
+
}
|