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']), ], }, slotImageUris: { 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, }, }, }, }, }; }