refactor: neutrino!

This commit is contained in:
cha0s 2020-06-15 17:26:20 -05:00
parent 2492c03596
commit 55003db99d
74 changed files with 143 additions and 202 deletions

View File

@ -1,6 +1,7 @@
import D from 'debug'; import D from 'debug';
import {invokeHookFlat} from 'scwp';
import {fastApply, invokeHookFlat} from '@avocado/core'; import {fastApply} from '@avocado/core';
const debug = D('@avocado:behavior:context'); const debug = D('@avocado:behavior:context');

View File

@ -1,4 +1,4 @@
import {invokeHookFlat} from '@avocado/core'; import {invokeHookFlat} from 'scwp';
let _behaviorItems; let _behaviorItems;

View File

@ -11,7 +11,7 @@ const decorate = compose(
StateProperty('isBehaving'), StateProperty('isBehaving'),
); );
export class Behaved extends decorate(Trait) { export default class Behaved extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,15 +0,0 @@
const path = require('path');
module.exports = ({entries, paths, root, rules}) => {
rules.push({
test: new RegExp('@avocado/packages/core/hook/entry.js$'),
use: {
loader: '@avocado/core/hook/loader',
options: {
paths,
root,
},
},
});
entries.push('@avocado/core/hook/entry');
};

View File

@ -35,21 +35,28 @@ module.exports = function(source) {
const parts = relativePath.split('/'); const parts = relativePath.split('/');
// Chop off basename. // Chop off basename.
const basename = parts.pop(); const basename = parts.pop();
const moduleName = path.basename(basename, '.js');
// Module or local? // Module or local?
let hookKey;
let importDirectory; let importDirectory;
if ('node_modules' === parts[0]) { if ('node_modules' === parts[0]) {
importDirectory = parts.slice(1).join('/'); importDirectory = parts.slice(1).join('/');
hookKey = `${importDirectory}/${moduleName}`;
} }
else { else {
importDirectory = `${root}/${parts.join('/')}`; importDirectory = `${root}/${parts.join('/')}`;
hookKey = `./${parts.join('/')}/${moduleName}`;
} }
const moduleName = path.basename(basename, '.js');
// Register hooks. // Register hooks.
const importPath = `${importDirectory}/${moduleName}`; const importPath = `${importDirectory}/${moduleName}`;
return [ return [
`registerHooks('${importPath}', require('${importPath}'));`, `registerHooks('${hookKey}', require('${importPath}'));`,
].join('\n'); ].join('\n');
}); });
// Shortcut.
if (0 === registers.length) {
return '';
}
// Import trait registry first. // Import trait registry first.
const output = [ const output = [
`import {registerHooks} from '@avocado/core/hook/registry'`, `import {registerHooks} from '@avocado/core/hook/registry'`,

View File

@ -12,7 +12,7 @@ import {SynchronizedMixin} from '@avocado/net';
import {Resource} from '@avocado/resource'; import {Resource} from '@avocado/resource';
import {hasTrait, lookupTrait} from './trait/registry'; import {hasTrait, lookupTrait} from './trait/registry';
import {EntityUpdateTraitPacket} from './packets/entity-update-trait.packet'; import EntityUpdateTraitPacket from './packets/entity-update-trait.packet';
const debug = D('@avocado:entity:traits'); const debug = D('@avocado:entity:traits');
@ -88,7 +88,7 @@ const decorate = compose(
let numericUid = AVOCADO_SERVER ? 1 : 1000000000; let numericUid = AVOCADO_SERVER ? 1 : 1000000000;
export class Entity extends decorate(Resource) { export default class Entity extends decorate(Resource) {
constructor(json, jsonext) { constructor(json, jsonext) {
super(); super();

View File

@ -1,8 +1,6 @@
export {Entity} from './entity.synchronized'; export {default as Entity} from './entity.synchronized';
export { export {default as EntityListUpdateEntityPacket} from './packets/entity-list-update-entity.packet';
EntityListUpdateEntityPacket,
} from './packets/entity-list-update-entity.packet';
export {EntityList, EntityListView} from './list'; export {EntityList, EntityListView} from './list';

View File

@ -5,8 +5,8 @@ import {
SynchronizedDestroyPacket, SynchronizedDestroyPacket,
} from '@avocado/net'; } from '@avocado/net';
import {EntityListUpdateEntityPacket} from '../packets/entity-list-update-entity.packet'; import EntityListUpdateEntityPacket from '../packets/entity-list-update-entity.packet';
import {Entity} from '../entity.synchronized'; import Entity from '../entity.synchronized';
const decorate = compose( const decorate = compose(
EventEmitter, EventEmitter,

View File

@ -1,3 +1,3 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class DiedPacket extends Packet {} export default class DiedPacket extends Packet {}

View File

@ -1,6 +1,6 @@
import {BundlePacket, Packet} from '@avocado/net'; import {BundlePacket, Packet} from '@avocado/net';
export class EntityListUpdateEntityPacket extends Packet { export default class EntityListUpdateEntityPacket extends Packet {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -2,7 +2,7 @@ import {BundlePacket, SynchronizedUpdatePacket} from '@avocado/net';
import {idFromTrait, lookupTrait, traitFromId} from '../trait/registry'; import {idFromTrait, lookupTrait, traitFromId} from '../trait/registry';
export class EntityUpdateTraitPacket extends SynchronizedUpdatePacket { export default class EntityUpdateTraitPacket extends SynchronizedUpdatePacket {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateAlivePacket extends Packet { export default class TraitUpdateAlivePacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateDirectionalDirectionPacket extends Packet { export default class TraitUpdateDirectionalDirectionPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -1,7 +1,7 @@
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdatePositionedPositionPacket extends Packet { export default class TraitUpdatePositionedPositionPacket extends Packet {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -3,7 +3,7 @@ const idToTraitMap = new Map();
const traitToIdMap = new Map(); const traitToIdMap = new Map();
const traitRegistry = new Map(); const traitRegistry = new Map();
export function registerTrait(Trait) { export function registerTrait({default: Trait}) {
const hadTrait = traitRegistry.has(Trait.type()); const hadTrait = traitRegistry.has(Trait.type());
traitRegistry.set(Trait.type(), Trait); traitRegistry.set(Trait.type(), Trait);
if (!hadTrait) { if (!hadTrait) {

View File

@ -1,20 +0,0 @@
const path = require('path');
module.exports = ({entries, paths, root, rules}) => {
rules.push({
test: new RegExp('@avocado/packages/entity/trait/traits.avopack.js$'),
use: {
loader: '@avocado/core/webpack/autoreg',
options: {
paths,
registrar: {
function: 'registerTrait',
module: '@avocado/entity',
},
root,
type: 'trait',
},
},
});
entries.push('@avocado/entity/trait/traits.avopack');
};

View File

@ -0,0 +1,10 @@
function traits(scwp) {
scwp.enterSelf();
scwp.loadSelf('scwp/autoreg', {
paths: scwp.paths,
registrar: './registry:registerTrait',
root: scwp.root,
type: 'trait',
});
}
module.exports = traits;

View File

@ -8,8 +8,8 @@ import {
import {compose} from '@avocado/core'; import {compose} from '@avocado/core';
import {StateProperty, Trait} from '../trait'; import {StateProperty, Trait} from '../trait';
import {DiedPacket} from '../packets/died.packet'; import DiedPacket from '../packets/died.packet';
import {TraitUpdateAlivePacket} from '../packets/trait-update-alive.packet'; import TraitUpdateAlivePacket from '../packets/trait-update-alive.packet';
const decorate = compose( const decorate = compose(
StateProperty('isDying', { StateProperty('isDying', {
@ -23,7 +23,7 @@ const decorate = compose(
}), }),
); );
export class Alive extends decorate(Trait) { export default class Alive extends decorate(Trait) {
static defaultParams() { static defaultParams() {
const playDeathSound = buildInvoke(['entity', 'playSound'], [ const playDeathSound = buildInvoke(['entity', 'playSound'], [

View File

@ -8,7 +8,7 @@ const decorate = compose(
}), }),
); );
export class Debuggable extends decorate(Trait) { export default class Debuggable extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {

View File

@ -2,9 +2,7 @@ import {compose} from '@avocado/core';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import {StateProperty, Trait} from '../trait'; import {StateProperty, Trait} from '../trait';
import { import TraitUpdateDirectionalDirectionPacket from '../packets/trait-update-directional-direction.packet';
TraitUpdateDirectionalDirectionPacket,
} from '../packets/trait-update-directional-direction.packet';
const decorate = compose( const decorate = compose(
StateProperty('direction', { StateProperty('direction', {
@ -12,7 +10,7 @@ const decorate = compose(
}), }),
); );
export class Directional extends decorate(Trait) { export default class Directional extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -8,7 +8,7 @@ const decorate = compose(
StateProperty('isTicking'), StateProperty('isTicking'),
); );
export class Existent extends decorate(Trait) { export default class Existent extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {

View File

@ -2,7 +2,7 @@ import {Rectangle, Vector} from '@avocado/math';
import {Trait} from '../trait'; import {Trait} from '../trait';
export class Listed extends Trait { export default class Listed extends Trait {
static type() { static type() {
return 'listed'; return 'listed';

View File

@ -8,7 +8,7 @@ const decorate = compose(
StateProperty('speed'), StateProperty('speed'),
) )
export class Mobile extends decorate(Trait) { export default class Mobile extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {

View File

@ -5,7 +5,7 @@ import {StateProperty, Trait} from '../trait';
const decorate = compose( const decorate = compose(
); );
export class Perishable extends decorate(Trait) { export default class Perishable extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -2,7 +2,7 @@ import {compose, EventEmitter} from '@avocado/core';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import {Trait} from '../trait'; import {Trait} from '../trait';
import {TraitUpdatePositionedPositionPacket} from '../packets/trait-update-positioned-position.packet'; import TraitUpdatePositionedPositionPacket from '../packets/trait-update-positioned-position.packet';
const decorate = compose( const decorate = compose(
EventEmitter, EventEmitter,
@ -15,7 +15,7 @@ const decorate = compose(
); );
// < 16768 will pack into 1 short per axe and give +/- 0.25 precision. // < 16768 will pack into 1 short per axe and give +/- 0.25 precision.
export class Positioned extends decorate(Trait) { export default class Positioned extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {

View File

@ -11,7 +11,7 @@ const decorate = compose(
StateProperty('maxSpawns'), StateProperty('maxSpawns'),
); );
export class Spawner extends decorate(Trait) { export default class Spawner extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateVisiblePacket extends Packet { export default class TraitUpdateVisiblePacket extends Packet {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -3,7 +3,7 @@ import {Renderer as PIXIRenderer} from '@pixi/core';
export class Renderer { export class Renderer {
constructor(size = [0, 0], type = 'auto') { constructor(size = [0, 0], type = 'auto') {
this.renderer = new PIXIRenderer(size[0], size[1]); this.renderer = new PIXIRenderer({width: size[0], height: size[1]});
// Need to set size explicitly since v5. // Need to set size explicitly since v5.
this.renderer.view.width = size[0]; this.renderer.view.width = size[0];
this.renderer.view.height = size[1]; this.renderer.view.height = size[1];

View File

@ -1,20 +0,0 @@
const path = require('path');
module.exports = ({options, side}) => {
if ('server' === side) {
const pixiPackages = [
'constants',
'core',
'display',
'graphics',
'settings',
'text',
];
pixiPackages.forEach((pixiPackage) => {
options.resolve.alias[`@pixi/${pixiPackage}`] = path.join(
__dirname,
pixiPackage,
);
});
}
};

View File

@ -0,0 +1,25 @@
const {join} = require('path');
function pixi(scwp) {
const {neutrino} = scwp;
if (neutrino) {
if ('server' === (process.env.SIDE || '').toLowerCase()) {
const pixiPackages = [
'constants',
'core',
'display',
'graphics',
'settings',
'text',
];
pixiPackages.forEach((pixiPackage) => {
neutrino.config.resolve.alias
.set(`@pixi/${pixiPackage}`, join(
__dirname,
pixiPackage,
));
});
}
}
}
module.exports = pixi;

View File

@ -11,7 +11,7 @@ const decorate = compose(
}), }),
); );
export class Pictured extends decorate(Trait) { export default class Pictured extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -5,7 +5,7 @@ import {Color, Primitives} from '@avocado/graphics';
const decorate = compose( const decorate = compose(
) )
export class Primitive extends decorate(Trait) { export default class Primitive extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

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

View File

@ -8,7 +8,7 @@ const decorate = compose(
}), }),
) )
export class Textual extends decorate(Trait) { export default class Textual extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {

View File

@ -6,9 +6,7 @@ import {Rectangle, Vector} from '@avocado/math';
import {Container} from '../container'; import {Container} from '../container';
import {hasGraphics} from '../has-graphics'; import {hasGraphics} from '../has-graphics';
import { import TraitUpdateVisiblePacket from '../packets/trait-update-visible.packet';
TraitUpdateVisiblePacket,
} from '../packets/trait-update-visible.packet';
const AUTO_ZINDEX = 1 << 16; const AUTO_ZINDEX = 1 << 16;
@ -30,7 +28,7 @@ const decorate = compose(
}), }),
); );
export class Visible extends decorate(Trait) { export default class Visible extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,3 +1,3 @@
export {ActionRegistry} from './action-registry'; export {ActionRegistry} from './action-registry';
export {InputNormalizer} from './normalizer'; export {InputNormalizer} from './normalizer';
export {InputPacket} from './packet/input.packet'; export {default as InputPacket} from './packet/input.packet';

View File

@ -2,7 +2,7 @@ import * as I from 'immutable';
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class InputPacket extends Packet { export default class InputPacket extends Packet {
static setActionIds(actionIds) { static setActionIds(actionIds) {
this._actionIds = actionIds; this._actionIds = actionIds;

View File

@ -3,7 +3,7 @@ import io from 'socket.io-client';
import {compose, EventEmitter} from '@avocado/core'; import {compose, EventEmitter} from '@avocado/core';
import {allPackets, idFromPacket} from '../packet'; import allPackets, idFromPacket from '...packet';
const debug = D('@avocado:client:socket'); const debug = D('@avocado:client:socket');

View File

@ -1,7 +1,7 @@
import io from 'socket.io-client'; import io from 'socket.io-client';
import 'register-packets'; import 'register-packets';
import {SocketIoParser} from '../packet'; import SocketIoParser from '...packet';
let socket = null; let socket = null;

View File

@ -16,12 +16,6 @@ export class Packet {
'inherit from Packet.schema within your packet subclass schema definition.', 'inherit from Packet.schema within your packet subclass schema definition.',
].join(' ')); ].join(' '));
} }
if (!schema.data) {
throw new Error([
`No data found in '${this.name}.schema'. This is usually due to forgetting to`,
'inherit from Packet.schema within your packet subclass schema definition.',
].join(' '));
}
this._builder = schemapack.build(schema); this._builder = schemapack.build(schema);
} }
return this._builder; return this._builder;

View File

@ -1,23 +0,0 @@
const path = require('path');
module.exports = ({entries, paths, root, rules}) => {
rules.push({
test: new RegExp('@avocado/packages/net/packet/packets.avopack.js$'),
use: {
loader: '@avocado/core/webpack/autoreg',
options: {
classTransformer: (Packet) => {
return `${Packet}Packet`;
},
paths,
registrar: {
function: 'registerPacket',
module: '@avocado/net',
},
root,
type: 'packet',
},
},
});
entries.push('@avocado/net/packet/packets.avopack');
};

View File

@ -1,8 +1,8 @@
import {idFromSynchronized, synchronizedFromId} from './registry'; import {idFromSynchronized, synchronizedFromId} from './registry';
import {SynchronizedCreatePacket} from './synchronized-create.packet'; import SynchronizedCreatePacket from './synchronized-create.packet';
import {SynchronizedDestroyPacket} from './synchronized-destroy.packet'; import SynchronizedDestroyPacket from './synchronized-destroy.packet';
import {SynchronizedUpdatePacket} from './synchronized-update.packet'; import SynchronizedUpdatePacket from './synchronized-update.packet';
export class ClientSynchronizer { export class ClientSynchronizer {

View File

@ -10,7 +10,7 @@ export {ServerSynchronizer} from './server';
export {SynchronizedMixin} from './synchronized' export {SynchronizedMixin} from './synchronized'
export {SynchronizedPacket} from './synchronized.packet'; export {default as SynchronizedPacket} from './synchronized.packet';
export {SynchronizedCreatePacket} from './synchronized-create.packet'; export {default as SynchronizedCreatePacket} from './synchronized-create.packet';
export {SynchronizedDestroyPacket} from './synchronized-destroy.packet'; export {default as SynchronizedDestroyPacket} from './synchronized-destroy.packet';
export {SynchronizedUpdatePacket} from './synchronized-update.packet'; export {default as SynchronizedUpdatePacket} from './synchronized-update.packet';

View File

@ -10,7 +10,7 @@ export function idFromSynchronized(Synchronized) {
export function synchronizedFromId(id) { export function synchronizedFromId(id) {
return idToSynchronizedMap.get(id); return idToSynchronizedMap.get(id);
} }
export function registerSynchronized(Synchronized) { export function registerSynchronized({default: Synchronized}) {
if (synchronizedToIdMap.has(Synchronized)) { if (synchronizedToIdMap.has(Synchronized)) {
return; return;
} }

View File

@ -1,20 +0,0 @@
const path = require('path');
module.exports = ({entries, paths, root, rules}) => {
rules.push({
test: new RegExp('@avocado/packages/net/s13n/s13n.avopack.js$'),
use: {
loader: '@avocado/core/webpack/autoreg',
options: {
paths,
registrar: {
function: 'registerSynchronized',
module: '@avocado/net',
},
root,
type: 'synchronized',
},
},
});
entries.push('@avocado/net/s13n/s13n.avopack');
};

View File

@ -0,0 +1,12 @@
const {join} = require('path');
function s13n(scwp) {
scwp.enterSelf();
scwp.loadSelf('scwp/autoreg', {
paths: scwp.paths,
registrar: './registry:registerSynchronized',
root: scwp.root,
type: 'synchronized',
});
}
module.exports = s13n;

View File

@ -1,7 +1,7 @@
import {idFromSynchronized} from './registry'; import {idFromSynchronized} from './registry';
import {SynchronizedCreatePacket} from './synchronized-create.packet'; import SynchronizedCreatePacket from './synchronized-create.packet';
import {SynchronizedDestroyPacket} from './synchronized-destroy.packet'; import SynchronizedDestroyPacket from './synchronized-destroy.packet';
export class ServerSynchronizer { export class ServerSynchronizer {

View File

@ -1,8 +1,8 @@
import msgpack from 'msgpack-lite'; import msgpack from 'msgpack-lite';
import {SynchronizedPacket} from './synchronized.packet'; import SynchronizedPacket from './synchronized.packet';
export class SynchronizedCreatePacket extends SynchronizedPacket { export default class SynchronizedCreatePacket extends SynchronizedPacket {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -1,3 +1,3 @@
import {SynchronizedPacket} from './synchronized.packet'; import SynchronizedPacket from './synchronized.packet';
export class SynchronizedDestroyPacket extends SynchronizedPacket {} export default class SynchronizedDestroyPacket extends SynchronizedPacket {}

View File

@ -1,3 +1,3 @@
import {SynchronizedPacket} from './synchronized.packet'; import SynchronizedPacket from './synchronized.packet';
export class SynchronizedUpdatePacket extends SynchronizedPacket {} export default class SynchronizedUpdatePacket extends SynchronizedPacket {}

View File

@ -1,6 +1,6 @@
import {idFromSynchronized} from './registry'; import {idFromSynchronized} from './registry';
import {SynchronizedCreatePacket} from './synchronized-create.packet'; import SynchronizedCreatePacket from './synchronized-create.packet';
import {SynchronizedDestroyPacket} from './synchronized-destroy.packet'; import SynchronizedDestroyPacket from './synchronized-destroy.packet';
export function SynchronizedMixin(Superclass) { export function SynchronizedMixin(Superclass) {

View File

@ -1,6 +1,6 @@
import {Packet} from '../packet/packet'; import {Packet} from '../packet/packet';
export class SynchronizedPacket extends Packet { export default class SynchronizedPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -8,7 +8,7 @@ const decorate = compose(
StateProperty('isColliding'), StateProperty('isColliding'),
); );
export class Collider extends decorate(Trait) { export default class Collider extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -6,7 +6,7 @@ import {Range, Vector} from '@avocado/math';
const decorate = compose( const decorate = compose(
); );
export class Emitted extends decorate(Trait) { export default class Emitted extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -12,7 +12,7 @@ const PI_180 = Math.PI / 180;
const decorate = compose( const decorate = compose(
); );
export class Emitter extends decorate(Trait) { export default class Emitter extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -10,7 +10,7 @@ const decorate = compose(
}), }),
); );
export class Physical extends decorate(Trait) { export default class Physical extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {

View File

@ -7,7 +7,7 @@ import {ShapeView} from '../shape-view';
const decorate = compose( const decorate = compose(
); );
export class Shaped extends decorate(Trait) { export default class Shaped extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -2,7 +2,7 @@ import {Trait} from '@avocado/entity';
import {Sound} from '..'; import {Sound} from '..';
export class Audible extends Trait { export default class Audible extends Trait {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TraitUpdateAnimatedPacket extends Packet { export default class TraitUpdateAnimatedPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -4,7 +4,7 @@ import {Rectangle, Vector} from '@avocado/math';
import {Animation} from '../animation'; import {Animation} from '../animation';
import {AnimationView} from '../animation-view'; import {AnimationView} from '../animation-view';
import {TraitUpdateAnimatedPacket} from '../packets/trait-update-animated.packet'; import TraitUpdateAnimatedPacket from '../packets/trait-update-animated.packet';
const decorate = compose( const decorate = compose(
StateProperty('currentAnimation', { StateProperty('currentAnimation', {
@ -15,7 +15,7 @@ const decorate = compose(
}), }),
); );
export class Animated extends decorate(Trait) { export default class Animated extends decorate(Trait) {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,7 +1,7 @@
export {Camera} from './camera'; export {Camera} from './camera';
export {Layer} from './layer'; export {Layer} from './layer';
export {LayerView} from './layer-view'; export {LayerView} from './layer-view';
export {Room} from './room.synchronized'; export {default as Room} from './room.synchronized';
export {RoomView} from './room-view'; export {RoomView} from './room-view';
export {TilesRenderer} from './tiles-renderer'; export {TilesRenderer} from './tiles-renderer';
export {Tiles} from './tiles'; export {Tiles} from './tiles';

View File

@ -11,12 +11,8 @@ import {
} from '@avocado/net'; } from '@avocado/net';
import {ShapeList} from '@avocado/physics'; import {ShapeList} from '@avocado/physics';
import { import LayerUpdateTilesetUriPacket from './packets/layer-update-tileset-uri.packet';
LayerUpdateTilesetUriPacket, import TilesUpdatePacket from './packets/tiles-update.packet';
} from './packets/layer-update-tileset-uri.packet';
import {
TilesUpdatePacket,
} from './packets/tiles-update.packet';
import {Tiles} from './tiles'; import {Tiles} from './tiles';

View File

@ -3,7 +3,7 @@ import * as I from 'immutable';
import {arrayUnique, compose, EventEmitter, flatten} from '@avocado/core'; import {arrayUnique, compose, EventEmitter, flatten} from '@avocado/core';
import {Layer} from './layer'; import {Layer} from './layer';
import {LayersUpdateLayerPacket} from './packets/layers-update-layer.packet'; import LayersUpdateLayerPacket from './packets/layers-update-layer.packet';
const decorate = compose( const decorate = compose(
EventEmitter, EventEmitter,

View File

@ -1,6 +1,6 @@
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class LayerUpdateTilesetUriPacket extends Packet { export default class LayerUpdateTilesetUriPacket extends Packet {
static get schema() { static get schema() {
return { return {

View File

@ -1,6 +1,6 @@
import {BundlePacket, Packet} from '@avocado/net'; import {BundlePacket, Packet} from '@avocado/net';
export class LayersUpdateLayerPacket extends Packet { export default class LayersUpdateLayerPacket extends Packet {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -1,7 +1,7 @@
import {BundlePacket} from '@avocado/net'; import {BundlePacket} from '@avocado/net';
import {SynchronizedUpdatePacket} from '@avocado/net'; import {SynchronizedUpdatePacket} from '@avocado/net';
export class RoomUpdateLayersPacket extends SynchronizedUpdatePacket { export default class RoomUpdateLayersPacket extends SynchronizedUpdatePacket {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -1,7 +1,7 @@
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import {SynchronizedUpdatePacket} from '@avocado/net'; import {SynchronizedUpdatePacket} from '@avocado/net';
export class RoomUpdateSizePacket extends SynchronizedUpdatePacket { export default class RoomUpdateSizePacket extends SynchronizedUpdatePacket {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -1,7 +1,7 @@
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
import {Packet} from '@avocado/net'; import {Packet} from '@avocado/net';
export class TilesUpdatePacket extends Packet { export default class TilesUpdatePacket extends Packet {
static pack(packet) { static pack(packet) {
const data = packet.data[1]; const data = packet.data[1];

View File

@ -7,8 +7,8 @@ import {RectangleShape} from '@avocado/physics';
import {Resource} from '@avocado/resource'; import {Resource} from '@avocado/resource';
import {Layers} from './layers'; import {Layers} from './layers';
import {RoomUpdateSizePacket} from './packets/room-update-size.packet'; import RoomUpdateSizePacket from './packets/room-update-size.packet';
import {RoomUpdateLayersPacket} from './packets/room-update-layers.packet'; import RoomUpdateLayersPacket from './packets/room-update-layers.packet';
const ROOM_BOUND_SIZE = 64; const ROOM_BOUND_SIZE = 64;
const HALF_ROOM_BOUND_SIZE = ROOM_BOUND_SIZE / 2; const HALF_ROOM_BOUND_SIZE = ROOM_BOUND_SIZE / 2;
@ -27,7 +27,7 @@ const decorate = compose(
let synchronizationId = 1; let synchronizationId = 1;
export class Room extends decorate(Resource) { export default class Room extends decorate(Resource) {
constructor(json) { constructor(json) {
super(); super();

View File

@ -3,7 +3,7 @@ import * as I from 'immutable';
import {compose, EventEmitter} from '@avocado/core'; import {compose, EventEmitter} from '@avocado/core';
import {Rectangle, Vector} from '@avocado/math'; import {Rectangle, Vector} from '@avocado/math';
import {TilesUpdatePacket} from './packets/tiles-update.packet'; import TilesUpdatePacket from './packets/tiles-update.packet';
const CHUNK_AXIS = 10; const CHUNK_AXIS = 10;

View File

@ -2,7 +2,7 @@ import {Trait} from '@avocado/entity';
import {Camera} from '../camera'; import {Camera} from '../camera';
export class Followed extends Trait { export default class Followed extends Trait {
static defaultParams() { static defaultParams() {
return { return {

View File

@ -1,7 +1,7 @@
import {Trait} from '@avocado/entity'; import {Trait} from '@avocado/entity';
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
export class Layered extends Trait { export default class Layered extends Trait {
static type() { static type() {
return 'layered'; return 'layered';

View File

@ -1,6 +1,6 @@
import {Trait} from '@avocado/entity'; import {Trait} from '@avocado/entity';
export class Roomed extends Trait { export default class Roomed extends Trait {
static type() { static type() {
return 'roomed'; return 'roomed';

View File

@ -8,7 +8,7 @@ const decorate = compose(
}), }),
); );
export class TileEntity extends decorate(Trait) { export default class TileEntity extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {