99 lines
1.9 KiB
JavaScript
99 lines
1.9 KiB
JavaScript
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
|
|
|
import {AFFINITY_NONE} from '../../common/combat/constants';
|
|
|
|
// 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,
|
|
],
|
|
},
|
|
slotImages: {
|
|
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: {},
|
|
},
|
|
};
|
|
}
|