기본 배치 건물이 시야를 제공하도록 변경

This commit is contained in:
2026-02-26 00:37:38 +09:00
parent a4eae438de
commit 600f35ae8f
10 changed files with 289 additions and 31 deletions

View File

@@ -10,6 +10,9 @@ namespace Northbound
public class FogOfWarVisibility : MonoBehaviour
{
[Header("Visibility Settings")]
[Tooltip("Always show this object regardless of fog state (for core, important structures)")]
public bool alwaysVisible = false;
[Tooltip("Show this object in explored areas (greyed out) or only when visible")]
public bool showInExploredAreas = false;
@@ -19,10 +22,13 @@ namespace Northbound
[Tooltip("Renderers to show/hide (auto-detected if empty)")]
public Renderer[] renderers;
[Header("Height-Based Distant Visibility")]
[Header("Extended Visibility")]
[Tooltip("Enable visibility from farther away based on object height")]
public bool enableDistantVisibility = true;
[Tooltip("Base visibility range (additional range beyond player vision)")]
public float baseVisibilityRange = 10f;
[Tooltip("Visibility range multiplier per unit of height (default: 2x vision per 1m height)")]
public float heightVisibilityMultiplier = 2.0f;
@@ -76,8 +82,17 @@ namespace Northbound
// CRITICAL: Start hidden and stay hidden until fog system confirms visibility
// Force initial hide - don't use SetVisible because _isVisible defaults to false
// which would cause early return
_isVisible = true; // Set to true first so SetVisible(false) actually runs
SetVisible(false);
// 단, alwaysVisible이면 항상 보임
if (alwaysVisible)
{
_isVisible = false;
SetVisible(true);
}
else
{
_isVisible = true; // Set to true first so SetVisible(false) actually runs
SetVisible(false);
}
}
/// <summary>
@@ -165,21 +180,50 @@ namespace Northbound
{
if (NetworkManager.Singleton == null) return ulong.MaxValue;
var localPlayer = NetworkManager.Singleton.SpawnManager.GetLocalPlayerObject();
if (localPlayer != null)
// 방법 1: SpawnManager에서 찾기
NetworkObject localPlayer = null;
if (NetworkManager.Singleton.SpawnManager != null)
{
var playerController = localPlayer.GetComponent<NetworkPlayerController>();
if (playerController != null)
localPlayer = NetworkManager.Singleton.SpawnManager.GetLocalPlayerObject();
}
// 방법 2: LocalClient에서 찾기
if (localPlayer == null && NetworkManager.Singleton.LocalClient != null)
{
localPlayer = NetworkManager.Singleton.LocalClient.PlayerObject;
}
// 방법 3: 직접 검색 (IsLocalPlayer인 플레이어 찾기)
if (localPlayer == null)
{
var allPlayers = FindObjectsByType<NetworkPlayerController>(FindObjectsSortMode.None);
foreach (var player in allPlayers)
{
return playerController.OwnerPlayerId;
if (player.IsLocalPlayer)
{
localPlayer = player.GetComponent<NetworkObject>();
break;
}
}
}
return ulong.MaxValue;
if (localPlayer == null) return ulong.MaxValue;
var playerController = localPlayer.GetComponent<NetworkPlayerController>();
if (playerController == null) return ulong.MaxValue;
return playerController.OwnerPlayerId;
}
private void UpdateVisibility()
{
// 항상 보이는 객체는 fog 체크 안함
if (alwaysVisible)
{
SetVisible(true);
return;
}
var fogSystem = FogOfWarSystem.Instance;
if (fogSystem == null)
{
@@ -268,11 +312,14 @@ namespace Northbound
// Calculate extended visibility range based on height
// Taller objects can be seen from farther away
// Formula: Base range + (height - minHeight) * multiplier
float extendedRange = (_objectHeight - minHeightForDistantVisibility) * heightVisibilityMultiplier;
float extendedRange = 0f;
if (_objectHeight >= minHeightForDistantVisibility)
{
extendedRange = (_objectHeight - minHeightForDistantVisibility) * heightVisibilityMultiplier;
}
// Get player's vision range (assume average vision provider has ~15 unit range)
float baseVisionRange = 15f; // You can make this configurable
float totalRange = baseVisionRange + extendedRange;
// Total range = player vision + base visibility + height bonus
float totalRange = baseVisibilityRange + extendedRange;
return distanceToPlayer <= totalRange;
}