mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: start of mixer
This commit is contained in:
1 parent
5747d7549f
commit
f3762e356f
7 files changed
+278
No files matched your search
@@ -0,0 +1,64 @@
|
||||
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';
|
||||
import {
|
||||
LocaleProvider,
|
||||
type LocaleAcceptorProps,
|
||||
} from '../../../hooks/useLocale';
|
||||
import { MixerEphemeral } from '../../../stores/mixerEphemeral';
|
||||
|
||||
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)
|
||||
],
|
||||
);
|
||||
const gunTank = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
|
||||
const gunTurret = useRef(
|
||||
gunTank.current.turrets[
|
||||
Math.floor(Math.random() * gunTank.current.turrets.length)
|
||||
],
|
||||
);
|
||||
const gun = useRef(
|
||||
gunTurret.current.guns[
|
||||
Math.floor(Math.random() * gunTurret.current.guns.length)
|
||||
],
|
||||
);
|
||||
|
||||
return (
|
||||
<LocaleProvider locale={locale}>
|
||||
<MixerEphemeral.Provider
|
||||
data={{
|
||||
hull: hull.current,
|
||||
turret: { tank: turretTank.current, turret: turret.current },
|
||||
gun: {
|
||||
tank: gunTank.current,
|
||||
turret: gunTurret.current,
|
||||
gun: gun.current,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Content />
|
||||
</MixerEphemeral.Provider>
|
||||
</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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
import { PageWrapper } from '../../../components/PageWrapper';
|
||||
import BaseLayout from '../../../layouts/BaseLayout.astro';
|
||||
import { Page } from './_index';
|
||||
|
||||
export { getStaticPaths } from '../index.astro';
|
||||
|
||||
const { locale } = Astro.params;
|
||||
---
|
||||
|
||||
<BaseLayout>
|
||||
<PageWrapper p="0" maxWidth="unset">
|
||||
<Page {locale} client:load />
|
||||
</PageWrapper>
|
||||
</BaseLayout>
|
||||
Reference in new issue
Block a user