2024-06-28 08:53:20 -05:00
|
|
|
const {Direction, Position, Wielder} = wielder
|
2024-07-24 09:28:35 -05:00
|
|
|
const projected = Wielder.activeItem()?.project(Position.tile, Direction.quantize(4))
|
2024-06-28 08:53:20 -05:00
|
|
|
if (projected?.length > 0) {
|
2024-06-25 10:44:37 -05:00
|
|
|
|
2024-06-26 09:17:35 -05:00
|
|
|
const {Controlled, Emitter, Sound, Sprite} = wielder
|
|
|
|
const {TileLayers} = ecs.get(1)
|
|
|
|
const layer = TileLayers.layer(0)
|
2024-06-25 10:44:37 -05:00
|
|
|
|
2024-06-26 09:17:35 -05:00
|
|
|
Controlled.locked = 1
|
|
|
|
const [, direction] = Sprite.animation.split(':')
|
|
|
|
|
|
|
|
for (let i = 0; i < 2; ++i) {
|
2024-09-17 01:25:39 -05:00
|
|
|
Sound.play('/resources/hoe/dig.wav');
|
2024-07-12 17:41:55 -05:00
|
|
|
for (const {x, y} of projected) {
|
2024-06-26 09:17:35 -05:00
|
|
|
Emitter.emit({
|
2024-08-03 16:02:09 -05:00
|
|
|
entity: {
|
|
|
|
Behaving: {
|
|
|
|
routines: {
|
|
|
|
initial: 'await delta(entity.Forces, {forceY: {delta: 640, duration: 0.125}}).promise',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Forces: {forceY: -80},
|
|
|
|
Position: {
|
|
|
|
x: x * layer.tileSize.x + (layer.tileSize.x / 2),
|
|
|
|
y: y * layer.tileSize.y + (layer.tileSize.y / 2),
|
|
|
|
},
|
|
|
|
Sprite: {
|
|
|
|
tint: 0x552200,
|
|
|
|
},
|
|
|
|
Ttl: {ttl: 0.35},
|
|
|
|
},
|
2024-08-01 00:39:54 -05:00
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
path: ['Sprite', 'lightness'],
|
|
|
|
value: [0.05, 0.25],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: ['Sprite', 'alpha'],
|
2024-08-01 15:44:54 -05:00
|
|
|
value: [0.5, 1],
|
2024-08-01 00:39:54 -05:00
|
|
|
},
|
|
|
|
{
|
2024-08-01 15:44:54 -05:00
|
|
|
path: ['Sprite', 'scale'],
|
|
|
|
value: [0.05, 0.1],
|
2024-08-01 00:39:54 -05:00
|
|
|
},
|
|
|
|
],
|
2024-08-03 16:02:09 -05:00
|
|
|
frequency: 0.05,
|
2024-07-30 09:56:53 -05:00
|
|
|
shape: {
|
|
|
|
type: 'filledRect',
|
2024-08-01 15:44:54 -05:00
|
|
|
payload: {width: 12, height: 12},
|
2024-07-30 09:56:53 -05:00
|
|
|
},
|
2024-08-03 16:02:09 -05:00
|
|
|
spurt: 5,
|
|
|
|
ttl: 0.4,
|
2024-07-30 09:56:53 -05:00
|
|
|
});
|
2024-06-26 09:17:35 -05:00
|
|
|
}
|
|
|
|
Sprite.animation = ['moving', direction].join(':');
|
2024-06-28 13:10:14 -05:00
|
|
|
await wait(0.3)
|
2024-06-26 09:17:35 -05:00
|
|
|
Sprite.animation = ['idle', direction].join(':');
|
2024-06-28 13:10:14 -05:00
|
|
|
await wait(0.1)
|
2024-06-26 04:18:54 -05:00
|
|
|
}
|
2024-06-25 10:44:37 -05:00
|
|
|
|
2024-07-12 17:41:55 -05:00
|
|
|
for (const position of projected) {
|
|
|
|
TileLayers.layer(1).stamp(position, [[7]])
|
2024-06-25 10:44:37 -05:00
|
|
|
}
|
|
|
|
|
2024-06-26 09:17:35 -05:00
|
|
|
Controlled.locked = 0;
|
|
|
|
|
|
|
|
}
|