fix: explicit types for minification

This commit is contained in:
cha0s 2019-05-05 04:26:35 -05:00
parent 91ffcb890f
commit 537cc167f8
30 changed files with 120 additions and 22 deletions

View File

@ -2,10 +2,15 @@ import {Traversal} from './traversal';
export class Action extends Traversal {
static type() {
return 'action';
}
toJSON() {
return {
...super.toJSON(),
type: 'action',
};
}
}

View File

@ -9,6 +9,10 @@ const decorate = compose(
export class Actions extends decorate(Traversals) {
static type() {
return 'actions';
}
constructor() {
super();
this._index = 0;

View File

@ -4,6 +4,10 @@ export function Collection(type) {
const plural = `${type}s`;
return class Collection {
static type() {
return plural;
}
constructor() {
this[plural] = [];
}

View File

@ -2,6 +2,10 @@ import {fromJSON as behaviorItemFromJSON} from './registry';
export class Condition {
static type() {
return 'condition';
}
constructor() {
this.operator = '';
this.operands = [];

View File

@ -1,5 +1,9 @@
export class Literal {
static type() {
return 'literal';
}
constructor() {
this.value = null;
}

View File

@ -13,10 +13,5 @@ export function deregister(BehaviorItem) {
}
export function register(BehaviorItem) {
if (!BehaviorItem.type) {
BehaviorItem.type = function() {
return BehaviorItem.name.toLowerCase();
}
}
behaviorItemRegistry.set(BehaviorItem.type(), BehaviorItem);
}

View File

@ -2,6 +2,10 @@ import {Actions} from './actions';
export class Routine {
static type() {
return 'routine';
}
constructor() {
this._context = undefined;
this.actions = new Actions();

View File

@ -2,6 +2,10 @@ import {Routine} from './routine';
export class Routines {
static type() {
return 'routines';
}
constructor() {
this._context = undefined;
this.routines = {};

View File

@ -2,6 +2,10 @@ import {fromJSON as behaviorItemFromJSON} from './registry';
export class Traversal {
static type() {
return 'traversal';
}
constructor() {
this.hash = undefined;
this.steps = [];

View File

@ -22,6 +22,10 @@ export class Behaved extends decorate(Trait) {
}
}
static type() {
return 'behaved';
}
initialize() {
this._context = createContext();
this._context.add('entity', this.entity);

View File

@ -95,10 +95,6 @@ export class Trait extends decorate(class {}) {
return [];
}
static type() {
return this.name.toLowerCase();
}
}
export function StateProperty(key, meta = {}) {

View File

@ -16,4 +16,8 @@ export class Debuggable extends decorate(Trait) {
};
}
static type() {
return 'debuggable';
}
}

View File

@ -24,6 +24,10 @@ export class Directional extends decorate(Trait) {
};
}
static type() {
return 'directional';
}
initialize() {
this.directionCount = this.params.directionCount;
}

View File

@ -8,7 +8,7 @@ const decorate = compose(
StateProperty('isTicking'),
);
class ExistentBase extends Trait {
export class Existent extends decorate(Trait) {
static defaultState() {
return {
@ -17,6 +17,10 @@ class ExistentBase extends Trait {
};
}
static type() {
return 'existent';
}
initialize() {
this._isTicking = this.params.isTicking;
}
@ -50,5 +54,3 @@ class ExistentBase extends Trait {
}
}
export class Existent extends decorate(ExistentBase) {}

View File

@ -4,6 +4,10 @@ import {Trait} from '../trait';
export class Listed extends Trait {
static type() {
return 'listed';
}
initialize() {
this.entity.list = undefined;
this.quadTreeAabb = [];

View File

@ -8,7 +8,7 @@ const decorate = compose(
StateProperty('speed'),
)
class MobileBase extends Trait {
export class Mobile extends decorate(Trait) {
static defaultState() {
return {
@ -17,6 +17,10 @@ class MobileBase extends Trait {
};
}
static type() {
return 'mobile';
}
initialize() {
this.requestedMovement = [0, 0];
}
@ -75,5 +79,3 @@ class MobileBase extends Trait {
}
}
export class Mobile extends decorate(MobileBase) {}

View File

@ -14,7 +14,7 @@ const decorate = compose(
);
// < 16768 will pack into 1 short per axe and give +/- 0.25 precision.
class PositionedBase extends Trait {
export class Positioned extends decorate(Trait) {
static defaultState() {
return {
@ -23,6 +23,10 @@ class PositionedBase extends Trait {
};
}
static type() {
return 'positioned';
}
initialize() {
this.on('_positionChanged', this.on_positionChanged, this);
const x = this.state.get('x') >> 2;
@ -143,5 +147,3 @@ class PositionedBase extends Trait {
}
}
export class Positioned extends decorate(PositionedBase) {}

View File

@ -28,6 +28,10 @@ export class Spawner extends decorate(Trait) {
};
}
static type() {
return 'spawner';
}
destroy() {
this.children = [];
}

View File

@ -15,6 +15,10 @@ export class Emitter extends decorate(Trait) {
}
}
static type() {
return 'emitter';
}
static addEmitter(emitter) {
if (!this._emitters) {
this._emitters = [];

View File

@ -25,6 +25,10 @@ export class Pictured extends decorate(Trait) {
};
}
static type() {
return 'pictured';
}
initialize() {
this._cachedAabbs = {};
this._images = this.params.images;

View File

@ -10,5 +10,11 @@ const decorate = compose(
})
)
export class Staged extends decorate(Trait) {}
export class Staged extends decorate(Trait) {
static type() {
return 'staged';
}
}

View File

@ -49,6 +49,10 @@ export class Visible extends decorate(Trait) {
};
}
static type() {
return 'visible';
}
initialize() {
if (hasGraphics) {
this._container = new Container();

View File

@ -23,6 +23,10 @@ export class Collider extends decorate(Trait) {
}
}
static type() {
return 'collider';
}
initialize() {
this._collisionGroup = this.params.collisionGroup;
this._collidesWithGroups = this.params.collidesWithGroups;

View File

@ -18,6 +18,10 @@ export class Physical extends decorate(Trait) {
};
}
static type() {
return 'physical';
}
initialize() {
this._body = undefined;
this.bodyView = undefined;

View File

@ -15,6 +15,10 @@ export class Shaped extends decorate(Trait) {
};
}
static type() {
return 'shaped';
}
initialize() {
this._shape = shapeFromJSON(this.params.shape);
this.shapeView = undefined;

View File

@ -10,6 +10,10 @@ export class Audible extends Trait {
};
}
static type() {
return 'audible';
}
hydrate() {
this.loadSounds();
}

View File

@ -14,7 +14,7 @@ const decorate = compose(
}),
);
class AnimatedBase extends Trait {
export class Animated extends decorate(Trait) {
static defaultParams() {
return {
@ -29,6 +29,10 @@ class AnimatedBase extends Trait {
};
}
static type() {
return 'animated';
}
initialize() {
this._animations = this.params.animations;
this.animations = {};
@ -263,5 +267,3 @@ class AnimatedBase extends Trait {
}
}
export class Animated extends decorate(AnimatedBase) {}

View File

@ -10,6 +10,10 @@ export class Followed extends Trait {
}
}
static type() {
return 'followed';
}
initialize() {
const camera = new Camera();
camera.viewSize = this.params.viewSize;

View File

@ -2,6 +2,10 @@ import {Trait} from '@avocado/entity';
export class Layered extends Trait {
static type() {
return 'layered';
}
initialize() {
this._layer = undefined;
}

View File

@ -2,6 +2,10 @@ import {Trait} from '@avocado/entity';
export class Roomed extends Trait {
static type() {
return 'roomed';
}
initialize() {
this._room = undefined;
}