@rpgjs/common 4.0.0-beta.10 → 4.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import { intersection, generateUID, toRadians, isInstanceOf } from './Utils';
2
- import { Hit, HitType } from './Hit';
3
- import { RpgShape } from './Shape';
1
+ import { intersection, generateUID, toRadians, isInstanceOf } from './Utils.js';
2
+ import { Hit, HitType } from './Hit.js';
3
+ import { RpgShape } from './Shape.js';
4
4
  import SAT from 'sat';
5
- import { RpgCommonMap } from './Map';
6
- import { RpgPlugin, HookServer } from './Plugin';
7
- import { GameSide } from './Game';
8
- import { Vector2d, Vector2dZero } from './Vector2d';
5
+ import { RpgCommonMap } from './Map.js';
6
+ import { RpgPlugin, HookServer } from './Plugin.js';
7
+ import { GameSide } from './Game.js';
8
+ import { Vector2d, Vector2dZero } from './Vector2d.js';
9
9
  import { Behavior, Direction, MoveClientMode, PlayerType } from '@rpgjs/types';
10
10
  import { from, map, mergeMap, Subject, tap, takeUntil } from 'rxjs';
11
11
  const ACTIONS = { IDLE: 0, RUN: 1, ACTION: 2 };
package/lib/Event.js CHANGED
@@ -1,4 +1,4 @@
1
- import { RpgCommonPlayer } from './Player';
1
+ import { RpgCommonPlayer } from './Player.js';
2
2
  export class RpgCommonEvent extends RpgCommonPlayer {
3
3
  }
4
4
  //# sourceMappingURL=Event.js.map
