humus-old/server/fixtures/kitty.entity.js
2019-10-02 00:48:44 -05:00

135 lines
2.7 KiB
JavaScript

import {buildInvoke, buildTraversal} from '@avocado/behavior';
// A kitteh.
export function kittyJSON() {
const move = buildInvoke(['entity', 'moveFor'], [
buildInvoke(
['Math', 'Vector', 'fromDirection'],
[
buildTraversal(['entity', 'direction']),
],
),
buildInvoke(['Math', 'randomNumber'], [0.25, 2.5, false]),
]);
const stopAnimating = buildTraversal(
['entity', 'isAnimating'],
false
);
const firstWait = buildInvoke(['Timing', 'wait'], [
buildInvoke(['Math', 'randomNumber'], [1, 4, false])
]);
const turn = buildTraversal(
['entity', 'direction'],
buildInvoke(['Math', 'randomNumber'], [0, 3])
);
const secondWait = buildInvoke(['Timing', 'wait'], [
buildInvoke(['Math', '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: [
turn,
move,
stopAnimating,
firstWait,
turn,
secondWait,
startAnimating,
],
},
},
},
},
},
},
collider: {
params: {
collidesWithGroups: [
'default',
'environmental',
'projectile',
],
},
},
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: {},
},
};
}