humus-old/server/fixtures/tomato-seeds.entity.js
2019-09-08 03:21:56 -05:00

96 lines
2.4 KiB
JavaScript

import {buildInvoke, buildTraversal, buildCondition} from '@avocado/behavior';
// Tomato seeds.
export function tomatoSeedsJSON() {
const hasExistingTomato = buildInvoke(
['wielder', 'layer', 'hasTileEntityWithUriAt'],
[
buildTraversal(['target']),
'/tomato-plant.entity.json',
],
);
return {
traits: {
existent: {},
item: {
params: {
itemActions: {
type: 'actions',
traversals: [
buildInvoke(['item', 'useTool']),
],
},
slotImages: {
default: '/seeds.png',
},
},
},
spawner: {
params: {
spawns: {
'tomato-plant': {
uri: '/tomato-plant.entity.json',
},
},
},
},
tool: {
params: {
// Has to be wet dirt.
condition: buildCondition('and', [
buildCondition('is', [
7,
buildInvoke(
['wielder', 'layer', 'tileAt'],
[
buildTraversal(['target']),
],
),
]),
buildCondition('is', [
false,
hasExistingTomato,
]),
]),
actions: {
type: 'actions',
traversals: [
buildInvoke(
['item', 'spawnAt'],
[
'tomato-plant',
buildInvoke(
['Math', 'Vector', 'add'],
[
buildInvoke(
['Math', 'Vector', 'mul'],
[
buildTraversal(['target']),
buildTraversal(['wielder', 'layer', 'tileset', 'tileSize']),
],
),
buildInvoke(
['Math', 'Vector', 'scale'],
[
buildTraversal(['wielder', 'layer', 'tileset', 'tileSize']),
0.5,
]
),
]
),
],
),
],
},
target: {
type: 'projection',
distance: -1,
length: 3,
width: 3,
},
},
},
},
};
}