@rpgjs/client 5.0.0-alpha.10 → 5.0.0-alpha.2
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/Game/EffectManager.d.ts +5 -0
- package/dist/RpgClient.d.ts +68 -99
- package/dist/RpgClientEngine.d.ts +4 -86
- package/dist/components/effects/index.d.ts +4 -0
- package/dist/components/index.d.ts +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.js +4 -4
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +2 -6
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +2 -2
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +35 -95
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +186 -45
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +5 -187
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +383 -5
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +28 -384
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +17 -24
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +25 -147
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +2413 -16
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +88 -2395
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +103 -108
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +57 -95
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +12 -62
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +37 -18
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +3 -25
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +314 -87
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +21 -37
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +9 -3
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +2 -2
- package/dist/index30.js +6 -317
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +171 -24
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +497 -7
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +9 -8
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +4400 -9
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +307 -4394
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +85 -310
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +56 -169
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +16 -497
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +10 -51
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +5 -18
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +1 -2
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.js +2 -10
- package/dist/index7.js.map +1 -1
- package/dist/index8.js +6 -24
- package/dist/index8.js.map +1 -1
- package/dist/index9.js +2 -2
- package/dist/presets/index.d.ts +0 -102
- package/dist/services/loadMap.d.ts +2 -123
- package/dist/services/mmorpg.d.ts +3 -7
- package/package.json +12 -14
- package/src/Game/{AnimationManager.ts → EffectManager.ts} +2 -2
- package/src/Game/Object.ts +0 -69
- package/src/RpgClient.ts +67 -101
- package/src/RpgClientEngine.ts +24 -159
- package/src/components/character.ce +33 -74
- package/src/components/{animations → effects}/animation.ce +5 -3
- package/src/components/{animations → effects}/index.ts +1 -1
- package/src/components/index.ts +1 -2
- package/src/components/scenes/draw-map.ce +23 -6
- package/src/components/scenes/element-map.ce +23 -0
- package/src/components/scenes/event-layer.ce +3 -3
- package/src/core/setup.ts +0 -2
- package/src/index.ts +1 -1
- package/src/module.ts +5 -23
- package/src/presets/index.ts +1 -5
- package/src/services/loadMap.ts +2 -131
- package/src/services/mmorpg.ts +4 -20
- package/tsconfig.json +1 -1
- package/vite.config.ts +1 -1
- package/dist/Game/AnimationManager.d.ts +0 -8
- package/dist/components/animations/index.d.ts +0 -4
- package/dist/index40.js +0 -20
- package/dist/index40.js.map +0 -1
- package/dist/index41.js +0 -82
- package/dist/index41.js.map +0 -1
- package/dist/presets/animation.d.ts +0 -31
- package/dist/presets/lpc.d.ts +0 -89
- package/src/presets/animation.ts +0 -46
- package/src/presets/lpc.ts +0 -108
- /package/src/components/{animations → effects}/hit.ce +0 -0
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
<Sprite sheet x y anchor={0.5} />
|
|
2
2
|
|
|
3
3
|
<script>
|
|
4
|
+
import { signal } from "canvasengine";
|
|
4
5
|
import { RpgClientEngine } from "../../RpgClientEngine";
|
|
5
6
|
import { inject } from "../../core/inject";
|
|
6
7
|
|
|
7
|
-
const { x, y,
|
|
8
|
+
const { x, y, name, onFinish } = defineProps();
|
|
8
9
|
|
|
9
10
|
const client = inject(RpgClientEngine);
|
|
10
11
|
const spritesheets = client.spritesheets;
|
|
11
12
|
|
|
12
13
|
const sheet = {
|
|
13
|
-
definition: spritesheets.get(
|
|
14
|
-
playing:
|
|
14
|
+
definition: spritesheets.get(name()),
|
|
15
|
+
playing: 'default',
|
|
15
16
|
onFinish
|
|
16
17
|
};
|
|
18
|
+
|
|
17
19
|
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
<Container sound={backgroundMusic} >
|
|
2
2
|
<Container sound={backgroundAmbientSound} />
|
|
3
3
|
|
|
4
|
-
<
|
|
4
|
+
<!-- <Sprite image={map.@fullImage} scale /> -->
|
|
5
|
+
|
|
6
|
+
<sceneComponent() data={map.@data} />
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
<!-- <Container sortableChildren={true}>
|
|
9
|
+
@for (obj of middleLayer) {
|
|
10
|
+
<ElementMap ...obj image={map.@gridImage} scale />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@for ((event,id) of events) {
|
|
14
|
+
<Character id={id} object={event} isMe={false} />
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@for ((player,id) of players) {
|
|
18
|
+
<Character id={id} object={player} isMe={true} />
|
|
19
|
+
}
|
|
20
|
+
</Container> -->
|
|
21
|
+
|
|
22
|
+
@for (effect of effects) {
|
|
7
23
|
<Container>
|
|
8
|
-
@for (animation of
|
|
9
|
-
<
|
|
24
|
+
@for (animation of effect.current) {
|
|
25
|
+
<effect.component ...animation />
|
|
10
26
|
}
|
|
11
27
|
</Container>
|
|
12
28
|
}
|
|
@@ -18,16 +34,17 @@
|
|
|
18
34
|
import { RpgClientEngine } from "../../RpgClientEngine";
|
|
19
35
|
|
|
20
36
|
const engine = inject(RpgClientEngine);
|
|
21
|
-
const
|
|
37
|
+
const effects = engine.effects
|
|
22
38
|
const map = engine.sceneMap.data
|
|
23
39
|
const sceneComponent = computed(() => map()?.component)
|
|
24
|
-
const sceneParams = map()?.params
|
|
25
40
|
const mapParams = map().params
|
|
26
41
|
const animations = engine.sceneMap.animations
|
|
27
42
|
const backgroundMusic = { src: mapParams?.backgroundMusic, autoplay: true, loop: true }
|
|
28
43
|
const backgroundAmbientSound = { src: mapParams?.backgroundAmbientSound, autoplay: true, loop: true }
|
|
29
44
|
|
|
30
45
|
const data = signal(map().data)
|
|
46
|
+
// const middleLayer = computed(() => data().filter(obj => obj.layer === 1))
|
|
47
|
+
// const topLayer = computed(() => data().filter(obj => obj.layer === 2))
|
|
31
48
|
|
|
32
49
|
const scale = mapParams?.scale || 1
|
|
33
50
|
const worldWidth = (mapParams?.width || 2048) * scale
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<Sprite image rectangle x y zIndex />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
const {
|
|
5
|
+
image,
|
|
6
|
+
rect,
|
|
7
|
+
drawIn,
|
|
8
|
+
id,
|
|
9
|
+
} = defineProps()
|
|
10
|
+
|
|
11
|
+
const rectangle = {
|
|
12
|
+
x: rect[0],
|
|
13
|
+
y: rect[1],
|
|
14
|
+
width: rect[2],
|
|
15
|
+
height: rect[3]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const x = drawIn[0]
|
|
19
|
+
const y = drawIn[1]
|
|
20
|
+
|
|
21
|
+
const zIndex = y + rectangle.height
|
|
22
|
+
</script>
|
|
23
|
+
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<Container sortableChildren={true}>
|
|
2
2
|
@for ((event,id) of events) {
|
|
3
|
-
<Character id={id} object={event} />
|
|
3
|
+
<Character id={id} object={event} isMe={false} />
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
@for ((player,id) of players) {
|
|
7
|
-
<Character id={id} object={player} />
|
|
7
|
+
<Character id={id} object={player} isMe={true} />
|
|
8
8
|
}
|
|
9
9
|
</Container>
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
|
-
import { effect, signal } from 'canvasengine'
|
|
12
|
+
import { effect, signal, computed, mount } from 'canvasengine'
|
|
13
13
|
import { inject } from "../../core/inject";
|
|
14
14
|
import { RpgClientEngine } from "../../RpgClientEngine";
|
|
15
15
|
import Character from "../character.ce";
|
package/src/core/setup.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,6 +8,6 @@ export * from "./services/loadMap";
|
|
|
8
8
|
export * from "./module";
|
|
9
9
|
export * from "./Gui/Gui";
|
|
10
10
|
export * from "./components/gui";
|
|
11
|
-
export * from "./components/
|
|
11
|
+
export * from "./components/effects";
|
|
12
12
|
export * from "./presets";
|
|
13
13
|
export * from "./components";
|
package/src/module.ts
CHANGED
|
@@ -43,12 +43,12 @@ export function provideClientModules(modules: RpgClient[]) {
|
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
if (module.
|
|
47
|
-
const
|
|
48
|
-
module.
|
|
46
|
+
if (module.effects) {
|
|
47
|
+
const effects = [...module.effects];
|
|
48
|
+
module.effects = {
|
|
49
49
|
load: (engine: RpgClientEngine) => {
|
|
50
|
-
|
|
51
|
-
engine.
|
|
50
|
+
effects.forEach((effect) => {
|
|
51
|
+
engine.addEffect(effect);
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
54
|
};
|
|
@@ -63,24 +63,6 @@ export function provideClientModules(modules: RpgClient[]) {
|
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
if (module.sprite) {
|
|
67
|
-
const sprite = {...module.sprite};
|
|
68
|
-
module.sprite = {
|
|
69
|
-
...sprite,
|
|
70
|
-
load: (engine: RpgClientEngine) => {
|
|
71
|
-
if (sprite.componentsBehind) {
|
|
72
|
-
sprite.componentsBehind.forEach((component) => {
|
|
73
|
-
engine.addSpriteComponentBehind(component);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (sprite.componentsInFront) {
|
|
77
|
-
sprite.componentsInFront.forEach((component) => {
|
|
78
|
-
engine.addSpriteComponentInFront(component);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
66
|
return module;
|
|
85
67
|
});
|
|
86
68
|
return modules
|
package/src/presets/index.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { AnimationSpritesheetPreset } from "./animation";
|
|
2
|
-
import { LPCSpritesheetPreset } from "./lpc";
|
|
3
1
|
import { RMSpritesheet } from "./rmspritesheet";
|
|
4
2
|
|
|
5
3
|
export const Presets = {
|
|
6
|
-
RMSpritesheet
|
|
7
|
-
LPCSpritesheetPreset,
|
|
8
|
-
AnimationSpritesheetPreset
|
|
4
|
+
RMSpritesheet
|
|
9
5
|
}
|
package/src/services/loadMap.ts
CHANGED
|
@@ -3,45 +3,12 @@ import { UpdateMapToken, UpdateMapService } from "@rpgjs/common";
|
|
|
3
3
|
|
|
4
4
|
export const LoadMapToken = 'LoadMapToken'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Represents the structure of map data that should be returned by the load map callback.
|
|
8
|
-
* This interface defines all the properties that can be provided when loading a custom map.
|
|
9
|
-
*
|
|
10
|
-
* @interface MapData
|
|
11
|
-
*/
|
|
12
|
-
type MapData = {
|
|
13
|
-
/** Raw map data that will be passed to the map component */
|
|
14
|
-
data: any;
|
|
15
|
-
/** CanvasEngine component that will render the map */
|
|
16
|
-
component: any;
|
|
17
|
-
/** Optional map width in pixels, used for viewport calculations */
|
|
18
|
-
width?: number;
|
|
19
|
-
/** Optional map height in pixels, used for viewport calculations */
|
|
20
|
-
height?: number;
|
|
21
|
-
/** Optional map events data (NPCs, interactive objects, etc.) */
|
|
22
|
-
events?: any;
|
|
23
|
-
/** Optional map identifier, defaults to the mapId parameter if not provided */
|
|
24
|
-
id?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Callback function type for loading map data.
|
|
29
|
-
* This function receives a map ID and should return either a MapData object directly
|
|
30
|
-
* or a Promise that resolves to a MapData object.
|
|
31
|
-
*
|
|
32
|
-
* @callback LoadMapOptions
|
|
33
|
-
* @param {string} mapId - The identifier of the map to load
|
|
34
|
-
* @returns {Promise<MapData> | MapData} The map data object or a promise resolving to it
|
|
35
|
-
*/
|
|
36
|
-
export type LoadMapOptions = (mapId: string) => Promise<MapData> | MapData
|
|
6
|
+
export type LoadMapOptions = (mapId: string) => Promise<void>
|
|
37
7
|
|
|
38
8
|
export class LoadMapService {
|
|
39
9
|
private updateMapService: UpdateMapService;
|
|
40
10
|
|
|
41
11
|
constructor(private context: Context, private options: LoadMapOptions) {
|
|
42
|
-
if (context['side'] === 'server') {
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
12
|
this.updateMapService = inject(context, UpdateMapToken);
|
|
46
13
|
}
|
|
47
14
|
|
|
@@ -52,107 +19,11 @@ export class LoadMapService {
|
|
|
52
19
|
}
|
|
53
20
|
}
|
|
54
21
|
|
|
55
|
-
/**
|
|
56
|
-
* Creates a dependency injection configuration for custom map loading on the client side.
|
|
57
|
-
*
|
|
58
|
-
* This function allows you to customize how maps are loaded and displayed by providing
|
|
59
|
-
* a callback that defines custom map data and rendering components. It's designed to work
|
|
60
|
-
* with the RPG-JS dependency injection system and enables integration of custom map formats
|
|
61
|
-
* like Tiled TMX files or any other map data structure.
|
|
62
|
-
*
|
|
63
|
-
* The function sets up the necessary service providers for map loading, including:
|
|
64
|
-
* - UpdateMapToken: Handles map updates in the client context
|
|
65
|
-
* - LoadMapToken: Provides the LoadMapService with your custom loading logic
|
|
66
|
-
*
|
|
67
|
-
* **Design Concept:**
|
|
68
|
-
* The function follows the provider pattern, creating a modular way to inject custom
|
|
69
|
-
* map loading behavior into the RPG-JS client engine. It separates the concern of
|
|
70
|
-
* map data fetching from map rendering, allowing developers to focus on their specific
|
|
71
|
-
* map format while leveraging the engine's rendering capabilities.
|
|
72
|
-
*
|
|
73
|
-
* @param {LoadMapOptions} options - Callback function that handles map loading logic
|
|
74
|
-
* @returns {Array<Object>} Array of dependency injection provider configurations
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* import { provideLoadMap } from '@rpgjs/client'
|
|
79
|
-
* import { createModule } from '@rpgjs/common'
|
|
80
|
-
* import MyTiledMapComponent from './MyTiledMapComponent.ce'
|
|
81
|
-
*
|
|
82
|
-
* // Basic usage with JSON map data
|
|
83
|
-
* export function provideCustomMap() {
|
|
84
|
-
* return createModule("CustomMap", [
|
|
85
|
-
* provideLoadMap(async (mapId) => {
|
|
86
|
-
* const response = await fetch(`/maps/${mapId}.json`)
|
|
87
|
-
* const mapData = await response.json()
|
|
88
|
-
*
|
|
89
|
-
* return {
|
|
90
|
-
* data: mapData,
|
|
91
|
-
* component: MyTiledMapComponent,
|
|
92
|
-
* width: mapData.width,
|
|
93
|
-
* height: mapData.height,
|
|
94
|
-
* events: mapData.events
|
|
95
|
-
* }
|
|
96
|
-
* })
|
|
97
|
-
* ])
|
|
98
|
-
* }
|
|
99
|
-
*
|
|
100
|
-
* // Advanced usage with Tiled TMX files
|
|
101
|
-
* export function provideTiledMap() {
|
|
102
|
-
* return createModule("TiledMap", [
|
|
103
|
-
* provideLoadMap(async (mapId) => {
|
|
104
|
-
* // Load TMX file
|
|
105
|
-
* const tmxResponse = await fetch(`/tiled/${mapId}.tmx`)
|
|
106
|
-
* const tmxData = await tmxResponse.text()
|
|
107
|
-
*
|
|
108
|
-
* // Parse TMX data (using a TMX parser)
|
|
109
|
-
* const parsedMap = parseTMX(tmxData)
|
|
110
|
-
*
|
|
111
|
-
* return {
|
|
112
|
-
* data: parsedMap,
|
|
113
|
-
* component: TiledMapRenderer,
|
|
114
|
-
* width: parsedMap.width * parsedMap.tilewidth,
|
|
115
|
-
* height: parsedMap.height * parsedMap.tileheight,
|
|
116
|
-
* events: parsedMap.objectGroups?.find(g => g.name === 'events')?.objects
|
|
117
|
-
* }
|
|
118
|
-
* })
|
|
119
|
-
* ])
|
|
120
|
-
* }
|
|
121
|
-
*
|
|
122
|
-
* // Synchronous usage for static maps
|
|
123
|
-
* export function provideStaticMap() {
|
|
124
|
-
* return createModule("StaticMap", [
|
|
125
|
-
* provideLoadMap((mapId) => {
|
|
126
|
-
* const staticMaps = {
|
|
127
|
-
* 'town': { tiles: [...], npcs: [...] },
|
|
128
|
-
* 'dungeon': { tiles: [...], monsters: [...] }
|
|
129
|
-
* }
|
|
130
|
-
*
|
|
131
|
-
* return {
|
|
132
|
-
* data: staticMaps[mapId],
|
|
133
|
-
* component: StaticMapComponent,
|
|
134
|
-
* width: 800,
|
|
135
|
-
* height: 600
|
|
136
|
-
* }
|
|
137
|
-
* })
|
|
138
|
-
* ])
|
|
139
|
-
* }
|
|
140
|
-
* ```
|
|
141
|
-
*
|
|
142
|
-
* @since 4.0.0
|
|
143
|
-
* @see {@link LoadMapOptions} for callback function signature
|
|
144
|
-
* @see {@link MapData} for return data structure
|
|
145
|
-
*/
|
|
146
22
|
export function provideLoadMap(options: LoadMapOptions) {
|
|
147
23
|
return [
|
|
148
24
|
{
|
|
149
25
|
provide: UpdateMapToken,
|
|
150
|
-
useFactory: (context: Context) =>
|
|
151
|
-
if (context['side'] === 'client') {
|
|
152
|
-
console.warn('UpdateMapToken is not overridden')
|
|
153
|
-
}
|
|
154
|
-
return
|
|
155
|
-
},
|
|
26
|
+
useFactory: (context: Context) => console.warn('UpdateMapToken is not overridden'),
|
|
156
27
|
},
|
|
157
28
|
{
|
|
158
29
|
provide: LoadMapToken,
|
package/src/services/mmorpg.ts
CHANGED
|
@@ -6,28 +6,23 @@ import { AbstractWebsocket, WebSocketToken } from "./AbstractSocket";
|
|
|
6
6
|
import { UpdateMapService, UpdateMapToken } from "@rpgjs/common";
|
|
7
7
|
|
|
8
8
|
interface MmorpgOptions {
|
|
9
|
-
host
|
|
9
|
+
host: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
class BridgeWebsocket extends AbstractWebsocket {
|
|
13
13
|
private socket: any;
|
|
14
14
|
|
|
15
|
-
constructor(protected context: Context, private options: MmorpgOptions
|
|
15
|
+
constructor(protected context: Context, private options: MmorpgOptions) {
|
|
16
16
|
super(context);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
async connection(
|
|
19
|
+
async connection() {
|
|
20
20
|
// tmp
|
|
21
21
|
class Room {
|
|
22
22
|
|
|
23
23
|
}
|
|
24
24
|
const instance = new Room()
|
|
25
|
-
this.socket = await connectionRoom(
|
|
26
|
-
host: this.options.host || window.location.host,
|
|
27
|
-
room: "lobby-1",
|
|
28
|
-
}, instance)
|
|
29
|
-
|
|
30
|
-
listeners?.(this.socket)
|
|
25
|
+
this.socket = await connectionRoom(this.options, instance)
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
on(key: string, callback: (data: any) => void) {
|
|
@@ -41,17 +36,6 @@ class BridgeWebsocket extends AbstractWebsocket {
|
|
|
41
36
|
emit(event: string, data: any) {
|
|
42
37
|
this.socket.emit(event, data);
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
updateProperties({ room }: { room: any }) {
|
|
46
|
-
this.socket.conn.updateProperties({
|
|
47
|
-
room: room,
|
|
48
|
-
host: this.options.host
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async reconnect(listeners?: (data: any) => void) {
|
|
53
|
-
this.socket.conn.reconnect()
|
|
54
|
-
}
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
class UpdateMapStandaloneService extends UpdateMapService {
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -24,7 +24,7 @@ export default defineConfig({
|
|
|
24
24
|
fileName: 'index'
|
|
25
25
|
},
|
|
26
26
|
rollupOptions: {
|
|
27
|
-
external: [/@rpgjs/, 'esbuild', 'canvasengine', '@canvasengine/presets', 'rxjs'
|
|
27
|
+
external: [/@rpgjs/, 'esbuild', 'canvasengine', '@canvasengine/presets', 'rxjs'],
|
|
28
28
|
output: {
|
|
29
29
|
preserveModules: true,
|
|
30
30
|
preserveModulesRoot: 'src'
|
package/dist/index40.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useProps, useDefineProps, animatedSignal, h, Container, Rect, Text } from 'canvasengine';
|
|
2
|
-
|
|
3
|
-
function component($$props) {
|
|
4
|
-
useProps($$props);
|
|
5
|
-
const defineProps = useDefineProps($$props);
|
|
6
|
-
var _a = defineProps(), text = _a.text, isSelected = _a.isSelected;
|
|
7
|
-
var alpha = animatedSignal(1, {
|
|
8
|
-
repeatType: "reverse",
|
|
9
|
-
duration: 500,
|
|
10
|
-
repeat: Infinity,
|
|
11
|
-
});
|
|
12
|
-
alpha.set(0.5);
|
|
13
|
-
var height = 40;
|
|
14
|
-
var width = 256;
|
|
15
|
-
let $this = h(Container, null, [h(Rect, { width, height, color: '#595971', alpha, visible: isSelected }), h(Container, { flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }, h(Text, { text, color: '#fff', fontSize: 18, margin: 10 }))]);
|
|
16
|
-
return $this
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { component as default };
|
|
20
|
-
//# sourceMappingURL=index40.js.map
|
package/dist/index40.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index40.js","sources":["../src/components/gui/dialogbox/itemMenu.ce"],"sourcesContent":["<Container>\n <Rect width height color=\"#595971\" alpha visible={isSelected} />\n <Container flexDirection=\"row\" alignItems=\"center\" justifyContent=\"center\">\n <Text text color=\"#fff\" fontSize={18} margin={10} />\n </Container>\n</Container>\n\n<script>\nimport { animatedSignal } from \"canvasengine\";\n\nconst { text, isSelected } = defineProps();\n\nconst alpha = animatedSignal(1, {\n repeatType: \"reverse\",\n duration: 500,\n repeat: Infinity,\n});\n\nalpha.set(0.5);\n\nconst height = 40;\nconst width = 256;\n</script>"],"names":[],"mappings":";;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,EAAE,CAAC,UAAU;AAC1E,IAAI,KAAK,GAAG,cAAc,CAAC,CAAC,EAAE;AAC9B,IAAI,UAAU,EAAE,SAAS;AACzB,IAAI,QAAQ,EAAE,GAAG;AACjB,IAAI,MAAM,EAAE,QAAQ;AACpB,CAAC,CAAC;AACF,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AACd,IAAI,MAAM,GAAG,EAAE;AACf,IAAI,KAAK,GAAG,GAAG;AACf,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACrQ,QAAQ,OAAO;AACf;;;;"}
|
package/dist/index41.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { RpgCommonPlayer } from '@rpgjs/common';
|
|
2
|
-
import { trigger, signal } from 'canvasengine';
|
|
3
|
-
|
|
4
|
-
class RpgClientObject extends RpgCommonPlayer {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.emitParticleTrigger = trigger();
|
|
8
|
-
this.particleName = signal("");
|
|
9
|
-
this.animationCurrentIndex = signal(0);
|
|
10
|
-
this.animationIsPlaying = signal(false);
|
|
11
|
-
}
|
|
12
|
-
flash(color, duration = 100) {
|
|
13
|
-
const lastTint = this.tint();
|
|
14
|
-
this.tint.set(color);
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
this.tint.set(lastTint);
|
|
17
|
-
}, duration);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Reset animation state when animation changes externally
|
|
21
|
-
*
|
|
22
|
-
* This method should be called when the animation changes due to movement
|
|
23
|
-
* or other external factors to ensure the animation system doesn't get stuck
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* // Reset when player starts moving
|
|
28
|
-
* player.resetAnimationState();
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
resetAnimationState() {
|
|
32
|
-
this.animationIsPlaying.set(false);
|
|
33
|
-
this.animationCurrentIndex.set(0);
|
|
34
|
-
if (this.animationSubscription) {
|
|
35
|
-
this.animationSubscription.unsubscribe();
|
|
36
|
-
this.animationSubscription = void 0;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Set a custom animation for a specific number of times
|
|
41
|
-
*
|
|
42
|
-
* Plays a custom animation for the specified number of repetitions.
|
|
43
|
-
* The animation system prevents overlapping animations and automatically
|
|
44
|
-
* returns to the previous animation when complete.
|
|
45
|
-
*
|
|
46
|
-
* @param animationName - Name of the animation to play
|
|
47
|
-
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```ts
|
|
51
|
-
* // Play attack animation 3 times
|
|
52
|
-
* player.setAnimation('attack', 3);
|
|
53
|
-
*
|
|
54
|
-
* // Play continuous spell animation
|
|
55
|
-
* player.setAnimation('spell');
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
setAnimation(animationName, nbTimes = Infinity) {
|
|
59
|
-
if (this.animationIsPlaying()) return;
|
|
60
|
-
this.animationIsPlaying.set(true);
|
|
61
|
-
const previousAnimationName = this.animationName();
|
|
62
|
-
this.animationCurrentIndex.set(0);
|
|
63
|
-
if (this.animationSubscription) {
|
|
64
|
-
this.animationSubscription.unsubscribe();
|
|
65
|
-
}
|
|
66
|
-
this.animationSubscription = this.animationCurrentIndex.observable.subscribe((index) => {
|
|
67
|
-
if (index >= nbTimes) {
|
|
68
|
-
this.animationCurrentIndex.set(0);
|
|
69
|
-
this.animationName.set(previousAnimationName);
|
|
70
|
-
this.animationIsPlaying.set(false);
|
|
71
|
-
if (this.animationSubscription) {
|
|
72
|
-
this.animationSubscription.unsubscribe();
|
|
73
|
-
this.animationSubscription = void 0;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
this.animationName.set(animationName);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { RpgClientObject };
|
|
82
|
-
//# sourceMappingURL=index41.js.map
|
package/dist/index41.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index41.js","sources":["../src/Game/Object.ts"],"sourcesContent":["import { RpgCommonPlayer } from \"@rpgjs/common\";\nimport { trigger, signal } from \"canvasengine\";\nimport { Subscription } from \"rxjs\";\n\nexport abstract class RpgClientObject extends RpgCommonPlayer {\n abstract type: string;\n emitParticleTrigger = trigger()\n particleName = signal('')\n animationCurrentIndex = signal(0)\n animationIsPlaying = signal(false)\n private animationSubscription?: Subscription\n\n flash(color: string, duration: number = 100) {\n const lastTint = this.tint()\n this.tint.set(color);\n setTimeout(() => {\n this.tint.set(lastTint)\n }, duration)\n }\n\n /**\n * Reset animation state when animation changes externally\n * \n * This method should be called when the animation changes due to movement\n * or other external factors to ensure the animation system doesn't get stuck\n * \n * @example\n * ```ts\n * // Reset when player starts moving\n * player.resetAnimationState();\n * ```\n */\n resetAnimationState() {\n this.animationIsPlaying.set(false);\n this.animationCurrentIndex.set(0);\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n }\n\n /**\n * Set a custom animation for a specific number of times\n * \n * Plays a custom animation for the specified number of repetitions.\n * The animation system prevents overlapping animations and automatically\n * returns to the previous animation when complete.\n * \n * @param animationName - Name of the animation to play\n * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)\n * \n * @example\n * ```ts\n * // Play attack animation 3 times\n * player.setAnimation('attack', 3);\n * \n * // Play continuous spell animation\n * player.setAnimation('spell');\n * ```\n */\n setAnimation(animationName: string, nbTimes: number = Infinity) {\n if (this.animationIsPlaying()) return;\n this.animationIsPlaying.set(true);\n const previousAnimationName = this.animationName();\n this.animationCurrentIndex.set(0);\n \n // Clean up any existing subscription\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n }\n \n this.animationSubscription = this.animationCurrentIndex.observable.subscribe(index => {\n if (index >= nbTimes) {\n this.animationCurrentIndex.set(0);\n this.animationName.set(previousAnimationName);\n this.animationIsPlaying.set(false);\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n }\n })\n this.animationName.set(animationName);\n }\n} "],"names":[],"mappings":";;;AAIO,MAAe,wBAAwB,eAAgB,CAAA;AAAA,EAAvD,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEL,IAAA,IAAA,CAAA,mBAAA,GAAsB,OAAQ,EAAA;AAC9B,IAAA,IAAA,CAAA,YAAA,GAAe,OAAO,EAAE,CAAA;AACxB,IAAA,IAAA,CAAA,qBAAA,GAAwB,OAAO,CAAC,CAAA;AAChC,IAAA,IAAA,CAAA,kBAAA,GAAqB,OAAO,KAAK,CAAA;AAAA;AAAA,EAGjC,KAAA,CAAM,KAAe,EAAA,QAAA,GAAmB,GAAK,EAAA;AAC3C,IAAM,MAAA,QAAA,GAAW,KAAK,IAAK,EAAA;AAC3B,IAAK,IAAA,CAAA,IAAA,CAAK,IAAI,KAAK,CAAA;AACnB,IAAA,UAAA,CAAW,MAAM;AACf,MAAK,IAAA,CAAA,IAAA,CAAK,IAAI,QAAQ,CAAA;AAAA,OACrB,QAAQ,CAAA;AAAA;AACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,mBAAsB,GAAA;AACpB,IAAK,IAAA,CAAA,kBAAA,CAAmB,IAAI,KAAK,CAAA;AACjC,IAAK,IAAA,CAAA,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAChC,IAAA,IAAI,KAAK,qBAAuB,EAAA;AAC9B,MAAA,IAAA,CAAK,sBAAsB,WAAY,EAAA;AACvC,MAAA,IAAA,CAAK,qBAAwB,GAAA,MAAA;AAAA;AAC/B;AACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,YAAA,CAAa,aAAuB,EAAA,OAAA,GAAkB,QAAU,EAAA;AAC9D,IAAI,IAAA,IAAA,CAAK,oBAAsB,EAAA;AAC/B,IAAK,IAAA,CAAA,kBAAA,CAAmB,IAAI,IAAI,CAAA;AAChC,IAAM,MAAA,qBAAA,GAAwB,KAAK,aAAc,EAAA;AACjD,IAAK,IAAA,CAAA,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAGhC,IAAA,IAAI,KAAK,qBAAuB,EAAA;AAC9B,MAAA,IAAA,CAAK,sBAAsB,WAAY,EAAA;AAAA;AAGzC,IAAA,IAAA,CAAK,qBAAwB,GAAA,IAAA,CAAK,qBAAsB,CAAA,UAAA,CAAW,UAAU,CAAS,KAAA,KAAA;AACpF,MAAA,IAAI,SAAS,OAAS,EAAA;AACpB,QAAK,IAAA,CAAA,qBAAA,CAAsB,IAAI,CAAC,CAAA;AAChC,QAAK,IAAA,CAAA,aAAA,CAAc,IAAI,qBAAqB,CAAA;AAC5C,QAAK,IAAA,CAAA,kBAAA,CAAmB,IAAI,KAAK,CAAA;AACjC,QAAA,IAAI,KAAK,qBAAuB,EAAA;AAC9B,UAAA,IAAA,CAAK,sBAAsB,WAAY,EAAA;AACvC,UAAA,IAAA,CAAK,qBAAwB,GAAA,MAAA;AAAA;AAC/B;AACF,KACD,CAAA;AACD,IAAK,IAAA,CAAA,aAAA,CAAc,IAAI,aAAa,CAAA;AAAA;AAExC;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an animation spritesheet preset with automatic frame generation
|
|
3
|
-
*
|
|
4
|
-
* This function generates animation frames based on the provided width and height dimensions.
|
|
5
|
-
* It creates a sequence of frames that progresses through the spritesheet from left to right,
|
|
6
|
-
* top to bottom, with each frame having a 10ms time increment.
|
|
7
|
-
*
|
|
8
|
-
* @param {number} framesWidth - The number of frames horizontally in the spritesheet
|
|
9
|
-
* @param {number} framesHeight - The number of frames vertically in the spritesheet
|
|
10
|
-
* @returns {Object} Animation preset configuration object
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```javascript
|
|
14
|
-
* // For a 4x4 spritesheet
|
|
15
|
-
* const preset = AnimationSpritesheetPreset(4, 4);
|
|
16
|
-
* // This will generate 16 frames with coordinates from (0,0) to (3,3)
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare const AnimationSpritesheetPreset: (framesWidth: number, framesHeight: number) => {
|
|
20
|
-
framesWidth: number;
|
|
21
|
-
framesHeight: number;
|
|
22
|
-
textures: {
|
|
23
|
-
default: {
|
|
24
|
-
animations: () => {
|
|
25
|
-
time: number;
|
|
26
|
-
frameX: number;
|
|
27
|
-
frameY: number;
|
|
28
|
-
}[][];
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|