73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
|
|
|
import {kittyJSON} from './kitty.entity';
|
|
|
|
// A MAMA kitteh.
|
|
export function mamaKittyJSON() {
|
|
|
|
const spawn = buildInvoke(
|
|
['entity', 'spawnAt'],
|
|
[
|
|
'kitteh',
|
|
buildInvoke(
|
|
['Utility', 'makeArray'],
|
|
[
|
|
buildTraversal(['entity', 'x']),
|
|
buildTraversal(['entity', 'y']),
|
|
],
|
|
),
|
|
buildTraversal(['context', 'json']),
|
|
],
|
|
);
|
|
|
|
const playDeathSound = buildInvoke(['entity', 'playSound'], [
|
|
buildTraversal(['entity', 'deathSound']),
|
|
]);
|
|
const squeeze = buildInvoke(['entity', 'transition'], [
|
|
{
|
|
opacity: 0,
|
|
visibleScaleX: .3,
|
|
visibleScaleY: 3,
|
|
},
|
|
0.2,
|
|
]);
|
|
const murderKitties = buildInvoke(['entity', 'killAllChildren']);
|
|
|
|
const json = JSON.parse(JSON.stringify(kittyJSON()));
|
|
const {traits} = json;
|
|
traits.alive.params = {
|
|
deathActions: {
|
|
type: 'actions',
|
|
traversals: [
|
|
playDeathSound,
|
|
murderKitties,
|
|
squeeze,
|
|
],
|
|
},
|
|
};
|
|
traits.alive.state = {
|
|
life: 500,
|
|
maxLife: 500,
|
|
};
|
|
traits.animated.params.animations.idle.offset = [0, -8];
|
|
traits.behaved.params.routines.routines.initial.routine.traversals.push(...[
|
|
spawn,
|
|
]);
|
|
traits.existent.state.name = 'Mama Kitty';
|
|
traits.visible.state.visibleScale = [2, 2];
|
|
traits.shaped.params.shape.size = [16, 8];
|
|
traits.spawner = {
|
|
params: {
|
|
spawns: {
|
|
kitteh: {
|
|
uri: '/kitty.entity.json',
|
|
},
|
|
},
|
|
},
|
|
state: {
|
|
maxSpawns: 10,
|
|
},
|
|
};
|
|
return json;
|
|
}
|