Add basic multiplayer

This commit is contained in:
schmelczerandras 2020-10-05 19:07:17 +02:00
parent 0f0a1eaf67
commit 46a48e7c15
113 changed files with 1362 additions and 754 deletions

View file

@ -0,0 +1,8 @@
import { v4 } from 'uuid';
import { Id } from './identity';
export class IdentityManager {
public static generateId(): Id {
return v4();
}
}

View file

@ -0,0 +1 @@
export type Id = number;

View file

@ -1,4 +1,5 @@
export enum TransportEvents {
PlayerJoining = "PlayerJoining",
PlayerSendingInfo = "PlayerSendingInfo",
PlayerJoining = 'PlayerJoining',
PlayerToServer = 'PlayerToServer',
ServerToPlayer = 'ServerToPlayer',
}

View file

@ -0,0 +1,11 @@
/**
* static type: string must be implemented
* @param constructor
*/
export const typed = <T extends { new (...args: any[]): {} }>(constructor: T) => {
return class extends constructor {
public get type(): string {
return (this as any).constructor.type;
}
};
};