Optimise grid and interaction context

This commit is contained in:
Mitchell McCaffrey
2021-03-12 11:02:58 +11:00
parent 01d738b9c6
commit e6fd10a904
14 changed files with 406 additions and 135 deletions

View File

@@ -1,18 +1,21 @@
import React, { useRef } from "react";
import { Group, Circle, Rect } from "react-konva";
import { useMapInteraction } from "../../contexts/MapInteractionContext";
import {
useDebouncedStageScale,
useMapWidth,
useMapHeight,
useSetPreventMapInteraction,
} from "../../contexts/MapInteractionContext";
import { useKeyboard } from "../../contexts/KeyboardContext";
import Vector2 from "../../helpers/Vector2";
function MapGridEditor({ map, onGridChange }) {
const {
mapWidth,
mapHeight,
stageScale,
setPreventMapInteraction,
} = useMapInteraction();
const stageScale = useDebouncedStageScale();
const mapWidth = useMapWidth();
const mapHeight = useMapHeight();
const setPreventMapInteraction = useSetPreventMapInteraction();
const mapSize = { x: mapWidth, y: mapHeight };