-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameRoom.ts
48 lines (36 loc) · 1.05 KB
/
GameRoom.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Room, Client } from "colyseus";
import { GameState } from './Schema';
import { Game } from './game';
export class GameRoom extends Room
{
// maxClients = 6;
game = new Game();
onCreate (options:any)
{
this.setState(new GameState());
const w = this.state.world;
// this.setSimulationInterval((dt) => this.update(dt));
this.onMessage("avatar", (client, message) => {
const avatar = this.state.avatars[client.id];
this.game.processAvatarMessage(message, avatar, this.state);
});
}
onJoin (client:Client, options:any)
{
this.state.createAvatar(client.id, 0);
}
onLeave (client:Client, consented:boolean)
{
this.state.removeAvatar(client.id);
}
onDispose() {}
// update(elapsed:number)
// {
// let dt = elapsed/1000;
// this.game.update(dt, this.state);
// }
// broadcastPatch()
// {
// return super.broadcastPatch();
// }
}