humus-old/server/fixtures/kitty.entity.js
2019-11-03 10:42:48 -06:00

159 lines
3.1 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]),
]);
const stopAnimating = buildTraversal(
['entity', 'isAnimating'],
false
);
const firstWait = buildInvoke(['Timing', 'wait'], [
buildInvoke(['Math', 'randomNumber'], [1, 4])
]);
const turn = buildTraversal(
['entity', 'direction'],
buildInvoke(
['Math', 'floor'],
[
buildInvoke(['Math', 'randomNumber'], [0, 4])
]
),
);
const secondWait = buildInvoke(['Timing', 'wait'], [
buildInvoke(['Math', 'randomNumber'], [0.5, 3])
]);
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: {},
lootable: {
params: {
table: [
{
perc: 20,
json: {
uri: '/rock.entity.json',
},
},
{
perc: 70,
json: {
uri: '/yarn-ball.entity.json',
},
},
],
},
},
mobile: {
state: {
speed: 40,
},
},
physical: {},
positioned: {},
roomed: {},
shaped: {
params: {
shape: {
type: 'rectangle',
position: [0, 0],
size: [8, 4],
},
},
},
spawner: {},
vulnerable: {},
},
};
}