summaryrefslogtreecommitdiff
path: root/src/components/map/groups/RoomGroup.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-08-26 13:53:21 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:05:45 +0200
commitbbb802b4142d11f020994ac4d9ae9c1610ac4038 (patch)
treeea5419b2c1c0fc2af22c11e94b4981a9445ec26c /src/components/map/groups/RoomGroup.js
parent8302923a08728d36746af3560ebc35685c2b9da5 (diff)
Enable going from room to tile and back
Diffstat (limited to 'src/components/map/groups/RoomGroup.js')
-rw-r--r--src/components/map/groups/RoomGroup.js43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/components/map/groups/RoomGroup.js b/src/components/map/groups/RoomGroup.js
index 179a24a2..b6c285e9 100644
--- a/src/components/map/groups/RoomGroup.js
+++ b/src/components/map/groups/RoomGroup.js
@@ -1,22 +1,39 @@
import React from "react";
import {Group} from "react-konva";
+import GrayContainer from "../../../containers/map/GrayContainer";
+import TileContainer from "../../../containers/map/TileContainer";
import Shapes from "../../../shapes/index";
import {deriveWallLocations} from "../../../util/tile-calculations";
import WallSegment from "../elements/WallSegment";
-import TileGroup from "./TileGroup";
-const RoomGroup = ({room, onClick}) => (
- <Group
- onClick={onClick}
- >
- {room.tiles.map(tile => (
- <TileGroup key={tile.id} tile={tile}/>
- ))}
- {deriveWallLocations(room).map((wallSegment, index) => (
- <WallSegment key={index} wallSegment={wallSegment}/>
- ))}
- </Group>
-);
+const RoomGroup = ({room, interactionLevel, onClick}) => {
+ return (
+ <Group
+ onClick={onClick}
+ >
+ {(() => {
+ if (interactionLevel.mode === "OBJECT" && interactionLevel.roomId === room.id) {
+ return [
+ room.tiles
+ .filter(tile => tile.id !== interactionLevel.tileId)
+ .map(tile => <TileContainer key={tile.id} tile={tile}/>),
+ <GrayContainer key={-1}/>,
+ room.tiles
+ .filter(tile => tile.id === interactionLevel.tileId)
+ .map(tile => <TileContainer key={tile.id} tile={tile}/>)
+ ];
+ } else {
+ return room.tiles.map(tile => (
+ <TileContainer key={tile.id} tile={tile}/>
+ ));
+ }
+ })()}
+ {deriveWallLocations(room).map((wallSegment, index) => (
+ <WallSegment key={index} wallSegment={wallSegment}/>
+ ))}
+ </Group>
+ );
+};
RoomGroup.propTypes = {
room: Shapes.Room,