From 5c4019096d71a2260d445e2b355bd8b8e89ef1ef Mon Sep 17 00:00:00 2001 From: Alex Christopher Richards Date: Sun, 27 Jul 2025 00:38:31 -0400 Subject: [PATCH 1/4] Moved useFrame to useRespawn --- .../frontend/src/game/hooks/useRespawn.tsx | 19 +++++++++++++++++- packages/frontend/src/game/player/Player.tsx | 20 +++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/frontend/src/game/hooks/useRespawn.tsx b/packages/frontend/src/game/hooks/useRespawn.tsx index 9143795..41359e4 100644 --- a/packages/frontend/src/game/hooks/useRespawn.tsx +++ b/packages/frontend/src/game/hooks/useRespawn.tsx @@ -2,15 +2,32 @@ import React from "react"; import { useFrame } from "@react-three/fiber"; import { dispatch, GamePlayerState, getPlayerId } from "../utils/geckos/geckos"; import { PlayerActions, WeaponActions } from "@fps/lib"; +import type { Camera, Vector3 } from "three"; +import type { Capsule } from "three-stdlib"; interface RespawnProps { + camera: Camera; + capsule: React.MutableRefObject; playerStateRef: React.MutableRefObject; + playerVelocity: React.MutableRefObject; + wasAliveRef: React.MutableRefObject; } export const useRespawn = (props: RespawnProps) => { - const { playerStateRef } = props; + const { camera, capsule, playerStateRef, playerVelocity, wasAliveRef } = props; useFrame(() => { + const isAlive = playerStateRef.current.isAlive; + if (!wasAliveRef.current && isAlive) { + const pos = playerStateRef.current.position; + capsule.current.start.set(pos.x, pos.y, pos.z); + capsule.current.end.set(pos.x, pos.y, pos.z); + camera.position.set(pos.x, pos.y, pos.z); + camera.quaternion.copy(playerStateRef.current.direction); + playerVelocity.current.set(0, 0, 0); + } + wasAliveRef.current = isAlive; + const [gamepad] = navigator.getGamepads(); if (gamepad == null) return; diff --git a/packages/frontend/src/game/player/Player.tsx b/packages/frontend/src/game/player/Player.tsx index 43e23de..09faaed 100644 --- a/packages/frontend/src/game/player/Player.tsx +++ b/packages/frontend/src/game/player/Player.tsx @@ -5,7 +5,7 @@ import { useControls } from "./hooks/useControls"; import { useCameraMotion } from "../hooks/useCameraMotion"; import { useCanPlayerRise } from "./hooks/useCanPlayerRise"; import { useDeleteWeapons } from "./hooks/useDeleteWeapons"; -import { useFrame, useThree } from "@react-three/fiber"; +import { useThree } from "@react-three/fiber"; import { useHitDetection } from "../hooks/useHitDetection"; import { useRegen } from "./hooks/useRegen"; import { useReload } from "./hooks/useReload"; @@ -43,20 +43,6 @@ export const Player: React.FC = (props) => { const capsule = React.useRef(new Capsule(new Vector3(0, 10, 0), new Vector3(0, 11, 0), 0.5)); const wasAliveRef = React.useRef(playerStateRef.current.isAlive); - // TODO: Move to own hook (or maybe just useRespawn?) https://app.clickup.com/t/86b5v1hxh - useFrame(() => { - const isAlive = playerStateRef.current.isAlive; - if (!wasAliveRef.current && isAlive) { - const pos = playerStateRef.current.position; - capsule.current.start.set(pos.x, pos.y, pos.z); - capsule.current.end.set(pos.x, pos.y, pos.z); - camera.position.set(pos.x, pos.y, pos.z); - camera.quaternion.copy(playerStateRef.current.direction); - playerVelocity.current.set(0, 0, 0); - } - wasAliveRef.current = isAlive; - }); - // Handles hit detection useHitDetection({ gameStateRef, @@ -67,7 +53,11 @@ export const Player: React.FC = (props) => { // Handles respawning logic useRespawn({ + camera, + capsule, playerStateRef, + playerVelocity, + wasAliveRef, }); // Handles Cannot stand / crouch here messages From b081e538972609443e45bfbc7dd450590764f093 Mon Sep 17 00:00:00 2001 From: Alex Christopher Richards Date: Sun, 27 Jul 2025 00:40:00 -0400 Subject: [PATCH 2/4] typo --- packages/frontend/src/game/player/Player.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/game/player/Player.tsx b/packages/frontend/src/game/player/Player.tsx index 09faaed..6484add 100644 --- a/packages/frontend/src/game/player/Player.tsx +++ b/packages/frontend/src/game/player/Player.tsx @@ -39,7 +39,7 @@ export const Player: React.FC = (props) => { const { camera } = useThree(); // Single camera is shared between hooks const playerOnFloor = React.useRef(false); const playerVelocity = React.useRef(new Vector3()); - const playerDirection = React.useRef(new Vector3()); // TODO: Remove this and jsut use GamePlayerState https://app.clickup.com/t/86b5v1h2p + const playerDirection = React.useRef(new Vector3()); // TODO: Remove this and just use GamePlayerState https://app.clickup.com/t/86b5v1h2p const capsule = React.useRef(new Capsule(new Vector3(0, 10, 0), new Vector3(0, 11, 0), 0.5)); const wasAliveRef = React.useRef(playerStateRef.current.isAlive); From b8c1879d2b658f0617585971d82d69d4e984a23d Mon Sep 17 00:00:00 2001 From: Alex Christopher Richards Date: Sun, 27 Jul 2025 00:51:58 -0400 Subject: [PATCH 3/4] update pipeline name --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a751a34..fafe596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: jobs: build: + name: build-main-pipeline runs-on: ubuntu-latest steps: From 781526c27c6b243a02741707768664d6fd4f8b5a Mon Sep 17 00:00:00 2001 From: Alex Christopher Richards Date: Sun, 27 Jul 2025 00:54:48 -0400 Subject: [PATCH 4/4] pipeline test --- packages/frontend/src/game/hooks/useRespawn.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/game/hooks/useRespawn.tsx b/packages/frontend/src/game/hooks/useRespawn.tsx index 41359e4..002d717 100644 --- a/packages/frontend/src/game/hooks/useRespawn.tsx +++ b/packages/frontend/src/game/hooks/useRespawn.tsx @@ -38,7 +38,7 @@ export const useRespawn = (props: RespawnProps) => { }), ); - // TODO: Update initial spawn to select gun via select class https://app.clickup.com/t/86b5r3rjy + // TODO: Update initial spawn to select gun via select a class https://app.clickup.com/t/86b5r3rjy if (playerStateRef.current.currentWeapon === null) { dispatch( WeaponActions.assignToPlayer({ playerId: getPlayerId(), weapon: "Saiga" }),