Setup formatting
This commit is contained in:
parent
d34f25295c
commit
dd850d11d1
45 changed files with 230 additions and 190 deletions
|
|
@ -3,5 +3,5 @@ import { CommandGenerator } from './command-generator';
|
|||
|
||||
export const broadcastCommands = (
|
||||
commandGenerators: Array<CommandGenerator>,
|
||||
commandReceivers: Array<CommandReceiver>
|
||||
commandReceivers: Array<CommandReceiver>,
|
||||
) => commandReceivers.forEach((r) => commandGenerators.forEach((g) => g.subscribe(r)));
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
import { Command } from './command';
|
||||
|
||||
export type CommandExecutors = {
|
||||
[type: string]: (command: Command) => void;
|
||||
[type: string]: (command: any) => unknown;
|
||||
};
|
||||
|
||||
export abstract class CommandReceiver {
|
||||
protected commandExecutors: CommandExecutors = {};
|
||||
|
||||
protected defaultCommandExecutor(command: Command) { }
|
||||
|
||||
public reactsToCommand(commandType: string): boolean {
|
||||
return Object.prototype.hasOwnProperty.call(this.commandExecutors, commandType);
|
||||
}
|
||||
|
||||
protected defaultCommandExecutor(_: Command) {}
|
||||
|
||||
public sendCommand(command: Command) {
|
||||
const commandType = command.type;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { serializable } from '../transport/serialization/serializable';
|
|||
|
||||
@serializable
|
||||
export class Circle {
|
||||
constructor(public center: vec2, public radius: number) { }
|
||||
constructor(public center: vec2, public radius: number) {}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [this.center, this.radius];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { serializable } from '../transport/serialization/serializable';
|
|||
|
||||
@serializable
|
||||
export class Rectangle {
|
||||
constructor(public topLeft = vec2.create(), public size = vec2.create()) { }
|
||||
constructor(public topLeft = vec2.create(), public size = vec2.create()) {}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [this.topLeft, this.size];
|
||||
|
|
|
|||
|
|
@ -33,4 +33,3 @@ export * from './objects/types/tunnel-base';
|
|||
export * from './settings';
|
||||
export * from './transport/transport-events';
|
||||
export * from './transport/identity';
|
||||
export * from './transport/type-to-base-type';
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export class CharacterBase extends GameObject {
|
|||
id: Id,
|
||||
public head: Circle,
|
||||
public leftFoot: Circle,
|
||||
public rightFoot: Circle
|
||||
public rightFoot: Circle,
|
||||
) {
|
||||
super(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export class TunnelBase extends GameObject {
|
|||
public readonly from: vec2,
|
||||
public readonly to: vec2,
|
||||
public readonly fromRadius: number,
|
||||
public readonly toRadius: number
|
||||
public readonly toRadius: number,
|
||||
) {
|
||||
super(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export type DeserializableClass = { new(...args: Array<any>): {}; name: string };
|
||||
export type DeserializableClass = { new (...args: Array<any>): unknown; name: string };
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { serializableMapping } from './serializable-mapping';
|
|||
|
||||
export const overrideDeserialization = (
|
||||
source: SerializableClass,
|
||||
target: DeserializableClass
|
||||
target: DeserializableClass,
|
||||
) => {
|
||||
serializableMapping.set(source.name, {
|
||||
constructor: target,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type SerializableClass = {
|
||||
new(...args: Array<any>): { toArray(): Array<any> };
|
||||
new (...args: Array<any>): { toArray(): Array<any> };
|
||||
name: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
export const typeToBaseType = <T extends { new(...args: any[]): {} }>(
|
||||
constructor: T
|
||||
) => {
|
||||
const parent = constructor;
|
||||
return class extends constructor {
|
||||
public static get type(): string {
|
||||
return Object.getPrototypeOf((parent as any).prototype).constructor.name;
|
||||
}
|
||||
|
||||
public get type(): string {
|
||||
return Object.getPrototypeOf((parent as any).prototype).constructor.name;
|
||||
}
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue