2024-06-28 16:38:49 -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 16:38:49 -05:00
|
|
|
if (projected?.length > 0) {
|
|
|
|
|
|
|
|
const {Controlled, Emitter, Sound, Sprite} = wielder
|
|
|
|
const {TileLayers, Water} = ecs.get(1)
|
|
|
|
const layer = TileLayers.layer(0)
|
|
|
|
|
|
|
|
Controlled.locked = 1
|
|
|
|
const [, direction] = Sprite.animation.split(':')
|
|
|
|
Sprite.animation = ['idle', direction].join(':');
|
|
|
|
|
|
|
|
Sound.play('/assets/watering-can/water.wav');
|
2024-07-30 09:56:53 -05:00
|
|
|
|
|
|
|
for (const {x, y} of projected) {
|
|
|
|
Emitter.emit({
|
|
|
|
count: 25,
|
|
|
|
frequency: 0.01,
|
|
|
|
shape: {
|
|
|
|
type: 'filledRect',
|
|
|
|
payload: {width: 16, height: 16},
|
|
|
|
},
|
|
|
|
entity: {
|
|
|
|
Forces: {forceY: 100},
|
|
|
|
Position: {
|
|
|
|
x: x * layer.tileSize.x + (layer.tileSize.x / 2),
|
|
|
|
y: y * layer.tileSize.y - layer.tileSize.y,
|
|
|
|
},
|
|
|
|
Sprite: {
|
|
|
|
scaleX: 0.2,
|
|
|
|
scaleY: 0.2,
|
|
|
|
tint: 0x0022aa,
|
|
|
|
},
|
|
|
|
Ttl: {ttl: 0.25},
|
|
|
|
}
|
|
|
|
});
|
2024-06-28 16:38:49 -05:00
|
|
|
}
|
2024-07-30 09:56:53 -05:00
|
|
|
await wait(0.5);
|
2024-06-28 16:38:49 -05:00
|
|
|
|
2024-07-12 17:41:55 -05:00
|
|
|
for (const {x, y} of projected) {
|
|
|
|
const tileIndex = layer.area.x * y + x
|
2024-06-28 16:38:49 -05:00
|
|
|
let w;
|
|
|
|
if (Water.water[tileIndex]) {
|
|
|
|
w = Water.water[tileIndex]
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
w = 0
|
|
|
|
}
|
|
|
|
Water.water[tileIndex] = Math.min(255, 64 + w);
|
|
|
|
}
|
|
|
|
|
|
|
|
Controlled.locked = 0;
|
|
|
|
|
|
|
|
}
|