건축모드 네트워크 환경 적용
This commit is contained in:
@@ -400,34 +400,35 @@ namespace Northbound
|
||||
GameObject foundationObj = Instantiate(foundationPrefab, snappedPosition + data.placementOffset, Quaternion.Euler(0, rotation * 90f, 0));
|
||||
NetworkObject netObj = foundationObj.GetComponent<NetworkObject>();
|
||||
|
||||
// Add FogOfWarVisibility component to hide foundations in unexplored areas
|
||||
if (foundationObj.GetComponent<FogOfWarVisibility>() == null)
|
||||
{
|
||||
var visibility = foundationObj.AddComponent<FogOfWarVisibility>();
|
||||
visibility.showInExploredAreas = true; // Foundations remain visible in explored areas
|
||||
visibility.updateInterval = 0.2f;
|
||||
}
|
||||
|
||||
if (netObj != null)
|
||||
{
|
||||
netObj.SpawnWithOwnership(requestingClientId);
|
||||
// 스폰 먼저 실행 (서버 소유권으로 스폰)
|
||||
// 소유자 정보는 _ownerId NetworkVariable에 별도로 저장하므로 NetworkObject 소유권은 서버 유지
|
||||
netObj.Spawn();
|
||||
|
||||
// 스폰 후에 초기화 (OnNetworkSpawn 이후에 호출되어 타이밍 문제 해결)
|
||||
BuildingFoundation foundation = foundationObj.GetComponent<BuildingFoundation>();
|
||||
if (foundation != null)
|
||||
if (foundation == null)
|
||||
{
|
||||
foundation.Initialize(data, gridPosition, rotation, requestingClientId, playerTeam);
|
||||
placedFoundations.Add(foundation); // 토대 목록에 추가
|
||||
Debug.Log($"<color=yellow>[BuildingManager] {data.buildingName} 토대 생성 (소유자: {requestingClientId}, 위치: {gridPosition})</color>");
|
||||
Destroy(foundationObj);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
// Initialize에서 NetworkVariable을 설정하고 데이터를 로드함
|
||||
foundation.Initialize(data, gridPosition, rotation, requestingClientId, playerTeam);
|
||||
|
||||
// Add FogOfWarVisibility component to hide foundations in unexplored areas
|
||||
if (foundationObj.GetComponent<FogOfWarVisibility>() == null)
|
||||
{
|
||||
Debug.LogError("<color=red>[BuildingManager] BuildingFoundation 컴포넌트가 없습니다!</color>");
|
||||
netObj.Despawn(true);
|
||||
var visibility = foundationObj.AddComponent<FogOfWarVisibility>();
|
||||
visibility.showInExploredAreas = true; // Foundations remain visible in explored areas
|
||||
visibility.updateInterval = 0.2f;
|
||||
}
|
||||
|
||||
placedFoundations.Add(foundation); // 토대 목록에 추가
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("<color=red>[BuildingManager] NetworkObject 컴포넌트가 없습니다!</color>");
|
||||
Destroy(foundationObj);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user