Add basic multiplayer
This commit is contained in:
parent
0f0a1eaf67
commit
46a48e7c15
113 changed files with 1362 additions and 754 deletions
26
shared/src/objects/deserialize.ts
Normal file
26
shared/src/objects/deserialize.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { CreatePlayerCommand } from '../commands/types/create-player';
|
||||
import { MoveActionCommand } from '../commands/types/move-action';
|
||||
import { PrimaryActionCommand } from '../commands/types/primary-action';
|
||||
import { SecondaryActionCommand } from '../commands/types/secondary-action';
|
||||
import { SetViewAreaActionCommand } from '../commands/types/set-view-area-action';
|
||||
import { TernaryActionCommand } from '../commands/types/ternary-action';
|
||||
import { UpdateObjectsCommand } from '../commands/types/update-objects';
|
||||
import { Command, CreateObjectsCommand, DeleteObjectsCommand } from '../main';
|
||||
|
||||
export const commandConstructors: {
|
||||
[type: string]: new (...values: Array<any>) => any;
|
||||
} = {
|
||||
[CreateObjectsCommand.type]: CreateObjectsCommand,
|
||||
[DeleteObjectsCommand.type]: DeleteObjectsCommand,
|
||||
[CreatePlayerCommand.type]: CreatePlayerCommand,
|
||||
[MoveActionCommand.type]: MoveActionCommand,
|
||||
[PrimaryActionCommand.type]: PrimaryActionCommand,
|
||||
[SecondaryActionCommand.type]: SecondaryActionCommand,
|
||||
[TernaryActionCommand.type]: TernaryActionCommand,
|
||||
[SetViewAreaActionCommand.type]: SetViewAreaActionCommand,
|
||||
[UpdateObjectsCommand.type]: UpdateObjectsCommand,
|
||||
};
|
||||
|
||||
export const deserializeCommand = ([type, ...values]: [string, Array<any>]): Command => {
|
||||
return new commandConstructors[type](...values);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue