기본 배치 건물이 시야를 제공하도록 변경
This commit is contained in:
@@ -3,8 +3,16 @@ using UnityEngine;
|
||||
|
||||
namespace Northbound
|
||||
{
|
||||
public class WorkerSpawner : NetworkBehaviour, IInteractable
|
||||
public class WorkerSpawner : NetworkBehaviour, IInteractable, IVisionProvider, ITeamMember
|
||||
{
|
||||
[Header("Vision Settings")]
|
||||
[Tooltip("워커 홀이 제공하는 시야 범위")]
|
||||
public float visionRange = 10f;
|
||||
|
||||
[Header("Team")]
|
||||
[Tooltip("건물의 팀")]
|
||||
public TeamType initialTeam = TeamType.Player;
|
||||
|
||||
[Header("Spawner Settings")]
|
||||
public GameObject workerPrefab;
|
||||
public Transform spawnPoint;
|
||||
@@ -34,11 +42,24 @@ namespace Northbound
|
||||
{
|
||||
base.OnNetworkSpawn();
|
||||
_workerCount.OnValueChanged += OnWorkerCountChanged;
|
||||
|
||||
if (IsServer)
|
||||
{
|
||||
// 시야 제공자로 등록
|
||||
FogOfWarSystem.Instance?.RegisterVisionProvider(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
_workerCount.OnValueChanged -= OnWorkerCountChanged;
|
||||
|
||||
if (IsServer)
|
||||
{
|
||||
// 시야 제공자 등록 해제
|
||||
FogOfWarSystem.Instance?.UnregisterVisionProvider(this);
|
||||
}
|
||||
|
||||
base.OnNetworkDespawn();
|
||||
}
|
||||
|
||||
@@ -240,9 +261,37 @@ namespace Northbound
|
||||
Vector3 spawnCenter = spawnPoint != null ? spawnPoint.position : transform.position;
|
||||
Gizmos.DrawWireSphere(spawnCenter, spawnRadius);
|
||||
|
||||
UnityEditor.Handles.Label(spawnCenter + Vector3.up * 2f,
|
||||
UnityEditor.Handles.Label(spawnCenter + Vector3.up * 2f,
|
||||
$"Worker Spawner\nWorkers: {_workerCount.Value}/{maxWorkers}");
|
||||
#endif
|
||||
}
|
||||
|
||||
#region IVisionProvider Implementation
|
||||
|
||||
public ulong GetOwnerId() => 0; // 워커 홀은 모든 플레이어에게 시야 제공
|
||||
|
||||
public float GetVisionRange() => visionRange;
|
||||
|
||||
Transform IVisionProvider.GetTransform() => transform;
|
||||
|
||||
public bool IsActive() => IsSpawned;
|
||||
|
||||
TeamType IVisionProvider.GetTeam() => initialTeam;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITeamMember Implementation
|
||||
|
||||
public TeamType GetTeam() => initialTeam;
|
||||
|
||||
public bool IsDead() => false; // 워커 홀은 파괴되지 않음
|
||||
|
||||
public void SetTeam(TeamType team)
|
||||
{
|
||||
// 워커 홀의 팀은 변경할 수 없음
|
||||
Debug.LogWarning("[WorkerSpawner] 워커 홀의 팀은 변경할 수 없습니다.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user