@rpgjs/action-battle 5.0.0-beta.1 → 5.0.0-beta.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/LICENSE +19 -0
- package/README.md +94 -0
- package/dist/ai.server.d.ts +31 -27
- package/dist/animations.d.ts +16 -0
- package/dist/client/index.js +15 -31
- package/dist/client/index10.js +376 -0
- package/dist/client/index2.js +63 -46
- package/dist/client/index3.js +50 -1287
- package/dist/client/index4.js +301 -331
- package/dist/client/index5.js +36 -291
- package/dist/client/index6.js +99 -95
- package/dist/client/index7.js +33 -60
- package/dist/client/index8.js +39 -53
- package/dist/client/index9.js +1167 -27
- package/dist/client.d.ts +3 -2
- package/dist/config.d.ts +2 -0
- package/dist/index.d.ts +5 -5
- package/dist/server/index.js +14 -31
- package/dist/server/index2.js +39 -332
- package/dist/server/index3.js +62 -1287
- package/dist/server/index4.js +1167 -53
- package/dist/server/index5.js +35 -28
- package/dist/server/index6.js +376 -0
- package/dist/server.d.ts +3 -3
- package/dist/ui/state.d.ts +3 -3
- package/package.json +5 -5
- package/src/ai.server.ts +79 -28
- package/src/animations.ts +110 -0
- package/src/config.ts +16 -0
- package/src/index.ts +7 -1
- package/src/server.ts +16 -3
- package/src/types.ts +47 -0
package/dist/client/index8.js
CHANGED
|
@@ -1,55 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
mode: "both"
|
|
7
|
-
},
|
|
8
|
-
targeting: {
|
|
9
|
-
enabled: true,
|
|
10
|
-
showGrid: true,
|
|
11
|
-
colors: {
|
|
12
|
-
area: 3120887,
|
|
13
|
-
edge: 1796760,
|
|
14
|
-
cursor: 16765286
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
skills: {
|
|
19
|
-
defaultAoeMask: ["#"]
|
|
20
|
-
},
|
|
21
|
-
targeting: {
|
|
22
|
-
affects: "events",
|
|
23
|
-
allowEmptyTarget: true
|
|
24
|
-
}
|
|
1
|
+
var DEFAULT_ANIMATION_BY_KEY = {
|
|
2
|
+
attack: "attack",
|
|
3
|
+
hurt: "hurt",
|
|
4
|
+
die: "die",
|
|
5
|
+
castSkill: "skill"
|
|
25
6
|
};
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
targeting: {
|
|
47
|
-
...DEFAULT_ACTION_BATTLE_OPTIONS.targeting,
|
|
48
|
-
...options.targeting
|
|
49
|
-
}
|
|
50
|
-
};
|
|
7
|
+
function resolveActionBattleAnimation(key, entity, animations, context, defaults = {}) {
|
|
8
|
+
const defaultAnimationName = defaults.animationName ?? DEFAULT_ANIMATION_BY_KEY[key];
|
|
9
|
+
const defaultRepeat = defaults.repeat ?? 1;
|
|
10
|
+
const hasConfiguredAnimation = animations ? Object.prototype.hasOwnProperty.call(animations, key) : false;
|
|
11
|
+
if (!hasConfiguredAnimation && key !== "attack") return null;
|
|
12
|
+
const configured = hasConfiguredAnimation ? animations?.[key] : defaultAnimationName;
|
|
13
|
+
const result = typeof configured === "function" ? configured(entity, context) : configured;
|
|
14
|
+
if (result == null) return null;
|
|
15
|
+
if (typeof result === "string") return {
|
|
16
|
+
animationName: result,
|
|
17
|
+
repeat: defaultRepeat,
|
|
18
|
+
waitEnd: false
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
animationName: result.animationName ?? defaultAnimationName,
|
|
22
|
+
graphic: result.graphic,
|
|
23
|
+
repeat: result.repeat ?? defaultRepeat,
|
|
24
|
+
waitEnd: result.waitEnd ?? false,
|
|
25
|
+
delayMs: result.delayMs
|
|
26
|
+
};
|
|
51
27
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
function playActionBattleAnimation(key, entity, animations, context, defaults = {}) {
|
|
29
|
+
const animation = resolveActionBattleAnimation(key, entity, animations, context, defaults);
|
|
30
|
+
if (!animation) return null;
|
|
31
|
+
if (animation.graphic !== void 0) entity.setGraphicAnimation(animation.animationName, animation.graphic, animation.repeat);
|
|
32
|
+
else entity.setGraphicAnimation(animation.animationName, animation.repeat);
|
|
33
|
+
return animation;
|
|
34
|
+
}
|
|
35
|
+
function getActionBattleAnimationRemovalDelay(animation) {
|
|
36
|
+
if (!animation) return 0;
|
|
37
|
+
if (animation.delayMs !== void 0) return animation.delayMs;
|
|
38
|
+
return animation.waitEnd ? 500 : 0;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { getActionBattleAnimationRemovalDelay, playActionBattleAnimation };
|