refactor: split traits use local imports

This commit is contained in:
cha0s 2019-04-14 20:33:52 -05:00
parent fda1dfb3f3
commit 4a137d0bac
10 changed files with 47 additions and 40 deletions

View File

@ -8,4 +8,3 @@ export {
fromJSON as behaviorItemFromJSON,
register as registerBehaviorItem
} from './item/registry';
export {Routines} from './item/routines';

View File

@ -1,7 +1,9 @@
import {compose} from '@avocado/core';
import {createContext, Routines} from '@avocado/behavior';
import {StateProperty, Trait} from '@avocado/entity';
import {createContext} from '../context';
import {Routines} from '../item/routines';
const decorate = compose(
StateProperty('isBehaving'),
StateProperty('currentRoutine'),

View File

@ -1,8 +1,10 @@
import {compose} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity';
import {Image, Sprite} from '@avocado/graphics';
import {Rectangle, Vector} from '@avocado/math';
import {Image} from '../image';
import {Sprite} from '../sprite';
const decorate = compose(
StateProperty('currentImage', {
track: true,

View File

@ -1,8 +1,10 @@
import {compose} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity';
import {hasGraphics, Container} from '@avocado/graphics';
import {Rectangle, Vector} from '@avocado/math';
import {Container} from '../container';
import {hasGraphics} from '../has-graphics';
const decorate = compose(
StateProperty('isVisible', {
track: true,

View File

@ -1,34 +1,7 @@
export {BodyView} from './body-view';
import {PolygonShape} from './polygon';
export {PolygonShape};
import {CircleShape} from './circle';
export {CircleShape};
import {RectangleShape} from './rectangle';
export {RectangleShape};
import {ShapeList} from './list';
export {ShapeList};
export {CircleShape} from './circle';
export {ShapeList} from './list';
export {PolygonShape} from './polygon';
export {RectangleShape} from './rectangle';
export {shapeFromJSON} from './shape-from-json';
export {ShapeView} from './shape-view';
export function shapeFromJSON(json) {
let shape;
switch (json.type) {
case 'circle':
shape = new CircleShape();
break;
case 'list':
shape = new ShapeList();
break;
case 'polygon':
shape = new PolygonShape();
break;
case 'rectangle':
shape = new RectangleShape();
break;
}
return shape.fromJSON(json);
}

View File

@ -0,0 +1,23 @@
import {PolygonShape} from './polygon';
import {CircleShape} from './circle';
import {RectangleShape} from './rectangle';
import {ShapeList} from './list';
export function shapeFromJSON(json) {
let shape;
switch (json.type) {
case 'circle':
shape = new CircleShape();
break;
case 'list':
shape = new ShapeList();
break;
case 'polygon':
shape = new PolygonShape();
break;
case 'rectangle':
shape = new RectangleShape();
break;
}
return shape.fromJSON(json);
}

View File

@ -1,7 +1,8 @@
import {compose} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity';
import {Vector} from '@avocado/math';
import {BodyView} from '@avocado/physics';
import {BodyView} from '../body-view';
const decorate = compose(
StateProperty('addedToPhysics', {

View File

@ -1,6 +1,8 @@
import {compose} from '@avocado/core';
import {Trait} from '@avocado/entity';
import {shapeFromJSON, ShapeView} from '@avocado/physics';
import {shapeFromJSON} from '../shape-from-json';
import {ShapeView} from '../shape-view';
const decorate = compose(
);

View File

@ -1,7 +1,9 @@
import {compose} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity';
import {Rectangle, Vector} from '@avocado/math';
import {Animation, AnimationView} from '@avocado/timing';
import {Animation} from '../animation';
import {AnimationView} from '../animation-view';
const decorate = compose(
StateProperty('currentAnimation', {

View File

@ -1,5 +1,6 @@
import {Trait} from '@avocado/entity';
import {Camera} from '@avocado/topdown';
import {Camera} from '../camera';
export class Followed extends Trait {