diff --git a/app/react-components/ecs.jsx b/app/react-components/ecs.jsx
index a056d5b..fc95bc3 100644
--- a/app/react-components/ecs.jsx
+++ b/app/react-components/ecs.jsx
@@ -72,7 +72,11 @@ export default function EcsComponent() {
)}
{activeTool && (
-
+
)}
)
diff --git a/app/react-components/targeting-ghost.jsx b/app/react-components/targeting-ghost.jsx
index d6ccf1e..bd038f5 100644
--- a/app/react-components/targeting-ghost.jsx
+++ b/app/react-components/targeting-ghost.jsx
@@ -33,7 +33,7 @@ const TargetingGhostInternal = PixiComponent('TargetingGhost', {
},
})
-export default function TargetingGhost({entity, projection}) {
+export default function TargetingGhost({ecs, entity, projection}) {
const [radians, setRadians] = useState(0);
useEffect(() => {
const handle = setInterval(() => {
@@ -43,60 +43,22 @@ export default function TargetingGhost({entity, projection}) {
clearInterval(handle);
};
}, []);
- const {Direction: {direction}, Position: {x, y}} = entity;
- const tileX = x - (x % tileSize.x);
- const tileY = y - (y % tileSize.y);
- let startX = tileX + (tileSize.x / 2);
- let startY = tileY + (tileSize.y / 2);
- switch (direction) {
- case 0:
- startX += projection.distance[1] * tileSize.x;
- startY -= projection.distance[0] * tileSize.y;
- break;
- case 1:
- startX += projection.distance[0] * tileSize.x;
- startY += projection.distance[1] * tileSize.y;
- break;
- case 2:
- startX -= projection.distance[1] * tileSize.x;
- startY += projection.distance[0] * tileSize.y;
- break;
- case 3:
- startX -= projection.distance[0] * tileSize.x;
- startY -= projection.distance[1] * tileSize.y;
- break;
- }
+ const {TileLayers: {layers: [layer]}} = ecs.get(1);
+ const {Position, Wielder} = entity;
+ const projected = Wielder.project(Position.tile, projection)
const ghosts = [];
- for (const row in projection.grid) {
- const columns = projection.grid[row];
- for (const column in columns) {
- const targeted = projection.grid[row][column];
- if (targeted) {
- let axe;
- switch (direction) {
- case 0:
- axe = [column, row];
- break;
- case 1:
- axe = [-row, column];
- break;
- case 2:
- axe = [-column, -row];
- break;
- case 3:
- axe = [row, -column];
- break;
- }
- ghosts.push(
-
- );
- }
+ for (const {x, y} of projected) {
+ if (x < 0 || y < 0 || x >= layer.area.x || y >= layer.area.y) {
+ continue;
}
+ ghosts.push(
+
+ );
}
return <>{ghosts}>;
}