Simplify types
This commit is contained in:
parent
6eddb4834b
commit
ba8b1a29fd
30 changed files with 52 additions and 76 deletions
|
|
@ -7,7 +7,7 @@ export type CommandExecutors = {
|
|||
export abstract class CommandReceiver {
|
||||
protected commandExecutors: CommandExecutors = {};
|
||||
|
||||
protected defaultCommandExecutor(command: Command) {}
|
||||
protected defaultCommandExecutor(command: Command) { }
|
||||
|
||||
public reactsToCommand(commandType: string): boolean {
|
||||
return Object.prototype.hasOwnProperty.call(this.commandExecutors, commandType);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import { Id } from '../transport/identity';
|
||||
import { Typed } from '../transport/typed';
|
||||
|
||||
export abstract class Command {
|
||||
public get type(): string {
|
||||
return (this as any).constructor.type;
|
||||
}
|
||||
}
|
||||
export abstract class Command extends Typed { }
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { Command } from '../command';
|
||||
|
||||
export class CreateObjectsCommand extends Command {
|
||||
public static readonly type = 'CreateObjectsCommand';
|
||||
|
||||
public constructor(public readonly serializedObjects: string) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { Command } from '../command';
|
||||
|
||||
export class CreatePlayerCommand extends Command {
|
||||
public static readonly type = 'CreatePlayerCommand';
|
||||
|
||||
public constructor(public readonly serializedPlayer: string) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { Id } from '../../transport/identity';
|
|||
import { Command } from '../command';
|
||||
|
||||
export class DeleteObjectsCommand extends Command {
|
||||
public static readonly type = 'DeleteObjectsCommand';
|
||||
|
||||
public constructor(public readonly ids: Array<Id>) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { vec2 } from 'gl-matrix';
|
|||
import { Command } from '../command';
|
||||
|
||||
export class MoveActionCommand extends Command {
|
||||
public static readonly type = 'MoveActionCommand';
|
||||
|
||||
public constructor(public readonly delta: vec2) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { vec2 } from 'gl-matrix';
|
|||
import { Command } from '../command';
|
||||
|
||||
export class PrimaryActionCommand extends Command {
|
||||
public static readonly type = 'PrimaryActionCommand';
|
||||
|
||||
public constructor(public readonly position: vec2) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { vec2 } from 'gl-matrix';
|
|||
import { Command } from '../command';
|
||||
|
||||
export class SecondaryActionCommand extends Command {
|
||||
public static readonly type = 'SecondaryActionCommand';
|
||||
|
||||
public constructor(public readonly position: vec2) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { Rectangle } from '../../helper/rectangle';
|
|||
import { Command } from '../command';
|
||||
|
||||
export class SetViewAreaActionCommand extends Command {
|
||||
public static readonly type = 'SetViewAreaAction';
|
||||
|
||||
public constructor(public readonly viewArea: Rectangle) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { Command } from '../command';
|
||||
|
||||
export class StepCommand extends Command {
|
||||
public static readonly type = 'StepCommand';
|
||||
|
||||
public constructor(public readonly deltaTimeInMiliseconds: DOMHighResTimeStamp) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { vec2 } from 'gl-matrix';
|
|||
import { Command } from '../command';
|
||||
|
||||
export class TernaryActionCommand extends Command {
|
||||
public static readonly type = 'TernaryActionCommand';
|
||||
|
||||
public constructor(public readonly position: vec2) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { Command } from '../command';
|
||||
|
||||
export class UpdateObjectsCommand extends Command {
|
||||
public static readonly type = 'UpdateObjectsCommand';
|
||||
|
||||
public constructor(public readonly serializedObjects: string) {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue