97 lines
1.8 KiB
JavaScript
97 lines
1.8 KiB
JavaScript
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
|
|
|
// Rock.
|
|
export function rockJSON() {
|
|
const spawnProjectile = buildInvoke(
|
|
['item', 'spawn'],
|
|
[
|
|
'rock'
|
|
],
|
|
)
|
|
const setProjectileIntoContext = buildInvoke(
|
|
['context', 'add'],
|
|
[
|
|
'projectile',
|
|
spawnProjectile,
|
|
],
|
|
)
|
|
const setWielderIntoProjectile = buildInvoke(
|
|
['projectile', 'context', 'add'],
|
|
[
|
|
'wielder',
|
|
buildTraversal(['wielder']),
|
|
],
|
|
);
|
|
const setProjectileBehaving = buildTraversal(
|
|
['projectile', 'isBehaving'],
|
|
true,
|
|
);
|
|
return {
|
|
traits: {
|
|
collider: {
|
|
params: {
|
|
isSensor: true,
|
|
},
|
|
},
|
|
existent: {
|
|
state: {
|
|
name: 'Rock',
|
|
},
|
|
},
|
|
item: {
|
|
params: {
|
|
cooldown: 0.33,
|
|
itemActions: {
|
|
type: 'actions',
|
|
traversals: [
|
|
setProjectileIntoContext,
|
|
setWielderIntoProjectile,
|
|
setProjectileBehaving,
|
|
],
|
|
},
|
|
slotImageUris: {
|
|
default: '/rock.png',
|
|
},
|
|
},
|
|
},
|
|
layered: {},
|
|
listed: {},
|
|
magnetic: {},
|
|
mobile: {},
|
|
physical: {},
|
|
pictured: {
|
|
params: {
|
|
images: {
|
|
initial: {
|
|
offset: [0, 0],
|
|
size: [12, 12], // Derive?
|
|
uri: '/rock.png',
|
|
},
|
|
}
|
|
},
|
|
},
|
|
positioned: {},
|
|
roomed: {},
|
|
shaped: {
|
|
params: {
|
|
shape: {
|
|
type: 'rectangle',
|
|
position: [0, 0],
|
|
size: [12, 12],
|
|
},
|
|
},
|
|
},
|
|
spawner: {
|
|
params: {
|
|
spawns: {
|
|
rock: {
|
|
uri: '/rock-projectile.entity.json',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
visible: {},
|
|
},
|
|
};
|
|
}
|