From b81829384690c04e460b3aef826494c823398cfb Mon Sep 17 00:00:00 2001 From: "Rei.K" Date: Mon, 11 May 2026 00:18:34 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E3=83=AF=E3=83=BC=E3=83=8B=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E5=89=8A=E6=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tests/MVC/MessagePipeServiceTests.cs | 3 +- .../Tests/PlayMode/InputServiceTests.cs | 3 +- .../Tests/PlayMode/UIInteractionTests.cs | 3 +- .../Network/MemoryResponseCacheTests.cs | 4 +- .../Tests/Shared/Network/RequestQueueTests.cs | 2 +- ...coreTimeAttackTotalResultSceneComponent.cs | 5 +-- .../Scenes/SurvivorAccountLinkDialog.cs | 6 +-- .../Shared/Exceptions/NetworkException.cs | 41 ++++--------------- .../Survivor/SurvivorNetworkStageConnector.cs | 4 -- .../Shaders/Editor/EnemyVisualEffectSetup.cs | 15 +++---- .../Shaders/Editor/MaterialShaderConverter.cs | 15 +++---- 11 files changed, 33 insertions(+), 68 deletions(-) diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/MVC/MessagePipeServiceTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/MVC/MessagePipeServiceTests.cs index 59dab850f..d0e85e9e7 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/MVC/MessagePipeServiceTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/MVC/MessagePipeServiceTests.cs @@ -280,11 +280,10 @@ public void PublishForget_Signal_DoesNotBlock() { // Arrange const int key = 700; - var received = false; var subscription = _service.SubscribeAsync(key, async ct => { await UniTask.Delay(10, cancellationToken: ct); - received = true; + _ = true; }); // Act - Should return immediately diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/InputServiceTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/InputServiceTests.cs index 8e52ef67c..391cf6b46 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/InputServiceTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/InputServiceTests.cs @@ -135,9 +135,8 @@ public IEnumerator KeyboardInput_IsDetected() _inputService.EnablePlayer(); yield return null; - bool moveDetected = false; var moveAction = _inputService.Player.Move; - moveAction.performed += ctx => moveDetected = true; + moveAction.performed += ctx => _ = true; // Act - WASDキー押下をシミュレート Press(_keyboard.wKey); diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/UIInteractionTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/UIInteractionTests.cs index d1f810244..67822151c 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/UIInteractionTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/PlayMode/UIInteractionTests.cs @@ -76,8 +76,7 @@ public IEnumerator Button_WhenDisabled_CannotClick() // Arrange var button = CreateButton("DisabledButton"); button.interactable = false; - bool clicked = false; - button.onClick.AddListener(() => clicked = true); + button.onClick.AddListener(() => _ = true); yield return null; // Assert - interactable が false diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/MemoryResponseCacheTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/MemoryResponseCacheTests.cs index 4d437a234..02a7d9869 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/MemoryResponseCacheTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/MemoryResponseCacheTests.cs @@ -75,7 +75,7 @@ public async Task GetAsync_WhenKeyIsEmpty_ReturnsNull() } [Test] - public async Task SetAsync_WithNullKey_DoesNotThrow() + public void SetAsync_WithNullKey_DoesNotThrow() { // Act & Assert Assert.DoesNotThrowAsync(async () => @@ -167,7 +167,7 @@ public async Task RemoveAsync_RemovesEntry() } [Test] - public async Task RemoveAsync_NonexistentKey_DoesNotThrow() + public void RemoveAsync_NonexistentKey_DoesNotThrow() { // Act & Assert Assert.DoesNotThrowAsync(async () => diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/RequestQueueTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/RequestQueueTests.cs index 4df1ac72e..647ce9dca 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/RequestQueueTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/Network/RequestQueueTests.cs @@ -268,7 +268,7 @@ public async Task ClearAsync_RemovesAllRequests() #region ProcessQueueAsync Tests [Test] - public async Task ProcessQueueAsync_WhenEmpty_DoesNotThrow() + public void ProcessQueueAsync_WhenEmpty_DoesNotThrow() { // Act & Assert Assert.DoesNotThrowAsync(async () => await _queue.ProcessQueueAsync()); diff --git a/src/Game.Client/Assets/Programs/Runtime/MVC/ScoreTimeAttack/Scenes/ScoreTimeAttackTotalResultSceneComponent.cs b/src/Game.Client/Assets/Programs/Runtime/MVC/ScoreTimeAttack/Scenes/ScoreTimeAttackTotalResultSceneComponent.cs index efec489fc..b563af0c3 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVC/ScoreTimeAttack/Scenes/ScoreTimeAttackTotalResultSceneComponent.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVC/ScoreTimeAttack/Scenes/ScoreTimeAttackTotalResultSceneComponent.cs @@ -16,9 +16,6 @@ namespace Game.ScoreTimeAttack.Scenes { public class ScoreTimeAttackTotalResultSceneComponent : GameSceneComponent { - private AudioService _audioService; - private AudioService AudioService => _audioService ??= GameServiceManager.Get(); - private GameSceneService _sceneService; private GameSceneService SceneService => _sceneService ??= GameServiceManager.Get(); @@ -104,4 +101,4 @@ public override UniTask Ready() return UniTask.CompletedTask; } } -} \ No newline at end of file +} diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorAccountLinkDialog.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorAccountLinkDialog.cs index 0d3ad545c..bccafefd2 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorAccountLinkDialog.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorAccountLinkDialog.cs @@ -54,7 +54,7 @@ public override async UniTask Startup() // イベント購読 SceneComponent.OnCloseClicked - .Subscribe(_ => OnClose().Forget()) + .Subscribe(_ => OnClose()) .AddTo(Disposables); SceneComponent.OnLinkEmailClicked @@ -116,7 +116,7 @@ public override async UniTask Ready() Observable.EveryValueChanged(_inputService, x => x.UI.Escape.WasPressedThisFrame(), UnityFrameProvider.Update) .Subscribe(escape => { - if (escape) OnClose().Forget(); + if (escape) OnClose(); }) .AddTo(Disposables); } @@ -164,7 +164,7 @@ private async UniTask RefreshStatusViewAsync() } } - private async UniTaskVoid OnClose() + private void OnClose() { SceneComponent.SetInteractables(false); TrySetResult(Unit.Default); diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Exceptions/NetworkException.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Exceptions/NetworkException.cs index eeb624fea..c8dfd7d64 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Exceptions/NetworkException.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Exceptions/NetworkException.cs @@ -69,16 +69,10 @@ public override string ToString() /// public class NetworkTimeoutException : NetworkException { - private const string ErrorCode = "NETWORK_TIMEOUT"; - private const int ErrorLevel = 2; - - /// - /// タイムアウト秒数 - /// public int TimeoutSeconds { get; } public NetworkTimeoutException(string endpoint, int timeoutSeconds, int retryCount = 0) - : base($"リクエストがタイムアウトしました({timeoutSeconds}秒)", ErrorCode, ErrorLevel, endpoint, null, retryCount) + : base($"リクエストがタイムアウトしました({timeoutSeconds}秒)", "NETWORK_TIMEOUT", 2, endpoint, null, retryCount) { TimeoutSeconds = timeoutSeconds; } @@ -94,21 +88,18 @@ public override string ToString() /// public class NetworkConnectionException : NetworkException { - private const string ErrorCode = "NETWORK_CONNECTION_FAILED"; - private const int ErrorLevel = 2; - public NetworkConnectionException(string endpoint, int retryCount = 0) - : base("サーバーに接続できません", ErrorCode, ErrorLevel, endpoint, null, retryCount) + : base("サーバーに接続できません", "NETWORK_CONNECTION_FAILED", 2, endpoint, null, retryCount) { } public NetworkConnectionException(string message, string endpoint, int retryCount = 0) - : base(message, ErrorCode, ErrorLevel, endpoint, null, retryCount) + : base(message, "NETWORK_CONNECTION_FAILED", 2, endpoint, null, retryCount) { } public NetworkConnectionException(string message, Exception innerException, string endpoint, int retryCount = 0) - : base(message, innerException, ErrorCode, ErrorLevel, endpoint, null, retryCount) + : base(message, innerException, "NETWORK_CONNECTION_FAILED", 2, endpoint, null, retryCount) { } } @@ -118,16 +109,10 @@ public NetworkConnectionException(string message, Exception innerException, stri /// public class NetworkServerException : NetworkException { - private const string ErrorCode = "NETWORK_SERVER_ERROR"; - private const int ErrorLevel = 2; - - /// - /// サーバーからのエラーメッセージ - /// public string ServerMessage { get; } public NetworkServerException(string endpoint, int statusCode, string serverMessage = null, int retryCount = 0) - : base($"サーバーエラーが発生しました({statusCode})", ErrorCode, ErrorLevel, endpoint, statusCode, retryCount) + : base($"サーバーエラーが発生しました({statusCode})", "NETWORK_SERVER_ERROR", 2, endpoint, statusCode, retryCount) { ServerMessage = serverMessage; } @@ -144,16 +129,10 @@ public override string ToString() /// public class NetworkClientException : NetworkException { - private const string ErrorCode = "NETWORK_CLIENT_ERROR"; - private const int ErrorLevel = 1; // Warning(クライアント側の問題のため) - - /// - /// サーバーからのエラーメッセージ - /// public string ServerMessage { get; } public NetworkClientException(string endpoint, int statusCode, string serverMessage = null, int retryCount = 0) - : base($"クライアントエラーが発生しました({statusCode})", ErrorCode, ErrorLevel, endpoint, statusCode, retryCount) + : base($"クライアントエラーが発生しました({statusCode})", "NETWORK_CLIENT_ERROR", 1, endpoint, statusCode, retryCount) { ServerMessage = serverMessage; } @@ -170,16 +149,10 @@ public override string ToString() /// public class NetworkRetryExhaustedException : NetworkException { - private const string ErrorCode = "NETWORK_RETRY_EXHAUSTED"; - private const int ErrorLevel = 2; - - /// - /// 最後に発生したエラー - /// public Exception LastError { get; } public NetworkRetryExhaustedException(string endpoint, int maxRetries, Exception lastError = null) - : base($"リトライ上限({maxRetries}回)に達しました", lastError, ErrorCode, ErrorLevel, endpoint, null, maxRetries) + : base($"リトライ上限({maxRetries}回)に達しました", lastError, "NETWORK_RETRY_EXHAUSTED", 2, endpoint, null, maxRetries) { LastError = lastError; } diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs index d46119ad1..8865622b6 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs @@ -34,7 +34,6 @@ public class SurvivorNetworkStageConnector : ISurvivorNetworkStageConnector private SurvivorFusionRunner _runner; private SurvivorUnityServerSession _session; - private GameMode _gameMode; private bool _isConnecting; // Addressables で読み込んだプレハブ(解放用に保持) @@ -51,7 +50,6 @@ public async UniTask StartHostAsync(int stageId) try { - _gameMode = GameMode.Host; var sessionName = _sessionConfig.SessionName; var playerCount = _sessionConfig.PlayerCount; @@ -95,7 +93,6 @@ public async UniTask ConnectAsync(int stageId) try { - _gameMode = GameMode.Client; var sessionName = _sessionConfig.SessionName; var source = _sessionConfig.ConnectionSource; var isP2PClient = source == ConnectionSource.P2PClient; @@ -150,7 +147,6 @@ public async UniTask StartServerAsync(int stageId) try { - _gameMode = GameMode.Server; var sessionName = _sessionConfig.SessionName; var playerCount = _sessionConfig.PlayerCount; diff --git a/src/Game.Client/Assets/Shaders/Editor/EnemyVisualEffectSetup.cs b/src/Game.Client/Assets/Shaders/Editor/EnemyVisualEffectSetup.cs index 36319960e..7df63390e 100644 --- a/src/Game.Client/Assets/Shaders/Editor/EnemyVisualEffectSetup.cs +++ b/src/Game.Client/Assets/Shaders/Editor/EnemyVisualEffectSetup.cs @@ -3,6 +3,7 @@ using UnityEditor; using UnityEngine; using Game.MVP.Survivor.Enemy; +using UnityEngine.Rendering; namespace Game.Editor.Shaders { @@ -402,24 +403,24 @@ private bool ConvertMaterial(Material material) var savedFloats = new Dictionary(); var oldShader = material.shader; - int propertyCount = ShaderUtil.GetPropertyCount(oldShader); + int propertyCount = oldShader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { - string propName = ShaderUtil.GetPropertyName(oldShader, i); - var propType = ShaderUtil.GetPropertyType(oldShader, i); + string propName = oldShader.GetPropertyName(i); + var propType = oldShader.GetPropertyType(i); switch (propType) { - case ShaderUtil.ShaderPropertyType.TexEnv: + case ShaderPropertyType.Texture: var tex = material.GetTexture(propName); if (tex != null) savedTextures[propName] = tex; break; - case ShaderUtil.ShaderPropertyType.Color: + case ShaderPropertyType.Color: savedColors[propName] = material.GetColor(propName); break; - case ShaderUtil.ShaderPropertyType.Float: - case ShaderUtil.ShaderPropertyType.Range: + case ShaderPropertyType.Float: + case ShaderPropertyType.Range: savedFloats[propName] = material.GetFloat(propName); break; } diff --git a/src/Game.Client/Assets/Shaders/Editor/MaterialShaderConverter.cs b/src/Game.Client/Assets/Shaders/Editor/MaterialShaderConverter.cs index 2a1ce47bc..9da7ce4ab 100644 --- a/src/Game.Client/Assets/Shaders/Editor/MaterialShaderConverter.cs +++ b/src/Game.Client/Assets/Shaders/Editor/MaterialShaderConverter.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; +using UnityEngine.Rendering; namespace Game.Editor.Shaders { @@ -191,24 +192,24 @@ private bool ConvertMaterial(Material material) var savedFloats = new Dictionary(); var oldShader = material.shader; - int propertyCount = ShaderUtil.GetPropertyCount(oldShader); + int propertyCount = oldShader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { - string propName = ShaderUtil.GetPropertyName(oldShader, i); - var propType = ShaderUtil.GetPropertyType(oldShader, i); + string propName = oldShader.GetPropertyName(i); + var propType = oldShader.GetPropertyType(i); switch (propType) { - case ShaderUtil.ShaderPropertyType.TexEnv: + case ShaderPropertyType.Texture: var tex = material.GetTexture(propName); if (tex != null) savedTextures[propName] = tex; break; - case ShaderUtil.ShaderPropertyType.Color: + case ShaderPropertyType.Color: savedColors[propName] = material.GetColor(propName); break; - case ShaderUtil.ShaderPropertyType.Float: - case ShaderUtil.ShaderPropertyType.Range: + case ShaderPropertyType.Float: + case ShaderPropertyType.Range: savedFloats[propName] = material.GetFloat(propName); break; } From bfe2de779a72c0ff81733700dbccfbc4e63c7070 Mon Sep 17 00:00:00 2001 From: "Rei.K" Date: Mon, 11 May 2026 01:57:51 +0900 Subject: [PATCH 2/5] rename --- .../Shared/Network/Survivor/SurvivorFusionRunner.cs | 2 +- ...vivorUnityServerSession.cs => SurvivorFusionSession.cs} | 7 ++----- ...ServerSession.cs.meta => SurvivorFusionSession.cs.meta} | 0 .../Network/Survivor/SurvivorNetworkStageConnector.cs | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) rename src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/{SurvivorUnityServerSession.cs => SurvivorFusionSession.cs} (94%) rename src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/{SurvivorUnityServerSession.cs.meta => SurvivorFusionSession.cs.meta} (100%) diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs index 5d2c9a0d9..7a7b5e1b0 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs @@ -22,7 +22,7 @@ public class SurvivorFusionRunner : MonoBehaviour, INetworkRunnerCallbacks public NetworkRunner Runner { get; private set; } /// セッション管理(Host/Server 時に設定) - internal SurvivorUnityServerSession Session { get; set; } + internal SurvivorFusionSession Session { get; set; } /// Shutdown 時の通知 internal Action OnShutdownCallback { get; set; } diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorUnityServerSession.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs similarity index 94% rename from src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorUnityServerSession.cs rename to src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs index 5fafd288e..68f6a7c8e 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorUnityServerSession.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs @@ -12,10 +12,9 @@ namespace Game.Shared.Network.Survivor /// Fusion セッション管理。プレイヤー接続追跡と AllPlayersReady 通知を担当。 /// SurvivorNetworkStageConnector から生成され、SurvivorFusionRunner のコールバックを受ける。 /// - public class SurvivorUnityServerSession + public class SurvivorFusionSession { private readonly IFusionRunnerService _runnerService; - private readonly IPublisher _allPlayersReadyPub; private readonly IPublisher _gameStartedPub; private readonly IPublisher _allPlayersDisconnectedPub; @@ -26,16 +25,14 @@ public class SurvivorUnityServerSession public int ConnectedPlayerCount => _connectedPlayers.Count; - public SurvivorUnityServerSession( + public SurvivorFusionSession( IFusionRunnerService runnerService, - IPublisher allPlayersReadyPub, IPublisher gameStartedPub, IPublisher allPlayersDisconnectedPub, int expectedPlayerCount, NetworkObject playerPrefab) { _runnerService = runnerService; - _allPlayersReadyPub = allPlayersReadyPub; _gameStartedPub = gameStartedPub; _allPlayersDisconnectedPub = allPlayersDisconnectedPub; _expectedPlayerCount = expectedPlayerCount; diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorUnityServerSession.cs.meta b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs.meta similarity index 100% rename from src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorUnityServerSession.cs.meta rename to src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs.meta diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs index 8865622b6..265967dd9 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs @@ -24,7 +24,6 @@ public class SurvivorNetworkStageConnector : ISurvivorNetworkStageConnector [Inject] private readonly IFusionRunnerService _runnerService; [Inject] private readonly IUnityServerSessionConfig _sessionConfig; [Inject] private readonly IUnityServerAuthProviderFactory _authProviderFactory; - [Inject] private readonly IPublisher _allPlayersReadyPub; [Inject] private readonly IPublisher _gameStartedPub; [Inject] private readonly IPublisher _allPlayersDisconnectedPub; @@ -33,7 +32,7 @@ public class SurvivorNetworkStageConnector : ISurvivorNetworkStageConnector private const string EnemyBatchSyncAddress = "SurvivorFusionEnemyBatchSync"; private SurvivorFusionRunner _runner; - private SurvivorUnityServerSession _session; + private SurvivorFusionSession _session; private bool _isConnecting; // Addressables で読み込んだプレハブ(解放用に保持) @@ -272,9 +271,8 @@ private void CreateSession(int expectedPlayerCount) if (_playerPrefabAsset != null) playerPrefab = _playerPrefabAsset.GetComponent(); - _session = new SurvivorUnityServerSession( + _session = new SurvivorFusionSession( _runnerService, - _allPlayersReadyPub, _gameStartedPub, _allPlayersDisconnectedPub, expectedPlayerCount, From 54e82430d7c919a81bee8c8571fe9327e4181d53 Mon Sep 17 00:00:00 2001 From: "Rei.K" Date: Mon, 11 May 2026 02:20:10 +0900 Subject: [PATCH 3/5] =?UTF-8?q?NetworkRunner=E6=A9=9F=E8=83=BD=E7=B5=B1?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Network/Survivor/SurvivorFusionRunner.cs | 125 +++++++++++++++-- .../Network/Survivor/SurvivorFusionSession.cs | 129 ------------------ .../Survivor/SurvivorFusionSession.cs.meta | 2 - .../Survivor/SurvivorNetworkStageConnector.cs | 34 +---- 4 files changed, 118 insertions(+), 172 deletions(-) delete mode 100644 src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs delete mode 100644 src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs.meta diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs index 7a7b5e1b0..1c73ac708 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs @@ -1,11 +1,14 @@ using System; using System.Collections.Generic; +using Cysharp.Threading.Tasks; using Fusion; using Fusion.Addons.Physics; using Fusion.Photon.Realtime; using Fusion.Sockets; using Game.Shared.Network.Fusion; +using Game.Shared.Signals.Survivor; using Game.Shared.Unity.Server; +using MessagePipe; using UnityEngine; using VContainer; @@ -13,7 +16,7 @@ namespace Game.Shared.Network.Survivor { /// /// Fusion 2 NetworkRunner を保持する MonoBehaviour コンテナ。 - /// INetworkRunnerCallbacks を実装し、セッション管理へ委譲する。 + /// INetworkRunnerCallbacks を実装し、プレイヤー接続管理・セッション通知を直接担当する。 /// (ここでいう「保持」は GameObject に NetworkRunner を同居させる意味で、 /// Fusion GameMode.Host とは別概念) /// @@ -21,9 +24,6 @@ public class SurvivorFusionRunner : MonoBehaviour, INetworkRunnerCallbacks { public NetworkRunner Runner { get; private set; } - /// セッション管理(Host/Server 時に設定) - internal SurvivorFusionSession Session { get; set; } - /// Shutdown 時の通知 internal Action OnShutdownCallback { get; set; } @@ -33,17 +33,38 @@ public class SurvivorFusionRunner : MonoBehaviour, INetworkRunnerCallbacks /// VContainer リゾルバ(クライアント側レプリカの DI 注入用) internal IObjectResolver Resolver { get; set; } - /// IFusionRunnerService(SurvivorFusionStageConnector が設定) - internal IFusionRunnerService RunnerService { get; set; } - /// 接続認証プロバイダ。Server モード時に設定すると OnConnectRequest で検証する。 internal IUnityServerAuthProvider AuthProvider { get; set; } + // --- VContainer フィールドインジェクション --- + [Inject] private IPublisher _gameStartedPub; + [Inject] private IPublisher _allPlayersDisconnectedPub; + [Inject] private IUnityServerSessionConfig _sessionConfig; + [Inject] private IFusionRunnerService _runnerService; + + // --- セッション管理フィールド(Host/Server 時のみ使用) --- + private readonly HashSet _connectedPlayers = new(); + private bool _allPlayersNotified; + private NetworkObject _playerPrefab; + private bool _sessionEnabled; + public void Initialize() { DontDestroyOnLoad(gameObject); } + /// + /// Host/Server モード時のセッション設定。StartAsync の前に呼ぶこと。 + /// この呼び出しによりセッション系コールバック処理が有効化される (_sessionEnabled = true)。 + /// SpawnConnectedPlayers はステージシーンロード後に呼ぶこと。 + /// + /// スポーンするプレイヤーの NetworkObject プレハブ + public void Configure(NetworkObject playerPrefab) + { + _playerPrefab = playerPrefab; + _sessionEnabled = true; + } + // 診断: 5 秒間の FPS / 最大フレーム時間 / OnInput 呼出回数を集計 private const float DiagSummaryInterval = 5f; private int _diagFrameCount; @@ -51,7 +72,7 @@ public void Initialize() private float _diagMaxFrameTime; private float _diagLastSummaryTime; - private void Update() + protected void Update() { if (Runner == null || !Runner.IsRunning) return; @@ -77,7 +98,7 @@ private void Update() /// FusionConnectionConfig に必要なパラメータをすべてまとめて受け取る。 /// /// 接続設定(GameMode / SessionName / Address / ConnectionToken 等) - public async Cysharp.Threading.Tasks.UniTask StartAsync(FusionConnectionConfig config) + public async UniTask StartAsync(FusionConnectionConfig config) { Runner = gameObject.AddComponent(); Runner.ProvideInput = config.GameMode != GameMode.Server; @@ -143,7 +164,20 @@ public async Cysharp.Threading.Tasks.UniTask StartAsync(FusionC /// public void SpawnConnectedPlayers(Vector3 position, Quaternion rotation) { - Session?.SpawnConnectedPlayers(Runner, position, rotation); + if (_playerPrefab == null) + { + Debug.LogError("[SurvivorFusionRunner] Player prefab is null!"); + return; + } + + foreach (var player in _connectedPlayers) + { + if (Runner.GetPlayerObject(player) != null) continue; + + var playerObj = Runner.Spawn(_playerPrefab, position, rotation, inputAuthority: player); + Runner.SetPlayerObject(player, playerObj); + Debug.Log($"[SurvivorFusionRunner] Spawned player {player} at {position}"); + } } // ===================================================================== @@ -153,13 +187,51 @@ public void SpawnConnectedPlayers(Vector3 position, Quaternion rotation) public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) { Debug.Log($"[SurvivorFusionRunner] Player joined: {player}"); - Session?.OnPlayerJoined(runner, player); + + if (!_sessionEnabled) return; + + _connectedPlayers.Add(player); + Debug.Log($"[SurvivorFusionRunner] Player tracked: {player} ({_connectedPlayers.Count}/{_sessionConfig.PlayerCount})"); + + // Spawn はステージシーンロード後に SpawnConnectedPlayers() で行う + + if (_connectedPlayers.Count >= _sessionConfig.PlayerCount && !_allPlayersNotified) + { + _allPlayersNotified = true; + NotifyAllPlayersReadyAsync().Forget(); + } } public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { Debug.Log($"[SurvivorFusionRunner] Player left: {player}"); - Session?.OnPlayerLeft(runner, player); + + if (!_sessionEnabled) return; + + // 切断時の Pause クリーンアップ (LevelUp 中切断で全体停止が永続化するのを防ぐ) + if (_runnerService != null && _runnerService.TryGet(out var gs)) + { + gs.OnPlayerDisconnectedCleanup(player); + } + + // プレイヤー NetworkObject をデスポーン + var playerObj = runner.GetPlayerObject(player); + if (playerObj != null) + { + runner.Despawn(playerObj); + } + + _connectedPlayers.Remove(player); + Debug.Log($"[SurvivorFusionRunner] Player removed: {player} ({_connectedPlayers.Count} remaining)"); + + if (_connectedPlayers.Count <= 0 && _allPlayersNotified) + { + // リトライ時に再接続を受け入れるためリセット + _allPlayersNotified = false; + + Debug.Log("[SurvivorFusionRunner] All players disconnected"); + _allPlayersDisconnectedPub?.Publish(new SurvivorSignals.Session.AllPlayersDisconnected()); + } } public void OnInput(NetworkRunner runner, NetworkInput input) @@ -185,7 +257,7 @@ public void OnConnectedToServer(NetworkRunner runner) public void OnDisconnectedFromServer(NetworkRunner runner, NetDisconnectReason reason) { Debug.Log($"[SurvivorFusionRunner] Disconnected from server: {reason}"); - RunnerService?.RaiseClientDisconnected(); + _runnerService?.RaiseClientDisconnected(); } // --- 未使用コールバック(最小実装) --- @@ -226,5 +298,32 @@ public void OnSceneLoadDone(NetworkRunner runner) { } public void OnSceneLoadStart(NetworkRunner runner) { } public void OnObjectExitAOI(NetworkRunner runner, NetworkObject obj, PlayerRef player) { } public void OnObjectEnterAOI(NetworkRunner runner, NetworkObject obj, PlayerRef player) { } + + // ===================================================================== + // Private + // ===================================================================== + + /// + /// AllPlayersReady を1フレーム遅延で発火する。 + /// SurvivorStageConnectScene の WaitForAllPlayersReadyAsync() が購読登録を完了した後に届くようにする。 + /// + private async UniTaskVoid NotifyAllPlayersReadyAsync() + { + await UniTask.NextFrame(); + + // ゲーム状態にプレイヤー数を設定(全滅判定用) + if (_runnerService.TryGet(out var gs)) + { + gs.SetTotalPlayerCount(_sessionConfig.PlayerCount); + + // RPC で全クライアントに通知(MPPM 等では別 DI コンテナのため MessagePipe だけでは届かない) + gs.RpcNotifyAllPlayersReady(); + } + + // サーバーローカルの GameStarted シグナル + _gameStartedPub?.Publish(new SurvivorSignals.Session.GameStarted(Time.time)); + + Debug.Log("[SurvivorFusionRunner] AllPlayersReady (RPC) + GameStarted published"); + } } } diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs deleted file mode 100644 index 68f6a7c8e..000000000 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Collections.Generic; -using Cysharp.Threading.Tasks; -using Fusion; -using Game.Shared.Network.Fusion; -using Game.Shared.Signals.Survivor; -using MessagePipe; -using UnityEngine; - -namespace Game.Shared.Network.Survivor -{ - /// - /// Fusion セッション管理。プレイヤー接続追跡と AllPlayersReady 通知を担当。 - /// SurvivorNetworkStageConnector から生成され、SurvivorFusionRunner のコールバックを受ける。 - /// - public class SurvivorFusionSession - { - private readonly IFusionRunnerService _runnerService; - private readonly IPublisher _gameStartedPub; - private readonly IPublisher _allPlayersDisconnectedPub; - - private readonly int _expectedPlayerCount; - private readonly NetworkObject _playerPrefab; - private readonly HashSet _connectedPlayers = new(); - private bool _allPlayersNotified; - - public int ConnectedPlayerCount => _connectedPlayers.Count; - - public SurvivorFusionSession( - IFusionRunnerService runnerService, - IPublisher gameStartedPub, - IPublisher allPlayersDisconnectedPub, - int expectedPlayerCount, - NetworkObject playerPrefab) - { - _runnerService = runnerService; - _gameStartedPub = gameStartedPub; - _allPlayersDisconnectedPub = allPlayersDisconnectedPub; - _expectedPlayerCount = expectedPlayerCount; - _playerPrefab = playerPrefab; - } - - public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) - { - _connectedPlayers.Add(player); - Debug.Log($"[SurvivorFusionSession] Player joined: {player} ({ConnectedPlayerCount}/{_expectedPlayerCount})"); - - // Spawn はステージシーンロード後に SpawnConnectedPlayers() で行う - - if (runner.IsServer && ConnectedPlayerCount >= _expectedPlayerCount && !_allPlayersNotified) - { - _allPlayersNotified = true; - NotifyAllPlayersReadyAsync().Forget(); - } - } - - /// - /// 接続中の全プレイヤーを指定位置にスポーンする。 - /// ステージシーンロード後に SurvivorNetworkStageScene から呼ばれる。 - /// - public void SpawnConnectedPlayers(NetworkRunner runner, Vector3 position, Quaternion rotation) - { - if (_playerPrefab == null) - { - Debug.LogError("[SurvivorFusionSession] Player prefab is null!"); - return; - } - - foreach (var player in _connectedPlayers) - { - if (runner.GetPlayerObject(player) != null) continue; - - var playerObj = runner.Spawn(_playerPrefab, position, rotation, inputAuthority: player); - runner.SetPlayerObject(player, playerObj); - Debug.Log($"[SurvivorFusionSession] Spawned player {player} at {position}"); - } - } - - public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) - { - // 切断時の Pause クリーンアップ (LevelUp 中切断で全体停止が永続化するのを防ぐ) - if (_runnerService != null && _runnerService.TryGet(out var gs)) - { - gs.OnPlayerDisconnectedCleanup(player); - } - - // プレイヤー NetworkObject をデスポーン - var playerObj = runner.GetPlayerObject(player); - if (playerObj != null) - { - runner.Despawn(playerObj); - } - - _connectedPlayers.Remove(player); - Debug.Log($"[SurvivorFusionSession] Player left: {player} ({ConnectedPlayerCount} remaining)"); - - if (ConnectedPlayerCount <= 0 && _allPlayersNotified) - { - // リトライ時に再接続を受け入れるためリセット - _allPlayersNotified = false; - - Debug.Log("[SurvivorFusionSession] All players disconnected"); - _allPlayersDisconnectedPub?.Publish(new SurvivorSignals.Session.AllPlayersDisconnected()); - } - } - - /// - /// AllPlayersReady を1フレーム遅延で発火する。 - /// SurvivorStageConnectScene の WaitForAllPlayersReadyAsync() が購読登録を完了した後に届くようにする。 - /// - private async UniTaskVoid NotifyAllPlayersReadyAsync() - { - await UniTask.NextFrame(); - - // ゲーム状態にプレイヤー数を設定(全滅判定用) - if (_runnerService.TryGet(out var gs)) - { - gs.SetTotalPlayerCount(_expectedPlayerCount); - - // RPC で全クライアントに通知(MPPM 等では別 DI コンテナのため MessagePipe だけでは届かない) - gs.RpcNotifyAllPlayersReady(); - } - - // サーバーローカルの GameStarted シグナル - _gameStartedPub?.Publish(new SurvivorSignals.Session.GameStarted(Time.time)); - - Debug.Log("[SurvivorFusionSession] AllPlayersReady (RPC) + GameStarted published"); - } - } -} diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs.meta b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs.meta deleted file mode 100644 index 8e6706bf9..000000000 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionSession.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 9bd5c162153ea7a4bbbd1adf678e5da7 \ No newline at end of file diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs index 265967dd9..aed77de67 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs @@ -5,9 +5,7 @@ using Game.Shared.Environment; using Game.Shared.Network.Fusion; using Game.Shared.Services; -using Game.Shared.Signals.Survivor; using Game.Shared.Unity.Server; -using MessagePipe; using UnityEngine; using VContainer; @@ -24,15 +22,12 @@ public class SurvivorNetworkStageConnector : ISurvivorNetworkStageConnector [Inject] private readonly IFusionRunnerService _runnerService; [Inject] private readonly IUnityServerSessionConfig _sessionConfig; [Inject] private readonly IUnityServerAuthProviderFactory _authProviderFactory; - [Inject] private readonly IPublisher _gameStartedPub; - [Inject] private readonly IPublisher _allPlayersDisconnectedPub; private const string GameStateAddress = "SurvivorFusionGameState"; private const string PlayerAddress = "SurvivorFusionPlayer"; private const string EnemyBatchSyncAddress = "SurvivorFusionEnemyBatchSync"; private SurvivorFusionRunner _runner; - private SurvivorFusionSession _session; private bool _isConnecting; // Addressables で読み込んだプレハブ(解放用に保持) @@ -50,11 +45,11 @@ public async UniTask StartHostAsync(int stageId) try { var sessionName = _sessionConfig.SessionName; - var playerCount = _sessionConfig.PlayerCount; await PreloadPrefabsAsync(); EnsureRunner(); - CreateSession(playerCount); + _playerPrefabAsset.TryGetComponent(out var playerPrefab); + _runner.Configure(playerPrefab); var config = new FusionConnectionConfig { @@ -147,11 +142,12 @@ public async UniTask StartServerAsync(int stageId) try { var sessionName = _sessionConfig.SessionName; - var playerCount = _sessionConfig.PlayerCount; await PreloadPrefabsAsync(); EnsureRunner(); - CreateSession(playerCount); + + _playerPrefabAsset.TryGetComponent(out var playerPrefab); + _runner.Configure(playerPrefab); var serverPort = _sessionConfig.ServerPort; @@ -202,7 +198,6 @@ public async UniTask DisconnectAsync() } } - _session = null; ReleasePrefabs(); _runnerService.Clear(); Debug.Log("[SurvivorFusionStageConnector] Disconnected"); @@ -255,8 +250,8 @@ private void EnsureRunner() var go = new GameObject("[FusionRunner]"); _runner = go.AddComponent(); _runner.Initialize(); + _resolver.Inject(_runner); _runner.Resolver = _resolver; - _runner.RunnerService = _runnerService; _runner.OnShutdownCallback = OnRunnerShutdown; // 認証プロバイダを設定(Client 側は NullFactory が null を返すため認証スキップ) @@ -265,22 +260,6 @@ private void EnsureRunner() _runner.AuthProvider = authProvider; } - private void CreateSession(int expectedPlayerCount) - { - NetworkObject playerPrefab = null; - if (_playerPrefabAsset != null) - playerPrefab = _playerPrefabAsset.GetComponent(); - - _session = new SurvivorFusionSession( - _runnerService, - _gameStartedPub, - _allPlayersDisconnectedPub, - expectedPlayerCount, - playerPrefab); - - _runner.Session = _session; - } - private void SpawnGameState(NetworkRunner runner) { if (_gameStatePrefabAsset == null) return; @@ -307,7 +286,6 @@ private void OnRunnerShutdown(ShutdownReason reason) { _runnerService.Clear(); _runnerService.RaiseClientDisconnected(); - _session = null; } } } From 60b0a68a348aafdb24ef6d4a652b3d7fa69a12d9 Mon Sep 17 00:00:00 2001 From: "Rei.K" Date: Mon, 11 May 2026 05:30:56 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E3=82=B2=E3=83=BC=E3=83=A0=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3=E9=96=8B=E5=A7=8B=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=AE=E7=B5=B1=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/Tests/Shared/LobbyClientTests.cs | 2 +- .../Tests/Shared/MatchmakingClientTests.cs | 2 +- .../Survivor/Scenes/SurvivorLobbyRoomScene.cs | 8 ++--- .../MVP/Survivor/Scenes/SurvivorLobbyScene.cs | 16 +++++----- .../Survivor/IUnityServerSessionConfig.cs | 10 ++----- .../Survivor/UnityServerSessionConfig.cs | 22 ++++---------- .../Shared/Realtime/Client/ILobbyClient.cs | 2 +- .../Realtime/Client/IMatchmakingClient.cs | 3 +- .../Shared/Realtime/Client/LobbyClient.cs | 4 +-- .../Realtime/Client/MatchmakingClient.cs | 8 ++--- src/Game.Realtime/Hubs/LobbyHub.cs | 6 ++-- src/Game.Realtime/Hubs/MatchmakingHub.cs | 7 +++-- .../Services/MatchmakingProcessor.cs | 14 +++++---- ...chStartInfo.cs => GameSessionStartInfo.cs} | 23 +++++++-------- .../Runtime/Shared/Realtime/Hubs/ILobbyHub.cs | 2 +- .../Shared/Realtime/Hubs/IMatchmakingHub.cs | 29 ++----------------- 16 files changed, 60 insertions(+), 98 deletions(-) rename src/Game.Shared/Runtime/Shared/Dto/Realtime/{MatchStartInfo.cs => GameSessionStartInfo.cs} (56%) diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/LobbyClientTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/LobbyClientTests.cs index cc1c1e7f2..85ea6a882 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/LobbyClientTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/LobbyClientTests.cs @@ -107,7 +107,7 @@ public void Events_CanBeSubscribedAndUnsubscribed() void OnPlayerLeft(string a, string b) => playerLeftCalled = true; void OnMessageReceived(string a, string b, string c) => messageReceivedCalled = true; void OnReadyChanged(string a, bool b) => readyChangedCalled = true; - void OnGameStarting(MatchStartInfo info) => gameStartingCalled = true; + void OnGameStarting(GameSessionStartInfo info) => gameStartingCalled = true; void OnLobbyClosed(string _) => lobbyClosedCalled = true; void OnDisconnected(string _) => disconnectedCalled = true; diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/MatchmakingClientTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/MatchmakingClientTests.cs index 3d8ff87f8..612e1646f 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/Shared/MatchmakingClientTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/Shared/MatchmakingClientTests.cs @@ -96,7 +96,7 @@ public void Events_CanBeSubscribedAndUnsubscribed() var cancelledCalled = false; var disconnectedCalled = false; - void OnMatchFound(Game.Library.Shared.Realtime.Hubs.MatchResult _) => matchFoundCalled = true; + void OnMatchFound(Game.Library.Shared.Dto.GameSessionStartInfo _) => matchFoundCalled = true; void OnQueueUpdated(int _) => queueUpdatedCalled = true; void OnCancelled(string _) => cancelledCalled = true; void OnDisconnected(string _) => disconnectedCalled = true; diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs index 4f19c462b..195a0ab23 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs @@ -126,7 +126,7 @@ private void HandlePlayerReadyChanged(string userId, bool isReady) SceneComponent.UpdatePlayerReady(userId, isReady); } - private void HandleGameStarting(MatchStartInfo info) + private void HandleGameStarting(GameSessionStartInfo info) { OnGameStarting(info).Forget(); } @@ -195,7 +195,7 @@ private async UniTaskVoid OnLeave() await _sceneService.TransitionAsync(); } - private async UniTaskVoid OnGameStarting(MatchStartInfo info) + private async UniTaskVoid OnGameStarting(GameSessionStartInfo info) { if (_isExitingLobby) return; _isExitingLobby = true; @@ -219,9 +219,9 @@ private async UniTaskVoid OnGameStarting(MatchStartInfo info) _sessionConfig.Configure(source, info, info.PlayerCount); - // セッション開始(stageId はロビー情報から取得) + // セッション開始 var playerId = _saveService.Data.SelectedPlayerId; - _saveService.StartSession(_stageId, playerId); + _saveService.StartSession(info.StageId, playerId); await _saveService.SaveIfDirtyAsync(); Debug.Log($"[SurvivorLobbyRoomScene] Transitioning to StageConnectScene (topology={info.Topology}, source={source}, session={info.SessionName}, region={info.PhotonRegion})"); diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs index 1afa86b4b..ccdbbcbf3 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs @@ -1,7 +1,6 @@ using System; using Cysharp.Threading.Tasks; using Game.Library.Shared.Dto; -using Game.Library.Shared.Realtime.Hubs; using Game.MVP.Core.Scenes; using Game.MVP.Survivor.SaveData; using Game.Shared.Network.Survivor; @@ -85,9 +84,9 @@ private void UnsubscribeMatchmakingEvents() _matchmakingClient.OnMatchmakingCancelled -= HandleMatchmakingCancelled; } - private void HandleMatchFound(MatchResult result) + private void HandleMatchFound(GameSessionStartInfo info) { - OnMatchFound(result).Forget(); + OnMatchFound(info).Forget(); } private void HandleQueueStatusUpdated(int count) @@ -215,18 +214,17 @@ private async UniTaskVoid OnQuickMatch(int stageId, int matchSize) } } - private async UniTaskVoid OnMatchFound(MatchResult result) + private async UniTaskVoid OnMatchFound(GameSessionStartInfo info) { - Debug.Log($"[SurvivorLobbyScene] Match found: {result.MatchId}"); - int playerCount = result.PlayerIds?.Length > 0 ? result.PlayerIds.Length : 1; - _sessionConfig.Configure(ConnectionSource.Matchmaking, result, playerCount); + Debug.Log($"[SurvivorLobbyScene] Match found: {info.SessionName}"); + _sessionConfig.Configure(ConnectionSource.Matchmaking, info, info.PlayerCount); SceneComponent.SetInteractables(false); try { - // セッション開始(stageId は MatchResult から取得) + // セッション開始(stageId はサーバー送信の GameSessionStartInfo から取得) var playerId = _saveService.Data.SelectedPlayerId; - _saveService.StartSession(result.StageId, playerId); + _saveService.StartSession(info.StageId, playerId); await _saveService.SaveIfDirtyAsync(); await _matchmakingClient.DisconnectAsync(); diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs index 0e67481de..c10e04a7c 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs @@ -1,5 +1,4 @@ using Game.Library.Shared.Dto; -using Game.Library.Shared.Realtime.Hubs; namespace Game.Shared.Network.Survivor { @@ -51,14 +50,11 @@ public interface IUnityServerSessionConfig /// 全パラメータを初期化する。未指定はデフォルト値で補完。 void Configure(ConnectionSource source, string address = null, ushort? port = null, string sessionName = null, string sessionToken = null, int? playerCount = null); - /// マッチメイキング結果から全パラメータを一括設定する。 - void Configure(ConnectionSource source, MatchResult result, int playerCount); - /// - /// MatchStartInfo (DS / P2P 両用) から全パラメータを一括設定する。 - /// LobbyHub.OnGameStarting 経由のゲーム開始フローで使用する。 + /// GameSessionStartInfo (DS / P2P 両用) から全パラメータを一括設定する。 + /// LobbyHub.OnGameStarting および MatchmakingHub.OnMatchFound 経由のゲーム開始フローで使用する。 /// - void Configure(ConnectionSource source, MatchStartInfo info, int playerCount); + void Configure(ConnectionSource source, GameSessionStartInfo info, int playerCount); /// /// 指定パラメータのみ上書きする。null は既存値を維持。 diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs index 744dafbae..9e8a4d4bf 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs @@ -1,5 +1,4 @@ using Game.Library.Shared.Dto; -using Game.Library.Shared.Realtime.Hubs; namespace Game.Shared.Network.Survivor { @@ -112,22 +111,13 @@ public void Configure(ConnectionSource source, string address = null, ushort? po } /// - /// マッチメイキング結果から全パラメータを一括設定する。 - /// - /// 接続元の種別。 - /// マッチメイキングサーバーから受け取った 。 - /// ゲーム開始時点の実接続プレイヤー数 (全滅判定の分母)。 - public void Configure(ConnectionSource source, MatchResult result, int playerCount) - => Configure(source, result.ServerAddress, (ushort)result.ServerPort, result.MatchId, result.SessionToken, playerCount); - - /// - /// MatchStartInfo (DS / P2P 両用) から全パラメータを一括設定する。 - /// LobbyHub.OnGameStarting 経由のゲーム開始フローで使用する。 + /// GameSessionStartInfo (DS / P2P 両用) から全パラメータを一括設定する。 + /// LobbyHub.OnGameStarting および MatchmakingHub.OnMatchFound 経由のゲーム開始フローで使用する。 /// /// 接続元の種別 (P2PHost / P2PClient / Matchmaking 等、呼出側で host/client 判定して指定)。 - /// サーバーから受信した 。 - /// ゲーム開始時点の実接続プレイヤー数 (全滅判定の分母)。 から取得すること。 - public void Configure(ConnectionSource source, MatchStartInfo info, int playerCount) + /// サーバーから受信した 。 + /// ゲーム開始時点の実接続プレイヤー数 (全滅判定の分母)。 から取得すること。 + public void Configure(ConnectionSource source, GameSessionStartInfo info, int playerCount) { ConnectionSource = source; SessionName = info.SessionName; @@ -155,7 +145,7 @@ public void Configure(ConnectionSource source, MatchStartInfo info, int playerCo /// /// 指定パラメータのみ上書きする。null は既存値を維持。 /// Dedicated Server のセッション開始時に sessionName のみ更新する用途で使用する。 - /// NOTE: PhotonRegion は本メソッドでは更新しない (Configure(source, MatchStartInfo, playerCount) overload 経由でのみ更新)。 + /// NOTE: PhotonRegion は本メソッドでは更新しない (Configure(source, GameSessionStartInfo, playerCount) overload 経由でのみ更新)。 /// /// 接続先アドレス。null で既存値を維持。 /// 接続先ポート番号。null で既存値を維持。 diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/ILobbyClient.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/ILobbyClient.cs index e5853f407..1e0095a32 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/ILobbyClient.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/ILobbyClient.cs @@ -109,7 +109,7 @@ public interface ILobbyClient : IDisposable /// /// ゲーム開始イベント (DS / P2P 統一、Topology で受信側が分岐) /// - event Action OnGameStarting; + event Action OnGameStarting; /// /// ロビー閉鎖イベント (reason) diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/IMatchmakingClient.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/IMatchmakingClient.cs index f9bc0fb15..a9c5c544f 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/IMatchmakingClient.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/IMatchmakingClient.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using Game.Library.Shared.Dto; -using Game.Library.Shared.Realtime.Hubs; namespace Game.Shared.Realtime.Client { @@ -38,7 +37,7 @@ public interface IMatchmakingClient : IDisposable /// /// マッチ成立イベント /// - event Action OnMatchFound; + event Action OnMatchFound; /// /// キュー人数更新イベント diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/LobbyClient.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/LobbyClient.cs index 8d48b981a..7e1a87215 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/LobbyClient.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/LobbyClient.cs @@ -30,7 +30,7 @@ public class LobbyClient : ILobbyClient, ILobbyHubReceiver public event Action OnPlayerLeft; public event Action OnMessageReceived; public event Action OnPlayerReadyChanged; - public event Action OnGameStarting; + public event Action OnGameStarting; public event Action OnLobbyClosed; public event Action OnStageChanged; public event Action OnDisconnected; @@ -280,7 +280,7 @@ void ILobbyHubReceiver.OnPlayerReadyChanged(string userId, bool isReady) OnPlayerReadyChanged?.Invoke(userId, isReady); } - void ILobbyHubReceiver.OnGameStarting(MatchStartInfo info) + void ILobbyHubReceiver.OnGameStarting(GameSessionStartInfo info) { Debug.Log($"[LobbyClient] Game starting: topology={info.Topology}, session={info.SessionName}"); OnGameStarting?.Invoke(info); diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/MatchmakingClient.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/MatchmakingClient.cs index 8387c14fa..a9ebd76e9 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/MatchmakingClient.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Realtime/Client/MatchmakingClient.cs @@ -26,7 +26,7 @@ public class MatchmakingClient : IMatchmakingClient, IMatchmakingHubReceiver public bool IsSearching { get; private set; } - public event Action OnMatchFound; + public event Action OnMatchFound; public event Action OnQueueStatusUpdated; public event Action OnMatchmakingCancelled; public event Action OnDisconnected; @@ -142,11 +142,11 @@ void IMatchmakingHubReceiver.OnMatchmakingStarted(int estimatedWaitSeconds) Debug.Log($"[MatchmakingClient] Matchmaking started. Estimated wait: {estimatedWaitSeconds}s"); } - void IMatchmakingHubReceiver.OnMatchFound(MatchResult result) + void IMatchmakingHubReceiver.OnMatchFound(GameSessionStartInfo info) { IsSearching = false; - Debug.Log($"[MatchmakingClient] Match found: {result.MatchId}"); - OnMatchFound?.Invoke(result); + Debug.Log($"[MatchmakingClient] Match found: {info.SessionName}"); + OnMatchFound?.Invoke(info); } void IMatchmakingHubReceiver.OnMatchmakingCancelled(string reason) diff --git a/src/Game.Realtime/Hubs/LobbyHub.cs b/src/Game.Realtime/Hubs/LobbyHub.cs index d1d4e47a1..b1d739064 100644 --- a/src/Game.Realtime/Hubs/LobbyHub.cs +++ b/src/Game.Realtime/Hubs/LobbyHub.cs @@ -252,7 +252,7 @@ private async Task StartDsGameAsync(LobbyPlayerInfo[] players, LobbyInfo lobby, if (lobbyMap != null && lobbyMap.TryGetValue(player.UserId, out var connId)) { - var info = new MatchStartInfo + var info = new GameSessionStartInfo { Topology = NetworkTopology.DedicatedServer, SessionName = matchId, @@ -260,6 +260,7 @@ private async Task StartDsGameAsync(LobbyPlayerInfo[] players, LobbyInfo lobby, ServerPort = _unityServerConfig.ServerPort, SessionToken = authResponse.Token, PlayerCount = players.Length, + StageId = stageId, HostUserId = lobby.HostUserId, }; _currentGroup!.Only(new[] { connId }).OnGameStarting(info); @@ -295,13 +296,14 @@ private async Task StartP2PGameAsync(LobbyPlayerInfo[] players, LobbyInfo lobby, var sessionName = $"p2p-{Guid.NewGuid():N}"; // 36 文字、Photon SessionName 制限 64 内 var photonRegion = "jp"; // 将来的に LobbyInfo.PhotonRegion フィールド追加 + UI 選択 - var info = new MatchStartInfo + var info = new GameSessionStartInfo { Topology = NetworkTopology.PeerToPeer, SessionName = sessionName, PhotonRegion = photonRegion, HostUserId = hostUserId, PlayerCount = players.Length, + StageId = lobby.StageId, }; // ① Host にだけ先に broadcast。 diff --git a/src/Game.Realtime/Hubs/MatchmakingHub.cs b/src/Game.Realtime/Hubs/MatchmakingHub.cs index e694beac0..28c25bf04 100644 --- a/src/Game.Realtime/Hubs/MatchmakingHub.cs +++ b/src/Game.Realtime/Hubs/MatchmakingHub.cs @@ -1,3 +1,4 @@ +using Game.Library.Shared.Dto; using Game.Library.Shared.Realtime.Hubs; using Game.Realtime.Validation; using Game.Server.Shared.Extensions; @@ -47,12 +48,12 @@ public async ValueTask SubscribeAsync(string gameMode) var channel = RedisChannel.Literal($"matchmaking:notify:{_userId}"); await _subscriber.SubscribeAsync(channel, (_, message) => { - var result = JsonHelper.TryDeserialize(message.ToString(), _logger, $"match result for user {_userId}"); - if (result != null) + var info = JsonHelper.TryDeserialize(message.ToString(), _logger, $"match start info for user {_userId}"); + if (info != null) { try { - Client.OnMatchFound(result); + Client.OnMatchFound(info); } catch (Exception ex) { diff --git a/src/Game.Realtime/Services/MatchmakingProcessor.cs b/src/Game.Realtime/Services/MatchmakingProcessor.cs index 2502205de..febfe8382 100644 --- a/src/Game.Realtime/Services/MatchmakingProcessor.cs +++ b/src/Game.Realtime/Services/MatchmakingProcessor.cs @@ -1,3 +1,4 @@ +using Game.Library.Shared.Dto; using Game.Library.Shared.Realtime.Hubs; using Game.Server.Shared.Extensions; using Microsoft.Extensions.Options; @@ -290,24 +291,27 @@ private async Task CreateMatchAsync(string gameMode, string[] playerIds, int sta await Task.WhenAll([leaderAuthTask, .. followerTasks]); - // 全トークンが揃ったら MatchResult を配信 + // 全トークンが揃ったら GameSessionStartInfo を配信 await Task.WhenAll(playerIds.Select(async (playerId, index) => { var authResponse = index == 0 ? await leaderAuthTask : await followerTasks[index - 1]; - var matchResult = new MatchResult + var info = new GameSessionStartInfo { - MatchId = matchId, - PlayerIds = playerIds, + Topology = NetworkTopology.DedicatedServer, + SessionName = matchId, ServerAddress = _unityServerConfig.ServerAddress, ServerPort = _unityServerConfig.ServerPort, SessionToken = authResponse.Token, + PlayerCount = playerIds.Length, StageId = stageId, + // 先頭プレイヤーを暫定 Host として populate(現状ホスト概念なし、将来の P2P Quick Match 対応の拡張余地) + HostUserId = playerIds[0], }; - var json = JsonHelper.Serialize(matchResult); + var json = JsonHelper.Serialize(info); var channel = RedisChannel.Literal($"matchmaking:notify:{playerId}"); await subscriber.PublishAsync(channel, json); diff --git a/src/Game.Shared/Runtime/Shared/Dto/Realtime/MatchStartInfo.cs b/src/Game.Shared/Runtime/Shared/Dto/Realtime/GameSessionStartInfo.cs similarity index 56% rename from src/Game.Shared/Runtime/Shared/Dto/Realtime/MatchStartInfo.cs rename to src/Game.Shared/Runtime/Shared/Dto/Realtime/GameSessionStartInfo.cs index c2730e96b..d60d7fa12 100644 --- a/src/Game.Shared/Runtime/Shared/Dto/Realtime/MatchStartInfo.cs +++ b/src/Game.Shared/Runtime/Shared/Dto/Realtime/GameSessionStartInfo.cs @@ -3,39 +3,32 @@ namespace Game.Library.Shared.Dto { /// - /// LobbyHub.OnGameStarting で server から client に送信されるゲーム開始情報。 + /// LobbyHub.OnGameStarting / MatchmakingHub.OnMatchFound で server から client に送信されるゲームセッション開始情報。 /// DS / P2P 両モード兼用 — で実際に使用するフィールドが決まる。 - /// - /// NOTE: 既存 (Quick Match 用) とはセマンティクス分離のため別 DTO。 - /// Quick Match 経路を将来統合する場合は MatchResult を MatchStartInfo に置換可能。 /// [MessagePackObject] - public record MatchStartInfo + public record GameSessionStartInfo { /// ネットワークトポロジ。受信側はこれで分岐する。 [Key(0)] public NetworkTopology Topology { get; init; } - /// セッション識別子。DS: matchId、P2P: Photon SessionName。 + /// セッション識別子 [Key(1)] public string SessionName { get; init; } = string.Empty; - // --- DS 専用 (Topology == Dedicated 時に使用、P2P では null/0) --- - - /// DS サーバーアドレス (Topology == Dedicated 時に使用)。 + /// サーバーアドレス [Key(2)] public string? ServerAddress { get; init; } - /// DS サーバーポート (Topology == Dedicated 時に使用)。 + /// サーバーポート [Key(3)] public int ServerPort { get; init; } - /// DS セッショントークン (Topology == Dedicated 時に使用)。 + /// セッショントークン [Key(4)] public string? SessionToken { get; init; } - // --- P2P 専用 (Topology == PeerToPeer 時に使用、DS では null) --- - /// Photon Cloud リージョン [Key(5)] public string? PhotonRegion { get; init; } @@ -50,5 +43,9 @@ public record MatchStartInfo /// [Key(7)] public int PlayerCount { get; init; } + + /// ステージ ID。Quick Match / Lobby 両経路でゲーム開始ステージを示す。 + [Key(8)] + public int StageId { get; init; } } } diff --git a/src/Game.Shared/Runtime/Shared/Realtime/Hubs/ILobbyHub.cs b/src/Game.Shared/Runtime/Shared/Realtime/Hubs/ILobbyHub.cs index 1e40af041..62398d2ed 100644 --- a/src/Game.Shared/Runtime/Shared/Realtime/Hubs/ILobbyHub.cs +++ b/src/Game.Shared/Runtime/Shared/Realtime/Hubs/ILobbyHub.cs @@ -37,7 +37,7 @@ public interface ILobbyHubReceiver /// /// ゲーム開始通知。Topology に応じて DS フィールドまたは P2P フィールドが populate される。 /// - void OnGameStarting(MatchStartInfo info); + void OnGameStarting(GameSessionStartInfo info); /// /// ステージ変更通知 diff --git a/src/Game.Shared/Runtime/Shared/Realtime/Hubs/IMatchmakingHub.cs b/src/Game.Shared/Runtime/Shared/Realtime/Hubs/IMatchmakingHub.cs index f96754a01..21104e96f 100644 --- a/src/Game.Shared/Runtime/Shared/Realtime/Hubs/IMatchmakingHub.cs +++ b/src/Game.Shared/Runtime/Shared/Realtime/Hubs/IMatchmakingHub.cs @@ -1,34 +1,9 @@ using System.Threading.Tasks; +using Game.Library.Shared.Dto; using MagicOnion; -using MessagePack; namespace Game.Library.Shared.Realtime.Hubs { - /// - /// マッチメイキング結果 - /// - [MessagePackObject] - public class MatchResult - { - [Key(0)] - public string MatchId { get; set; } = string.Empty; - - [Key(1)] - public string[] PlayerIds { get; set; } = System.Array.Empty(); - - [Key(2)] - public string ServerAddress { get; set; } = string.Empty; - - [Key(3)] - public int ServerPort { get; set; } - - [Key(4)] - public string SessionToken { get; set; } = string.Empty; - - [Key(5)] - public int StageId { get; set; } - } - /// /// マッチメイキングHub クライアント受信インターフェース /// @@ -42,7 +17,7 @@ public interface IMatchmakingHubReceiver /// /// マッチが成立した通知 /// - void OnMatchFound(MatchResult result); + void OnMatchFound(GameSessionStartInfo info); /// /// マッチメイキングがキャンセルされた通知 From 71f11bf4612f5fa38a817e94c68f32fec6cd48ae Mon Sep 17 00:00:00 2001 From: "Rei.K" Date: Mon, 11 May 2026 05:54:18 +0900 Subject: [PATCH 5/5] rename: GameSessionConfig --- .../Server/SurvivorServerGameLoopTests.cs | 6 ++--- .../MVP/Survivor/DI/SurvivorLifetimeScope.cs | 2 +- .../Survivor/Scenes/SurvivorGameStageScene.cs | 2 +- .../Survivor/Scenes/SurvivorLobbyRoomScene.cs | 8 +++--- .../MVP/Survivor/Scenes/SurvivorLobbyScene.cs | 4 +-- .../Scenes/SurvivorStageConnectScene.cs | 16 ++++++------ .../MVP/Survivor/Scenes/SurvivorStageScene.cs | 2 +- .../MVP/Survivor/Scenes/SurvivorTitleScene.cs | 2 +- .../Survivor/Server/SurvivorServerGameLoop.cs | 2 +- ...rSessionConfig.cs => GameSessionConfig.cs} | 26 +++++++++---------- ...nfig.cs.meta => GameSessionConfig.cs.meta} | 0 ...SessionConfig.cs => IGameSessionConfig.cs} | 8 +++--- ...fig.cs.meta => IGameSessionConfig.cs.meta} | 0 .../Survivor/SurvivorFusionGameState.cs | 2 +- .../Network/Survivor/SurvivorFusionRunner.cs | 2 +- .../Survivor/SurvivorNetworkStageConnector.cs | 6 ++--- .../Unity/Server/UnityServerBootstrap.cs | 6 ++--- 17 files changed, 47 insertions(+), 47 deletions(-) rename src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/{UnityServerSessionConfig.cs => GameSessionConfig.cs} (88%) rename src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/{UnityServerSessionConfig.cs.meta => GameSessionConfig.cs.meta} (100%) rename src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/{IUnityServerSessionConfig.cs => IGameSessionConfig.cs} (89%) rename src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/{IUnityServerSessionConfig.cs.meta => IGameSessionConfig.cs.meta} (100%) diff --git a/src/Game.Client/Assets/Programs/Editor/Tests/MVP/Survivor/Server/SurvivorServerGameLoopTests.cs b/src/Game.Client/Assets/Programs/Editor/Tests/MVP/Survivor/Server/SurvivorServerGameLoopTests.cs index 221ce84b9..807884ce1 100644 --- a/src/Game.Client/Assets/Programs/Editor/Tests/MVP/Survivor/Server/SurvivorServerGameLoopTests.cs +++ b/src/Game.Client/Assets/Programs/Editor/Tests/MVP/Survivor/Server/SurvivorServerGameLoopTests.cs @@ -41,7 +41,7 @@ public class SurvivorServerGameLoopTests private IMasterDataService _masterDataService; private IFusionRunnerService _runnerService; private ISurvivorNetworkStageConnector _networkConnector; - private IUnityServerSessionConfig _sessionConfig; + private IGameSessionConfig _sessionConfig; private IUnityServerHttpListener _listener; private IUnityServerRegistryApiClient _registry; private UnityServerBootstrap _bootstrap; @@ -60,7 +60,7 @@ public void SetUp() _masterDataService = Substitute.For(); _runnerService = Substitute.For(); _networkConnector = Substitute.For(); - _sessionConfig = Substitute.For(); + _sessionConfig = Substitute.For(); _listener = Substitute.For(); _registry = Substitute.For(); _bootstrap = CreateBootstrapMock(); @@ -442,7 +442,7 @@ private static UnityServerBootstrap CreateBootstrapMock() var configProvider = new UnityServerConfigProvider(); var listenerMock = Substitute.For(); var registryMock = Substitute.For(); - var sessionConfigMock = Substitute.For(); + var sessionConfigMock = Substitute.For(); var bootstrap = new UnityServerBootstrap(configProvider, listenerMock, registryMock, sessionConfigMock); diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/DI/SurvivorLifetimeScope.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/DI/SurvivorLifetimeScope.cs index dda1f2614..f2819cd9c 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/DI/SurvivorLifetimeScope.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/DI/SurvivorLifetimeScope.cs @@ -53,7 +53,7 @@ protected override void Configure(IContainerBuilder builder) builder.Register(Lifetime.Singleton).As(); builder.Register(Lifetime.Singleton).As(); builder.Register(Lifetime.Singleton).As(); - builder.Register(Lifetime.Singleton).As(); + builder.Register(Lifetime.Singleton).As(); if (UnityPlaymodeHelper.IsServer()) { diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorGameStageScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorGameStageScene.cs index 15b0fa158..48fa9e85f 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorGameStageScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorGameStageScene.cs @@ -51,7 +51,7 @@ public partial class SurvivorGameStageScene : GamePrefabScene _damageReceivedSub; [Inject] private readonly ISubscriber _playerDiedSub; diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs index 195a0ab23..b8659b045 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyRoomScene.cs @@ -19,7 +19,7 @@ public class SurvivorLobbyRoomScene : GamePrefabScene "SurvivorLobbyRoomScene"; @@ -205,16 +205,16 @@ private async UniTaskVoid OnGameStarting(GameSessionStartInfo info) SceneComponent.ShowNotification($"Game starting ({info.Topology})..."); // Topology に応じて ConnectionSource を決定 - ConnectionSource source; + GameConnectionSource source; if (info.Topology == NetworkTopology.PeerToPeer) { var myUserId = _authSessionService.UserId; var isHost = myUserId == info.HostUserId; - source = isHost ? ConnectionSource.P2PHost : ConnectionSource.P2PClient; + source = isHost ? GameConnectionSource.P2PHost : GameConnectionSource.P2PClient; } else { - source = ConnectionSource.Matchmaking; + source = GameConnectionSource.Matchmaking; } _sessionConfig.Configure(source, info, info.PlayerCount); diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs index ccdbbcbf3..a051529cd 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorLobbyScene.cs @@ -20,7 +20,7 @@ public class SurvivorLobbyScene : GamePrefabScene "SurvivorLobbyScene"; @@ -217,7 +217,7 @@ private async UniTaskVoid OnQuickMatch(int stageId, int matchSize) private async UniTaskVoid OnMatchFound(GameSessionStartInfo info) { Debug.Log($"[SurvivorLobbyScene] Match found: {info.SessionName}"); - _sessionConfig.Configure(ConnectionSource.Matchmaking, info, info.PlayerCount); + _sessionConfig.Configure(GameConnectionSource.Matchmaking, info, info.PlayerCount); SceneComponent.SetInteractables(false); try diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageConnectScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageConnectScene.cs index 2967a5eab..f11368b06 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageConnectScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageConnectScene.cs @@ -35,7 +35,7 @@ public class SurvivorStageConnectScene : GamePrefabScene _allPlayersReadySub; [Inject] private readonly IFusionRunnerService _runnerService; [Inject] private readonly IUnityServerApiService _unityServerApiService; - [Inject] private readonly IUnityServerSessionConfig _sessionConfig; + [Inject] private readonly IGameSessionConfig _sessionConfig; [Inject] private readonly IAuthSessionRefresher _authSessionRefresher; [Inject] private readonly ILobbyClient _lobbyClient; @@ -124,7 +124,7 @@ private async UniTaskVoid ConnectAndTransitionAsync() { // 本番 P2P Host (Lobby 経由で Configure 済) は MPPM tag より優先判定。 // P2PHost が Lobby 経由で確定しているケースでは MPPM tag を見ない。 - if (_sessionConfig.ConnectionSource == ConnectionSource.P2PHost) + if (_sessionConfig.ConnectionSource == GameConnectionSource.P2PHost) { Debug.Log("[SurvivorStageConnectScene] P2P Host mode"); SceneComponent.SetStatus("Starting P2P host..."); @@ -177,7 +177,7 @@ private async UniTaskVoid ConnectAndTransitionAsync() // P2P Host モードのみ Lobby Hub に「ホスト準備完了」を通知。 // Lobby Hub はこの通知を受けて他クライアントへ OnGameStarting を broadcast し、 // Photon セッション作成競合 (GameNotFound) を防ぐ。 - if (_sessionConfig.ConnectionSource == ConnectionSource.P2PHost) + if (_sessionConfig.ConnectionSource == GameConnectionSource.P2PHost) { Debug.Log("[SurvivorStageConnectScene] Notifying lobby hub: host is ready"); await _lobbyClient.NotifyHostReadyAsync(); @@ -198,7 +198,7 @@ private async UniTaskVoid ConnectAndTransitionAsync() // DS 経路 (Local/Remote/Matchmaking) → 既存 SurvivorStageScene 継続 var source = _sessionConfig.ConnectionSource; Debug.Log($"[DIAG-Phase3-Pre] starting transition, source={source}"); - if (source is ConnectionSource.P2PHost or ConnectionSource.P2PClient) + if (source is GameConnectionSource.P2PHost or GameConnectionSource.P2PClient) { Debug.Log($"[SurvivorStageConnectScene] Connection established (source={source}), transitioning to SurvivorGameStageScene"); await _sceneService.TransitionAsync(); @@ -243,7 +243,7 @@ private async UniTask PrepareClientConnectionAsync(int stageId) await _localServerOrchestrator.StartAsync(SceneComponent.destroyCancellationToken); var localTokenResult = await IssueTokenAsync(stageId); - _sessionConfig.Configure(ConnectionSource.Local, + _sessionConfig.Configure(GameConnectionSource.Local, port: _localServerOrchestrator.HeadlessServerPort, sessionName: localTokenResult.SessionName, sessionToken: localTokenResult.Token); @@ -260,7 +260,7 @@ private async UniTask PrepareClientConnectionAsync(int stageId) if (!string.IsNullOrEmpty(tokenResult?.ServerAddress) && tokenResult.ServerPort > 0) { // DS 割り当て済み: レスポンスに含まれる DS アドレスへ直接接続 - _sessionConfig.Configure(ConnectionSource.Remote, + _sessionConfig.Configure(GameConnectionSource.Remote, address: tokenResult.ServerAddress, port: (ushort)tokenResult.ServerPort, sessionName: tokenResult.SessionName, @@ -270,7 +270,7 @@ private async UniTask PrepareClientConnectionAsync(int stageId) else if (envConfig != null && !_sessionConfig.IsLocalAddress(envConfig.UnityServerAddress)) { // envConfig にリモートアドレスが設定されている場合のフォールバック(ローカル開発用) - _sessionConfig.Configure(ConnectionSource.Remote, + _sessionConfig.Configure(GameConnectionSource.Remote, address: envConfig.UnityServerAddress, port: envConfig.UnityServerPort, sessionName: tokenResult?.SessionName, @@ -280,7 +280,7 @@ private async UniTask PrepareClientConnectionAsync(int stageId) else { // ローカル接続(127.0.0.1) - _sessionConfig.Configure(ConnectionSource.Local, sessionName: tokenResult?.SessionName, sessionToken: tokenResult?.Token); + _sessionConfig.Configure(GameConnectionSource.Local, sessionName: tokenResult?.SessionName, sessionToken: tokenResult?.Token); Debug.Log($"[SurvivorStageConnectScene] ローカルサーバーへ接続 ({_sessionConfig.SessionName})..."); } } diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageScene.cs index 71b2b0a74..03228e97d 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorStageScene.cs @@ -42,7 +42,7 @@ public partial class SurvivorStageScene : GamePrefabScene _damageReceivedSub; [Inject] private readonly ISubscriber _playerDiedSub; diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorTitleScene.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorTitleScene.cs index fa0266322..be2cb3d3d 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorTitleScene.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Scenes/SurvivorTitleScene.cs @@ -26,7 +26,7 @@ public class SurvivorTitleScene : GamePrefabScene "SurvivorTitleScene"; diff --git a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Server/SurvivorServerGameLoop.cs b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Server/SurvivorServerGameLoop.cs index c896156c1..dc81d393b 100644 --- a/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Server/SurvivorServerGameLoop.cs +++ b/src/Game.Client/Assets/Programs/Runtime/MVP/Survivor/Server/SurvivorServerGameLoop.cs @@ -30,7 +30,7 @@ public class SurvivorServerGameLoop : IAsyncStartable [Inject] private readonly IMasterDataService _masterDataService; [Inject] private readonly IFusionRunnerService _runnerService; [Inject] private readonly ISurvivorNetworkStageConnector _networkConnector; - [Inject] private readonly IUnityServerSessionConfig _sessionConfig; + [Inject] private readonly IGameSessionConfig _sessionConfig; [Inject] private readonly IUnityServerHttpListener _listener; [Inject] private readonly IUnityServerRegistryApiClient _registry; [Inject] private readonly UnityServerBootstrap _bootstrap; diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/GameSessionConfig.cs similarity index 88% rename from src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs rename to src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/GameSessionConfig.cs index 9e8a4d4bf..4ae1209e9 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/GameSessionConfig.cs @@ -5,7 +5,7 @@ namespace Game.Shared.Network.Survivor /// /// ネットワーク接続の接続元を表す列挙型。 /// - public enum ConnectionSource + public enum GameConnectionSource { /// 未設定(初期値)。 None, @@ -30,10 +30,10 @@ public enum ConnectionSource } /// - /// の実装。 + /// の実装。 /// VContainer で Singleton 登録して使用する。 /// - public class UnityServerSessionConfig : IUnityServerSessionConfig + public class GameSessionConfig : IGameSessionConfig { /// SP ローカルセッションのデフォルト名。 private const string DefaultLocalSessionName = "sp-local"; @@ -48,7 +48,7 @@ public class UnityServerSessionConfig : IUnityServerSessionConfig private const ushort DefaultPort = 7777; /// 現在の接続元種別。 - public ConnectionSource ConnectionSource { get; private set; } + public GameConnectionSource ConnectionSource { get; private set; } /// 接続先サーバーアドレス。 public string ServerAddress { get; private set; } @@ -78,10 +78,10 @@ public class UnityServerSessionConfig : IUnityServerSessionConfig /// SurvivorStageConnectScene の Phase 2 判定で使用する。 /// P2PHost は Host モード起動 (= IsHostMode 経路) のためここには含めない。 /// - public bool IsClientConfigured => ConnectionSource is ConnectionSource.Local - or ConnectionSource.Remote - or ConnectionSource.Matchmaking - or ConnectionSource.P2PClient; + public bool IsClientConfigured => ConnectionSource is GameConnectionSource.Local + or GameConnectionSource.Remote + or GameConnectionSource.Matchmaking + or GameConnectionSource.P2PClient; /// /// Photon Cloud のリージョン識別子 (P2P 用、例: "jp", "us", "eu")。 @@ -99,12 +99,12 @@ or ConnectionSource.Matchmaking /// セッション名。null 時は 。 /// セッショントークン。null 時は空文字。 /// ゲーム開始時点の実接続プレイヤー数 (全滅判定の分母)。 - public void Configure(ConnectionSource source, string address = null, ushort? port = null, string sessionName = null, string sessionToken = null, int? playerCount = null) + public void Configure(GameConnectionSource source, string address = null, ushort? port = null, string sessionName = null, string sessionToken = null, int? playerCount = null) { ConnectionSource = source; ServerAddress = address ?? DefaultLocalAddress; ServerPort = port ?? DefaultPort; - SessionName = sessionName ?? (source is ConnectionSource.Remote ? DefaultRemoteSessionName : DefaultLocalSessionName); + SessionName = sessionName ?? (source is GameConnectionSource.Remote ? DefaultRemoteSessionName : DefaultLocalSessionName); SessionToken = sessionToken ?? string.Empty; PlayerCount = playerCount ?? 1; PhotonRegion = null; @@ -117,7 +117,7 @@ public void Configure(ConnectionSource source, string address = null, ushort? po /// 接続元の種別 (P2PHost / P2PClient / Matchmaking 等、呼出側で host/client 判定して指定)。 /// サーバーから受信した 。 /// ゲーム開始時点の実接続プレイヤー数 (全滅判定の分母)。 から取得すること。 - public void Configure(ConnectionSource source, GameSessionStartInfo info, int playerCount) + public void Configure(GameConnectionSource source, GameSessionStartInfo info, int playerCount) { ConnectionSource = source; SessionName = info.SessionName; @@ -170,7 +170,7 @@ public void UpdateConfigure(string address = null, ushort? port = null, string s /// public void Clear() { - ConnectionSource = ConnectionSource.None; + ConnectionSource = GameConnectionSource.None; ServerAddress = null; ServerPort = 0; SessionName = null; @@ -192,7 +192,7 @@ public bool IsHostUserId(string userId) public bool IsMultiPlayer() { - return ConnectionSource is ConnectionSource.Matchmaking or ConnectionSource.P2PHost or ConnectionSource.P2PClient + return ConnectionSource is GameConnectionSource.Matchmaking or GameConnectionSource.P2PHost or GameConnectionSource.P2PClient && PlayerCount > 1; } } diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs.meta b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/GameSessionConfig.cs.meta similarity index 100% rename from src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/UnityServerSessionConfig.cs.meta rename to src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/GameSessionConfig.cs.meta diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IGameSessionConfig.cs similarity index 89% rename from src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs rename to src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IGameSessionConfig.cs index c10e04a7c..31588827b 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IGameSessionConfig.cs @@ -8,10 +8,10 @@ namespace Game.Shared.Network.Survivor /// Configure(全パラメータ初期化)と UpdateConfigure(部分更新)に分離し、 /// ライフサイクルの異なるサーバーレベルパラメータとセッションレベルパラメータを明示的に管理する。 /// - public interface IUnityServerSessionConfig + public interface IGameSessionConfig { /// 接続ソース - ConnectionSource ConnectionSource { get; } + GameConnectionSource ConnectionSource { get; } /// 接続先サーバーアドレス。 string ServerAddress { get; } @@ -48,13 +48,13 @@ public interface IUnityServerSessionConfig string PhotonRegion { get; } /// 全パラメータを初期化する。未指定はデフォルト値で補完。 - void Configure(ConnectionSource source, string address = null, ushort? port = null, string sessionName = null, string sessionToken = null, int? playerCount = null); + void Configure(GameConnectionSource source, string address = null, ushort? port = null, string sessionName = null, string sessionToken = null, int? playerCount = null); /// /// GameSessionStartInfo (DS / P2P 両用) から全パラメータを一括設定する。 /// LobbyHub.OnGameStarting および MatchmakingHub.OnMatchFound 経由のゲーム開始フローで使用する。 /// - void Configure(ConnectionSource source, GameSessionStartInfo info, int playerCount); + void Configure(GameConnectionSource source, GameSessionStartInfo info, int playerCount); /// /// 指定パラメータのみ上書きする。null は既存値を維持。 diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs.meta b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IGameSessionConfig.cs.meta similarity index 100% rename from src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IUnityServerSessionConfig.cs.meta rename to src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/IGameSessionConfig.cs.meta diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionGameState.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionGameState.cs index 750561696..d6ab24901 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionGameState.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionGameState.cs @@ -17,7 +17,7 @@ namespace Game.Shared.Network.Survivor public class SurvivorFusionGameState : NetworkBehaviour { [Inject] private IFusionRunnerService _runnerService; - [Inject] private IUnityServerSessionConfig _sessionConfig; + [Inject] private IGameSessionConfig _sessionConfig; // --- MessagePipe Publishers --- // VContainer InjectGameObject で解決される。 diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs index 1c73ac708..b33fcbe19 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorFusionRunner.cs @@ -39,7 +39,7 @@ public class SurvivorFusionRunner : MonoBehaviour, INetworkRunnerCallbacks // --- VContainer フィールドインジェクション --- [Inject] private IPublisher _gameStartedPub; [Inject] private IPublisher _allPlayersDisconnectedPub; - [Inject] private IUnityServerSessionConfig _sessionConfig; + [Inject] private IGameSessionConfig _sessionConfig; [Inject] private IFusionRunnerService _runnerService; // --- セッション管理フィールド(Host/Server 時のみ使用) --- diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs index aed77de67..f8a350710 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Network/Survivor/SurvivorNetworkStageConnector.cs @@ -20,7 +20,7 @@ public class SurvivorNetworkStageConnector : ISurvivorNetworkStageConnector [Inject] private readonly IObjectResolver _resolver; [Inject] private readonly IAddressableAssetService _assetService; [Inject] private readonly IFusionRunnerService _runnerService; - [Inject] private readonly IUnityServerSessionConfig _sessionConfig; + [Inject] private readonly IGameSessionConfig _sessionConfig; [Inject] private readonly IUnityServerAuthProviderFactory _authProviderFactory; private const string GameStateAddress = "SurvivorFusionGameState"; @@ -77,7 +77,7 @@ public async UniTask StartHostAsync(int stageId) /// /// Client モードで Fusion セッションへ接続する。 - /// 接続パラメータ (SessionName / Address / Port / SessionToken) は IUnityServerSessionConfig から取得する。 + /// 接続パラメータ (SessionName / Address / Port / SessionToken) は IGameSessionConfig から取得する。 /// DS 経路 (Local/Remote/Matchmaking) と P2P 経路 (P2PClient) を ConnectionSource で内部分岐。 /// public async UniTask ConnectAsync(int stageId) @@ -89,7 +89,7 @@ public async UniTask ConnectAsync(int stageId) { var sessionName = _sessionConfig.SessionName; var source = _sessionConfig.ConnectionSource; - var isP2PClient = source == ConnectionSource.P2PClient; + var isP2PClient = source == GameConnectionSource.P2PClient; EnsureRunner(); diff --git a/src/Game.Client/Assets/Programs/Runtime/Shared/Unity/Server/UnityServerBootstrap.cs b/src/Game.Client/Assets/Programs/Runtime/Shared/Unity/Server/UnityServerBootstrap.cs index 727ac76d9..d750610de 100644 --- a/src/Game.Client/Assets/Programs/Runtime/Shared/Unity/Server/UnityServerBootstrap.cs +++ b/src/Game.Client/Assets/Programs/Runtime/Shared/Unity/Server/UnityServerBootstrap.cs @@ -27,7 +27,7 @@ public sealed class UnityServerBootstrap : IAsyncStartable, IDisposable private readonly UnityServerConfigProvider _configProvider; private readonly IUnityServerHttpListener _listener; private readonly IUnityServerRegistryApiClient _registry; - private readonly IUnityServerSessionConfig _sessionConfig; + private readonly IGameSessionConfig _sessionConfig; private CancellationTokenSource _heartbeatCts; private Task _heartbeatTask; @@ -47,7 +47,7 @@ public UnityServerBootstrap( UnityServerConfigProvider configProvider, IUnityServerHttpListener listener, IUnityServerRegistryApiClient registry, - IUnityServerSessionConfig sessionConfig) + IGameSessionConfig sessionConfig) { _configProvider = configProvider; _listener = listener; @@ -100,7 +100,7 @@ public async UniTask StartAsync(CancellationToken cancellation) _listener.Start(); // 4. Fusion ポート設定(SessionName / MaxPlayerCount はセッションリクエスト受信時に設定) - _sessionConfig.Configure(ConnectionSource.DedicatedServer, port: config.GamePort); + _sessionConfig.Configure(GameConnectionSource.DedicatedServer, port: config.GamePort); // 5. Application.quitting ハンドラー登録 Application.quitting += OnApplicationQuitting;