기존 시스템 재사용 프로토타입 보존
This commit is contained in:
@@ -9,6 +9,10 @@ using UnityEngine;
|
||||
[Header("Team Settings")]
|
||||
[Tooltip("포털의 팀 (Hostile 또는 Monster)")]
|
||||
[SerializeField] private TeamType portalTeam = TeamType.Hostile;
|
||||
[Header("Lifecycle")]
|
||||
[SerializeField] private bool spawnFromGlobalTimer = true;
|
||||
[SerializeField] private bool despawnWhenDestroyed = true;
|
||||
public event System.Action<ulong> OnPortalDestroyed;
|
||||
|
||||
[Header("Health Settings")]
|
||||
[Tooltip("최대 체력")]
|
||||
@@ -67,12 +71,18 @@ using UnityEngine;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalTimer.Instance.OnCycleStart += OnCycleStart;
|
||||
if (spawnFromGlobalTimer && GlobalTimer.Instance != null)
|
||||
{
|
||||
GlobalTimer.Instance.OnCycleStart += OnCycleStart;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
GlobalTimer.Instance.OnCycleStart -= OnCycleStart;
|
||||
if (spawnFromGlobalTimer && GlobalTimer.Instance != null)
|
||||
{
|
||||
GlobalTimer.Instance.OnCycleStart -= OnCycleStart;
|
||||
}
|
||||
|
||||
// 체력 변경 이벤트 정리 (나중에 추가할 경우 대비)
|
||||
|
||||
@@ -249,7 +259,7 @@ using UnityEngine;
|
||||
}
|
||||
}
|
||||
|
||||
private void DestroyPortal(ulong attackerId)
|
||||
private void DestroyPortal(ulong attackerId)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
|
||||
@@ -257,10 +267,40 @@ using UnityEngine;
|
||||
ShowDestroyEffectClientRpc();
|
||||
|
||||
// 몬스터 스폰 중지 (이벤트 구독 해제)
|
||||
GlobalTimer.Instance.OnCycleStart -= OnCycleStart;
|
||||
if (spawnFromGlobalTimer && GlobalTimer.Instance != null)
|
||||
{
|
||||
GlobalTimer.Instance.OnCycleStart -= OnCycleStart;
|
||||
}
|
||||
|
||||
// 네트워크 오브젝트 파괴 (약간의 딜레이)
|
||||
Invoke(nameof(DespawnPortal), 1.0f);
|
||||
OnPortalDestroyed?.Invoke(attackerId);
|
||||
|
||||
if (despawnWhenDestroyed)
|
||||
{
|
||||
Invoke(nameof(DespawnPortal), 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public int CurrentHealth => _currentHealth.Value;
|
||||
public int MaxHealth => maxHealth;
|
||||
|
||||
public void ConfigureLifecycle(bool useGlobalTimerSpawning, bool shouldDespawn)
|
||||
{
|
||||
spawnFromGlobalTimer = useGlobalTimerSpawning;
|
||||
despawnWhenDestroyed = shouldDespawn;
|
||||
}
|
||||
|
||||
public void RestorePortal(TeamType team)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
_team.Value = team;
|
||||
_currentHealth.Value = maxHealth;
|
||||
}
|
||||
|
||||
public void SetDormant()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
_team.Value = TeamType.Neutral;
|
||||
_currentHealth.Value = 0;
|
||||
}
|
||||
|
||||
private void DespawnPortal()
|
||||
|
||||
Reference in New Issue
Block a user