@rpgjs/action-battle 5.0.0-beta.2 → 5.0.0-beta.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/README.md +137 -0
- package/dist/ai.server.d.ts +8 -1
- package/dist/client/index.js +19 -31
- package/dist/client/index10.js +142 -29
- package/dist/client/index11.js +25 -0
- package/dist/client/index12.js +1222 -0
- package/dist/client/index13.js +46 -0
- package/dist/client/index14.js +10 -0
- package/dist/client/index15.js +448 -0
- package/dist/client/index2.js +93 -46
- package/dist/client/index3.js +82 -1329
- package/dist/client/index4.js +305 -344
- package/dist/client/index5.js +36 -291
- package/dist/client/index6.js +99 -95
- package/dist/client/index7.js +78 -61
- package/dist/client/index8.js +57 -65
- package/dist/client/index9.js +97 -62
- package/dist/client.d.ts +3 -2
- package/dist/core/context.d.ts +5 -0
- package/dist/core/defaults.d.ts +81 -0
- package/dist/core/hit.d.ts +2 -0
- package/dist/enemies/factory.d.ts +7 -0
- package/dist/index.d.ts +9 -4
- package/dist/server/index.js +18 -31
- package/dist/server/index10.js +10 -0
- package/dist/server/index2.js +59 -345
- package/dist/server/index3.js +92 -1329
- package/dist/server/index4.js +141 -67
- package/dist/server/index5.js +24 -29
- package/dist/server/index6.js +1219 -62
- package/dist/server/index7.js +37 -0
- package/dist/server/index8.js +46 -0
- package/dist/server/index9.js +447 -0
- package/dist/server.d.ts +5 -3
- package/dist/ui/state.d.ts +20 -3
- package/package.json +5 -5
- package/src/ai.server.ts +91 -24
- package/src/animations.ts +43 -4
- package/src/canvas-engine-shim.ts +4 -0
- package/src/client.ts +122 -2
- package/src/components/action-bar.ce +5 -3
- package/src/components/attack-preview.ce +90 -0
- package/src/config.ts +30 -0
- package/src/core/context.ts +35 -0
- package/src/core/contracts.ts +123 -0
- package/src/core/defaults.ts +162 -0
- package/src/core/hit.spec.ts +58 -0
- package/src/core/hit.ts +66 -0
- package/src/enemies/factory.ts +25 -0
- package/src/index.ts +40 -0
- package/src/server.ts +235 -71
- package/src/targeting.spec.ts +24 -0
- package/src/types/canvas-engine.d.ts +4 -0
- package/src/types.ts +46 -1
- package/src/ui/state.ts +57 -0
package/dist/client/index8.js
CHANGED
|
@@ -1,69 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
},
|
|
25
|
-
animations: {}
|
|
1
|
+
var DEFAULT_ANIMATION_BY_KEY = {
|
|
2
|
+
attack: "attack",
|
|
3
|
+
hurt: "hurt",
|
|
4
|
+
die: "die",
|
|
5
|
+
castSkill: "skill",
|
|
6
|
+
castSpell: "skill"
|
|
26
7
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
8
|
+
var getConfiguredAnimation = (key, animations) => {
|
|
9
|
+
if (!animations) return {
|
|
10
|
+
hasConfiguredAnimation: false,
|
|
11
|
+
configured: void 0
|
|
12
|
+
};
|
|
13
|
+
const hasConfiguredAnimation = Object.prototype.hasOwnProperty.call(animations, key);
|
|
14
|
+
if (hasConfiguredAnimation) return {
|
|
15
|
+
hasConfiguredAnimation,
|
|
16
|
+
configured: animations[key]
|
|
17
|
+
};
|
|
18
|
+
if (key === "castSkill") return {
|
|
19
|
+
hasConfiguredAnimation: Object.prototype.hasOwnProperty.call(animations, "castSpell"),
|
|
20
|
+
configured: animations.castSpell
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
hasConfiguredAnimation: false,
|
|
24
|
+
configured: void 0
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
function resolveActionBattleAnimation(key, entity, animations, context, defaults = {}) {
|
|
28
|
+
const defaultAnimationName = defaults.animationName ?? DEFAULT_ANIMATION_BY_KEY[key];
|
|
29
|
+
const defaultRepeat = defaults.repeat ?? 1;
|
|
30
|
+
const { hasConfiguredAnimation, configured: configuredAnimation } = getConfiguredAnimation(key, animations);
|
|
31
|
+
if (!hasConfiguredAnimation && key !== "attack") return null;
|
|
32
|
+
const configured = hasConfiguredAnimation ? configuredAnimation : defaultAnimationName;
|
|
33
|
+
const result = typeof configured === "function" ? configured(entity, context) : configured;
|
|
34
|
+
if (result == null) return null;
|
|
35
|
+
if (typeof result === "string") return {
|
|
36
|
+
animationName: result,
|
|
37
|
+
repeat: defaultRepeat,
|
|
38
|
+
waitEnd: false
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
animationName: result.animationName ?? defaultAnimationName,
|
|
42
|
+
graphic: result.graphic,
|
|
43
|
+
repeat: result.repeat ?? defaultRepeat,
|
|
44
|
+
waitEnd: result.waitEnd ?? false,
|
|
45
|
+
delayMs: result.delayMs
|
|
46
|
+
};
|
|
57
47
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
48
|
+
function playActionBattleAnimation(key, entity, animations, context, defaults = {}) {
|
|
49
|
+
const animation = resolveActionBattleAnimation(key, entity, animations, context, defaults);
|
|
50
|
+
if (!animation) return null;
|
|
51
|
+
if (animation.graphic !== void 0) entity.setGraphicAnimation(animation.animationName, animation.graphic, animation.repeat);
|
|
52
|
+
else entity.setGraphicAnimation(animation.animationName, animation.repeat);
|
|
53
|
+
return animation;
|
|
60
54
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
55
|
+
function getActionBattleAnimationRemovalDelay(animation) {
|
|
56
|
+
if (!animation) return 0;
|
|
57
|
+
if (animation.delayMs !== void 0) return animation.delayMs;
|
|
58
|
+
return animation.waitEnd ? 500 : 0;
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
getActionBattleOptions,
|
|
67
|
-
normalizeActionBattleOptions,
|
|
68
|
-
setActionBattleOptions
|
|
69
|
-
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { getActionBattleAnimationRemovalDelay, playActionBattleAnimation, resolveActionBattleAnimation };
|
package/dist/client/index9.js
CHANGED
|
@@ -1,64 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { normalizeActionBattleOptions } from "./index2.js";
|
|
2
|
+
import { setActionBattleOptions, startAttackPreview, stopAttackPreview } from "./index3.js";
|
|
3
|
+
import component from "./index4.js";
|
|
4
|
+
import component$1 from "./index6.js";
|
|
5
|
+
import component$2 from "./index7.js";
|
|
6
|
+
import { resolveActionBattleAnimation } from "./index8.js";
|
|
7
|
+
import { PrebuiltComponentAnimations, RpgClientEngine, RpgGui, inject } from "@rpgjs/client";
|
|
8
|
+
import { defineModule } from "@rpgjs/common";
|
|
9
|
+
//#region src/client.ts
|
|
10
|
+
var DEFAULT_ATTACK_LOCK_DURATION_MS = 350;
|
|
11
|
+
var beginLocalPlayerAttackLock = (engine, durationMs) => {
|
|
12
|
+
if (durationMs <= 0) return true;
|
|
13
|
+
const player = engine.scene?.getCurrentPlayer?.();
|
|
14
|
+
if (!player) return true;
|
|
15
|
+
const runtimePlayer = player;
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
if (typeof runtimePlayer.__actionBattleAttackLockedUntil === "number" && runtimePlayer.__actionBattleAttackLockedUntil > now) return false;
|
|
18
|
+
const lockId = (runtimePlayer.__actionBattleAttackLockId ?? 0) + 1;
|
|
19
|
+
runtimePlayer.__actionBattleAttackLockId = lockId;
|
|
20
|
+
runtimePlayer.__actionBattleAttackLockedUntil = now + durationMs;
|
|
21
|
+
const previousCanMove = typeof player.canMove === "function" ? player.canMove() : true;
|
|
22
|
+
const previousDirectionFixed = player.directionFixed;
|
|
23
|
+
const previousAnimationFixed = player.animationFixed;
|
|
24
|
+
if (typeof engine.interruptCurrentPlayerMovement === "function") engine.interruptCurrentPlayerMovement(player);
|
|
25
|
+
else engine.scene?.stopMovement?.(player);
|
|
26
|
+
player.canMove.set(false);
|
|
27
|
+
player.directionFixed = true;
|
|
28
|
+
player.animationFixed = true;
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
if (runtimePlayer.__actionBattleAttackLockId !== lockId) return;
|
|
31
|
+
runtimePlayer.__actionBattleAttackLockedUntil = 0;
|
|
32
|
+
player.canMove.set(previousCanMove);
|
|
33
|
+
player.directionFixed = previousDirectionFixed;
|
|
34
|
+
player.animationFixed = previousAnimationFixed;
|
|
35
|
+
}, durationMs);
|
|
36
|
+
return true;
|
|
7
37
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!hasConfiguredAnimation && key !== "attack") {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const configured = hasConfiguredAnimation ? animations?.[key] : defaultAnimationName;
|
|
16
|
-
const result = typeof configured === "function" ? configured(entity, context) : configured;
|
|
17
|
-
if (result == null) return null;
|
|
18
|
-
if (typeof result === "string") {
|
|
19
|
-
return {
|
|
20
|
-
animationName: result,
|
|
21
|
-
repeat: defaultRepeat,
|
|
22
|
-
waitEnd: false
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const animationName = result.animationName ?? defaultAnimationName;
|
|
26
|
-
return {
|
|
27
|
-
animationName,
|
|
28
|
-
graphic: result.graphic,
|
|
29
|
-
repeat: result.repeat ?? defaultRepeat,
|
|
30
|
-
waitEnd: result.waitEnd ?? false,
|
|
31
|
-
delayMs: result.delayMs
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function playActionBattleAnimation(key, entity, animations, context, defaults = {}) {
|
|
35
|
-
const animation = resolveActionBattleAnimation(
|
|
36
|
-
key,
|
|
37
|
-
entity,
|
|
38
|
-
animations,
|
|
39
|
-
context,
|
|
40
|
-
defaults
|
|
41
|
-
);
|
|
42
|
-
if (!animation) return null;
|
|
43
|
-
if (animation.graphic !== void 0) {
|
|
44
|
-
entity.setGraphicAnimation(
|
|
45
|
-
animation.animationName,
|
|
46
|
-
animation.graphic,
|
|
47
|
-
animation.repeat
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
entity.setGraphicAnimation(animation.animationName, animation.repeat);
|
|
51
|
-
}
|
|
52
|
-
return animation;
|
|
53
|
-
}
|
|
54
|
-
function getActionBattleAnimationRemovalDelay(animation) {
|
|
55
|
-
if (!animation) return 0;
|
|
56
|
-
if (animation.delayMs !== void 0) return animation.delayMs;
|
|
57
|
-
return animation.waitEnd ? DEFAULT_DIE_ANIMATION_DELAY_MS : 0;
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
DEFAULT_DIE_ANIMATION_DELAY_MS,
|
|
61
|
-
getActionBattleAnimationRemovalDelay,
|
|
62
|
-
playActionBattleAnimation,
|
|
63
|
-
resolveActionBattleAnimation
|
|
38
|
+
var resolveLocalPlayerDirection = (player) => {
|
|
39
|
+
if (typeof player.getDirection === "function") return player.getDirection();
|
|
40
|
+
if (typeof player.direction === "function") return player.direction();
|
|
41
|
+
return player.direction ?? "down";
|
|
64
42
|
};
|
|
43
|
+
var playLocalPlayerAttackAnimation = (player, options) => {
|
|
44
|
+
if (!player || typeof player.setAnimation !== "function") return;
|
|
45
|
+
const animation = resolveActionBattleAnimation("attack", player, options.animations);
|
|
46
|
+
if (!animation) return;
|
|
47
|
+
if (animation.graphic !== void 0) {
|
|
48
|
+
player.setAnimation(animation.animationName, animation.graphic, animation.repeat);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
player.setAnimation(animation.animationName, animation.repeat);
|
|
52
|
+
};
|
|
53
|
+
var showLocalAttackPreview = (player, options) => {
|
|
54
|
+
if (!player || options.attack?.showPreview === false) return;
|
|
55
|
+
const durationMs = Math.max(1, options.attack?.previewDurationMs ?? 180);
|
|
56
|
+
const previewId = startAttackPreview({
|
|
57
|
+
direction: resolveLocalPlayerDirection(player),
|
|
58
|
+
durationMs,
|
|
59
|
+
color: options.attack?.previewColor,
|
|
60
|
+
accentColor: options.attack?.previewAccentColor
|
|
61
|
+
});
|
|
62
|
+
setTimeout(() => stopAttackPreview(previewId), durationMs);
|
|
63
|
+
};
|
|
64
|
+
var createActionBattleClient = (options = {}) => {
|
|
65
|
+
const normalized = normalizeActionBattleOptions(options);
|
|
66
|
+
setActionBattleOptions(normalized);
|
|
67
|
+
const actionBarEnabled = normalized.ui?.actionBar?.enabled;
|
|
68
|
+
const componentsInFront = [...normalized.ui?.targeting?.enabled ? [component$1] : [], component$2];
|
|
69
|
+
const hitComponent = PrebuiltComponentAnimations?.Hit;
|
|
70
|
+
return defineModule({
|
|
71
|
+
componentAnimations: hitComponent ? [{
|
|
72
|
+
id: "hit",
|
|
73
|
+
component: hitComponent
|
|
74
|
+
}] : [],
|
|
75
|
+
gui: actionBarEnabled ? [{
|
|
76
|
+
id: "action-battle-action-bar",
|
|
77
|
+
component,
|
|
78
|
+
dependencies: () => {
|
|
79
|
+
return [inject(RpgClientEngine).scene.currentPlayer];
|
|
80
|
+
}
|
|
81
|
+
}] : [],
|
|
82
|
+
sprite: { componentsInFront },
|
|
83
|
+
sceneMap: { onAfterLoading() {
|
|
84
|
+
if (actionBarEnabled && normalized.ui?.actionBar?.autoOpen) inject(RpgGui).display("action-battle-action-bar");
|
|
85
|
+
} },
|
|
86
|
+
engine: { onInput(engine, { input }) {
|
|
87
|
+
if (input !== "action") return;
|
|
88
|
+
const player = engine.scene?.getCurrentPlayer?.();
|
|
89
|
+
if (!player) return;
|
|
90
|
+
const lockDurationMs = Math.max(0, normalized.attack?.lockDurationMs ?? DEFAULT_ATTACK_LOCK_DURATION_MS);
|
|
91
|
+
beginLocalPlayerAttackLock(engine, normalized.attack?.lockMovement === false ? 0 : lockDurationMs);
|
|
92
|
+
playLocalPlayerAttackAnimation(player, normalized);
|
|
93
|
+
showLocalAttackPreview(player, normalized);
|
|
94
|
+
} }
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
var client_default = createActionBattleClient();
|
|
98
|
+
//#endregion
|
|
99
|
+
export { createActionBattleClient, client_default as default };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { RpgClient } from '@rpgjs/client';
|
|
1
2
|
import { ActionBattleOptions } from './types';
|
|
2
|
-
export declare const createActionBattleClient: (options?: ActionBattleOptions) =>
|
|
3
|
-
declare const _default:
|
|
3
|
+
export declare const createActionBattleClient: (options?: ActionBattleOptions) => RpgClient;
|
|
4
|
+
declare const _default: RpgClient;
|
|
4
5
|
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ActionBattleOptions } from '../types';
|
|
2
|
+
import { ActionBattleSystems } from './contracts';
|
|
3
|
+
export declare const setActionBattleSystems: (options?: ActionBattleOptions) => void;
|
|
4
|
+
export declare const getActionBattleSystems: () => ActionBattleSystems;
|
|
5
|
+
export declare const createActionBattleSystems: (options?: ActionBattleOptions) => ActionBattleSystems;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { RpgPlayer } from '@rpgjs/server';
|
|
2
|
+
import { ActionBattleAiBehavior, ActionBattleAttackContext, ActionBattleCombatSystem, ActionBattleDamageContext, ActionBattleKnockbackContext, ActionBattleKnockbackResult, ActionBattleSystems } from './contracts';
|
|
3
|
+
export declare const DEFAULT_ZELDA_PLAYER_HITBOXES: {
|
|
4
|
+
up: {
|
|
5
|
+
offsetX: number;
|
|
6
|
+
offsetY: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
down: {
|
|
11
|
+
offsetX: number;
|
|
12
|
+
offsetY: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
left: {
|
|
17
|
+
offsetX: number;
|
|
18
|
+
offsetY: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
right: {
|
|
23
|
+
offsetX: number;
|
|
24
|
+
offsetY: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
default: {
|
|
29
|
+
offsetX: number;
|
|
30
|
+
offsetY: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const createDefaultPlayerHitboxResolver: (hitboxes?: {
|
|
36
|
+
up: {
|
|
37
|
+
offsetX: number;
|
|
38
|
+
offsetY: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
down: {
|
|
43
|
+
offsetX: number;
|
|
44
|
+
offsetY: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
left: {
|
|
49
|
+
offsetX: number;
|
|
50
|
+
offsetY: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
right: {
|
|
55
|
+
offsetX: number;
|
|
56
|
+
offsetY: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
default: {
|
|
61
|
+
offsetX: number;
|
|
62
|
+
offsetY: number;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
66
|
+
}) => (context: ActionBattleAttackContext) => {
|
|
67
|
+
x: any;
|
|
68
|
+
y: any;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
}[];
|
|
72
|
+
export declare const defaultRpgjsDamageResolver: (context: ActionBattleDamageContext) => {
|
|
73
|
+
damage: any;
|
|
74
|
+
defeated: boolean;
|
|
75
|
+
raw: any;
|
|
76
|
+
};
|
|
77
|
+
export declare const defaultKnockbackResolver: (context: ActionBattleKnockbackContext) => ActionBattleKnockbackResult;
|
|
78
|
+
export declare const defaultCombatSystem: ActionBattleCombatSystem;
|
|
79
|
+
export declare const defaultEnemyBehaviors: Record<string, ActionBattleAiBehavior>;
|
|
80
|
+
export declare const defaultActionBattleSystems: ActionBattleSystems;
|
|
81
|
+
export declare const getEntityWeaponKnockbackForce: (entity: RpgPlayer) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RpgEvent } from '@rpgjs/server';
|
|
2
|
+
import { BattleAi, BattleAiOptions } from '../ai.server';
|
|
3
|
+
export interface ActionBattleEnemyPreset extends BattleAiOptions {
|
|
4
|
+
stats?: (event: RpgEvent) => void;
|
|
5
|
+
}
|
|
6
|
+
export type ActionBattleEnemyPresetMap = Record<string, ActionBattleEnemyPreset>;
|
|
7
|
+
export declare const createActionEnemy: (event: RpgEvent, presetOrOptions: string | BattleAiOptions, presets?: ActionBattleEnemyPresetMap) => BattleAi;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { ActionBattleOptions } from './types';
|
|
2
2
|
export { BattleAi, AiState, EnemyType, AttackPattern, AiDebug, DEFAULT_KNOCKBACK } from './ai.server';
|
|
3
3
|
export type { HitResult, ApplyHitHooks, BattleAiOptions } from './ai.server';
|
|
4
|
-
export type { ActionBattleAnimationContext, ActionBattleAnimationEntity, ActionBattleAnimationKey, ActionBattleAnimationOptions, ActionBattleAnimationResolver, ActionBattleAnimationResult, ActionBattleOptions, ActionBattleActionBarData, ActionBattleActionBarItem, ActionBattleActionBarSkill, ActionBattleSkillTargeting, ActionBattleSkillTargetingResolver, ActionBattleUiOptions, ActionBattleUiActionBarOptions, ActionBattleUiTargetingOptions, } from './types';
|
|
4
|
+
export type { ActionBattleAnimationContext, ActionBattleAnimationEntity, ActionBattleAnimationKey, ActionBattleAnimationOptions, ActionBattleAnimationResolver, ActionBattleAnimationResult, ActionBattleOptions, ActionBattleActionBarData, ActionBattleActionBarItem, ActionBattleActionBarSkill, ActionBattleSkillTargeting, ActionBattleSkillTargetingResolver, ActionBattleAttackOptions, ActionBattleUiOptions, ActionBattleUiActionBarOptions, ActionBattleUiTargetingOptions, ActionBattleCombatOptions, ActionBattleSystemOptions, ActionBattleAiSystemOptions, } from './types';
|
|
5
|
+
export type { ActionBattleAiBehavior, ActionBattleAiContext, ActionBattleAiDecision, ActionBattleAttackContext, ActionBattleCombatSystem, ActionBattleDamageContext, ActionBattleDamageResult, ActionBattleDirection, ActionBattleEntity, ActionBattleHitContext, ActionBattleHitHooks, ActionBattleHitResult, ActionBattleHitbox, ActionBattleKnockbackContext, ActionBattleKnockbackResult, ActionBattleSystems, } from './core/contracts';
|
|
6
|
+
export { DEFAULT_ZELDA_PLAYER_HITBOXES, createDefaultPlayerHitboxResolver, defaultCombatSystem, defaultEnemyBehaviors, defaultKnockbackResolver, defaultRpgjsDamageResolver, } from './core/defaults';
|
|
7
|
+
export { createActionBattleSystems, getActionBattleSystems, } from './core/context';
|
|
8
|
+
export { applyActionBattleHit } from './core/hit';
|
|
9
|
+
export { createActionEnemy, type ActionBattleEnemyPreset, type ActionBattleEnemyPresetMap, } from './enemies/factory';
|
|
5
10
|
export { DEFAULT_PLAYER_ATTACK_HITBOXES, getPlayerWeaponKnockbackForce, applyPlayerHitToEvent, ACTION_BATTLE_ACTION_BAR_GUI_ID, openActionBattleActionBar, updateActionBattleActionBar, createActionBattleServer, } from './server';
|
|
6
|
-
export declare function provideActionBattle(options?: ActionBattleOptions): any;
|
|
11
|
+
export declare function provideActionBattle(options?: ActionBattleOptions): any[];
|
|
7
12
|
declare const _default: {
|
|
8
|
-
server:
|
|
9
|
-
client:
|
|
13
|
+
server: import('@rpgjs/server').RpgServer;
|
|
14
|
+
client: import('@rpgjs/client').RpgClient;
|
|
10
15
|
};
|
|
11
16
|
export default _default;
|
package/dist/server/index.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { DEFAULT_ZELDA_PLAYER_HITBOXES, createDefaultPlayerHitboxResolver, defaultCombatSystem, defaultEnemyBehaviors, defaultKnockbackResolver, defaultRpgjsDamageResolver } from "./index4.js";
|
|
2
|
+
import { createActionBattleSystems, getActionBattleSystems } from "./index5.js";
|
|
3
|
+
import { AiDebug, AiState, AttackPattern, BattleAi, DEFAULT_KNOCKBACK, EnemyType } from "./index6.js";
|
|
4
|
+
import { applyActionBattleHit } from "./index8.js";
|
|
5
|
+
import server_default, { ACTION_BATTLE_ACTION_BAR_GUI_ID, DEFAULT_PLAYER_ATTACK_HITBOXES, applyPlayerHitToEvent, createActionBattleServer, getPlayerWeaponKnockbackForce, openActionBattleActionBar, updateActionBattleActionBar } from "./index9.js";
|
|
6
|
+
import { createActionEnemy } from "./index10.js";
|
|
3
7
|
import { createModule } from "@rpgjs/common";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
var client = null;
|
|
10
|
+
var createActionBattleClient = null;
|
|
7
11
|
function provideActionBattle(options = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
]);
|
|
12
|
+
return createModule("ActionBattle", [{
|
|
13
|
+
server: createActionBattleServer?.(options),
|
|
14
|
+
client: createActionBattleClient?.(options)
|
|
15
|
+
}]);
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
ACTION_BATTLE_ACTION_BAR_GUI_ID,
|
|
21
|
-
AiDebug,
|
|
22
|
-
AiState,
|
|
23
|
-
AttackPattern,
|
|
24
|
-
BattleAi,
|
|
25
|
-
DEFAULT_KNOCKBACK,
|
|
26
|
-
DEFAULT_PLAYER_ATTACK_HITBOXES,
|
|
27
|
-
EnemyType,
|
|
28
|
-
applyPlayerHitToEvent,
|
|
29
|
-
createActionBattleServer,
|
|
30
|
-
index as default,
|
|
31
|
-
getPlayerWeaponKnockbackForce,
|
|
32
|
-
openActionBattleActionBar,
|
|
33
|
-
provideActionBattle,
|
|
34
|
-
updateActionBattleActionBar
|
|
17
|
+
var src_default = {
|
|
18
|
+
server: server_default,
|
|
19
|
+
client
|
|
35
20
|
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ACTION_BATTLE_ACTION_BAR_GUI_ID, AiDebug, AiState, AttackPattern, BattleAi, DEFAULT_KNOCKBACK, DEFAULT_PLAYER_ATTACK_HITBOXES, DEFAULT_ZELDA_PLAYER_HITBOXES, EnemyType, applyActionBattleHit, applyPlayerHitToEvent, createActionBattleServer, createActionBattleSystems, createActionEnemy, createDefaultPlayerHitboxResolver, src_default as default, defaultCombatSystem, defaultEnemyBehaviors, defaultKnockbackResolver, defaultRpgjsDamageResolver, getActionBattleSystems, getPlayerWeaponKnockbackForce, openActionBattleActionBar, provideActionBattle, updateActionBattleActionBar };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BattleAi } from "./index6.js";
|
|
2
|
+
//#region src/enemies/factory.ts
|
|
3
|
+
var createActionEnemy = (event, presetOrOptions, presets = {}) => {
|
|
4
|
+
const options = typeof presetOrOptions === "string" ? presets[presetOrOptions] : presetOrOptions;
|
|
5
|
+
if (!options) throw new Error(`Action battle enemy preset not found: ${presetOrOptions}`);
|
|
6
|
+
options.stats?.(event);
|
|
7
|
+
return new BattleAi(event, options);
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createActionEnemy };
|