Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -60,7 +60,7 @@ public void SetUp()
_masterDataService = Substitute.For<IMasterDataService>();
_runnerService = Substitute.For<IFusionRunnerService>();
_networkConnector = Substitute.For<ISurvivorNetworkStageConnector>();
_sessionConfig = Substitute.For<IUnityServerSessionConfig>();
_sessionConfig = Substitute.For<IGameSessionConfig>();
_listener = Substitute.For<IUnityServerHttpListener>();
_registry = Substitute.For<IUnityServerRegistryApiClient>();
_bootstrap = CreateBootstrapMock();
Expand Down Expand Up @@ -442,7 +442,7 @@ private static UnityServerBootstrap CreateBootstrapMock()
var configProvider = new UnityServerConfigProvider();
var listenerMock = Substitute.For<IUnityServerHttpListener>();
var registryMock = Substitute.For<IUnityServerRegistryApiClient>();
var sessionConfigMock = Substitute.For<IUnityServerSessionConfig>();
var sessionConfigMock = Substitute.For<IGameSessionConfig>();

var bootstrap = new UnityServerBootstrap(configProvider, listenerMock, registryMock, sessionConfigMock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () =>
Expand Down Expand Up @@ -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 () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace Game.ScoreTimeAttack.Scenes
{
public class ScoreTimeAttackTotalResultSceneComponent : GameSceneComponent
{
private AudioService _audioService;
private AudioService AudioService => _audioService ??= GameServiceManager.Get<AudioService>();

private GameSceneService _sceneService;
private GameSceneService SceneService => _sceneService ??= GameServiceManager.Get<GameSceneService>();

Expand Down Expand Up @@ -104,4 +101,4 @@ public override UniTask Ready()
return UniTask.CompletedTask;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override void Configure(IContainerBuilder builder)
builder.Register<GameSceneService>(Lifetime.Singleton).As<IGameSceneService>();
builder.Register<MasterDataService>(Lifetime.Singleton).As<IMasterDataService>();
builder.Register<FusionRunnerService>(Lifetime.Singleton).As<IFusionRunnerService>();
builder.Register<UnityServerSessionConfig>(Lifetime.Singleton).As<IUnityServerSessionConfig>();
builder.Register<GameSessionConfig>(Lifetime.Singleton).As<IGameSessionConfig>();

if (UnityPlaymodeHelper.IsServer())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override async UniTask Startup()

// イベント購読
SceneComponent.OnCloseClicked
.Subscribe(_ => OnClose().Forget())
.Subscribe(_ => OnClose())
.AddTo(Disposables);

SceneComponent.OnLinkEmailClicked
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ private async UniTask RefreshStatusViewAsync()
}
}

private async UniTaskVoid OnClose()
private void OnClose()
{
SceneComponent.SetInteractables(false);
TrySetResult(Unit.Default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public partial class SurvivorGameStageScene : GamePrefabScene<SurvivorGameStageS
[Inject] private readonly ILockOnService _lockOnService;
[Inject] private readonly ISurvivorNetworkStageConnector _networkConnector;
[Inject] private readonly IFusionRunnerService _runnerService;
[Inject] private readonly IUnityServerSessionConfig _sessionConfig;
[Inject] private readonly IGameSessionConfig _sessionConfig;
[Inject] private readonly IAuthSessionService _authSessionService;
[Inject] private readonly ISubscriber<SurvivorSignals.Player.DamageReceived> _damageReceivedSub;
[Inject] private readonly ISubscriber<SurvivorSignals.Player.Died> _playerDiedSub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SurvivorLobbyRoomScene : GamePrefabScene<SurvivorLobbyRoomScene, Su
[Inject] private readonly ILobbyClient _lobbyClient;
[Inject] private readonly ISurvivorSaveService _saveService;
[Inject] private readonly IAuthSessionService _authSessionService;
[Inject] private readonly IUnityServerSessionConfig _sessionConfig;
[Inject] private readonly IGameSessionConfig _sessionConfig;

protected override string AssetPathOrAddress => "SurvivorLobbyRoomScene";

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -195,7 +195,7 @@ private async UniTaskVoid OnLeave()
await _sceneService.TransitionAsync<SurvivorLobbyScene>();
}

private async UniTaskVoid OnGameStarting(MatchStartInfo info)
private async UniTaskVoid OnGameStarting(GameSessionStartInfo info)
{
if (_isExitingLobby) return;
_isExitingLobby = true;
Expand All @@ -205,23 +205,23 @@ private async UniTaskVoid OnGameStarting(MatchStartInfo 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);

// セッション開始(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})");
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +20,7 @@ public class SurvivorLobbyScene : GamePrefabScene<SurvivorLobbyScene, SurvivorLo
[Inject] private readonly IAuthSessionService _authSessionService;
[Inject] private readonly IAuthSessionRefresher _authSessionRefresher;
[Inject] private readonly ISurvivorSaveService _saveService;
[Inject] private readonly IUnityServerSessionConfig _sessionConfig;
[Inject] private readonly IGameSessionConfig _sessionConfig;

protected override string AssetPathOrAddress => "SurvivorLobbyScene";

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(GameConnectionSource.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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SurvivorStageConnectScene : GamePrefabScene<SurvivorStageConnectSce
[Inject] private readonly ISubscriber<SurvivorSignals.Session.AllPlayersReady> _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;

Expand Down Expand Up @@ -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...");
Expand Down Expand Up @@ -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();
Expand All @@ -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<SurvivorGameStageScene>();
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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})...");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class SurvivorStageScene : GamePrefabScene<SurvivorStageScene, Su
[Inject] private readonly ILockOnService _lockOnService;
[Inject] private readonly ISurvivorNetworkStageConnector _networkConnector;
[Inject] private readonly IFusionRunnerService _runnerService;
[Inject] private readonly IUnityServerSessionConfig _sessionConfig;
[Inject] private readonly IGameSessionConfig _sessionConfig;
[Inject] private readonly IAuthSessionService _authSessionService;
[Inject] private readonly ISubscriber<SurvivorSignals.Player.DamageReceived> _damageReceivedSub;
[Inject] private readonly ISubscriber<SurvivorSignals.Player.Died> _playerDiedSub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SurvivorTitleScene : GamePrefabScene<SurvivorTitleScene, SurvivorTi
[Inject] private readonly IAuthSessionRefresher _authSessionRefresher;
[Inject] private readonly INetworkService _networkService;
[Inject] private readonly ILobbyClient _lobbyClient;
[Inject] private readonly IUnityServerSessionConfig _sessionConfig;
[Inject] private readonly IGameSessionConfig _sessionConfig;

protected override string AssetPathOrAddress => "SurvivorTitleScene";

Expand Down
Loading
Loading