42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace Northbound
|
|
{
|
|
/// <summary>
|
|
/// 플레이어의 시야 제공 컴포넌트
|
|
/// </summary>
|
|
public class PlayerVisionProvider : NetworkBehaviour, IVisionProvider
|
|
{
|
|
private PlayerStats _playerStats;
|
|
|
|
public override void OnNetworkSpawn()
|
|
{
|
|
_playerStats = GetComponent<PlayerStats>();
|
|
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());
|
|
}
|
|
}
|
|
}
|