Add basic multiplayer
This commit is contained in:
parent
0f0a1eaf67
commit
46a48e7c15
113 changed files with 1362 additions and 754 deletions
8
shared/src/transport/identity-manager.ts
Normal file
8
shared/src/transport/identity-manager.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { v4 } from 'uuid';
|
||||
import { Id } from './identity';
|
||||
|
||||
export class IdentityManager {
|
||||
public static generateId(): Id {
|
||||
return v4();
|
||||
}
|
||||
}
|
||||
1
shared/src/transport/identity.ts
Normal file
1
shared/src/transport/identity.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export type Id = number;
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
export enum TransportEvents {
|
||||
PlayerJoining = "PlayerJoining",
|
||||
PlayerSendingInfo = "PlayerSendingInfo",
|
||||
PlayerJoining = 'PlayerJoining',
|
||||
PlayerToServer = 'PlayerToServer',
|
||||
ServerToPlayer = 'ServerToPlayer',
|
||||
}
|
||||
|
|
|
|||
11
shared/src/transport/typed.ts
Normal file
11
shared/src/transport/typed.ts
Normal 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;
|
||||
}
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue