feat: projection verification
This commit is contained in:
parent
559d77c92c
commit
b4c38d1ee0
|
@ -10,6 +10,7 @@ export default function(Component) {
|
|||
return Inventory.item(Wielder.activeSlot + 1);
|
||||
};
|
||||
Instance.prototype.project = function(position, projection) {
|
||||
const {TileLayers: {layers: [layer]}} = Component.ecs.get(1);
|
||||
const {Direction: {direction}} = Component.ecs.get(this.entity);
|
||||
let startX = position.x;
|
||||
let startY = position.y;
|
||||
|
@ -52,10 +53,12 @@ export default function(Component) {
|
|||
axe = [row, -column];
|
||||
break;
|
||||
}
|
||||
projected.push({
|
||||
x: startX + parseInt(axe[0]),
|
||||
y: startY + parseInt(axe[1]),
|
||||
})
|
||||
const x = startX + parseInt(axe[0]);
|
||||
const y = startY + parseInt(axe[1]);
|
||||
if (x < 0 || y < 0 || x >= layer.area.x || y >= layer.area.y) {
|
||||
continue;
|
||||
}
|
||||
projected.push({x, y});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
const {Controlled, Emitter, Position, Sound, Sprite, Wielder} = wielder
|
||||
const {TileLayers} = ecs.get(1)
|
||||
const layer = TileLayers.layer(0)
|
||||
const {Position, Wielder} = wielder
|
||||
const projected = Wielder.project(Position.tile, item.tool.projection)
|
||||
if (projected.length > 0) {
|
||||
|
||||
Controlled.locked = 1;
|
||||
const [, direction] = Sprite.animation.split(':');
|
||||
const {Controlled, Emitter, Sound, Sprite} = wielder
|
||||
const {TileLayers} = ecs.get(1)
|
||||
const layer = TileLayers.layer(0)
|
||||
|
||||
const dirtParticles = {
|
||||
Controlled.locked = 1
|
||||
const [, direction] = Sprite.animation.split(':')
|
||||
|
||||
const dirtParticles = {
|
||||
behaviors: [
|
||||
{
|
||||
type: 'moveAcceleration',
|
||||
|
@ -81,9 +84,9 @@ const dirtParticles = {
|
|||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
for (let i = 0; i < 2; ++i) {
|
||||
for (let i = 0; i < 2; ++i) {
|
||||
Sound.play('/assets/hoe/dig.wav');
|
||||
for (let i = 0; i < projected.length; ++i) {
|
||||
Emitter.emit({
|
||||
|
@ -109,15 +112,17 @@ for (let i = 0; i < 2; ++i) {
|
|||
await wait(300)
|
||||
Sprite.animation = ['idle', direction].join(':');
|
||||
await wait(100)
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < projected.length; ++i) {
|
||||
for (let i = 0; i < projected.length; ++i) {
|
||||
if ([1, 2, 3, 4].includes(layer.tile(projected[i]))) {
|
||||
layer.stamp(projected[i], [[6]])
|
||||
}
|
||||
else if ([6].includes(layer.tile(projected[i]))) {
|
||||
layer.stamp(projected[i], [[7]])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controlled.locked = 0;
|
||||
Controlled.locked = 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user