@rpgjs/client 4.2.2 → 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 -42
  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 -534
  104. package/src/RpgClient.ts +9 -5
  105. package/src/RpgClientEngine.ts +135 -815
  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 -177
  133. package/LICENSE +0 -19
  134. package/browser/React-f6f9b1de.js +0 -157
  135. package/browser/index-e74a289f.js +0 -44225
  136. package/browser/manifest.json +0 -21
  137. package/browser/rpg.client.js +0 -40
  138. package/browser/rpg.client.umd.cjs +0 -44414
  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 -490
  183. package/lib/Gui/Gui.js.map +0 -1
  184. package/lib/Gui/React.d.ts +0 -15
  185. package/lib/Gui/React.js +0 -113
  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 -674
  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 -145
  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,821 +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< void >}
309
- * @memberof RpgClientEngine
310
- */
311
- async start(options: { renderLoop: boolean } = {
312
- renderLoop: true
313
- }) {
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
- }
349
-
350
- /**
351
- * Display the next frame. Useful for unit tests
352
- *
353
- * @title Next Frame
354
- * @since 3.0.0-beta.5
355
- * @param {number} timestamp Indicate the timestamp of the frame
356
- * @method nextFrame()
357
- * @memberof RpgClientEngine
358
- */
359
- nextFrame(timestamp: number): void {
360
- this.scheduler.nextTick(timestamp)
361
- }
362
-
363
- async sendInput(actionName: string | Control) {
364
- const player = this.player
365
- if (!player) return
366
- if (player.canMove) {
367
- player.pendingMove.push({
368
- input: actionName,
369
- frame: this.scheduler.frame
370
- })
371
- }
372
- }
373
-
374
- get player(): RpgCommonPlayer | null {
375
- return this.gameEngine.world.getObject(this.gameEngine.playerId)
376
- }
377
-
378
- private serverReconciliation(player: RpgCommonPlayer) {
379
- let garbage: number[] = []
380
- this.serverFrames.forEach((serverData, frame) => {
381
- const { data: serverPos, time: serverTime } = serverData
382
- const client = this.clientFrames.get(frame)
383
- if (!client || (client && client.data.x != serverPos.x || client.data.y != serverPos.y)) {
384
- if (serverPos.x) player.position.x = serverPos.x
385
- if (serverPos.y) player.position.y = serverPos.y
386
- }
387
- player.position.z = serverPos.z
388
- garbage.push(frame)
389
- })
390
- garbage.forEach(frame => {
391
- this.serverFrames.delete(frame)
392
- this.clientFrames.delete(frame)
393
- })
394
- garbage = []
395
- }
396
-
397
- private async step(t: number, dt: number) {
398
- RpgPlugin.emit(HookClient.Step, [this, t, dt], true)
399
- }
400
-
401
- async processInput() {
402
- const player = this.player
403
- this.controls.preStep()
404
- if (player) {
405
- if (player.pendingMove.length > 0) {
406
- const { inputs: inputEvent } = await this.gameEngine.processInput<RpgCommonPlayer>(this.gameEngine.playerId, this.controls.options)
407
- if (inputEvent.length == 0) return
408
- const frame = Date.now()
409
- this.clientFrames.set(frame, {
410
- data: player.position.copy(),
411
- time: frame
412
- })
413
- if (this.socket) {
414
- this.socket.emit('move', { input: inputEvent, frame })
415
- }
416
- RpgPlugin.emit(HookClient.SendInput, [this, inputEvent], true)
417
- }
418
- if (player.canMove) this.serverReconciliation(player)
419
- }
420
- }
421
-
422
- /**
423
- *Connect to the server
424
- *
425
- * @title Connect to server
426
- * @method connection()
427
- * @returns {void}
428
- * @memberof RpgClientEngine
429
- */
430
- async connection(uri?: string) {
431
- const { standalone } = this.gameEngine
432
-
433
- this._serverUrl = uri || ''
434
-
435
- if (!standalone) {
436
- this.socket = this.io(uri, {
437
- auth: {
438
- token: this.session
439
- }
440
- })
441
- }
442
- else {
443
- this.socket = this.io
444
- }
445
-
446
- this.socket.on('connect', () => {
447
- if (RpgGui.exists(PrebuiltGui.Disconnect)) RpgGui.hide(PrebuiltGui.Disconnect)
448
- RpgPlugin.emit(HookClient.Connected, [this, this.socket], true)
449
- this.hasBeenDisconnected = false
450
- })
451
-
452
- this.socket.on('playerJoined', (playerEvent) => {
453
- this.gameEngine.playerId = playerEvent.playerId
454
- this.session = playerEvent.session
455
- })
456
-
457
- this.socket.on('connect_error', (err: any) => {
458
- RpgPlugin.emit(HookClient.ConnectedError, [this, err, this.socket], true)
459
- })
460
-
461
- this.socket.on('preLoadScene', ({ id, reconnect }: { id: string, reconnect?: boolean }) => {
462
- if (this.lastScene == id) {
463
- return
464
- }
465
- this.lastScene = id
466
- this.renderer.transitionScene(id)
467
- if (reconnect) {
468
- this.roomJoin.next('')
469
- this.roomJoin.complete()
470
- }
471
- })
472
-
473
- this.socket.on(SocketEvents.GameReload, () => {
474
- window.location.reload()
475
- })
476
-
477
- this.socket.on(SocketEvents.LoadScene, ({ name, data }) => {
478
- this.renderer.loadScene(name, data)
479
- })
480
-
481
- this.socket.on(SocketEvents.ChangeServer, async({ url, port }) => {
482
- const connection = url + ':' + port
483
- if (this.lastConnection == connection) {
484
- return
485
- }
486
- if (this.subscriptionWorld) {
487
- this.subscriptionWorld.unsubscribe()
488
- }
489
- this.lastConnection = connection
490
- this.serverChanging = true
491
- this.socket.disconnect()
492
- this.connection(connection)
493
- })
494
-
495
- this.socket.on('changeTile', ({ tiles, x, y }) => {
496
- const scene = this.renderer.getScene<SceneMap>()
497
- scene?.changeTile(x, y, tiles)
498
- })
499
-
500
- const callMethod = ({ objectId, params, name }) => {
501
- const scene = this.renderer.getScene<SceneMap>()
502
- const sprite = scene?.getPlayer(objectId)
503
- if (!sprite) return
504
- switch (name) {
505
- case SocketMethods.ShowAnimation:
506
- scene?.showAnimation({
507
- attachTo: sprite,
508
- graphic: params[0],
509
- animationName: params[1],
510
- replaceGraphic: params[2]
511
- })
512
- break
513
- case SocketMethods.CameraFollow:
514
- const [spriteId, options] = params
515
- scene?.cameraFollowSprite(spriteId, options)
516
- break
517
- case SocketMethods.PlaySound:
518
- RpgSound.play(params[0])
519
- break
520
- case SocketMethods.ModeMove:
521
- const player = this.player
522
- const { checkCollision } = params[0]
523
- if (player) {
524
- player.checkCollision = checkCollision
525
- }
526
- break
527
- }
528
- }
529
-
530
- this.socket.on(SocketEvents.CallMethod, callMethod)
531
-
532
- let lastRoomId = ''
533
-
534
- this.subscriptionWorld = World.listen(this.socket)
535
- .value
536
- .subscribe(async (val: { data: any, partial: any, time: number, roomId: string, resetProps: string[] }) => {
537
- const scene = this.renderer.getScene<SceneMap>()
538
-
539
- if (!val.data) {
540
- return
541
- }
542
-
543
- const partialRoom = val.partial
544
-
545
- if (val.roomId != lastRoomId) {
546
- this.clientFrames.clear()
547
- this.serverFrames.clear()
548
- this.gameEngine.resetObjects()
549
- lastRoomId = val.roomId
550
- this.isTeleported = false
551
- }
552
-
553
- const objectsChanged = {}
554
-
555
- const callAction = (objectId: string, paramsChanged) => {
556
- if (paramsChanged && SocketEvents.CallMethod in paramsChanged) {
557
- // Force rendering on the map (display events) and then perform actions on it (animation, etc.).
558
- this.renderer.draw(Date.now(), 1, 1, 1)
559
- callMethod({
560
- objectId,
561
- ...paramsChanged[SocketEvents.CallMethod]
562
- })
563
- }
564
- }
565
-
566
- const change = (prop, root = val, localEvent = false) => {
567
- const list = root.data[prop]
568
- const partial = root.partial[prop]
569
- const isShape = prop == 'shapes'
570
- if (!partial) {
571
- return
572
- }
573
- if (val.resetProps.indexOf(prop) != -1) {
574
- const objects = isShape ? this.gameEngine.getShapes() : this.gameEngine.getObjects()
575
- for (let key in objects) {
576
- const obj = objects[key]
577
- if (obj) {
578
- this.gameEngine.removeObjectAndShape(key)
579
- }
580
- }
581
- }
582
- for (let key in partial) {
583
- const obj = list[key]
584
- const paramsChanged = partial ? partial[key] : undefined
585
-
586
- if (obj == null || obj.deleted) {
587
- // perform actions on the sprite before deleting it
588
- callAction(key, paramsChanged)
589
- this.gameEngine.removeObjectAndShape(key)
590
- continue
591
- }
592
-
593
- if (!obj) continue
594
-
595
- if (!isShape) {
596
- obj.type = {
597
- users: PlayerType.Player,
598
- events: PlayerType.Event
599
- }[prop]
600
- }
601
- if (prop == 'users' && this.gameEngine.playerId == key) {
602
- if (obj.events) {
603
- const nbEvents = Object.values(obj.events)
604
- if (nbEvents.length == 0) {
605
- this.gameEngine.events = {}
606
- }
607
- else {
608
- change('events', {
609
- data: obj,
610
- partial: paramsChanged,
611
- time: val.time,
612
- roomId: val.roomId,
613
- resetProps: val.resetProps
614
- }, true)
615
- }
616
- }
617
- if (partialRoom?.pos && partialRoom?.frame !== undefined) {
618
- this.serverFrames.set(partialRoom.frame, {
619
- data: partialRoom.pos,
620
- time: Date.now()
621
- })
622
- }
623
- }
624
- objectsChanged[key] = this.gameEngine.updateObject({
625
- playerId: key,
626
- params: obj,
627
- localEvent,
628
- paramsChanged,
629
- isShape
630
- })
631
-
632
- // perform actions on the sprite after creation/update
633
- callAction(key, paramsChanged)
634
- }
635
- }
636
-
637
- if (partialRoom.join) {
638
- this.roomJoin.next(partialRoom)
639
- this.roomJoin.complete()
640
- }
641
-
642
- change('users')
643
- change('events')
644
- change('shapes')
645
-
646
- this.gameEngine.setObjectsChanged(objectsChanged)
647
-
648
- if (scene) {
649
- scene.update(val)
650
- }
651
- })
652
-
653
- this.socket.on('disconnect', (reason: string) => {
654
- if (this.serverChanging) {
655
- return
656
- }
657
- if (RpgGui.exists(PrebuiltGui.Disconnect)) RpgGui.display(PrebuiltGui.Disconnect)
658
- RpgPlugin.emit(HookClient.Disconnect, [this, reason, this.socket], true)
659
- this.hasBeenDisconnected = true
660
- })
661
-
662
- RpgGui._setSocket(this.socket)
663
-
664
- if (standalone) {
665
- await this.socket.connection({
666
- auth: {
667
- token: this.session
668
- }
669
- })
670
- }
671
-
672
- this.serverChanging = false
673
- }
674
-
675
- get world(): any {
676
- return World
677
- }
678
-
679
- // shortcuts
680
-
681
- /**
682
- * VueJS Application instance
683
- *
684
- * [https://v3.vuejs.org/api/application-api.html](https://v3.vuejs.org/api/application-api.html)
685
- *
686
- * @prop {Vue} [vueApp]
687
- * @readonly
688
- * @memberof RpgClientEngine
689
- * */
690
- get vueApp() {
691
- return this.renderer.app
692
- }
693
-
694
- /**
695
- * VueJS Parent component instance
696
- *
697
- * [https://v3.vuejs.org/api/instance-properties.html](https://v3.vuejs.org/api/instance-properties.html)
698
- *
699
- * @prop {Vue Instance} [vueInstance]
700
- * @readonly
701
- * @memberof RpgClientEngine
702
- * */
703
- get vueInstance() {
704
- return this.renderer.vm
705
- }
706
-
707
- /**
708
- * retrieves the current scene (SceneMap if you are on a map)
709
- *
710
- * @prop {RpgScene} [scene]
711
- * @deprecated
712
- * @readonly
713
- * @memberof RpgClientEngine
714
- * */
715
- get scene() {
716
- return this.renderer.getScene()
717
- }
718
-
719
- /**
720
- * retrieves the current scene (SceneMap if you are on a map)
721
- *
722
- * @title Connect to server
723
- * @method getScene()
724
- * @returns {RpgScene}
725
- * @memberof RpgClientEngine
726
- */
727
- getScene<T = Scene>(): T | null {
728
- return this.renderer.getScene<T>()
729
- }
730
-
731
- /**
732
- * get PIXI class
733
- * @prop {PIXI} [PIXI]
734
- * @readonly
735
- * @memberof RpgClientEngine
736
- */
737
- get PIXI() {
738
- return PIXI
739
- }
740
-
741
- /**
742
- * get player id of the current player
743
- * @prop {string} [playerId]
744
- * @readonly
745
- * @memberof RpgClientEngine
746
- */
747
- get playerId(): string {
748
- return this.gameEngine.playerId
749
- }
750
-
751
- /**
752
- * Finds the game mode from the environment variables sent by the compiler.
753
- * Can be used in menus to display options according to type
754
- *
755
- * @title Game Type
756
- * @prop {string|undefined} [gameType] mmorpg | rpg or undefined if environment variable not found
757
- * @readonly
758
- * @memberof RpgClientEngine
759
- * @since 4.0.0
760
- */
761
- get gameType(): 'mmorpg' | 'rpg' | undefined {
762
- return this.envs?.['VITE_RPG_TYPE']
763
- }
764
-
765
- /**
766
- * Find out if the game is in production or not, from the environment variables sent by the compiler.
767
- *
768
- * @title Game is dev mode
769
- * @prop {boolean} [isDev]
770
- * @readonly
771
- * @memberof RpgClientEngine
772
- * @since 4.0.0
773
- */
774
- get isDev(): boolean {
775
- return !this.envs?.['VITE_BUILT']
776
- }
777
-
778
- /**
779
- * Get the server url. This is the url for the websocket
780
- *
781
- * To customize the URL, use the `matchMakerService` configuration
782
- *
783
- * @title Server URL
784
- * @prop {string} [serverUrl] If empty string, server url is same as client url
785
- * @readonly
786
- * @memberof RpgClientEngine
787
- * @since 4.0.0
788
- */
789
- get serverUrl(): string {
790
- if (!this._serverUrl.startsWith('http')) {
791
- return 'http://' + this._serverUrl
792
- }
793
- return this._serverUrl
794
- }
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
+ }
795
124
 
796
- get assetsPath(): string {
797
- 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`)
798
129
  }
130
+ return effect.instance
131
+ }
799
132
 
800
- get module() {
801
- return RpgPlugin
802
- }
133
+ processInput({ input }: { input: number }) {
134
+ this.webSocket.emit('move', { input })
135
+ }
803
136
 
804
- reset() {
805
- this.subscriptionWorld.unsubscribe()
806
- this.world.reset()
807
- spritesheets.clear()
808
- sounds.clear()
809
- Assets.reset()
810
- utils.clearTextureCache()
811
- for (let textureUrl in utils.BaseTextureCache) {
812
- delete utils.BaseTextureCache[textureUrl]
813
- }
814
- for (let textureUrl in utils.TextureCache) {
815
- delete utils.TextureCache[textureUrl]
816
- }
817
- RpgGui.clear()
818
- RpgCommonMap.bufferClient.clear()
819
- RpgSound.clear()
820
- }
137
+ processAction({ action }: { action: number }) {
138
+ if (this.stopProcessingInput) return;
139
+ this.webSocket.emit('action', { action })
140
+ }
821
141
  }