diff --git a/src/components/BuildingPlan.tsx b/src/components/BuildingPlan.tsx index 4078fc1..01f3d08 100644 --- a/src/components/BuildingPlan.tsx +++ b/src/components/BuildingPlan.tsx @@ -1,27 +1,21 @@ -import { RoomT } from "../types/room"; +import { useRoomContext } from "../context"; import { Canvas } from "./Canvas"; export type BuildingPlanProps = { width: number; height: number }; export const BuildingPlan = ({ width, height }: BuildingPlanProps) => { - const room: RoomT = { - coordinates: { x: 100, y: 200 }, - free: true, - size: { h: 100, w: 200 }, - }; + const { state } = useRoomContext(); return ( { - ctx.fillStyle = room.free ? "green" : "gray"; - ctx.fillRect( - room.coordinates.x, - room.coordinates.y, - room.size.w, - room.size.h - ); + state.map.map(({ coordinates, size }, index) => { + const { free } = state.char[index]; + ctx.fillStyle = free ? "green" : "gray"; + ctx.fillRect(coordinates.x, coordinates.y, size.w, size.h); + }); }} /> );