91 lines
1.6 KiB
JavaScript
91 lines
1.6 KiB
JavaScript
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
|
|
|
// Mama kitty spawner.
|
|
export function mamaKittySpawnerJSON() {
|
|
|
|
const storeJSON = buildTraversal(
|
|
['context', 'json'],
|
|
{
|
|
traits: {
|
|
positioned: {
|
|
state: {},
|
|
},
|
|
},
|
|
},
|
|
);
|
|
|
|
function roomAxeValue(roomAxe) {
|
|
return buildInvoke(
|
|
['Math', 'randomNumber'],
|
|
[
|
|
100,
|
|
buildInvoke(
|
|
['Math', 'sub'],
|
|
[
|
|
buildTraversal(['entity', 'room', roomAxe]),
|
|
100,
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
const spawn = buildInvoke(
|
|
['entity', 'spawnAt'],
|
|
[
|
|
'mama',
|
|
buildInvoke(
|
|
['Utility', 'makeArray'],
|
|
[
|
|
roomAxeValue('width'),
|
|
roomAxeValue('height'),
|
|
],
|
|
),
|
|
buildTraversal(['context', 'json']),
|
|
],
|
|
);
|
|
|
|
return {
|
|
traits: {
|
|
behaved: {
|
|
params: {
|
|
routines: {
|
|
type: 'routines',
|
|
routines: {
|
|
initial: {
|
|
type: 'routine',
|
|
routine: {
|
|
type: 'actions',
|
|
traversals: [
|
|
spawn,
|
|
],
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
existent: {
|
|
state: {
|
|
name: 'Mama spawner',
|
|
},
|
|
},
|
|
layered: {},
|
|
listed: {},
|
|
roomed: {},
|
|
spawner: {
|
|
params: {
|
|
spawns: {
|
|
mama: {
|
|
uri: '/mama-kitty.entity.json',
|
|
},
|
|
},
|
|
},
|
|
state: {
|
|
maxSpawns: 2,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|