@rpgjs/client 4.3.0 → 5.0.0-alpha.1

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.
Files changed (323) hide show
  1. package/dist/Game/EffectManager.d.ts +5 -0
  2. package/dist/Game/Event.d.ts +4 -0
  3. package/dist/Game/Map.d.ts +7 -0
  4. package/dist/Game/Player.d.ts +4 -0
  5. package/dist/Gui/Gui.d.ts +23 -0
  6. package/{lib → dist}/RpgClient.d.ts +9 -6
  7. package/dist/RpgClientEngine.d.ts +43 -0
  8. package/dist/components/effects/index.d.ts +4 -0
  9. package/dist/components/gui/index.d.ts +3 -0
  10. package/dist/components/index.d.ts +2 -0
  11. package/dist/core/inject.d.ts +5 -0
  12. package/dist/core/setup.d.ts +6 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.js +13 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/index10.js +8 -0
  17. package/dist/index10.js.map +1 -0
  18. package/dist/index11.js +10 -0
  19. package/dist/index11.js.map +1 -0
  20. package/dist/index12.js +8 -0
  21. package/dist/index12.js.map +1 -0
  22. package/dist/index13.js +17 -0
  23. package/dist/index13.js.map +1 -0
  24. package/dist/index14.js +50 -0
  25. package/dist/index14.js.map +1 -0
  26. package/dist/index15.js +191 -0
  27. package/dist/index15.js.map +1 -0
  28. package/dist/index16.js +9 -0
  29. package/dist/index16.js.map +1 -0
  30. package/dist/index17.js +387 -0
  31. package/dist/index17.js.map +1 -0
  32. package/dist/index18.js +31 -0
  33. package/dist/index18.js.map +1 -0
  34. package/dist/index19.js +24 -0
  35. package/dist/index19.js.map +1 -0
  36. package/dist/index2.js +112 -0
  37. package/dist/index2.js.map +1 -0
  38. package/dist/index20.js +2421 -0
  39. package/dist/index20.js.map +1 -0
  40. package/dist/index21.js +114 -0
  41. package/dist/index21.js.map +1 -0
  42. package/dist/index22.js +109 -0
  43. package/dist/index22.js.map +1 -0
  44. package/dist/index23.js +71 -0
  45. package/dist/index23.js.map +1 -0
  46. package/dist/index24.js +21 -0
  47. package/dist/index24.js.map +1 -0
  48. package/dist/index25.js +41 -0
  49. package/dist/index25.js.map +1 -0
  50. package/dist/index26.js +5 -0
  51. package/dist/index26.js.map +1 -0
  52. package/dist/index27.js +322 -0
  53. package/dist/index27.js.map +1 -0
  54. package/dist/index28.js +25 -0
  55. package/dist/index28.js.map +1 -0
  56. package/dist/index29.js +11 -0
  57. package/dist/index29.js.map +1 -0
  58. package/dist/index3.js +87 -0
  59. package/dist/index3.js.map +1 -0
  60. package/dist/index30.js +11 -0
  61. package/dist/index30.js.map +1 -0
  62. package/dist/index31.js +174 -0
  63. package/dist/index31.js.map +1 -0
  64. package/dist/index32.js +501 -0
  65. package/dist/index32.js.map +1 -0
  66. package/dist/index33.js +12 -0
  67. package/dist/index33.js.map +1 -0
  68. package/dist/index34.js +4403 -0
  69. package/dist/index34.js.map +1 -0
  70. package/dist/index35.js +316 -0
  71. package/dist/index35.js.map +1 -0
  72. package/dist/index36.js +61 -0
  73. package/dist/index36.js.map +1 -0
  74. package/dist/index37.js +91 -0
  75. package/dist/index37.js.map +1 -0
  76. package/dist/index38.js +20 -0
  77. package/dist/index38.js.map +1 -0
  78. package/dist/index39.js +20 -0
  79. package/dist/index39.js.map +1 -0
  80. package/dist/index4.js +54 -0
  81. package/dist/index4.js.map +1 -0
  82. package/dist/index5.js +15 -0
  83. package/dist/index5.js.map +1 -0
  84. package/dist/index6.js +17 -0
  85. package/dist/index6.js.map +1 -0
  86. package/dist/index7.js +31 -0
  87. package/dist/index7.js.map +1 -0
  88. package/dist/index8.js +90 -0
  89. package/dist/index8.js.map +1 -0
  90. package/dist/index9.js +76 -0
  91. package/dist/index9.js.map +1 -0
  92. package/dist/module.d.ts +14 -0
  93. package/dist/presets/index.d.ts +22 -0
  94. package/{lib/Presets/AnimationSpritesheet.d.ts → dist/presets/rmspritesheet.d.ts} +6 -2
  95. package/dist/services/AbstractSocket.d.ts +15 -0
  96. package/dist/services/loadMap.d.ts +14 -0
  97. package/dist/services/mmorpg.d.ts +32 -0
  98. package/dist/services/standalone.d.ts +34 -0
  99. package/package.json +25 -41
  100. package/src/Game/EffectManager.ts +20 -0
  101. package/src/Game/Event.ts +5 -0
  102. package/src/Game/Map.ts +10 -0
  103. package/src/Game/Object.ts +16 -0
  104. package/src/Game/Player.ts +5 -0
  105. package/src/Gui/Gui.ts +80 -533
  106. package/src/RpgClient.ts +9 -5
  107. package/src/RpgClientEngine.ts +135 -818
  108. package/src/components/character.ce +104 -0
  109. package/src/components/effects/animation.ce +19 -0
  110. package/src/components/effects/hit.ce +87 -0
  111. package/src/components/effects/index.ts +7 -0
  112. package/src/components/gui/dialogbox/index.ce +194 -0
  113. package/src/components/gui/dialogbox/itemMenu.ce +23 -0
  114. package/src/components/gui/dialogbox/selection.ce +67 -0
  115. package/src/components/gui/index.ts +5 -0
  116. package/src/components/index.ts +3 -0
  117. package/src/components/scenes/canvas.ce +51 -0
  118. package/src/components/scenes/draw-map.ce +56 -0
  119. package/src/components/scenes/element-map.ce +23 -0
  120. package/src/components/scenes/event-layer.ce +20 -0
  121. package/src/core/inject.ts +17 -0
  122. package/src/core/setup.ts +18 -0
  123. package/src/index.ts +13 -29
  124. package/src/module.ts +93 -0
  125. package/src/presets/index.ts +5 -0
  126. package/src/{Presets/AnimationSpritesheet.ts → presets/rmspritesheet.ts} +4 -5
  127. package/src/services/AbstractSocket.ts +14 -0
  128. package/src/services/loadMap.ts +33 -0
  129. package/src/services/mmorpg.ts +64 -0
  130. package/src/services/standalone.ts +101 -0
  131. package/src/types/canvas-engine.d.ts +26 -0
  132. package/tsconfig.json +8 -3
  133. package/vite.config.ts +34 -0
  134. package/CHANGELOG.md +0 -189
  135. package/LICENSE +0 -19
  136. package/browser/React-ece4b906.js +0 -195
  137. package/browser/index-ba657126.js +0 -44229
  138. package/browser/manifest.json +0 -21
  139. package/browser/rpg.client.js +0 -40
  140. package/browser/rpg.client.umd.cjs +0 -44456
  141. package/lib/Components/AbstractComponent.d.ts +0 -32
  142. package/lib/Components/AbstractComponent.js +0 -93
  143. package/lib/Components/AbstractComponent.js.map +0 -1
  144. package/lib/Components/BarComponent.d.ts +0 -21
  145. package/lib/Components/BarComponent.js +0 -169
  146. package/lib/Components/BarComponent.js.map +0 -1
  147. package/lib/Components/Component.d.ts +0 -124
  148. package/lib/Components/Component.js +0 -425
  149. package/lib/Components/Component.js.map +0 -1
  150. package/lib/Components/DebugComponent.d.ts +0 -11
  151. package/lib/Components/DebugComponent.js +0 -32
  152. package/lib/Components/DebugComponent.js.map +0 -1
  153. package/lib/Components/ImageComponent.d.ts +0 -11
  154. package/lib/Components/ImageComponent.js +0 -30
  155. package/lib/Components/ImageComponent.js.map +0 -1
  156. package/lib/Components/ShapeComponent.d.ts +0 -11
  157. package/lib/Components/ShapeComponent.js +0 -57
  158. package/lib/Components/ShapeComponent.js.map +0 -1
  159. package/lib/Components/TextComponent.d.ts +0 -11
  160. package/lib/Components/TextComponent.js +0 -35
  161. package/lib/Components/TextComponent.js.map +0 -1
  162. package/lib/Components/TileComponent.d.ts +0 -10
  163. package/lib/Components/TileComponent.js +0 -40
  164. package/lib/Components/TileComponent.js.map +0 -1
  165. package/lib/Effects/Animation.d.ts +0 -55
  166. package/lib/Effects/Animation.js +0 -233
  167. package/lib/Effects/Animation.js.map +0 -1
  168. package/lib/Effects/AnimationCharacter.d.ts +0 -7
  169. package/lib/Effects/AnimationCharacter.js +0 -9
  170. package/lib/Effects/AnimationCharacter.js.map +0 -1
  171. package/lib/Effects/Spinner.d.ts +0 -7
  172. package/lib/Effects/Spinner.js +0 -18
  173. package/lib/Effects/Spinner.js.map +0 -1
  174. package/lib/Effects/Timeline.d.ts +0 -151
  175. package/lib/Effects/Timeline.js +0 -369
  176. package/lib/Effects/Timeline.js.map +0 -1
  177. package/lib/Effects/TransitionScene.d.ts +0 -18
  178. package/lib/Effects/TransitionScene.js +0 -50
  179. package/lib/Effects/TransitionScene.js.map +0 -1
  180. package/lib/GameEngine.d.ts +0 -68
  181. package/lib/GameEngine.js +0 -254
  182. package/lib/GameEngine.js.map +0 -1
  183. package/lib/Gui/Gui.d.ts +0 -110
  184. package/lib/Gui/Gui.js +0 -489
  185. package/lib/Gui/Gui.js.map +0 -1
  186. package/lib/Gui/React.d.ts +0 -28
  187. package/lib/Gui/React.js +0 -147
  188. package/lib/Gui/React.js.map +0 -1
  189. package/lib/Gui/Vue.d.ts +0 -13
  190. package/lib/Gui/Vue.js +0 -114
  191. package/lib/Gui/Vue.js.map +0 -1
  192. package/lib/Interfaces/Character.d.ts +0 -6
  193. package/lib/Interfaces/Character.js +0 -2
  194. package/lib/Interfaces/Character.js.map +0 -1
  195. package/lib/Interfaces/Scene.d.ts +0 -10
  196. package/lib/Interfaces/Scene.js +0 -2
  197. package/lib/Interfaces/Scene.js.map +0 -1
  198. package/lib/KeyboardControls.d.ts +0 -367
  199. package/lib/KeyboardControls.js +0 -714
  200. package/lib/KeyboardControls.js.map +0 -1
  201. package/lib/Logger.d.ts +0 -1
  202. package/lib/Logger.js +0 -4
  203. package/lib/Logger.js.map +0 -1
  204. package/lib/Presets/AnimationSpritesheet.js +0 -39
  205. package/lib/Presets/AnimationSpritesheet.js.map +0 -1
  206. package/lib/Presets/Scene.d.ts +0 -3
  207. package/lib/Presets/Scene.js +0 -5
  208. package/lib/Presets/Scene.js.map +0 -1
  209. package/lib/Renderer.d.ts +0 -62
  210. package/lib/Renderer.js +0 -300
  211. package/lib/Renderer.js.map +0 -1
  212. package/lib/Resources.d.ts +0 -22
  213. package/lib/Resources.js +0 -38
  214. package/lib/Resources.js.map +0 -1
  215. package/lib/RpgClient.js +0 -2
  216. package/lib/RpgClient.js.map +0 -1
  217. package/lib/RpgClientEngine.d.ts +0 -257
  218. package/lib/RpgClientEngine.js +0 -677
  219. package/lib/RpgClientEngine.js.map +0 -1
  220. package/lib/Scene/EventLayer.d.ts +0 -4
  221. package/lib/Scene/EventLayer.js +0 -8
  222. package/lib/Scene/EventLayer.js.map +0 -1
  223. package/lib/Scene/Map.d.ts +0 -109
  224. package/lib/Scene/Map.js +0 -319
  225. package/lib/Scene/Map.js.map +0 -1
  226. package/lib/Scene/Scene.d.ts +0 -184
  227. package/lib/Scene/Scene.js +0 -250
  228. package/lib/Scene/Scene.js.map +0 -1
  229. package/lib/Scene/SceneData.d.ts +0 -4
  230. package/lib/Scene/SceneData.js +0 -8
  231. package/lib/Scene/SceneData.js.map +0 -1
  232. package/lib/Sound/RpgSound.d.ts +0 -11
  233. package/lib/Sound/RpgSound.js +0 -46
  234. package/lib/Sound/RpgSound.js.map +0 -1
  235. package/lib/Sound/Sound.d.ts +0 -78
  236. package/lib/Sound/Sound.js +0 -12
  237. package/lib/Sound/Sound.js.map +0 -1
  238. package/lib/Sound/Sounds.d.ts +0 -2
  239. package/lib/Sound/Sounds.js +0 -6
  240. package/lib/Sound/Sounds.js.map +0 -1
  241. package/lib/Sprite/Character.d.ts +0 -18
  242. package/lib/Sprite/Character.js +0 -131
  243. package/lib/Sprite/Character.js.map +0 -1
  244. package/lib/Sprite/Player.d.ts +0 -3
  245. package/lib/Sprite/Player.js +0 -4
  246. package/lib/Sprite/Player.js.map +0 -1
  247. package/lib/Sprite/Spritesheet.d.ts +0 -365
  248. package/lib/Sprite/Spritesheet.js +0 -13
  249. package/lib/Sprite/Spritesheet.js.map +0 -1
  250. package/lib/Sprite/Spritesheets.d.ts +0 -3
  251. package/lib/Sprite/Spritesheets.js +0 -6
  252. package/lib/Sprite/Spritesheets.js.map +0 -1
  253. package/lib/Tilemap/CommonLayer.d.ts +0 -10
  254. package/lib/Tilemap/CommonLayer.js +0 -17
  255. package/lib/Tilemap/CommonLayer.js.map +0 -1
  256. package/lib/Tilemap/ImageLayer.d.ts +0 -4
  257. package/lib/Tilemap/ImageLayer.js +0 -16
  258. package/lib/Tilemap/ImageLayer.js.map +0 -1
  259. package/lib/Tilemap/Tile.d.ts +0 -21
  260. package/lib/Tilemap/Tile.js +0 -67
  261. package/lib/Tilemap/Tile.js.map +0 -1
  262. package/lib/Tilemap/TileLayer.d.ts +0 -13
  263. package/lib/Tilemap/TileLayer.js +0 -122
  264. package/lib/Tilemap/TileLayer.js.map +0 -1
  265. package/lib/Tilemap/TileSet.d.ts +0 -7
  266. package/lib/Tilemap/TileSet.js +0 -24
  267. package/lib/Tilemap/TileSet.js.map +0 -1
  268. package/lib/Tilemap/index.d.ts +0 -28
  269. package/lib/Tilemap/index.js +0 -151
  270. package/lib/Tilemap/index.js.map +0 -1
  271. package/lib/clientEntryPoint.d.ts +0 -89
  272. package/lib/clientEntryPoint.js +0 -48
  273. package/lib/clientEntryPoint.js.map +0 -1
  274. package/lib/index.d.ts +0 -26
  275. package/lib/index.js +0 -27
  276. package/lib/index.js.map +0 -1
  277. package/lib/inject.d.ts +0 -23
  278. package/lib/inject.js +0 -30
  279. package/lib/inject.js.map +0 -1
  280. package/rpg.toml +0 -14
  281. package/src/Components/AbstractComponent.ts +0 -120
  282. package/src/Components/BarComponent.ts +0 -181
  283. package/src/Components/Component.ts +0 -515
  284. package/src/Components/DebugComponent.ts +0 -36
  285. package/src/Components/ImageComponent.ts +0 -30
  286. package/src/Components/ShapeComponent.ts +0 -64
  287. package/src/Components/TextComponent.ts +0 -33
  288. package/src/Components/TileComponent.ts +0 -43
  289. package/src/Effects/Animation.ts +0 -310
  290. package/src/Effects/AnimationCharacter.ts +0 -7
  291. package/src/Effects/Spinner.ts +0 -19
  292. package/src/Effects/Timeline.ts +0 -378
  293. package/src/Effects/TransitionScene.ts +0 -59
  294. package/src/GameEngine.ts +0 -289
  295. package/src/Gui/React.ts +0 -193
  296. package/src/Gui/Vue.ts +0 -154
  297. package/src/Interfaces/Character.ts +0 -7
  298. package/src/Interfaces/Scene.ts +0 -9
  299. package/src/KeyboardControls.ts +0 -748
  300. package/src/Logger.ts +0 -3
  301. package/src/Presets/Scene.ts +0 -3
  302. package/src/Renderer.ts +0 -334
  303. package/src/Resources.ts +0 -39
  304. package/src/Scene/EventLayer.ts +0 -9
  305. package/src/Scene/Map.ts +0 -402
  306. package/src/Scene/Scene.ts +0 -305
  307. package/src/Scene/SceneData.ts +0 -13
  308. package/src/Sound/RpgSound.ts +0 -50
  309. package/src/Sound/Sound.ts +0 -91
  310. package/src/Sound/Sounds.ts +0 -7
  311. package/src/Sprite/Character.ts +0 -157
  312. package/src/Sprite/Player.ts +0 -3
  313. package/src/Sprite/Spritesheet.ts +0 -392
  314. package/src/Sprite/Spritesheets.ts +0 -8
  315. package/src/Tilemap/CommonLayer.ts +0 -20
  316. package/src/Tilemap/ImageLayer.ts +0 -20
  317. package/src/Tilemap/Tile.ts +0 -80
  318. package/src/Tilemap/TileLayer.ts +0 -142
  319. package/src/Tilemap/TileSet.ts +0 -40
  320. package/src/Tilemap/index.ts +0 -175
  321. package/src/clientEntryPoint.ts +0 -150
  322. package/src/inject.ts +0 -34
  323. package/src/types/howler.d.ts +0 -73
