@rpgjs/client 4.3.0 → 5.0.0-alpha.0

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 (321) 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 +91 -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 +20 -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/index4.js +54 -0
  79. package/dist/index4.js.map +1 -0
  80. package/dist/index5.js +15 -0
  81. package/dist/index5.js.map +1 -0
  82. package/dist/index6.js +17 -0
  83. package/dist/index6.js.map +1 -0
  84. package/dist/index7.js +31 -0
  85. package/dist/index7.js.map +1 -0
  86. package/dist/index8.js +90 -0
  87. package/dist/index8.js.map +1 -0
  88. package/dist/index9.js +76 -0
  89. package/dist/index9.js.map +1 -0
  90. package/dist/module.d.ts +14 -0
  91. package/dist/presets/index.d.ts +22 -0
  92. package/{lib/Presets/AnimationSpritesheet.d.ts → dist/presets/rmspritesheet.d.ts} +6 -2
  93. package/dist/services/AbstractSocket.d.ts +15 -0
  94. package/dist/services/loadMap.d.ts +14 -0
  95. package/dist/services/mmorpg.d.ts +32 -0
  96. package/dist/services/standalone.d.ts +34 -0
  97. package/package.json +25 -41
  98. package/src/Game/EffectManager.ts +20 -0
  99. package/src/Game/Event.ts +5 -0
  100. package/src/Game/Map.ts +10 -0
  101. package/src/Game/Object.ts +16 -0
  102. package/src/Game/Player.ts +5 -0
  103. package/src/Gui/Gui.ts +80 -533
  104. package/src/RpgClient.ts +9 -5
  105. package/src/RpgClientEngine.ts +135 -818
  106. package/src/components/character.ce +104 -0
  107. package/src/components/effects/animation.ce +19 -0
  108. package/src/components/effects/hit.ce +87 -0
  109. package/src/components/effects/index.ts +7 -0
  110. package/src/components/gui/dialogbox/index.ce +194 -0
  111. package/src/components/gui/dialogbox/itemMenu.ce +23 -0
  112. package/src/components/gui/dialogbox/selection.ce +67 -0
  113. package/src/components/gui/index.ts +5 -0
  114. package/src/components/index.ts +3 -0
  115. package/src/components/scenes/canvas.ce +51 -0
  116. package/src/components/scenes/draw-map.ce +56 -0
  117. package/src/components/scenes/element-map.ce +23 -0
  118. package/src/components/scenes/event-layer.ce +20 -0
  119. package/src/core/inject.ts +17 -0
  120. package/src/core/setup.ts +18 -0
  121. package/src/index.ts +13 -29
  122. package/src/module.ts +93 -0
  123. package/src/presets/index.ts +5 -0
  124. package/src/{Presets/AnimationSpritesheet.ts → presets/rmspritesheet.ts} +4 -5
  125. package/src/services/AbstractSocket.ts +14 -0
  126. package/src/services/loadMap.ts +33 -0
  127. package/src/services/mmorpg.ts +64 -0
  128. package/src/services/standalone.ts +101 -0
  129. package/src/types/canvas-engine.d.ts +26 -0
  130. package/tsconfig.json +8 -3
  131. package/vite.config.ts +34 -0
  132. package/CHANGELOG.md +0 -189
  133. package/LICENSE +0 -19
  134. package/browser/React-ece4b906.js +0 -195
  135. package/browser/index-ba657126.js +0 -44229
  136. package/browser/manifest.json +0 -21
  137. package/browser/rpg.client.js +0 -40
  138. package/browser/rpg.client.umd.cjs +0 -44456
  139. package/lib/Components/AbstractComponent.d.ts +0 -32
  140. package/lib/Components/AbstractComponent.js +0 -93
  141. package/lib/Components/AbstractComponent.js.map +0 -1
  142. package/lib/Components/BarComponent.d.ts +0 -21
  143. package/lib/Components/BarComponent.js +0 -169
  144. package/lib/Components/BarComponent.js.map +0 -1
  145. package/lib/Components/Component.d.ts +0 -124
  146. package/lib/Components/Component.js +0 -425
  147. package/lib/Components/Component.js.map +0 -1
  148. package/lib/Components/DebugComponent.d.ts +0 -11
  149. package/lib/Components/DebugComponent.js +0 -32
  150. package/lib/Components/DebugComponent.js.map +0 -1
  151. package/lib/Components/ImageComponent.d.ts +0 -11
  152. package/lib/Components/ImageComponent.js +0 -30
  153. package/lib/Components/ImageComponent.js.map +0 -1
  154. package/lib/Components/ShapeComponent.d.ts +0 -11
  155. package/lib/Components/ShapeComponent.js +0 -57
  156. package/lib/Components/ShapeComponent.js.map +0 -1
  157. package/lib/Components/TextComponent.d.ts +0 -11
  158. package/lib/Components/TextComponent.js +0 -35
  159. package/lib/Components/TextComponent.js.map +0 -1
  160. package/lib/Components/TileComponent.d.ts +0 -10
  161. package/lib/Components/TileComponent.js +0 -40
  162. package/lib/Components/TileComponent.js.map +0 -1
  163. package/lib/Effects/Animation.d.ts +0 -55
  164. package/lib/Effects/Animation.js +0 -233
  165. package/lib/Effects/Animation.js.map +0 -1
  166. package/lib/Effects/AnimationCharacter.d.ts +0 -7
  167. package/lib/Effects/AnimationCharacter.js +0 -9
  168. package/lib/Effects/AnimationCharacter.js.map +0 -1
  169. package/lib/Effects/Spinner.d.ts +0 -7
  170. package/lib/Effects/Spinner.js +0 -18
  171. package/lib/Effects/Spinner.js.map +0 -1
  172. package/lib/Effects/Timeline.d.ts +0 -151
  173. package/lib/Effects/Timeline.js +0 -369
  174. package/lib/Effects/Timeline.js.map +0 -1
  175. package/lib/Effects/TransitionScene.d.ts +0 -18
  176. package/lib/Effects/TransitionScene.js +0 -50
  177. package/lib/Effects/TransitionScene.js.map +0 -1
  178. package/lib/GameEngine.d.ts +0 -68
  179. package/lib/GameEngine.js +0 -254
  180. package/lib/GameEngine.js.map +0 -1
  181. package/lib/Gui/Gui.d.ts +0 -110
  182. package/lib/Gui/Gui.js +0 -489
  183. package/lib/Gui/Gui.js.map +0 -1
  184. package/lib/Gui/React.d.ts +0 -28
  185. package/lib/Gui/React.js +0 -147
  186. package/lib/Gui/React.js.map +0 -1
  187. package/lib/Gui/Vue.d.ts +0 -13
  188. package/lib/Gui/Vue.js +0 -114
  189. package/lib/Gui/Vue.js.map +0 -1
  190. package/lib/Interfaces/Character.d.ts +0 -6
  191. package/lib/Interfaces/Character.js +0 -2
  192. package/lib/Interfaces/Character.js.map +0 -1
  193. package/lib/Interfaces/Scene.d.ts +0 -10
  194. package/lib/Interfaces/Scene.js +0 -2
  195. package/lib/Interfaces/Scene.js.map +0 -1
  196. package/lib/KeyboardControls.d.ts +0 -367
  197. package/lib/KeyboardControls.js +0 -714
  198. package/lib/KeyboardControls.js.map +0 -1
  199. package/lib/Logger.d.ts +0 -1
  200. package/lib/Logger.js +0 -4
  201. package/lib/Logger.js.map +0 -1
  202. package/lib/Presets/AnimationSpritesheet.js +0 -39
  203. package/lib/Presets/AnimationSpritesheet.js.map +0 -1
  204. package/lib/Presets/Scene.d.ts +0 -3
  205. package/lib/Presets/Scene.js +0 -5
  206. package/lib/Presets/Scene.js.map +0 -1
  207. package/lib/Renderer.d.ts +0 -62
  208. package/lib/Renderer.js +0 -300
  209. package/lib/Renderer.js.map +0 -1
  210. package/lib/Resources.d.ts +0 -22
  211. package/lib/Resources.js +0 -38
  212. package/lib/Resources.js.map +0 -1
  213. package/lib/RpgClient.js +0 -2
  214. package/lib/RpgClient.js.map +0 -1
  215. package/lib/RpgClientEngine.d.ts +0 -257
  216. package/lib/RpgClientEngine.js +0 -677
  217. package/lib/RpgClientEngine.js.map +0 -1
  218. package/lib/Scene/EventLayer.d.ts +0 -4
  219. package/lib/Scene/EventLayer.js +0 -8
  220. package/lib/Scene/EventLayer.js.map +0 -1
  221. package/lib/Scene/Map.d.ts +0 -109
  222. package/lib/Scene/Map.js +0 -319
  223. package/lib/Scene/Map.js.map +0 -1
  224. package/lib/Scene/Scene.d.ts +0 -184
  225. package/lib/Scene/Scene.js +0 -250
  226. package/lib/Scene/Scene.js.map +0 -1
  227. package/lib/Scene/SceneData.d.ts +0 -4
  228. package/lib/Scene/SceneData.js +0 -8
  229. package/lib/Scene/SceneData.js.map +0 -1
  230. package/lib/Sound/RpgSound.d.ts +0 -11
  231. package/lib/Sound/RpgSound.js +0 -46
  232. package/lib/Sound/RpgSound.js.map +0 -1
  233. package/lib/Sound/Sound.d.ts +0 -78
  234. package/lib/Sound/Sound.js +0 -12
  235. package/lib/Sound/Sound.js.map +0 -1
  236. package/lib/Sound/Sounds.d.ts +0 -2
  237. package/lib/Sound/Sounds.js +0 -6
  238. package/lib/Sound/Sounds.js.map +0 -1
  239. package/lib/Sprite/Character.d.ts +0 -18
  240. package/lib/Sprite/Character.js +0 -131
  241. package/lib/Sprite/Character.js.map +0 -1
  242. package/lib/Sprite/Player.d.ts +0 -3
  243. package/lib/Sprite/Player.js +0 -4
  244. package/lib/Sprite/Player.js.map +0 -1
  245. package/lib/Sprite/Spritesheet.d.ts +0 -365
  246. package/lib/Sprite/Spritesheet.js +0 -13
  247. package/lib/Sprite/Spritesheet.js.map +0 -1
  248. package/lib/Sprite/Spritesheets.d.ts +0 -3
  249. package/lib/Sprite/Spritesheets.js +0 -6
  250. package/lib/Sprite/Spritesheets.js.map +0 -1
  251. package/lib/Tilemap/CommonLayer.d.ts +0 -10
  252. package/lib/Tilemap/CommonLayer.js +0 -17
  253. package/lib/Tilemap/CommonLayer.js.map +0 -1
  254. package/lib/Tilemap/ImageLayer.d.ts +0 -4
  255. package/lib/Tilemap/ImageLayer.js +0 -16
  256. package/lib/Tilemap/ImageLayer.js.map +0 -1
  257. package/lib/Tilemap/Tile.d.ts +0 -21
  258. package/lib/Tilemap/Tile.js +0 -67
  259. package/lib/Tilemap/Tile.js.map +0 -1
  260. package/lib/Tilemap/TileLayer.d.ts +0 -13
  261. package/lib/Tilemap/TileLayer.js +0 -122
  262. package/lib/Tilemap/TileLayer.js.map +0 -1
  263. package/lib/Tilemap/TileSet.d.ts +0 -7
  264. package/lib/Tilemap/TileSet.js +0 -24
  265. package/lib/Tilemap/TileSet.js.map +0 -1
  266. package/lib/Tilemap/index.d.ts +0 -28
  267. package/lib/Tilemap/index.js +0 -151
  268. package/lib/Tilemap/index.js.map +0 -1
  269. package/lib/clientEntryPoint.d.ts +0 -89
  270. package/lib/clientEntryPoint.js +0 -48
  271. package/lib/clientEntryPoint.js.map +0 -1
  272. package/lib/index.d.ts +0 -26
  273. package/lib/index.js +0 -27
  274. package/lib/index.js.map +0 -1
  275. package/lib/inject.d.ts +0 -23
  276. package/lib/inject.js +0 -30
  277. package/lib/inject.js.map +0 -1
  278. package/rpg.toml +0 -14
  279. package/src/Components/AbstractComponent.ts +0 -120
  280. package/src/Components/BarComponent.ts +0 -181
  281. package/src/Components/Component.ts +0 -515
  282. package/src/Components/DebugComponent.ts +0 -36
  283. package/src/Components/ImageComponent.ts +0 -30
  284. package/src/Components/ShapeComponent.ts +0 -64
  285. package/src/Components/TextComponent.ts +0 -33
  286. package/src/Components/TileComponent.ts +0 -43
  287. package/src/Effects/Animation.ts +0 -310
  288. package/src/Effects/AnimationCharacter.ts +0 -7
  289. package/src/Effects/Spinner.ts +0 -19
  290. package/src/Effects/Timeline.ts +0 -378
  291. package/src/Effects/TransitionScene.ts +0 -59
  292. package/src/GameEngine.ts +0 -289
  293. package/src/Gui/React.ts +0 -193
  294. package/src/Gui/Vue.ts +0 -154
  295. package/src/Interfaces/Character.ts +0 -7
  296. package/src/Interfaces/Scene.ts +0 -9
  297. package/src/KeyboardControls.ts +0 -748
  298. package/src/Logger.ts +0 -3
  299. package/src/Presets/Scene.ts +0 -3
  300. package/src/Renderer.ts +0 -334
  301. package/src/Resources.ts +0 -39
  302. package/src/Scene/EventLayer.ts +0 -9
  303. package/src/Scene/Map.ts +0 -402
  304. package/src/Scene/Scene.ts +0 -305
  305. package/src/Scene/SceneData.ts +0 -13
  306. package/src/Sound/RpgSound.ts +0 -50
  307. package/src/Sound/Sound.ts +0 -91
  308. package/src/Sound/Sounds.ts +0 -7
  309. package/src/Sprite/Character.ts +0 -157
  310. package/src/Sprite/Player.ts +0 -3
  311. package/src/Sprite/Spritesheet.ts +0 -392
  312. package/src/Sprite/Spritesheets.ts +0 -8
  313. package/src/Tilemap/CommonLayer.ts +0 -20
  314. package/src/Tilemap/ImageLayer.ts +0 -20
  315. package/src/Tilemap/Tile.ts +0 -80
  316. package/src/Tilemap/TileLayer.ts +0 -142
  317. package/src/Tilemap/TileSet.ts +0 -40
  318. package/src/Tilemap/index.ts +0 -175
  319. package/src/clientEntryPoint.ts +0 -150
  320. package/src/inject.ts +0 -34
  321. package/src/types/howler.d.ts +0 -73
