전장의 안개 구현
This commit is contained in:
48
Assets/Scripts/BuildingVisionProvider.cs
Normal file
48
Assets/Scripts/BuildingVisionProvider.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Northbound
|
||||
{
|
||||
/// <summary>
|
||||
/// 건물의 시야 제공 컴포넌트
|
||||
/// </summary>
|
||||
public class BuildingVisionProvider : NetworkBehaviour, IVisionProvider
|
||||
{
|
||||
[Header("Vision Settings")]
|
||||
public float visionRange = 15f;
|
||||
|
||||
private Building _building;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_building = GetComponent<Building>();
|
||||
}
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
if (IsServer)
|
||||
{
|
||||
FogOfWarSystem.Instance?.RegisterVisionProvider(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
if (IsServer)
|
||||
{
|
||||
FogOfWarSystem.Instance?.UnregisterVisionProvider(this);
|
||||
}
|
||||
}
|
||||
|
||||
public ulong GetOwnerId() => OwnerClientId;
|
||||
public float GetVisionRange() => visionRange;
|
||||
public Transform GetTransform() => transform;
|
||||
public bool IsActive() => IsSpawned;
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.cyan;
|
||||
Gizmos.DrawWireSphere(transform.position, visionRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user