2024-06-28 16:38:49 -05:00
|
|
|
const {Direction, Position, Wielder} = wielder
|
|
|
|
const projected = Wielder.activeItem()?.project(Position.tile, Direction.direction)
|
|
|
|
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(':');
|
|
|
|
|
|
|
|
const waterParticles = {
|
|
|
|
behaviors: [
|
|
|
|
{
|
|
|
|
type: 'moveAcceleration',
|
|
|
|
config: {
|
|
|
|
accel: {
|
|
|
|
x: 0,
|
|
|
|
y: 1500,
|
|
|
|
},
|
|
|
|
minStart: 0,
|
|
|
|
maxStart: 0,
|
|
|
|
rotate: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'moveSpeed',
|
|
|
|
config: {
|
|
|
|
speed: {
|
|
|
|
list: [
|
|
|
|
{
|
|
|
|
time: 0,
|
|
|
|
value: 30
|
|
|
|
},
|
|
|
|
{
|
|
|
|
time: 1,
|
|
|
|
value: 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'scale',
|
|
|
|
config: {
|
|
|
|
scale: {
|
|
|
|
list: [
|
|
|
|
{
|
|
|
|
value: 0.25,
|
|
|
|
time: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 0.125,
|
|
|
|
time: 1,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'textureSingle',
|
|
|
|
config: {
|
|
|
|
texture: 'tileset/38',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
],
|
|
|
|
lifetime: {
|
|
|
|
min: 0.25,
|
|
|
|
max: 0.25,
|
|
|
|
},
|
|
|
|
frequency: 0.01,
|
|
|
|
emitterLifetime: 0.25,
|
|
|
|
pos: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
},
|
|
|
|
rotation: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
Sound.play('/assets/watering-can/water.wav');
|
|
|
|
for (let i = 0; i < 2; ++i) {
|
2024-07-12 17:41:55 -05:00
|
|
|
for (const {x, y} of projected) {
|
2024-06-28 16:38:49 -05:00
|
|
|
Emitter.emit({
|
|
|
|
...waterParticles,
|
|
|
|
behaviors: [
|
|
|
|
...waterParticles.behaviors,
|
|
|
|
{
|
|
|
|
type: 'spawnShape',
|
|
|
|
config: {
|
|
|
|
type: 'rect',
|
|
|
|
data: {
|
2024-07-12 17:41:55 -05:00
|
|
|
x: x * layer.tileSize.x,
|
|
|
|
y: y * layer.tileSize.y - (layer.tileSize.y * 0.5),
|
2024-06-28 16:38:49 -05:00
|
|
|
w: layer.tileSize.x,
|
|
|
|
h: layer.tileSize.y,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
await wait(0.25);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|