@@ -1,824 +1,141 @@
1
- import { KeyboardControls } from './KeyboardControls'
2
- import { RpgRenderer } from './Renderer'
3
- import { _initSpritesheet, spritesheets } from './Sprite/Spritesheets'
4
- import { _initSound, sounds } from './Sound/Sounds'
5
- import { World } from 'simple-room-client'
6
- import { BehaviorSubject, Observable, Subject, Subscription, lastValueFrom } from 'rxjs'
7
- import { ajax } from 'rxjs/ajax'
8
- import { RpgGui } from './Gui/Gui'
9
- import {
10
- RpgCommonPlayer,
11
- PrebuiltGui,
12
- Utils,
13
- RpgPlugin,
14
- HookClient,
15
- RpgCommonMap,
16
- Scheduler,
17
- Control,
18
- InjectContext,
19
- } from '@rpgjs/common'
20
- import { RpgSound } from './Sound/RpgSound'
21
- import { SceneMap } from './Scene/Map'
22
- import { GameEngineClient } from './GameEngine'
23
- import { Scene } from './Scene/Scene'
24
- import { Spritesheet } from './Sprite/Spritesheet'
25
- import { log } from './Logger'
26
- import { Sound } from './Sound/Sound'
27
- import { constructor, ObjectFixtureList, PlayerType, SocketEvents, SocketMethods, Tick } from '@rpgjs/types'
28
- import { Assets, utils } from 'pixi.js'
29
- import * as PIXI from 'pixi.js'
30
-
31
- const { extractId, isString } = Utils
32
-
33
- declare var __RPGJS_PRODUCTION__: boolean;
34
-
35
- type FrameData = {
36
- time: number,
37
- data: any
38
- }
39
-
40
- type MatchMakerResponse = {
41
- url: string,
42
- port: string
43
- }
44
-
45
- export class RpgClientEngine {
46
-
47
- /**
48
- * Get the rendering
49
- *
50
- * @prop {RpgRenderer} [renderer]
51
- * @readonly
52
- * @deprecated Use `inject(RpgRenderer)` instead. Will be removed in v5
53
- * @memberof RpgClientEngine
54
- * */
55
- public renderer: RpgRenderer
56
-
57
- /**
58
- * Get the socket
59
- *
60
- * @prop {Socket} [socket]
61
- * @readonly
62
- * @memberof RpgClientEngine
63
- * */
64
- public socket: any
65
-
66
- /**
67
- * retrieve the global configurations assigned at the entry point
68
- *
69
- * @prop {object} [globalConfig]
70
- * @readonly
71
- * @memberof RpgClientEngine
72
- * */
73
- public globalConfig: any = {}
74
-
75
- /**
76
- * Get the class managing the keyboard
77
- *
78
- * @prop {KeyboardControls} [controls]
79
- * @deprecated Use `inject(KeyboardControls)` instead. Will be removed in v5
80
- * @readonly
81
- * @memberof RpgClientEngine
82
- * */
83
- public controls: KeyboardControls
84
-
85
- public _options: any
86
-
87
- private _tick: BehaviorSubject<Tick> = new BehaviorSubject({
88
- timestamp: -1,
89
- deltaTime: 0,
90
- frame: 0,
91
- deltaRatio: 1
1
+ import Canvas from "./components/scenes/canvas.ce";
2
+ import { Context, inject } from "@signe/di";
3
+ import { signal, bootstrapCanvas } from "canvasengine";
4
+ import { AbstractWebsocket, WebSocketToken } from "./services/AbstractSocket";
5
+ import { LoadMapService, LoadMapToken } from "./services/loadMap";
6
+ import { Hooks, ModulesToken } from "@rpgjs/common";
7
+ import { load } from "@signe/sync";
8
+ import { RpgClientMap } from "./Game/Map"
9
+ import { RpgGui } from "./Gui/Gui";
10
+ import { EffectManager } from "./Game/EffectManager";
11
+ import { lastValueFrom } from "rxjs";
12
+ import { GlobalConfigToken } from "./module";
13
+ import { ClientIo } from "@signe/room";
14
+
15
+ export class RpgClientEngine<T = any> {
16
+ private guiService: RpgGui;
17
+ private webSocket: AbstractWebsocket;
18
+ private loadMapService: LoadMapService;
19
+ private hooks: Hooks;
20
+ private sceneMap: RpgClientMap = new RpgClientMap();
21
+ private selector: HTMLElement;
22
+ public globalConfig: T;
23
+ public sceneComponent: any;
24
+ stopProcessingInput = false;
25
+
26
+ width = signal("100%");
27
+ height = signal("100%");
28
+ spritesheets: Map<string, any> = new Map();
29
+ sounds: Map<string, any> = new Map();
30
+ effects: any[] = [];
31
+ particleSettings: {
32
+ emitters: any[]
33
+ } = {
34
+ emitters: []
35
+ }
36
+
37
+ constructor(public context: Context) {
38
+ this.webSocket = inject(context, WebSocketToken);
39
+ this.guiService = inject(context, RpgGui);
40
+ this.loadMapService = inject(context, LoadMapToken);
41
+ this.hooks = inject<Hooks>(context, ModulesToken);
42
+ this.globalConfig = inject(context, GlobalConfigToken)
43
+ }
44
+
45
+ async start() {
46
+ this.selector = document.body.querySelector("#rpg") as HTMLElement;
47
+
48
+ await bootstrapCanvas(this.selector, Canvas);
49
+
50
+ await lastValueFrom(this.hooks.callHooks("client-engine-onStart", this));
51
+
52
+ this.hooks.callHooks("client-spritesheets-load", this).subscribe();
53
+ this.hooks.callHooks("client-sounds-load", this).subscribe();
54
+ this.hooks.callHooks("client-gui-load", this).subscribe();
55
+ this.hooks.callHooks("client-particles-load", this).subscribe();
56
+ this.hooks.callHooks("client-effects-load", this).subscribe();
57
+
58
+
59
+ await this.webSocket.connection(() => {
60
+ this.initListeners()
61
+ this.guiService._initialize()
62
+ });
63
+ }
64
+
65
+ private initListeners() {
66
+ this.webSocket.on("sync", (data) => {
67
+ load(this.sceneMap, data, true);
68
+ });
69
+
70
+ this.webSocket.on("changeMap", (data) => {
71
+ this.loadScene(data.mapId);
72
+ });
73
+
74
+ this.webSocket.on("showEffect", (data) => {
75
+ const { params, object, id } = data;
76
+ if (!object) {
77
+ throw new Error("Object not found");
78
+ }
79
+ const player = this.sceneMap.getObjectById(object);
80
+ this.getEffect(id).displayEffect(params, player)
81
+ });
82
+ }
83
+
84
+ private async loadScene(mapId: string) {
85
+ this.webSocket.updateProperties({ room: mapId })
86
+ await this.webSocket.reconnect(() => {
87
+ this.initListeners()
88
+ this.guiService._initialize()
92
89
  })
93
- public keyChange: Subject<string> = new Subject()
94
- public roomJoin: Subject<string> = new Subject()
95
- private hasBeenDisconnected: boolean = false
96
- private serverChanging: boolean = false
97
- private isTeleported: boolean = false
98
- // TODO, public or private
99
- io
100
- private lastTimestamp: number = 0
101
- private subscriptionWorld: Subscription
102
-
103
- private clientFrames: Map<number, FrameData> = new Map()
104
- private serverFrames: Map<number, FrameData> = new Map()
105
-
106
- private session: string | null = null
107
- private lastConnection: string = ''
108
- private lastScene: string = ''
109
- private matchMakerService: string | (() => MatchMakerResponse) | null = null
110
- private serverFps: number = 60
111
- private scheduler: Scheduler = new Scheduler()
112
- private _serverUrl: string = ''
113
- /**
114
- * * @deprecated Use `inject(GameEngineClient)` instead. Will be removed in v5
115
- */
116
- public gameEngine = this.context.inject(GameEngineClient)
117
-
118
- /**
119
- * Read objects synchronized with the server
120
- *
121
- * @prop {Observable< {
122
- [id: string]: {
123
- object: any,
124
- paramsChanged: any
125
- }
126
- } >} [objects]
127
- * @readonly
128
- * @memberof RpgClientEngine
129
- */
130
- objects: Observable<ObjectFixtureList> = this.gameEngine.objects
131
-
132
- envs?: object = {}
133
-
134
- constructor(private context: InjectContext, private options) {
135
- this.envs = options.envs || {}
136
- this.tick.subscribe(({ timestamp, deltaTime }) => {
137
- if (timestamp != -1) this.step(timestamp, deltaTime)
138
- })
139
- }
140
-
141
- private async _init() {
142
- this.renderer = this.context.inject(RpgRenderer)
143
-
144
- const pluginLoadResource = async (hookName: string, type: string) => {
145
- const resource = this.options[type] || []
146
- this.options[type] = [
147
- ...Utils.arrayFlat(await RpgPlugin.emit(hookName, resource)) || [],
148
- ...resource
149
- ]
150
- }
151
-
152
- await pluginLoadResource(HookClient.AddSpriteSheet, 'spritesheets')
153
- await pluginLoadResource(HookClient.AddGui, 'gui')
154
- await pluginLoadResource(HookClient.AddSound, 'sounds')
155
-
156
- this.renderer.options = {
157
- selector: '#rpg',
158
- selectorCanvas: '#canvas',
159
- selectorGui: '#gui',
160
- canvas: {},
161
- gui: [],
162
- spritesheets: [],
163
- sounds: [],
164
- ...this.options
165
- }
166
-
167
- this.io = this.options.io
168
- if (this.options.serverFps) this.serverFps = this.options.serverFps
169
- this.globalConfig = this.options.globalConfig
170
- this.gameEngine.standalone = this.options.standalone
171
- this.gameEngine.renderer = this.renderer
172
- this.gameEngine.clientEngine = this
173
-
174
- this.addSpriteSheet(this.renderer.options.spritesheets);
175
-
176
- (this.renderer.options.sounds || []).forEach(sound => {
177
- const id: any = isString(sound) ? extractId(sound) : undefined
178
- this.addSound(sound, id)
179
- })
180
-
181
- // deprecated
182
- if (typeof __RPGJS_PRODUCTION__ != 'undefined' && __RPGJS_PRODUCTION__) {
183
- if ('serviceWorker' in navigator) {
184
- window.addEventListener('load', () => {
185
- navigator.serviceWorker.register('/service-worker.js')
186
- })
187
- }
188
- }
189
-
190
- this.controls = this.context.inject(KeyboardControls)
191
- }
192
-
193
- private addResource(resourceClass, cb) {
194
- let array = resourceClass
195
- if (!Utils.isArray(resourceClass)) {
196
- array = [resourceClass]
197
- }
198
- cb(array, this)
199
- }
200
-
201
- /**
202
- * Listen to each frame
203
- *
204
- * @prop {Observable<{ timestamp: number, deltaTime: number, frame: number }>} tick
205
- * @readonly
206
- * @since 3.0.0-beta.5
207
- * @memberof RpgClientEngine
208
- * @example
209
- *
210
- * ```ts
211
- * client.tick.subscribe(({ timestamp, deltaTime, frame }) => {
212
- *
213
- * })
214
- * ```
215
- * */
216
- get tick(): Observable<Tick> {
217
- return this.scheduler.tick as any
218
- }
219
-
220
- /**
221
- * Adds Spritesheet classes
222
- *
223
- * @title Add Spritesheet
224
- * @method addSpriteSheet(spritesheetClass|spritesheetClass[])
225
- * @param { Class|Class[] } spritesheetClass
226
- * @method addSpriteSheet(url,id)
227
- * @param {string} url Define the url of the resource
228
- * @param {string} id Define a resource identifier
229
- * @returns {Class}
230
- * @since 3.0.0-beta.3
231
- * @memberof RpgClientEngine
232
- */
233
- addSpriteSheet(spritesheetClass: constructor<any>)
234
- addSpriteSheet(url: string, id: string)
235
- addSpriteSheet<T = any>(spritesheetClass: constructor<T> | string, id?: string): constructor<T> {
236
- if (typeof spritesheetClass === 'string') {
237
- if (!id) {
238
- throw log('Please, specify the resource ID (second parameter)')
239
- }
240
- @Spritesheet({
241
- id,
242
- image: this.getResourceUrl(spritesheetClass)
243
- })
244
- class AutoSpritesheet { }
245
- spritesheetClass = AutoSpritesheet as any
246
- }
247
- this.addResource(spritesheetClass, _initSpritesheet)
248
- return spritesheetClass as any
249
- }
250
-
251
- /**
252
- * Adds Sound classes
253
- *
254
- * @title Add Sound
255
- * @method addSound(soundClass|soundClass[])
256
- * @param { Class|Class[] } soundClass
257
- * @method addSound(url,id)
258
- * @param {string} url Define the url of the resource
259
- * @param {string} id Define a resource identifier
260
- * @returns {Class}
261
- * @since 3.0.0-beta.3
262
- * @memberof RpgClientEngine
263
- */
264
- addSound(soundClass: constructor<any>)
265
- addSound(url: string, id: string)
266
- addSound<T = any>(soundClass: constructor<T> | string, id?: string): constructor<T> {
267
- if (typeof soundClass === 'string') {
268
- if (!id) {
269
- throw log('Please, specify the resource ID (second parameter)')
270
- }
271
- @Sound({
272
- id,
273
- sound: this.getResourceUrl(soundClass)
274
- })
275
- class AutoSound { }
276
- soundClass = AutoSound as any
277
- }
278
- this.addResource(soundClass, _initSound)
279
- return soundClass as any
280
- }
281
-
282
- getResourceUrl(source: string): string {
283
- // @ts-ignore
284
- if (window.urlCache && window.urlCache[source]) {
285
- // @ts-ignore
286
- return window.urlCache[source]
287
- }
288
-
289
- if (source.startsWith('data:')) {
290
- return source
291
- }
292
-
293
- // @ts-ignore
294
- const staticDir = this.envs.VITE_BUILT
295
-
296
- if (staticDir) {
297
- return this.assetsPath + '/' + Utils.basename(source)
298
- }
299
-
300
- return source
301
- }
302
-
303
- /**
304
- * Starts the client side and connects to the server
305
- *
306
- * @title Start Client Engine
307
- * @method start()
308
- * @returns {Promise< RpgClientEngine >}
309
- * @memberof RpgClientEngine
310
- */
311
- async start(options: { renderLoop: boolean } = {
312
- renderLoop: true
313
- }): Promise<RpgClientEngine> {
314
- await this._init()
315
- await this.renderer.init()
316
- const { maxFps } = this.options
317
-
318
- if (options.renderLoop) {
319
- this.scheduler.start({
320
- maxFps
321
- })
322
- // The processing is outside the rendering loop because if the FPS are lower (or higher) then the sending to the server would be slower or faster. Here it is constant
323
- setInterval(() => {
324
- this.processInput()
325
- }, Utils.fps2ms(this.serverFps))
326
- }
327
- const ret: boolean[] = await RpgPlugin.emit(HookClient.Start, this)
328
- this.matchMakerService = this.options.globalConfig.matchMakerService
329
- const hasFalseValue = ret.findIndex(el => el === false) != - 1
330
- if (!hasFalseValue) {
331
- let serverUri = {} as MatchMakerResponse
332
- if (this.matchMakerService) {
333
- if (Utils.isFunction(this.matchMakerService)) {
334
- serverUri = (this.matchMakerService as Function)()
335
- }
336
- else {
337
- serverUri = await lastValueFrom(ajax.getJSON<MatchMakerResponse>(this.matchMakerService as string))
338
- }
339
-
340
- }
341
- // @ts-ignore
342
- const envUrl = this.envs.VITE_SERVER_URL
343
- await this.connection(
344
- serverUri.url ? serverUri.url + ':' + serverUri.port :
345
- envUrl ? envUrl : undefined
346
- )
347
- }
348
- return this
349
- }
350
-
351
- /**
352
- * Display the next frame. Useful for unit tests
353
- *
354
- * @title Next Frame
355
- * @since 3.0.0-beta.5
356
- * @param {number} timestamp Indicate the timestamp of the frame
357
- * @method nextFrame()
358
- * @memberof RpgClientEngine
359
- */
360
- nextFrame(timestamp: number): void {
361
- this.scheduler.nextTick(timestamp)
362
- }
363
-
364
- async sendInput(actionName: string | Control) {
365
- const player = this.player
366
- if (!player) return
367
- if (player.canMove) {
368
- player.pendingMove.push({
369
- input: actionName,
370
- frame: this.scheduler.frame
371
- })
372
- }
373
- }
374
-
375
- get player(): RpgCommonPlayer | null {
376
- return this.gameEngine.world.getObject(this.gameEngine.playerId)
377
- }
378
-
379
- private serverReconciliation(player: RpgCommonPlayer) {
380
- let garbage: number[] = []
381
- this.serverFrames.forEach((serverData, frame) => {
382
- const { data: serverPos, time: serverTime } = serverData
383
- const client = this.clientFrames.get(frame)
384
- if (!client || (client && client.data.x != serverPos.x || client.data.y != serverPos.y)) {
385
- if (serverPos.x) player.position.x = serverPos.x
386
- if (serverPos.y) player.position.y = serverPos.y
387
- }
388
- player.position.z = serverPos.z
389
- garbage.push(frame)
390
- })
391
- garbage.forEach(frame => {
392
- this.serverFrames.delete(frame)
393
- this.clientFrames.delete(frame)
394
- })
395
- garbage = []
396
- }
397
-
398
- private async step(t: number, dt: number) {
399
- RpgPlugin.emit(HookClient.Step, [this, t, dt], true)
400
- }
401
-
402
- async processInput() {
403
- const player = this.player
404
- this.controls.preStep()
405
- if (player) {
406
- if (player.pendingMove.length > 0) {
407
- const { inputs: inputEvent } = await this.gameEngine.processInput<RpgCommonPlayer>(this.gameEngine.playerId, this.controls.options)
408
- if (inputEvent.length == 0) return
409
- const frame = Date.now()
410
- this.clientFrames.set(frame, {
411
- data: player.position.copy(),
412
- time: frame
413
- })
414
- if (this.socket) {
415
- this.socket.emit('move', { input: inputEvent, frame })
416
- }
417
- RpgPlugin.emit(HookClient.SendInput, [this, inputEvent], true)
418
- }
419
- if (player.canMove) this.serverReconciliation(player)
420
- }
421
- }
422
-
423
- /**
424
- *Connect to the server
425
- *
426
- * @title Connect to server
427
- * @method connection()
428
- * @returns {void}
429
- * @memberof RpgClientEngine
430
- */
431
- async connection(uri?: string) {
432
- const { standalone } = this.gameEngine
433
- const { globalConfig } = this
434
-
435
- this._serverUrl = uri || ''
436
-
437
- if (!standalone) {
438
- this.socket = this.io(uri, {
439
- auth: {
440
- token: this.session
441
- },
442
- ...(globalConfig.socketIoClient || {})
443
- })
444
- }
445
- else {
446
- this.socket = this.io
447
- }
448
-
449
- this.socket.on('connect', () => {
450
- if (RpgGui.exists(PrebuiltGui.Disconnect)) RpgGui.hide(PrebuiltGui.Disconnect)
451
- RpgPlugin.emit(HookClient.Connected, [this, this.socket], true)
452
- this.hasBeenDisconnected = false
453
- })
454
-
455
- this.socket.on('playerJoined', (playerEvent) => {
456
- this.gameEngine.playerId = playerEvent.playerId
457
- this.session = playerEvent.session
458
- })
459
-
460
- this.socket.on('connect_error', (err: any) => {
461
- RpgPlugin.emit(HookClient.ConnectedError, [this, err, this.socket], true)
462
- })
463
-
464
- this.socket.on('preLoadScene', ({ id, reconnect }: { id: string, reconnect?: boolean }) => {
465
- if (this.lastScene == id) {
466
- return
467
- }
468
- this.lastScene = id
469
- this.renderer.transitionScene(id)
470
- if (reconnect) {
471
- this.roomJoin.next('')
472
- this.roomJoin.complete()
473
- }
474
- })
475
-
476
- this.socket.on(SocketEvents.GameReload, () => {
477
- window.location.reload()
478
- })
479
-
480
- this.socket.on(SocketEvents.LoadScene, ({ name, data }) => {
481
- this.renderer.loadScene(name, data)
482
- })
483
-
484
- this.socket.on(SocketEvents.ChangeServer, async ({ url, port }) => {
485
- const connection = url + ':' + port
486
- if (this.lastConnection == connection) {
487
- return
488
- }
489
- if (this.subscriptionWorld) {
490
- this.subscriptionWorld.unsubscribe()
491
- }
492
- this.lastConnection = connection
493
- this.serverChanging = true
494
- this.socket.disconnect()
495
- this.connection(connection)
496
- })
497
-
498
- this.socket.on('changeTile', ({ tiles, x, y }) => {
499
- const scene = this.renderer.getScene<SceneMap>()
500
- scene?.changeTile(x, y, tiles)
501
- })
502
-
503
- const callMethod = ({ objectId, params, name }) => {
504
- const scene = this.renderer.getScene<SceneMap>()
505
- const sprite = scene?.getPlayer(objectId)
506
- if (!sprite) return
507
- switch (name) {
508
- case SocketMethods.ShowAnimation:
509
- scene?.showAnimation({
510
- attachTo: sprite,
511
- graphic: params[0],
512
- animationName: params[1],
513
- replaceGraphic: params[2]
514
- })
515
- break
516
- case SocketMethods.CameraFollow:
517
- const [spriteId, options] = params
518
- scene?.cameraFollowSprite(spriteId, options)
519
- break
520
- case SocketMethods.PlaySound:
521
- RpgSound.play(params[0])
522
- break
523
- case SocketMethods.ModeMove:
524
- const player = this.player
525
- const { checkCollision } = params[0]
526
- if (player) {
527
- player.checkCollision = checkCollision
528
- }
529
- break
530
- }
531
- }
532
-
533
- this.socket.on(SocketEvents.CallMethod, callMethod)
534
-
535
- let lastRoomId = ''
536
-
537
- this.subscriptionWorld = World.listen(this.socket)
538
- .value
539
- .subscribe(async (val: { data: any, partial: any, time: number, roomId: string, resetProps: string[] }) => {
540
- const scene = this.renderer.getScene<SceneMap>()
541
-
542
- if (!val.data) {
543
- return
544
- }
545
-
546
- const partialRoom = val.partial
547
-
548
- if (val.roomId != lastRoomId) {
549
- this.clientFrames.clear()
550
- this.serverFrames.clear()
551
- this.gameEngine.resetObjects()
552
- lastRoomId = val.roomId
553
- this.isTeleported = false
554
- }
555
-
556
- const objectsChanged = {}
557
-
558
- const callAction = (objectId: string, paramsChanged) => {
559
- if (paramsChanged && SocketEvents.CallMethod in paramsChanged) {
560
- // Force rendering on the map (display events) and then perform actions on it (animation, etc.).
561
- this.renderer.draw(Date.now(), 1, 1, 1)
562
- callMethod({
563
- objectId,
564
- ...paramsChanged[SocketEvents.CallMethod]
565
- })
566
- }
567
- }
568
-
569
- const change = (prop, root = val, localEvent = false) => {
570
- const list = root.data[prop]
571
- const partial = root.partial[prop]
572
- const isShape = prop == 'shapes'
573
- if (!partial) {
574
- return
575
- }
576
- if (val.resetProps.indexOf(prop) != -1) {
577
- const objects = isShape ? this.gameEngine.getShapes() : this.gameEngine.getObjects()
578
- for (let key in objects) {
579
- const obj = objects[key]
580
- if (obj) {
581
- this.gameEngine.removeObjectAndShape(key)
582
- }
583
- }
584
- }
585
- for (let key in partial) {
586
- const obj = list[key]
587
- const paramsChanged = partial ? partial[key] : undefined
588
-
589
- if (obj == null || obj.deleted) {
590
- // perform actions on the sprite before deleting it
591
- callAction(key, paramsChanged)
592
- this.gameEngine.removeObjectAndShape(key)
593
- continue
594
- }
595
-
596
- if (!obj) continue
597
-
598
- if (!isShape) {
599
- obj.type = {
600
- users: PlayerType.Player,
601
- events: PlayerType.Event
602
- }[prop]
603
- }
604
- if (prop == 'users' && this.gameEngine.playerId == key) {
605
- if (obj.events) {
606
- const nbEvents = Object.values(obj.events)
607
- if (nbEvents.length == 0) {
608
- this.gameEngine.events = {}
609
- }
610
- else {
611
- change('events', {
612
- data: obj,
613
- partial: paramsChanged,
614
- time: val.time,
615
- roomId: val.roomId,
616
- resetProps: val.resetProps
617
- }, true)
618
- }
619
- }
620
- if (partialRoom?.pos && partialRoom?.frame !== undefined) {
621
- this.serverFrames.set(partialRoom.frame, {
622
- data: partialRoom.pos,
623
- time: Date.now()
624
- })
625
- }
626
- }
627
- objectsChanged[key] = this.gameEngine.updateObject({
628
- playerId: key,
629
- params: obj,
630
- localEvent,
631
- paramsChanged,
632
- isShape
633
- })
634
-
635
- // perform actions on the sprite after creation/update
636
- callAction(key, paramsChanged)
637
- }
638
- }
639
-
640
- if (partialRoom.join) {
641
- this.roomJoin.next(partialRoom)
642
- this.roomJoin.complete()
643
- }
644
-
645
- change('users')
646
- change('events')
647
- change('shapes')
648
-
649
- this.gameEngine.setObjectsChanged(objectsChanged)
650
-
651
- if (scene) {
652
- scene.update(val)
653
- }
654
- })
655
-
656
- this.socket.on('disconnect', (reason: string) => {
657
- if (this.serverChanging) {
658
- return
659
- }
660
- if (RpgGui.exists(PrebuiltGui.Disconnect)) RpgGui.display(PrebuiltGui.Disconnect)
661
- RpgPlugin.emit(HookClient.Disconnect, [this, reason, this.socket], true)
662
- this.hasBeenDisconnected = true
663
- })
664
-
665
- RpgGui._setSocket(this.socket)
666
-
667
- if (standalone) {
668
- await this.socket.connection({
669
- auth: {
670
- token: this.session
671
- }
672
- })
673
- }
674
-
675
- this.serverChanging = false
676
- }
677
-
678
- get world(): any {
679
- return World
680
- }
681
-
682
- // shortcuts
683
-
684
- /**
685
- * VueJS Application instance
686
- *
687
- * [https://v3.vuejs.org/api/application-api.html](https://v3.vuejs.org/api/application-api.html)
688
- *
689
- * @prop {Vue} [vueApp]
690
- * @readonly
691
- * @memberof RpgClientEngine
692
- * */
693
- get vueApp() {
694
- return this.renderer.app
695
- }
696
-
697
- /**
698
- * VueJS Parent component instance
699
- *
700
- * [https://v3.vuejs.org/api/instance-properties.html](https://v3.vuejs.org/api/instance-properties.html)
701
- *
702
- * @prop {Vue Instance} [vueInstance]
703
- * @readonly
704
- * @memberof RpgClientEngine
705
- * */
706
- get vueInstance() {
707
- return this.renderer.vm
708
- }
709
-
710
- /**
711
- * retrieves the current scene (SceneMap if you are on a map)
712
- *
713
- * @prop {RpgScene} [scene]
714
- * @deprecated
715
- * @readonly
716
- * @memberof RpgClientEngine
717
- * */
718
- get scene() {
719
- return this.renderer.getScene()
720
- }
721
-
722
- /**
723
- * retrieves the current scene (SceneMap if you are on a map)
724
- *
725
- * @title Connect to server
726
- * @method getScene()
727
- * @returns {RpgScene}
728
- * @memberof RpgClientEngine
729
- */
730
- getScene<T = Scene>(): T | null {
731
- return this.renderer.getScene<T>()
732
- }
733
-
734
- /**
735
- * get PIXI class
736
- * @prop {PIXI} [PIXI]
737
- * @readonly
738
- * @memberof RpgClientEngine
739
- */
740
- get PIXI() {
741
- return PIXI
742
- }
743
-
744
- /**
745
- * get player id of the current player
746
- * @prop {string} [playerId]
747
- * @readonly
748
- * @memberof RpgClientEngine
749
- */
750
- get playerId(): string {
751
- return this.gameEngine.playerId
752
- }
753
-
754
- /**
755
- * Finds the game mode from the environment variables sent by the compiler.
756
- * Can be used in menus to display options according to type
757
- *
758
- * @title Game Type
759
- * @prop {string|undefined} [gameType] mmorpg | rpg or undefined if environment variable not found
760
- * @readonly
761
- * @memberof RpgClientEngine
762
- * @since 4.0.0
763
- */
764
- get gameType(): 'mmorpg' | 'rpg' | undefined {
765
- return this.envs?.['VITE_RPG_TYPE']
766
- }
767
-
768
- /**
769
- * Find out if the game is in production or not, from the environment variables sent by the compiler.
770
- *
771
- * @title Game is dev mode
772
- * @prop {boolean} [isDev]
773
- * @readonly
774
- * @memberof RpgClientEngine
775
- * @since 4.0.0
776
- */
777
- get isDev(): boolean {
778
- return !this.envs?.['VITE_BUILT']
779
- }
780
-
781
- /**
782
- * Get the server url. This is the url for the websocket
783
- *
784
- * To customize the URL, use the `matchMakerService` configuration
785
- *
786
- * @title Server URL
787
- * @prop {string} [serverUrl] If empty string, server url is same as client url
788
- * @readonly
789
- * @memberof RpgClientEngine
790
- * @since 4.0.0
791
- */
792
- get serverUrl(): string {
793
- if (!this._serverUrl.startsWith('http')) {
794
- return 'http://' + this._serverUrl
795
- }
796
- return this._serverUrl
797
- }
90
+ const res = await this.loadMapService.load(mapId)
91
+ this.sceneMap.data.set(res)
92
+ this.hooks.callHooks("client-sceneMap-onAfterLoading", this.sceneMap).subscribe();
93
+ //this.sceneMap.loadPhysic()
94
+ }
95
+
96
+ addSpriteSheet<T = any>(spritesheetClass: any, id?: string): any {
97
+ this.spritesheets.set(id || spritesheetClass.id, spritesheetClass);
98
+ return spritesheetClass as any;
99
+ }
100
+
101
+ addSound(sound: any, id?: string) {
102
+ this.sounds.set(id || sound.id, sound);
103
+ return sound;
104
+ }
105
+
106
+ addParticle(particle: any) {
107
+ this.particleSettings.emitters.push(particle)
108
+ return particle;
109
+ }
110
+
111
+ addEffect(effect: {
112
+ component: any,
113
+ id: string
114
+ }) {
115
+ const instance = new EffectManager()
116
+ this.effects.push({
117
+ id: effect.id,
118
+ component: effect.component,
119
+ instance: instance,
120
+ current: instance.current
121
+ })
122
+ return effect;
123
+ }
798
124
 
799
- get assetsPath(): string {
800
- return this.envs?.['VITE_ASSETS_PATH'] || 'assets'
125
+ getEffect(id: string): EffectManager {
126
+ const effect = this.effects.find((effect) => effect.id === id)
127
+ if (!effect) {
128
+ throw new Error(`Effect with id ${id} not found`)
801
129
  }
130
+ return effect.instance
131
+ }
802
132
 
803
- get module() {
804
- return RpgPlugin
805
- }
133
+ processInput({ input }: { input: number }) {
134
+ this.webSocket.emit('move', { input })
135
+ }
806
136
 
807
- reset() {
808
- this.subscriptionWorld.unsubscribe()
809
- this.world.reset()
810
- spritesheets.clear()
811
- sounds.clear()
812
- Assets.reset()
813
- utils.clearTextureCache()
814
- for (let textureUrl in utils.BaseTextureCache) {
815
- delete utils.BaseTextureCache[textureUrl]
816
- }
817
- for (let textureUrl in utils.TextureCache) {
818
- delete utils.TextureCache[textureUrl]
819
- }
820
- RpgGui.clear()
821
- RpgCommonMap.bufferClient.clear()
822
- RpgSound.clear()
823
- }
137
+ processAction({ action }: { action: number }) {
138
+ if (this.stopProcessingInput) return;
139
+ this.webSocket.emit('action', { action })
140
+ }
824
141
  }