@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.
@@ -1,47 +1,64 @@
1
- import { PrebuiltComponentAnimations, inject, RpgGui, RpgClientEngine } from "@rpgjs/client";
2
- import { defineModule } from "@rpgjs/common";
3
- import component$1 from "./index5.js";
4
- import component from "./index6.js";
5
- import { setActionBattleOptions } from "./index7.js";
6
- import { normalizeActionBattleOptions } from "./index8.js";
7
- const createActionBattleClient = (options = {}) => {
8
- const normalized = normalizeActionBattleOptions(options);
9
- setActionBattleOptions(normalized);
10
- const actionBarEnabled = normalized.ui?.actionBar?.enabled;
11
- const targetingEnabled = normalized.ui?.targeting?.enabled;
12
- const hitComponent = PrebuiltComponentAnimations?.Hit;
13
- return defineModule({
14
- componentAnimations: hitComponent ? [
15
- {
16
- id: "hit",
17
- component: hitComponent
18
- }
19
- ] : [],
20
- gui: actionBarEnabled ? [
21
- {
22
- id: "action-battle-action-bar",
23
- component: component$1,
24
- dependencies: () => {
25
- const engine = inject(RpgClientEngine);
26
- return [engine.scene.currentPlayer];
27
- }
28
- }
29
- ] : [],
30
- sprite: {
31
- componentsInFront: targetingEnabled ? [component] : []
32
- },
33
- sceneMap: {
34
- onAfterLoading() {
35
- if (actionBarEnabled && normalized.ui?.actionBar?.autoOpen) {
36
- const gui = inject(RpgGui);
37
- gui.display("action-battle-action-bar");
38
- }
39
- }
40
- }
41
- });
42
- };
43
- const client = createActionBattleClient();
44
- export {
45
- createActionBattleClient,
46
- client as default
1
+ //#region src/config.ts
2
+ var DEFAULT_ACTION_BATTLE_OPTIONS = {
3
+ ui: {
4
+ actionBar: {
5
+ enabled: false,
6
+ autoOpen: false,
7
+ mode: "both"
8
+ },
9
+ targeting: {
10
+ enabled: true,
11
+ showGrid: true,
12
+ colors: {
13
+ area: 3120887,
14
+ edge: 1796760,
15
+ cursor: 16765286
16
+ }
17
+ }
18
+ },
19
+ skills: { defaultAoeMask: ["#"] },
20
+ targeting: {
21
+ affects: "events",
22
+ allowEmptyTarget: true
23
+ },
24
+ animations: {}
47
25
  };
26
+ var currentActionBattleOptions = DEFAULT_ACTION_BATTLE_OPTIONS;
27
+ function normalizeActionBattleOptions(options = {}) {
28
+ return {
29
+ ui: {
30
+ actionBar: {
31
+ ...DEFAULT_ACTION_BATTLE_OPTIONS.ui?.actionBar,
32
+ ...options.ui?.actionBar
33
+ },
34
+ targeting: {
35
+ ...DEFAULT_ACTION_BATTLE_OPTIONS.ui?.targeting,
36
+ ...options.ui?.targeting,
37
+ colors: {
38
+ ...DEFAULT_ACTION_BATTLE_OPTIONS.ui?.targeting?.colors,
39
+ ...options.ui?.targeting?.colors
40
+ }
41
+ }
42
+ },
43
+ skills: {
44
+ ...DEFAULT_ACTION_BATTLE_OPTIONS.skills,
45
+ ...options.skills
46
+ },
47
+ targeting: {
48
+ ...DEFAULT_ACTION_BATTLE_OPTIONS.targeting,
49
+ ...options.targeting
50
+ },
51
+ animations: {
52
+ ...DEFAULT_ACTION_BATTLE_OPTIONS.animations,
53
+ ...options.animations
54
+ }
55
+ };
56
+ }
57
+ function setActionBattleOptions(options) {
58
+ currentActionBattleOptions = options;
59
+ }
60
+ function getActionBattleOptions() {
61
+ return currentActionBattleOptions;
62
+ }
63
+ //#endregion
64
+ export { DEFAULT_ACTION_BATTLE_OPTIONS, getActionBattleOptions, normalizeActionBattleOptions, setActionBattleOptions };