@@ -1,4 +1,4 @@
1
- import { isPromise } from './Utils';
1
+ import { isPromise } from './Utils.js';
2
2
  export class EventEmitter {
3
3
  constructor() {
4
4
  this.listeners = {};
package/lib/Game.js CHANGED
@@ -1,10 +1,10 @@
1
- import { generateUID, isClass } from './Utils';
2
- import { EventEmitter } from './EventEmitter';
3
- import { RpgCommonPlayer } from './Player';
1
+ import { generateUID, isClass } from './Utils.js';
2
+ import { EventEmitter } from './EventEmitter.js';
3
+ import { RpgCommonPlayer } from './Player.js';
4
4
  import { Control, Direction } from '@rpgjs/types';
5
- import { RpgPlugin } from './Plugin';
6
- import { GameWorker } from './Worker';
7
- import { RpgShape } from './Shape';
5
+ import { RpgPlugin } from './Plugin.js';
6
+ import { GameWorker } from './Worker.js';
7
+ import { RpgShape } from './Shape.js';
8
8
  export var GameSide;
9
9
  (function (GameSide) {
10
10
  GameSide["Server"] = "server";
package/lib/Hit.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HitType } from '@rpgjs/types';
2
2
  import SAT from 'sat';
3
- import { isInstanceOf } from './Utils';
3
+ import { isInstanceOf } from './Utils.js';
4
4
  export { HitType } from '@rpgjs/types';
5
5
  class HitClass {
6
6
  createObjectHitbox(x, y, z, w, h) {
package/lib/Map.js CHANGED
@@ -1,9 +1,9 @@
1
- import Utils, { random, generateUID } from './Utils';
2
- import { RpgShape } from './Shape';
3
- import { Hit } from './Hit';
4
- import { VirtualGrid } from './VirtualGrid';
1
+ import Utils, { random, generateUID } from './Utils.js';
2
+ import { RpgShape } from './Shape.js';
3
+ import { Hit } from './Hit.js';
4
+ import { VirtualGrid } from './VirtualGrid.js';
5
5
  import { MapClass } from '@rpgjs/tiled';
6
- import { AbstractObject } from './AbstractObject';
6
+ import { AbstractObject } from './AbstractObject.js';
7
7
  import { map, Subject, takeUntil, mergeMap, from, filter } from 'rxjs';
8
8
  const buffer = new Map();
9
9
  const bufferClient = new Map();
package/lib/Module.js CHANGED
@@ -1,6 +1,6 @@
1
- import { RpgPlugin, HookServer, HookClient } from './Plugin';
2
- import { isArray, isClass, isFunction, isPromise } from './Utils';
3
- import { warning } from './Logger';
1
+ import { RpgPlugin, HookServer, HookClient } from './Plugin.js';
2
+ import { isArray, isClass, isFunction, isPromise } from './Utils.js';
3
+ import { warning } from './Logger.js';
4
4
  var Side;
5
5
  (function (Side) {
6
6
  Side["Server"] = "server";
package/lib/Player.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AbstractObject } from './AbstractObject';
1
+ import { AbstractObject } from './AbstractObject.js';
2
2
  export const LiteralDirection = {
3
3
  1: 'up',
4
4
  2: 'right',
package/lib/Plugin.js CHANGED
@@ -1,5 +1,5 @@
1
- import { EventEmitter } from './EventEmitter';
2
- import { isArray } from './Utils';
1
+ import { EventEmitter } from './EventEmitter.js';
2
+ import { isArray } from './Utils.js';
3
3
  export var HookServer;
4
4
  (function (HookServer) {
5
5
  HookServer["Start"] = "Server.Start";
@@ -10,6 +10,7 @@ export declare class Scheduler extends EventEmitter {
10
10
  private requestedDelay;
11
11
  private lastTimestamp;
12
12
  private _tick;
13
+ private _stop;
13
14
  get tick(): Observable<Tick>;
14
15
  nextTick(timestamp: number): void;
15
16
  /**
@@ -21,4 +22,5 @@ export declare class Scheduler extends EventEmitter {
21
22
  fps?: number;
22
23
  delay?: number;
23
24
  }): this;
25
+ stop(): void;
24
26
  }
package/lib/Scheduler.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
- import { EventEmitter } from './EventEmitter';
3
- import Utils from './Utils';
2
+ import { EventEmitter } from './EventEmitter.js';
3
+ import Utils from './Utils.js';
4
4
  export class Scheduler extends EventEmitter {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -16,6 +16,7 @@ export class Scheduler extends EventEmitter {
16
16
  frame: 0,
17
17
  deltaRatio: 0
18
18
  });
19
+ this._stop = false;
19
20
  }
20
21
  get tick() {
21
22
  return this._tick.asObservable();
@@ -67,6 +68,8 @@ export class Scheduler extends EventEmitter {
67
68
  let now = Utils.preciseNow();
68
69
  let then = Utils.preciseNow();
69
70
  const loop = (timestamp) => {
71
+ if (this._stop)
72
+ return;
70
73
  requestAnimationFrame(loop);
71
74
  now = Utils.preciseNow();
72
75
  const elapsed = now - then;
@@ -79,5 +82,9 @@ export class Scheduler extends EventEmitter {
79
82
  }
80
83
  return this;
81
84
  }
85
+ stop() {
86
+ this._stop = true;
87
+ this._tick.complete();
88
+ }
82
89
  }
83
90
  //# sourceMappingURL=Scheduler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sche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{ TiledObjectClass } from '@rpgjs/tiled';
3
3
  import { PlayerType } from '@rpgjs/types';
4
- import { Vector2d } from './Vector2d';
4
+ import { Vector2d } from './Vector2d.js';
5
5
  export var ShapePositioning;
6
6
  (function (ShapePositioning) {
7
7
  ShapePositioning["Default"] = "default";
package/lib/index.js CHANGED
@@ -1,25 +1,25 @@
1
- import AbstractObject from './Player';
2
- export { LiteralDirection, RpgCommonPlayer } from './Player';
1
+ import AbstractObject from './Player.js';
2
+ export { LiteralDirection, RpgCommonPlayer } from './Player.js';
3
3
  export { AbstractObject };
4
- export { RpgCommonEvent } from './Event';
5
- export { RpgCommonMap } from './Map';
6
- export { RpgCommonGame, GameSide } from './Game';
7
- export { EventEmitter } from './EventEmitter';
8
- export { PrebuiltGui } from './gui/PrebuiltGui';
9
- export * as Utils from './Utils';
10
- export { RpgPlugin, HookServer, HookClient } from './Plugin';
11
- export * as TransportIo from './transports/io';
4
+ export { RpgCommonEvent } from './Event.js';
5
+ export { RpgCommonMap } from './Map.js';
6
+ export { RpgCommonGame, GameSide } from './Game.js';
7
+ export { EventEmitter } from './EventEmitter.js';
8
+ export { PrebuiltGui } from './gui/PrebuiltGui.js';
9
+ export * as Utils from './Utils.js';
10
+ export { RpgPlugin, HookServer, HookClient } from './Plugin.js';
11
+ export * as TransportIo from './transports/io.js';
12
12
  export { Input, Control } from '@rpgjs/types';
13
- export { Hit } from './Hit';
14
- export { Scheduler } from './Scheduler';
15
- export { RpgModule, loadModules } from './Module';
16
- export * as MockIo from './transports/io';
17
- export * as Logger from './Logger';
18
- export { RpgShape, ShapePositioning } from './Shape';
19
- export { VirtualGrid } from './VirtualGrid';
20
- export { RpgCommonWorldMaps } from './WorldMaps';
21
- export { Vector2d } from './Vector2d';
13
+ export { Hit } from './Hit.js';
14
+ export { Scheduler } from './Scheduler.js';
15
+ export { RpgModule, loadModules } from './Module.js';
16
+ export * as MockIo from './transports/io.js';
17
+ export * as Logger from './Logger.js';
18
+ export { RpgShape, ShapePositioning } from './Shape.js';
19
+ export { VirtualGrid } from './VirtualGrid.js';
20
+ export { RpgCommonWorldMaps } from './WorldMaps.js';
21
+ export { Vector2d } from './Vector2d.js';
22
22
  export { Direction } from '@rpgjs/types';
23
- export { transitionColor } from './Color';
24
- export { DefaultInput } from './DefaultInput';
23
+ export { transitionColor } from './Color.js';
24
+ export { DefaultInput } from './DefaultInput.js';
25
25
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import workerpool from 'workerpool';
2
- import { RpgCommonMap } from '../Map';
3
- import { RpgCommonGame, GameSide } from '../Game';
4
- import { RpgCommonPlayer } from '../Player';
2
+ import { RpgCommonMap } from '../Map.js';
3
+ import { RpgCommonGame, GameSide } from '../Game.js';
4
+ import { RpgCommonPlayer } from '../Player.js';
5
5
  const objects = {};
6
6
  let objectsByMap = {};
7
7
  const gameEngine = new RpgCommonGame(GameSide.Worker);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpgjs/common",
3
- "version": "4.0.0-beta.10",
3
+ "version": "4.0.0-beta.12",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -15,14 +15,14 @@
15
15
  "author": "Samuel Ronce",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@rpgjs/tiled": "^4.0.0-beta.10",
19
- "@rpgjs/types": "^4.0.0-beta.10",
18
+ "@rpgjs/tiled": "^4.0.0-beta.12",
19
+ "@rpgjs/types": "^4.0.0-beta.12",
20
20
  "rbush": "^3.0.1",
21
21
  "rxjs": "^7.8.0",
22
22
  "sat": "^0.9.0",
23
23
  "workerpool": "^6.4.0"
24
24
  },
25
- "gitHead": "3f2cc83f8738e0dd3503d3d3408a18bc2d8add71",
25
+ "gitHead": "674d63a05af4312416511893353b98ea5f4f14dd",
26
26
  "devDependencies": {
27
27
  "typescript": "^5.0.4"
28
28
  },
package/src/Scheduler.ts CHANGED
@@ -17,6 +17,7 @@ export class Scheduler extends EventEmitter {
17
17
  frame: 0,
18
18
  deltaRatio: 0
19
19
  })
20
+ private _stop: boolean = false
20
21
 
21
22
  get tick(): Observable<Tick> {
22
23
  return this._tick.asObservable()
@@ -72,6 +73,7 @@ export class Scheduler extends EventEmitter {
72
73
  let now = Utils.preciseNow()
73
74
  let then = Utils.preciseNow()
74
75
  const loop = (timestamp: number) => {
76
+ if (this._stop) return
75
77
  requestAnimationFrame(loop)
76
78
  now = Utils.preciseNow()
77
79
  const elapsed = now - then
@@ -85,4 +87,9 @@ export class Scheduler extends EventEmitter {
85
87
 
86
88
  return this;
87
89
  }
90
+
91
+ stop() {
92
+ this._stop = true
93
+ this._tick.complete()
94
+ }
88
95
  }