diff --git a/apps/client/src/scenes/game/GameManager.ts b/apps/client/src/scenes/game/GameManager.ts index 1ca9fbe..5ee9da1 100644 --- a/apps/client/src/scenes/game/GameManager.ts +++ b/apps/client/src/scenes/game/GameManager.ts @@ -1,3 +1,8 @@ +/** + * GameManager + * ゲーム全体の初期化,更新,破棄のライフサイクルを管理する + * マップ,ネットワーク同期,ゲームループを統合する + */ import { Application, Container, Ticker } from "pixi.js"; import { socketManager } from "@client/network/SocketManager"; import { GameMapController } from "./entities/map/GameMapController"; @@ -6,6 +11,7 @@ import { GameLoop } from "./application/GameLoop"; import type { GamePlayers } from "./application/game.types"; +/** ゲームシーンの実行ライフサイクルを管理するマネージャー */ export class GameManager { private app: Application; private worldContainer: Container; diff --git a/apps/client/src/scenes/game/GameScene.tsx b/apps/client/src/scenes/game/GameScene.tsx index e7432ba..0beeaa6 100644 --- a/apps/client/src/scenes/game/GameScene.tsx +++ b/apps/client/src/scenes/game/GameScene.tsx @@ -11,10 +11,7 @@ myId: string | null; } -/** - * メインゲーム画面コンポーネント - * UIの描画と GameManager への入力伝達のみを担当する - */ +/** メインゲーム画面を描画し入力をゲーム制御へ橋渡しする */ export function GameScene({ myId }: GameSceneProps) { const { pixiContainerRef, timeLeft, handleInput } = useGameSceneController(myId); diff --git a/apps/client/src/scenes/game/application/GameLoop.ts b/apps/client/src/scenes/game/application/GameLoop.ts index f9145b5..3b76a2c 100644 --- a/apps/client/src/scenes/game/application/GameLoop.ts +++ b/apps/client/src/scenes/game/application/GameLoop.ts @@ -1,3 +1,8 @@ +/** + * GameLoop + * 毎フレームの入力,シミュレーション,カメラ更新を進行する + * 各 Step を呼び出して更新順序を統制する + */ import { Application, Container, Ticker } from "pixi.js"; import { LocalPlayerController } from "../entities/player/PlayerController"; import type { GamePlayers } from "./game.types"; @@ -13,6 +18,7 @@ getJoystickInput: () => { x: number; y: number }; }; +/** ゲームのフレーム更新順序を管理するループ制御クラス */ export class GameLoop { private app: Application; private worldContainer: Container; diff --git a/apps/client/src/scenes/game/application/GameNetworkSync.ts b/apps/client/src/scenes/game/application/GameNetworkSync.ts index f401c1c..9146949 100644 --- a/apps/client/src/scenes/game/application/GameNetworkSync.ts +++ b/apps/client/src/scenes/game/application/GameNetworkSync.ts @@ -1,3 +1,8 @@ +/** + * GameNetworkSync + * ソケットイベントとゲーム内状態更新の同期を担う + * プレイヤー生成更新削除とマップ更新購読を管理する + */ import { Container } from "pixi.js"; import type { playerTypes } from "@repo/shared"; import { socketManager } from "@client/network/SocketManager"; @@ -13,6 +18,7 @@ onGameStart: (startTime: number) => void; }; +/** ゲーム中のネットワークイベント購読と同期処理を管理する */ export class GameNetworkSync { private worldContainer: Container; private players: GamePlayers; diff --git a/apps/client/src/scenes/game/application/GameTimer.ts b/apps/client/src/scenes/game/application/GameTimer.ts index 61a6148..b3fed35 100644 --- a/apps/client/src/scenes/game/application/GameTimer.ts +++ b/apps/client/src/scenes/game/application/GameTimer.ts @@ -1,5 +1,11 @@ +/** + * GameTimer + * ゲーム開始時刻を基準に残り時間を計算する + * 表示用の残り秒数取得を提供する + */ import { config } from "@repo/shared"; +/** ゲーム制限時間の残り秒数を管理するタイマーモデル */ export class GameTimer { private gameStartTime: number | null = null; diff --git a/apps/client/src/scenes/game/application/game.types.ts b/apps/client/src/scenes/game/application/game.types.ts index f008fdd..cb69775 100644 --- a/apps/client/src/scenes/game/application/game.types.ts +++ b/apps/client/src/scenes/game/application/game.types.ts @@ -1,4 +1,11 @@ +/** + * game.types + * ゲームアプリケーション層で共有する型定義をまとめる + * プレイヤーコントローラーの集合表現を提供する + */ import { LocalPlayerController, RemotePlayerController } from "../entities/player/PlayerController"; +/** ゲームで扱うプレイヤーコントローラーのユニオン型 */ export type GamePlayerController = LocalPlayerController | RemotePlayerController; +/** プレイヤーIDをキーにしたコントローラー管理マップ型 */ export type GamePlayers = Record; diff --git a/apps/client/src/scenes/game/application/loopSteps/CameraStep.ts b/apps/client/src/scenes/game/application/loopSteps/CameraStep.ts index 4871923..93dda17 100644 --- a/apps/client/src/scenes/game/application/loopSteps/CameraStep.ts +++ b/apps/client/src/scenes/game/application/loopSteps/CameraStep.ts @@ -1,3 +1,8 @@ +/** + * CameraStep + * ゲームループのカメラ段を担う + * ローカルプレイヤー位置に応じてワールド座標を更新する + */ import { Application, Container } from "pixi.js"; import { LocalPlayerController } from "../../entities/player/PlayerController"; @@ -7,6 +12,7 @@ me: LocalPlayerController; }; +/** カメラ追従更新を担うステップ */ export class CameraStep { public run({ app, worldContainer, me }: CameraStepParams) { const meDisplay = me.getDisplayObject(); diff --git a/apps/client/src/scenes/game/application/loopSteps/InputStep.ts b/apps/client/src/scenes/game/application/loopSteps/InputStep.ts index 6ca5551..721586b 100644 --- a/apps/client/src/scenes/game/application/loopSteps/InputStep.ts +++ b/apps/client/src/scenes/game/application/loopSteps/InputStep.ts @@ -1,3 +1,8 @@ +/** + * InputStep + * ゲームループの入力段を担う + * ジョイスティック入力をローカルプレイヤーへ適用する + */ import { LocalPlayerController } from "../../entities/player/PlayerController"; type InputStepOptions = { @@ -13,6 +18,7 @@ isMoving: boolean; }; +/** 入力段の更新処理を担うステップ */ export class InputStep { private getJoystickInput: () => { x: number; y: number }; diff --git a/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts b/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts index adcdc27..83b74e1 100644 --- a/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts +++ b/apps/client/src/scenes/game/application/loopSteps/SimulationStep.ts @@ -1,3 +1,8 @@ +/** + * SimulationStep + * ゲームループのシミュレーション段を担う + * ローカル更新とリモート補間更新を順に実行する + */ import { config } from "@repo/shared"; import { socketManager } from "@client/network/SocketManager"; import { LocalPlayerController, RemotePlayerController } from "../../entities/player/PlayerController"; @@ -10,11 +15,17 @@ isMoving: boolean; }; +/** シミュレーション段の更新処理を担うステップ */ export class SimulationStep { private lastPositionSentTime = 0; private wasMoving = false; public run({ me, players, deltaSeconds, isMoving }: SimulationStepParams) { + this.runLocalSimulation({ me, isMoving }); + this.runRemoteSimulation({ players, deltaSeconds }); + } + + private runLocalSimulation({ me, isMoving }: Pick) { if (isMoving) { me.tick(); @@ -33,7 +44,9 @@ } this.wasMoving = isMoving; + } + private runRemoteSimulation({ players, deltaSeconds }: Pick) { Object.values(players).forEach((player) => { if (player instanceof RemotePlayerController) { player.tick(deltaSeconds); diff --git a/apps/client/src/scenes/game/entities/player/PlayerModel.ts b/apps/client/src/scenes/game/entities/player/PlayerModel.ts index f6c1612..d42e4c8 100644 --- a/apps/client/src/scenes/game/entities/player/PlayerModel.ts +++ b/apps/client/src/scenes/game/entities/player/PlayerModel.ts @@ -6,9 +6,7 @@ import { config } from '@repo/shared'; import type { playerTypes } from '@repo/shared'; -/** - * プレイヤーの計算責務を担うモデル - */ +/** プレイヤーの座標計算と補間計算を管理するモデル */ export class PlayerModel { public readonly id: string; public readonly teamId: number; diff --git a/apps/client/src/scenes/game/entities/player/PlayerView.ts b/apps/client/src/scenes/game/entities/player/PlayerView.ts index 5adbb1d..902efdb 100644 --- a/apps/client/src/scenes/game/entities/player/PlayerView.ts +++ b/apps/client/src/scenes/game/entities/player/PlayerView.ts @@ -6,9 +6,7 @@ import { Graphics } from 'pixi.js'; import { config } from '@repo/shared'; -/** - * プレイヤーの描画責務を担うビュー - */ +/** プレイヤーのPixi描画オブジェクトを管理するビュー */ export class PlayerView { public readonly displayObject: Graphics; diff --git a/apps/client/src/scenes/game/hooks/useGameSceneController.ts b/apps/client/src/scenes/game/hooks/useGameSceneController.ts index a688a92..61ccda3 100644 --- a/apps/client/src/scenes/game/hooks/useGameSceneController.ts +++ b/apps/client/src/scenes/game/hooks/useGameSceneController.ts @@ -1,3 +1,8 @@ +/** + * useGameSceneController + * ゲーム画面の状態管理と GameManager 連携を担うフック + * Pixi描画領域,残り時間表示,入力橋渡しを提供する + */ import { useCallback, useEffect, useRef, useState } from "react"; import { config } from "@repo/shared"; import { GameInputManager } from "../GameInputManager"; @@ -11,6 +16,7 @@ const getInitialTimeDisplay = () => formatRemainingTime(config.GAME_CONFIG.GAME_DURATION_SEC); +/** ゲーム画面の状態と入力ハンドラを提供するフック */ export const useGameSceneController = (myId: string | null) => { const pixiContainerRef = useRef(null); const gameManagerRef = useRef(null);