클라이언트에게 시야 정보가 공유되지 않는 문제 수정

This commit is contained in:
2026-02-25 21:26:11 +09:00
parent 9a010524f2
commit 2f7eac05ce
2 changed files with 14 additions and 3 deletions

View File

@@ -365,6 +365,13 @@ namespace Northbound
ulong clientId = kvp.Key; ulong clientId = kvp.Key;
FogOfWarData fogData = kvp.Value; FogOfWarData fogData = kvp.Value;
// 해당 클라이언트가 여전히 연결되어 있는지 확인
if (NetworkManager.Singleton == null ||
!NetworkManager.Singleton.ConnectedClients.ContainsKey(clientId))
{
continue;
}
// 압축된 데이터로 전송 // 압축된 데이터로 전송
byte[] visibleData = fogData.GetVisibleData(); byte[] visibleData = fogData.GetVisibleData();
byte[] exploredData = fogData.GetExploredData(); byte[] exploredData = fogData.GetExploredData();

View File

@@ -9,10 +9,12 @@ namespace Northbound
public class PlayerVisionProvider : NetworkBehaviour, IVisionProvider public class PlayerVisionProvider : NetworkBehaviour, IVisionProvider
{ {
private PlayerStats _playerStats; private PlayerStats _playerStats;
private NetworkPlayerController _playerController;
public override void OnNetworkSpawn() public override void OnNetworkSpawn()
{ {
_playerStats = GetComponent<PlayerStats>(); _playerStats = GetComponent<PlayerStats>();
_playerController = GetComponent<NetworkPlayerController>();
if (IsServer) if (IsServer)
{ {
FogOfWarSystem.Instance?.RegisterVisionProvider(this); FogOfWarSystem.Instance?.RegisterVisionProvider(this);
@@ -27,7 +29,9 @@ namespace Northbound
} }
} }
public ulong GetOwnerId() => OwnerClientId; // NetworkPlayerController.OwnerPlayerId 사용 (실제 플레이어 ID)
// OwnerClientId는 서버 소유권이므로 잘못된 ID 반환
public ulong GetOwnerId() => _playerController?.OwnerPlayerId ?? OwnerClientId;
public float GetVisionRange() => _playerStats?.GetSight() ?? 10f; public float GetVisionRange() => _playerStats?.GetSight() ?? 10f;
public Transform GetTransform() => transform; public Transform GetTransform() => transform;
public bool IsActive() => IsSpawned; public bool IsActive() => IsSpawned;