21 lines
607 B
JavaScript
21 lines
607 B
JavaScript
import * as Math from '@/lib/math.js';
|
|
import Ticker from '@/lib/ticker.js';
|
|
|
|
const SHOTS = 10;
|
|
|
|
export default function*({ecs, where, wielder}) {
|
|
const {Player, Position} = wielder;
|
|
const offset = Math.random() * Math.TAU;
|
|
let count = SHOTS;
|
|
while (count--) {
|
|
ecs.create({
|
|
...ecs.readJson('/resources/magic-swords/shot.entity.json'),
|
|
Arbitrary: {blob: JSON.stringify({where})},
|
|
Direction: {direction: offset + Math.TAU * (count / SHOTS)},
|
|
Owned: {owner: Player ? Player.id : 0},
|
|
Position: {x: Position.x, y: Position.y},
|
|
});
|
|
yield Ticker.wait(0.03);
|
|
}
|
|
}
|