@drawcall/acta 0.1.2 → 0.1.4
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/dist/animations/index.d.ts +16 -0
- package/dist/animations/index.js +20 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +47 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const animationLoaders: {
|
|
2
|
+
readonly Pistol_Aim_Up: () => Promise<string>;
|
|
3
|
+
readonly Pistol_Aim_Neutral: () => Promise<string>;
|
|
4
|
+
readonly Pistol_Aim_Down: () => Promise<string>;
|
|
5
|
+
readonly Jog_Right: () => Promise<string>;
|
|
6
|
+
readonly Jog_Left: () => Promise<string>;
|
|
7
|
+
readonly Jog_Fwd_R: () => Promise<string>;
|
|
8
|
+
readonly Jog_Fwd: () => Promise<string>;
|
|
9
|
+
readonly Jog_Fwd_L: () => Promise<string>;
|
|
10
|
+
readonly Jog_Bwd_R: () => Promise<string>;
|
|
11
|
+
readonly Jog_Bwd: () => Promise<string>;
|
|
12
|
+
readonly Jog_Bwd_L: () => Promise<string>;
|
|
13
|
+
};
|
|
14
|
+
export type AnimationName = keyof typeof animationLoaders;
|
|
15
|
+
export declare const animationNames: AnimationName[];
|
|
16
|
+
export declare function loadAnimationUrl(name: AnimationName): Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const animationLoaders = {
|
|
2
|
+
'Pistol_Aim_Up': async () => (await import('./Pistol_Aim_Up.js')).default,
|
|
3
|
+
'Pistol_Aim_Neutral': async () => (await import('./Pistol_Aim_Neutral.js')).default,
|
|
4
|
+
'Pistol_Aim_Down': async () => (await import('./Pistol_Aim_Down.js')).default,
|
|
5
|
+
'Jog_Right': async () => (await import('./Jog_Right.js')).default,
|
|
6
|
+
'Jog_Left': async () => (await import('./Jog_Left.js')).default,
|
|
7
|
+
'Jog_Fwd_R': async () => (await import('./Jog_Fwd_R.js')).default,
|
|
8
|
+
'Jog_Fwd': async () => (await import('./Jog_Fwd.js')).default,
|
|
9
|
+
'Jog_Fwd_L': async () => (await import('./Jog_Fwd_L.js')).default,
|
|
10
|
+
'Jog_Bwd_R': async () => (await import('./Jog_Bwd_R.js')).default,
|
|
11
|
+
'Jog_Bwd': async () => (await import('./Jog_Bwd.js')).default,
|
|
12
|
+
'Jog_Bwd_L': async () => (await import('./Jog_Bwd_L.js')).default,
|
|
13
|
+
};
|
|
14
|
+
export const animationNames = Object.keys(animationLoaders);
|
|
15
|
+
export function loadAnimationUrl(name) {
|
|
16
|
+
const loader = animationLoaders[name];
|
|
17
|
+
if (!loader)
|
|
18
|
+
throw new Error(`Unknown animation: ${name}`);
|
|
19
|
+
return loader();
|
|
20
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export type Condition = {
|
|
|
11
11
|
type: 'and';
|
|
12
12
|
conditions: Condition[];
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Extracts all property names used in conditions within a behavior tree.
|
|
16
|
+
* @param behavior - The behavior to extract properties from
|
|
17
|
+
* @returns Array of unique property names
|
|
18
|
+
*/
|
|
19
|
+
export declare function getProperties(behavior: Behavior): string[];
|
|
14
20
|
export type Behavior = {
|
|
15
21
|
type: 'animation';
|
|
16
22
|
name: string;
|
package/dist/types.js
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Extracts all property names used in conditions within a behavior tree.
|
|
3
|
+
* @param behavior - The behavior to extract properties from
|
|
4
|
+
* @returns Array of unique property names
|
|
5
|
+
*/
|
|
6
|
+
export function getProperties(behavior) {
|
|
7
|
+
const properties = new Set();
|
|
8
|
+
function collectFromCondition(condition) {
|
|
9
|
+
switch (condition.type) {
|
|
10
|
+
case 'isTrue':
|
|
11
|
+
properties.add(condition.property);
|
|
12
|
+
break;
|
|
13
|
+
case 'not':
|
|
14
|
+
collectFromCondition(condition.condition);
|
|
15
|
+
break;
|
|
16
|
+
case 'or':
|
|
17
|
+
case 'and':
|
|
18
|
+
condition.conditions.forEach(collectFromCondition);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function collectFromBehavior(b) {
|
|
23
|
+
switch (b.type) {
|
|
24
|
+
case 'loop':
|
|
25
|
+
collectFromBehavior(b.behavior);
|
|
26
|
+
break;
|
|
27
|
+
case 'split':
|
|
28
|
+
collectFromBehavior(b.upperBodyBehavior);
|
|
29
|
+
collectFromBehavior(b.lowerBodyBehavior);
|
|
30
|
+
break;
|
|
31
|
+
case 'sequential':
|
|
32
|
+
case 'parallel':
|
|
33
|
+
b.behaviors.forEach(collectFromBehavior);
|
|
34
|
+
break;
|
|
35
|
+
case 'graph':
|
|
36
|
+
Object.values(b.states).forEach((state) => {
|
|
37
|
+
collectFromBehavior(state.behavior);
|
|
38
|
+
if (state.transitionsTo) {
|
|
39
|
+
Object.values(state.transitionsTo).forEach(collectFromCondition);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
collectFromBehavior(behavior);
|
|
46
|
+
return Array.from(properties);
|
|
47
|
+
}
|