@@ -1,13 +0,0 @@
1
- export interface SceneDataOptions {
2
- inputs?: {
3
-
4
- }
5
- }
6
-
7
- export function SceneData(options) {
8
- return (target) => {
9
- for (let key in options) {
10
- target.prototype[key] = options[key]
11
- }
12
- }
13
- }
@@ -1,50 +0,0 @@
1
- import { Howl, Howler } from 'howler'
2
- import { log } from '../Logger'
3
- import { sounds } from './Sounds'
4
-
5
- class RpgSoundClass {
6
- private sounds: Map<string, Howl> = new Map()
7
-
8
- get(id: string): Howl {
9
- if (this.sounds.has(id)) {
10
- return this.sounds.get(id) as Howl
11
- }
12
- const resource = sounds.get(id)
13
- if (!resource) {
14
- throw log(`Impossible to find the ${id} sound. Did you put the right name or create the sound?`)
15
- }
16
- const howl = new Howl({
17
- src: [resource.sound],
18
- loop: resource.loop,
19
- autoplay: resource.autoplay,
20
- volume: resource.volume,
21
- sprite: resource.sprite
22
- })
23
- this.sounds.set(id, howl)
24
- return howl
25
- }
26
-
27
- stop(id: string) {
28
- this.get(id).stop()
29
- }
30
-
31
- play(id: string): boolean {
32
- const sound = this.get(id)
33
- if (!sound.playing()) {
34
- sound.play()
35
- return true
36
- }
37
- return false
38
- }
39
-
40
- clear() {
41
- this.sounds.clear()
42
- this.global.stop()
43
- }
44
-
45
- get global(): typeof Howler {
46
- return Howler
47
- }
48
- }
49
-
50
- export const RpgSound = new RpgSoundClass()
@@ -1,91 +0,0 @@
1
- interface SoundOptions {
2
- /**
3
- * The link to the sound
4
- *
5
- * > Do not use the `images` property
6
- * > Remember to wrap the link to the image with the `require` function.
7
- *
8
- * ```ts
9
- * sound: require('./assets/sound.ogg')
10
- * ```
11
- *
12
- * @prop {string} [sound]
13
- * @memberof Sound
14
- * */
15
- sound?: string
16
-
17
- /**
18
- * The sound will restart at the beginning when it is finished.
19
- *
20
- * @prop {boolean} [loop]
21
- * @memberof Sound
22
- * */
23
- loop?: boolean,
24
-
25
- /**
26
- * Volume
27
- *
28
- * @prop {number} [volume]
29
- * @memberof Sound
30
- * */
31
- volume?: number
32
- }
33
-
34
- type SoundIdOptions = SoundOptions & {
35
- /**
36
- * Sound identifier.
37
- *
38
- * > Do not use the `sounds` property
39
- *
40
- * @prop {string} [id]
41
- * @memberof Sound
42
- * */
43
- id: string
44
-
45
- /**
46
- * The link to the sound
47
- *
48
- * > Do not use the `images` property
49
- * > Remember to wrap the link to the image with the `require` function.
50
- *
51
- * ```ts
52
- * sound: require('./assets/sound.ogg')
53
- * ```
54
- *
55
- * @prop {string} [sound]
56
- * @memberof Sound
57
- * */
58
- sound: string
59
- }
60
- type SoundIdsOptions = SoundOptions & {
61
- /**
62
- * Put the different sounds that are concerned by the properties below.
63
- * The key of the object is the identifier of the sound and the value and the link to the sound.
64
- *
65
- * > Remember to wrap the link to the sound with the `require` function.
66
- *
67
- * ```ts
68
- * sounds: {
69
- * hero: require('./assets/sound.ogg')
70
- * }
71
- * ```
72
- *
73
- * @prop { { [id: string]: string } } [sounds]
74
- * @memberof Sound
75
- * */
76
- sounds?: {
77
- [id: string]: string
78
- }
79
- }
80
-
81
- export function Sound(options: SoundIdOptions)
82
- export function Sound(options: SoundIdsOptions)
83
- export function Sound(options: SoundIdOptions | SoundIdsOptions) {
84
- return (target: Function) => {
85
- if ('sounds' in options) target['sounds'] = options.sounds
86
- if ('id' in options) target['id'] = options.id
87
- for (let key in options) {
88
- target.prototype[key] = options[key]
89
- }
90
- }
91
- }
@@ -1,7 +0,0 @@
1
- import { _initResource } from '../Resources'
2
-
3
- export const sounds = new Map()
4
-
5
- export function _initSound(_sounds, engine) {
6
- return _initResource(sounds, _sounds, 'sound', engine)
7
- }
@@ -1,157 +0,0 @@
1
- import { Utils, RpgPlugin, HookClient } from '@rpgjs/common'
2
- import { spritesheets } from './Spritesheets'
3
- import { Animation } from '../Effects/Animation'
4
- import { Animation as AnimationEnum } from '../Effects/AnimationCharacter'
5
- import { RpgComponent } from '../Components/Component'
6
- import { TransformOptions } from './Spritesheet'
7
- import { Sprite } from 'pixi.js'
8
-
9
- const { capitalize } = Utils
10
-
11
- export default class Character extends Sprite {
12
- static readonly id: string = 'graphic'
13
-
14
- private spritesheet: any
15
- private playStandardAnimation: boolean = true
16
- public animation: Animation
17
- private objSaved: object = {}
18
- private data: any = {}
19
-
20
- /** @internal */
21
- h: number = 1
22
- /** @internal */
23
- w: number = 1
24
-
25
- /** @internal */
26
- anim: Animation
27
-
28
- constructor(private component: RpgComponent, private graphic: string) {
29
- super()
30
- this.data = component.logic
31
- this.setGraphic(graphic)
32
- }
33
-
34
- /** @internal */
35
- showAnimation(graphic: string | string[], animationName: string): Animation | null {
36
- const refreshAnimation = (graphic: string) => {
37
- this.removeChild(this.animation)
38
- this.animation = new Animation(graphic)
39
- this.addChild(this.animation)
40
- this.setAnimationAnchor()
41
- }
42
- const memoryGraphic = this.graphic
43
- let graphicId: string | undefined = ''
44
-
45
- // Changes only graphics already defined on the character
46
- if (Utils.isArray(graphic)) {
47
- graphicId = (graphic as string[]).find(id => id == this.graphic)
48
- }
49
- else {
50
- graphicId = graphic as string
51
- }
52
-
53
- if (!graphicId) {
54
- return null
55
- }
56
-
57
- refreshAnimation(graphicId)
58
-
59
- this.component.animationIsPlaying = true
60
-
61
- this.animation.onFinish = () => {
62
- this.playStandardAnimation = true
63
- this.component.animationIsPlaying = false
64
- refreshAnimation(memoryGraphic)
65
- this.update(this.objSaved)
66
- }
67
-
68
- this.playStandardAnimation = false
69
- this.playAnimation(animationName)
70
- return this.animation
71
- }
72
-
73
- /** @internal */
74
- setGraphic(graphic: string) {
75
- (this.children as Animation[]).forEach((graphic: Animation, index: number) => {
76
- if (graphic.id == this.graphic) {
77
- this.removeChildAt(index)
78
- }
79
- })
80
- this.graphic = graphic
81
- this.spritesheet = spritesheets.get(this.graphic)
82
- this.animation = new Animation(this.graphic)
83
- this.addChild(this.animation)
84
- this.setAnimationAnchor()
85
- }
86
-
87
- getGraphicHeight(): number {
88
- return this.animation.getSpriteHeight()
89
- }
90
-
91
- getGraphicWidth(): number {
92
- return this.animation.getSpriteWidth()
93
- }
94
-
95
- animationSprite() {
96
- return this.animation.animation$
97
- }
98
-
99
- private setAnimationAnchor(): void {
100
- this.animation.hitbox = { h: this.data.hHitbox, w: this.data.wHitbox }
101
- this.animation.applyTransform = (frame, animation, spritesheet) => {
102
- const { spriteWidth, spriteHeight } = animation
103
- const prop: keyof TransformOptions = 'spriteRealSize'
104
- const currentAnchor = frame[prop] || animation[prop] || spritesheet[prop]
105
- if (currentAnchor) {
106
- return {}
107
- }
108
- return {
109
- spriteRealSize: {
110
- width: spriteWidth,
111
- height: spriteHeight
112
- }
113
- }
114
- }
115
- }
116
-
117
- /** @internal */
118
- update(obj, options: any = {}, deltaRatio: number = 1): {
119
- moving: boolean
120
- instance: Character
121
- } {
122
- const { moving } = options
123
- this.data = obj
124
- if (this.anim) this.anim.update(deltaRatio)
125
- if (this.animation) this.animation.update(deltaRatio)
126
-
127
- if (this.playStandardAnimation) {
128
- if (moving) {
129
- RpgPlugin.emit(HookClient.SpriteMove, this)
130
- this.playAnimation(AnimationEnum.Walk)
131
- }
132
- else {
133
- this.playAnimation(AnimationEnum.Stand)
134
- }
135
- }
136
-
137
- this.objSaved = obj
138
-
139
- return {
140
- moving,
141
- instance: this
142
- }
143
- }
144
-
145
- /** @internal */
146
- playAnimation(name: string) {
147
- const hook = `onCharacter${capitalize(name)}`
148
- if (!this.spritesheet) return
149
- if (this.spritesheet[hook]) {
150
- this.spritesheet[hook](this)
151
- }
152
- else if (this.animation.has(name)) {
153
- this.animation.play(name, [this.data.direction])
154
- }
155
- }
156
-
157
- }
@@ -1,3 +0,0 @@
1
- import Character from './Character'
2
-
3
- export class RpgSprite extends Character {}