2025-09-01 19:19:44 -05:00
|
|
|
import { Box } from "@radix-ui/themes";
|
|
|
|
|
import { useRef } from "react";
|
|
|
|
|
import { MixerScene } from "../../../components/MixerScene";
|
|
|
|
|
import { PageWrapper } from "../../../components/PageWrapper";
|
|
|
|
|
import { awaitableTankDefinitions } from "../../../core/awaitables/tankDefinitions";
|
2025-08-28 16:12:40 -05:00
|
|
|
import {
|
|
|
|
|
LocaleProvider,
|
|
|
|
|
type LocaleAcceptorProps,
|
2025-09-01 19:19:44 -05:00
|
|
|
} from "../../../hooks/useLocale";
|
|
|
|
|
import { Mixer } from "../../../stores/mixer";
|
2025-08-28 16:12:40 -05:00
|
|
|
|
|
|
|
|
const tankDefinitions = await awaitableTankDefinitions;
|
|
|
|
|
const tanks = Object.values(tankDefinitions.tanks);
|
|
|
|
|
|
|
|
|
|
export function Page({ locale }: LocaleAcceptorProps) {
|
|
|
|
|
const hull = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
|
|
|
|
|
const turretTank = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
|
|
|
|
|
const turret = useRef(
|
|
|
|
|
turretTank.current.turrets[
|
|
|
|
|
Math.floor(Math.random() * turretTank.current.turrets.length)
|
2025-09-01 19:19:44 -05:00
|
|
|
]
|
2025-08-28 16:12:40 -05:00
|
|
|
);
|
|
|
|
|
const gunTank = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
|
|
|
|
|
const gunTurret = useRef(
|
|
|
|
|
gunTank.current.turrets[
|
|
|
|
|
Math.floor(Math.random() * gunTank.current.turrets.length)
|
2025-09-01 19:19:44 -05:00
|
|
|
]
|
2025-08-28 16:12:40 -05:00
|
|
|
);
|
|
|
|
|
const gun = useRef(
|
|
|
|
|
gunTurret.current.guns[
|
|
|
|
|
Math.floor(Math.random() * gunTurret.current.guns.length)
|
2025-09-01 19:19:44 -05:00
|
|
|
]
|
2025-08-28 16:12:40 -05:00
|
|
|
);
|
|
|
|
|
|
2025-09-01 19:19:44 -05:00
|
|
|
Mixer.useInitialization({
|
|
|
|
|
hull: hull.current,
|
|
|
|
|
turret: { tank: turretTank.current, turret: turret.current },
|
|
|
|
|
gun: {
|
|
|
|
|
tank: gunTank.current,
|
|
|
|
|
turret: gunTurret.current,
|
|
|
|
|
gun: gun.current,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2025-08-28 16:12:40 -05:00
|
|
|
return (
|
|
|
|
|
<LocaleProvider locale={locale}>
|
2025-09-01 19:19:44 -05:00
|
|
|
<Content />
|
2025-08-28 16:12:40 -05:00
|
|
|
</LocaleProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Content() {
|
|
|
|
|
return (
|
|
|
|
|
<PageWrapper p="0">
|
|
|
|
|
<Box flexGrow="1" position="relative">
|
|
|
|
|
<Box position="absolute" width="100%" height="100%" top="0" left="0">
|
|
|
|
|
<MixerScene />
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</PageWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|