humus-old/server/fixtures/kitty.entity.js
2019-05-21 03:15:35 -05:00

120 lines
2.4 KiB
JavaScript

import {buildInvoke, buildTraversal} from '@avocado/behavior';
// A kitteh.
export function kittyJSON() {
const move = buildInvoke(['entity', 'moveFor'], [
buildInvoke(['global', 'randomNumber'], [0.25, 2.5, false])
]);
const stopAnimating = buildTraversal(
['entity', 'isAnimating'],
false
);
const firstWait = buildInvoke(['global', 'wait'], [
buildInvoke(['global', 'randomNumber'], [1, 4, false])
]);
const turn = buildTraversal(
['entity', 'direction'],
buildInvoke(['global', 'randomNumber'], [0, 3])
);
const secondWait = buildInvoke(['global', 'wait'], [
buildInvoke(['global', 'randomNumber'], [0.5, 3, false])
]);
const startAnimating = buildTraversal(
['entity', 'isAnimating'],
true
);
return {
traits: {
alive: {},
animated: {
params: {
animations: {
idle: {
offset: [0, -3],
uri: '/kitty.animation.json',
},
}
},
},
audible: {
params: {
sounds: {
deathSound: {
uri: '/ded.sound.json',
},
}
}
},
behaved: {
params: {
routines: {
type: 'routines',
routines: {
initial: {
type: 'routine',
routine: {
type: 'actions',
traversals: [
move,
stopAnimating,
firstWait,
turn,
secondWait,
startAnimating,
],
}
},
},
},
},
},
collider: {},
directional: {
params: {
directionCount: 4,
},
state: {
direction: 2,
},
},
emitter: {},
existent: {
state: {
name: 'Kitty',
},
},
visible: {
state: {
visibleScale: [1, 1],
}
},
layered: {},
listed: {},
mobile: {
state: {
speed: 40,
},
},
physical: {},
positioned: {},
roomed: {},
shaped: {
params: {
shape: {
type: 'rectangle',
position: [0, 0],
size: [8, 4],
},
},
},
vulnerable: {},
},
};
}