UI: Sync UI updates to game updates. (#1512)

There are a bunch of React components that update at the same rate
that the game engine processes cycles. Rather than have each place
that does so start its own timer to update that often, add a new
react hook that triggers an update shortly after the engine completes
a cycle.
This commit is contained in:
Tom Prince
2024-08-02 00:57:43 -06:00
committed by GitHub
parent 6483b5e7fe
commit 2f95d21503
22 changed files with 71 additions and 55 deletions

View File

@@ -25,12 +25,12 @@ import Typography from "@mui/material/Typography";
import Grid from "@mui/material/Grid";
import Button from "@mui/material/Button";
import { Box } from "@mui/material";
import { useRerender } from "../../ui/React/hooks";
import { useCycleRerender } from "../../ui/React/hooks";
/** Root React Component for the Hacknet Node UI */
export function HacknetRoot(): React.ReactElement {
const [open, setOpen] = useState(false);
const rerender = useRerender(200);
const rerender = useCycleRerender();
const [purchaseMultiplier, setPurchaseMultiplier] = useState<number | "MAX">(PurchaseMultipliers.x1);
let totalProduction = 0;