summaryrefslogtreecommitdiff
path: root/src/components/map/layers
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/map/layers')
-rw-r--r--src/components/map/layers/HoverTileLayerComponent.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components/map/layers/HoverTileLayerComponent.js b/src/components/map/layers/HoverTileLayerComponent.js
new file mode 100644
index 00000000..691b9733
--- /dev/null
+++ b/src/components/map/layers/HoverTileLayerComponent.js
@@ -0,0 +1,27 @@
+import React from 'react';
+import {Layer} from "react-konva";
+import HoverTile from "../elements/HoverTile";
+import {TILE_SIZE_IN_PIXELS} from "../MapConstants";
+
+const HoverTileLayerComponent = ({mainGroupX, mainGroupY, mouseX, mouseY, currentRoomInConstruction, isValid, onClick}) => {
+ if (currentRoomInConstruction === -1) {
+ return <Layer/>
+ }
+
+ const positionX = Math.floor((mouseX - mainGroupX) / TILE_SIZE_IN_PIXELS);
+ const positionY = Math.floor((mouseY - mainGroupY) / TILE_SIZE_IN_PIXELS);
+ const pixelX = positionX * TILE_SIZE_IN_PIXELS + mainGroupX;
+ const pixelY = positionY * TILE_SIZE_IN_PIXELS + mainGroupY;
+ const validity = isValid(positionX, positionY);
+
+ return (
+ <Layer>
+ <HoverTile
+ pixelX={pixelX} pixelY={pixelY}
+ isValid={validity} onClick={() => onClick(positionX, positionY)}
+ />
+ </Layer>
+ );
+};
+
+export default HoverTileLayerComponent;