클라이언트에서 밝혀지지 않은 곳의 적이 보이는 문제 수정
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Northbound
|
||||
private Color[] _colors;
|
||||
private MeshRenderer _meshRenderer;
|
||||
private float _updateTimer;
|
||||
private ulong _localClientId;
|
||||
private ulong _localPlayerId;
|
||||
private bool _isInitialized;
|
||||
|
||||
private void Start()
|
||||
@@ -49,14 +49,15 @@ namespace Northbound
|
||||
{
|
||||
if (_isInitialized) return;
|
||||
|
||||
_localClientId = NetworkManager.Singleton.LocalClientId;
|
||||
|
||||
var fogSystem = FogOfWarSystem.Instance;
|
||||
if (fogSystem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 로컬 플레이어의 실제 ID 가져오기 (없어도 텍스처는 생성)
|
||||
_localPlayerId = GetLocalPlayerId();
|
||||
|
||||
// 텍스처 생성 (Bilinear filtering for smooth edges)
|
||||
_fogTexture = new Texture2D(fogSystem.gridWidth, fogSystem.gridHeight)
|
||||
{
|
||||
@@ -105,11 +106,16 @@ namespace Northbound
|
||||
if (!_isInitialized && NetworkManager.Singleton != null && NetworkManager.Singleton.IsClient)
|
||||
{
|
||||
Initialize();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isInitialized) return;
|
||||
|
||||
// 로컬 플레이어 ID가 아직 없으면 다시 시도
|
||||
if (_localPlayerId == ulong.MaxValue)
|
||||
{
|
||||
_localPlayerId = GetLocalPlayerId();
|
||||
}
|
||||
|
||||
_updateTimer += Time.deltaTime;
|
||||
if (_updateTimer >= updateInterval)
|
||||
{
|
||||
@@ -135,7 +141,12 @@ namespace Northbound
|
||||
if (_meshRenderer != null)
|
||||
_meshRenderer.enabled = true;
|
||||
|
||||
var fogData = fogSystem.GetPlayerFogData(_localClientId);
|
||||
var fogData = fogSystem.GetPlayerFogData(_localPlayerId);
|
||||
if (fogData == null)
|
||||
{
|
||||
// fogData가 null이면 아직 서버에서 데이터를 받지 못함
|
||||
return;
|
||||
}
|
||||
|
||||
for (int y = 0; y < fogSystem.gridHeight; y++)
|
||||
{
|
||||
@@ -164,6 +175,26 @@ namespace Northbound
|
||||
_fogTexture.Apply();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 로컬 플레이어의 실제 ID 가져오기
|
||||
/// </summary>
|
||||
private ulong GetLocalPlayerId()
|
||||
{
|
||||
if (NetworkManager.Singleton == null) return ulong.MaxValue;
|
||||
|
||||
var localPlayer = NetworkManager.Singleton.SpawnManager.GetLocalPlayerObject();
|
||||
if (localPlayer != null)
|
||||
{
|
||||
var playerController = localPlayer.GetComponent<NetworkPlayerController>();
|
||||
if (playerController != null)
|
||||
{
|
||||
return playerController.OwnerPlayerId;
|
||||
}
|
||||
}
|
||||
|
||||
return ulong.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply box blur smoothing to create smooth circular vision edges
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user