chore: descriptions

This commit is contained in:
cha0s 2020-06-19 22:01:45 -05:00
parent b63f25d5bb
commit 83498542e5
20 changed files with 392 additions and 13 deletions

View File

@ -1,15 +1,29 @@
export function behaviorContextTypes() { export function behaviorContextTypes() {
return { return {
entity: (entity) => ( entity: (entity) => {
Object.values(entity.allTraitInstances()) const traitTypes = !entity
.reduce( ? {}
(r, {constructor: {behaviorContextTypes, describeParams, describeState}}) => ({ : Object.values(entity.allTraitInstances())
...r, .reduce(
...behaviorContextTypes(), (r, {constructor: {behaviorContextTypes, describeParams, describeState}}) => ({
...describeParams(), ...r,
...describeState(), ...behaviorContextTypes(),
}), {}, ...describeParams(),
) ...describeState(),
), }), {},
);
return {
...traitTypes,
invokeHook: {
type: 'object',
label: 'Invoke hook.',
args: [
['hook', {
type: 'string',
}],
],
},
};
},
}; };
} }

View File

@ -12,8 +12,16 @@ export default class Existent extends decorate(Trait) {
static behaviorContextTypes() { static behaviorContextTypes() {
return { return {
destroy: {
type: 'void',
label: 'Destroy',
},
destroyGently: {
type: 'void',
label: 'Kill? Then destroy',
},
transition: { transition: {
type: 'ticking-promise', type: 'void',
label: 'Transition $1 for $2 seconds using $3.', label: 'Transition $1 for $2 seconds using $3.',
args: [ args: [
['props', { ['props', {

View File

@ -13,6 +13,15 @@ export default class Perishable extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
ttl: {
type: 'number',
label: 'Time-to-live in seconds',
},
};
}
static type() { static type() {
return 'perishable'; return 'perishable';
} }

View File

@ -19,6 +19,10 @@ export default class Positioned extends decorate(Trait) {
static behaviorContextTypes() { static behaviorContextTypes() {
return { return {
position: {
type: 'vector',
label: 'Position',
},
setPosition: { setPosition: {
type: 'void', type: 'void',
label: 'Set position to $1.', label: 'Set position to $1.',

View File

@ -15,6 +15,10 @@ export default class Spawner extends decorate(Trait) {
static behaviorContextTypes() { static behaviorContextTypes() {
return { return {
killAllChildren: {
type: 'void',
label: 'Kill all spawned children',
},
spawn: { spawn: {
type: 'entity', type: 'entity',
label: 'Spawn $1 with $2 extensions.', label: 'Spawn $1 with $2 extensions.',
@ -72,6 +76,15 @@ export default class Spawner extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
spawns: {
type: 'object',
label: 'Entities that may be spawned',
},
};
}
static defaultState() { static defaultState() {
return { return {
isSpawning: true, isSpawning: true,
@ -79,6 +92,19 @@ export default class Spawner extends decorate(Trait) {
}; };
} }
static describeState() {
return {
isSpawning: {
type: 'bool',
label: 'Is spawning',
},
maxSpawns: {
type: 'number',
label: 'Maximum concurrent spawns',
},
};
}
static type() { static type() {
return 'spawner'; return 'spawner';
} }

View File

@ -25,6 +25,24 @@ export default class Pictured extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
images: {
type: 'object',
label: 'Images',
},
};
}
static describeState() {
return {
currentImage: {
type: 'string',
label: 'Current image',
},
};
}
static type() { static type() {
return 'pictured'; return 'pictured';
} }

View File

@ -13,6 +13,15 @@ export default class Primitive extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
primitives: {
type: 'object',
label: 'Primitives',
},
};
}
static type() { static type() {
return 'primitive'; return 'primitive';
} }

View File

@ -17,6 +17,19 @@ export default class Textual extends decorate(Trait) {
}; };
} }
static describeState() {
return {
text: {
type: 'string',
label: 'Text',
},
textStyle: {
type: 'object',
label: 'Text style',
},
};
}
static type() { static type() {
return 'textual'; return 'textual';
} }

View File

@ -57,6 +57,44 @@ export default class Visible extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
filter: {
type: 'object',
label: 'Filter',
},
trackPosition: {
type: 'bool',
label: 'Track position',
},
};
}
static describeState() {
return {
isVisible: {
type: 'bool',
label: 'Is visible',
},
opacity: {
type: 'number',
label: 'Opacity',
},
rotation: {
type: 'number',
label: 'Rotation',
},
visibleScale: {
type: 'vector',
label: 'Scale',
},
zIndex: {
type: 'number',
label: 'Z index',
},
};
}
static type() { static type() {
return 'visible'; return 'visible';
} }

View File

@ -75,6 +75,35 @@ export default class Collider extends decorate(Trait) {
} }
} }
static describeParams() {
return {
activeCollision: {
type: 'bool',
label: 'Actively check collisions',
},
collidesWithGroups: {
type: 'object',
label: 'Collides with groups',
},
collisionEndActions: {
type: 'actions',
label: 'Collision ending actions',
},
collisionStartActions: {
type: 'actions',
label: 'Collision starting actions',
},
collisionGroup: {
type: 'string',
label: 'Collision group',
},
isSensor: {
type: 'bool',
label: 'Is sensor',
},
};
}
static describeState() { static describeState() {
return { return {
isCheckingCollisions: { isCheckingCollisions: {
@ -83,7 +112,7 @@ export default class Collider extends decorate(Trait) {
}, },
isColliding: { isColliding: {
type: 'bool', type: 'bool',
label: 'Is colliding', label: 'Is able to collide',
}, },
} }
} }

View File

@ -8,6 +8,15 @@ const decorate = compose(
export default class Emitted extends decorate(Trait) { export default class Emitted extends decorate(Trait) {
static behaviorContextTypes() {
return {
particle: {
type: 'particle',
label: 'Create particle.',
},
};
}
static defaultParams() { static defaultParams() {
return { return {
alpha: { alpha: {
@ -35,6 +44,51 @@ export default class Emitted extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
alpha: {
type: 'object',
label: 'Alpha',
},
force: {
type: 'vector',
label: 'Force',
},
listed: {
type: 'bool',
label: 'Is listed',
},
mass: {
type: 'number',
label: 'Mass',
},
position: {
type: 'vector',
label: 'Position',
},
rotation: {
type: 'object',
label: 'Rotation',
},
scale: {
type: 'object',
label: 'Scale',
},
transient: {
type: 'bool',
label: 'Is transient',
},
ttl: {
type: 'number',
label: 'Time to live in seconds',
},
velocity: {
type: 'object',
label: 'Velocity',
},
};
}
static type() { static type() {
return 'emitted'; return 'emitted';
} }

View File

@ -14,12 +14,56 @@ const decorate = compose(
export default class Emitter extends decorate(Trait) { export default class Emitter extends decorate(Trait) {
static behaviorContextTypes() {
return {
emitParticleEntity: {
type: 'entity',
label: 'Create particle.',
args: [
['entity', {
type: 'entity',
}],
],
},
emitParticleJson: {
type: 'stream',
label: 'Create particle.',
args: [
['json', {
type: 'object',
}],
],
},
emitParticle: {
type: 'stream',
label: 'Create particle.',
args: [
['key', {
type: 'string',
}],
['json', {
type: 'object',
}],
],
},
};
}
static defaultParams() { static defaultParams() {
return { return {
particles: {}, particles: {},
}; };
} }
static describeParams() {
return {
particles: {
type: 'object',
label: 'Particles',
},
};
}
static type() { static type() {
return 'emitter'; return 'emitter';
} }

View File

@ -12,6 +12,29 @@ const decorate = compose(
export default class Physical extends decorate(Trait) { export default class Physical extends decorate(Trait) {
static behaviorContextTypes() {
return {
applyForce: {
type: 'void',
label: 'Apply force.',
args: [
['force', {
type: 'vector',
}],
],
},
applyImpulse: {
type: 'void',
label: 'Apply impulse.',
args: [
['impulse', {
type: 'vector',
}],
],
},
};
}
static defaultState() { static defaultState() {
return { return {
addedToPhysics: true, addedToPhysics: true,

View File

@ -15,6 +15,15 @@ export default class Shaped extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
shape: {
type: 'object',
label: 'Shape',
},
};
}
static type() { static type() {
return 'shaped'; return 'shaped';
} }

View File

@ -6,6 +6,15 @@ export default class Audible extends Trait {
static behaviorContextTypes() { static behaviorContextTypes() {
return { return {
hasSound: {
type: 'bool',
label: 'Has $1 sound',
args: [
['key', {
type: 'string',
}],
],
},
playSound: { playSound: {
type: 'void', type: 'void',
label: 'Play the $1 sound.', label: 'Play the $1 sound.',
@ -24,6 +33,15 @@ export default class Audible extends Trait {
}; };
} }
static describeParams() {
return {
sounds: {
type: 'object',
label: 'Sounds',
},
};
}
static type() { static type() {
return 'audible'; return 'audible';
} }

View File

@ -30,6 +30,15 @@ export default class Animated extends decorate(Trait) {
}; };
} }
static describeParams() {
return {
animations: {
type: 'object',
label: 'Animations',
},
};
}
static describeState() { static describeState() {
return { return {
isAnimating: { isAnimating: {

View File

@ -10,6 +10,15 @@ export default class Followed extends Trait {
} }
} }
static describeParams() {
return {
viewSize: {
type: 'vector',
label: 'View size',
},
};
}
static type() { static type() {
return 'followed'; return 'followed';
} }

View File

@ -3,6 +3,24 @@ import {Vector} from '@avocado/math';
export default class Layered extends Trait { export default class Layered extends Trait {
static behaviorContextTypes() {
return {
removeFromLayer: {
type: 'void',
label: 'Remove from layer.',
},
setIntoLayer: {
type: 'void',
label: 'Set into layer $1.',
args: [
['layer', {
type: 'layer',
}],
],
},
};
}
static type() { static type() {
return 'layered'; return 'layered';
} }

View File

@ -2,6 +2,24 @@ import {Trait} from '@avocado/entity';
export default class Roomed extends Trait { export default class Roomed extends Trait {
static behaviorContextTypes() {
return {
detachFromRoom: {
type: 'void',
label: 'Remove from room.',
},
attachToRoom: {
type: 'void',
label: 'Set into room $1.',
args: [
['room', {
type: 'room',
}],
],
},
};
}
static type() { static type() {
return 'roomed'; return 'roomed';
} }

View File

@ -16,6 +16,15 @@ export default class TileEntity extends decorate(Trait) {
}; };
} }
static describeState() {
return {
tileIndex: {
type: 'number',
label: 'Tile index',
},
};
}
static type() { static type() {
return 'tile-entity'; return 'tile-entity';
} }