import { Box, Center } from '@chakra-ui/react'; import { useEffect, useMemo, useState } from 'react'; import { useNuiEvent } from '../../hooks/useNuiEvent'; import { debugData } from '../../utils/debugData'; import Indicator from './indicator'; interface CustomGameDifficulty { areaSize: number; speedMultiplier: number; } type GameDifficulty = 'easy' | 'medium' | 'hard' | CustomGameDifficulty; export interface SkillCheckProps { visible: boolean; angle: number; difficultyOffset: number; difficulty: GameDifficulty; } const getRandomAngle = (min: number, max: number) => Math.floor(Math.random() * (max - min)) + min; const difficultyOffsets = { easy: 275, medium: 290, hard: 295, }; debugData([ { action: 'startSkillCheck', data: 'easy', }, ]); const SkillCheck: React.FC = () => { const [skillCheck, setSkillCheck] = useState({ visible: false, angle: 0, difficultyOffset: 315, difficulty: 'easy', }); useNuiEvent('startSkillCheck', (data: GameDifficulty) => { const offset = typeof data === 'object' ? data.areaSize : difficultyOffsets[data]; setSkillCheck({ visible: true, angle: -90 + getRandomAngle(120, 360 - (315 - offset)), difficultyOffset: offset, difficulty: data, }); }); return (
{skillCheck.visible && ( <> {/*Circle track*/} {/*SkillCheck area*/} E )}
); }; export default SkillCheck;