Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-party committed Jul 3, 2024
1 parent 58ab58d commit 420aa3a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hooks/data/useProjectile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import type { Projectile } from '@/config/projectiles';

export default function useProjectile(): Projectile {
const projectileData = useDataStore((s) => s.projectile);
const setProjectile = useDataStore((s) => s.setProjectile);

const projectile =
guns[projectileData.gunKey].projectiles[projectileData.index];
const gun = guns[projectileData.gunKey];
if (!gun) setProjectile(Object.keys(guns)[0], 0);

const projectile = gun.projectiles[projectileData.index];
if (!projectile) setProjectile(projectileData.gunKey, 0);

return projectile;
}

0 comments on commit 420aa3a

Please sign in to comment.