WIP
This commit is contained in:
parent
37954e2ef1
commit
cd75bdbfde
20 changed files with 253 additions and 131 deletions
|
|
@ -9,6 +9,19 @@ export abstract class Random {
|
|||
Random._seed = value;
|
||||
}
|
||||
|
||||
public static choose<T>(values: Array<T>): T | undefined {
|
||||
const to = values.length;
|
||||
if (to === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return values[Math.floor(this.getRandomInRange(0, to))];
|
||||
}
|
||||
|
||||
public static getRandomInRange(from: number, to: number): number {
|
||||
return from + this.getRandom() * (to - from);
|
||||
}
|
||||
|
||||
public static getRandom(): number {
|
||||
let t = (Random._seed += 0x6d2b79f5);
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export * from './commands/types/update-objects';
|
|||
export * from './commands/types/step';
|
||||
export * from './commands/types/ternary-action';
|
||||
export * from './commands/types/move-action';
|
||||
export * from './commands/types/set-aspect-ratio-action';
|
||||
export * from './commands/types/primary-action';
|
||||
export * from './commands/types/secondary-action';
|
||||
export * from './commands/command-receiver';
|
||||
|
|
@ -33,6 +32,7 @@ export * from './transport/serialization/serializable';
|
|||
export * from './transport/serialization/override-deserialization';
|
||||
export * from './objects/types/character-base';
|
||||
export * from './objects/types/lamp-base';
|
||||
export * from './objects/types/projectile-base';
|
||||
export * from './objects/types/tunnel-base';
|
||||
export * from './settings';
|
||||
export * from './transport/transport-events';
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class CharacterBase extends GameObject {
|
|||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
const { id, head, leftFoot, rightFoot } = this as any;
|
||||
const { id, head, leftFoot, rightFoot } = this;
|
||||
return [id, head, leftFoot, rightFoot];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export class LampBase extends GameObject {
|
|||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
const { id, center, color, lightness } = this as any;
|
||||
const { id, center, color, lightness } = this;
|
||||
return [id, center, color, lightness];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
shared/src/objects/types/projectile-base.ts
Normal file
15
shared/src/objects/types/projectile-base.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Id } from '../../transport/identity';
|
||||
import { serializable } from '../../transport/serialization/serializable';
|
||||
import { GameObject } from '../game-object';
|
||||
|
||||
@serializable
|
||||
export class ProjectileBase extends GameObject {
|
||||
constructor(id: Id, public center: vec2, public radius: number) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
return [this.id, this.center, this.radius];
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ export class TunnelBase extends GameObject {
|
|||
}
|
||||
|
||||
public toArray(): Array<any> {
|
||||
const { id, from, to, fromRadius, toRadius } = this as any;
|
||||
const { id, from, to, fromRadius, toRadius } = this;
|
||||
return [id, from, to, fromRadius, toRadius];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue