using Unity.Netcode;
using UnityEngine;
namespace Northbound
{
///
/// 플레이어의 시야 제공 컴포넌트
///
public class PlayerVisionProvider : NetworkBehaviour, IVisionProvider
{
private PlayerStats _playerStats;
public override void OnNetworkSpawn()
{
_playerStats = GetComponent();
if (IsServer)
{
FogOfWarSystem.Instance?.RegisterVisionProvider(this);
}
}
public override void OnNetworkDespawn()
{
if (IsServer)
{
FogOfWarSystem.Instance?.UnregisterVisionProvider(this);
}
}
public ulong GetOwnerId() => OwnerClientId;
public float GetVisionRange() => _playerStats?.GetSight() ?? 10f;
public Transform GetTransform() => transform;
public bool IsActive() => IsSpawned;
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, GetVisionRange());
}
}
}