Добавил возможность отслеживать спавн и уничтожение врагов

This commit is contained in:
2026-05-13 00:46:42 +03:00
parent bf9099c8b5
commit 87a0218d3b
6 changed files with 92 additions and 8 deletions
+10 -1
View File
@@ -11,6 +11,7 @@ public class Enemy : MonoBehaviour
[SerializeField] private int _killReward = 10;
[SerializeField] private UnityEvent<float> _onHealthChanged;
[SerializeField] private UnityEvent<OnEnemyDeathEventArgs> _onDeath;
[SerializeField] private UnityEvent _onDestroyed;
private Queue<Vector3> _path;
private Vector3 _target;
@@ -26,7 +27,13 @@ public class Enemy : MonoBehaviour
add => _onDeath.AddListener(value);
remove => _onDeath.RemoveListener(value);
}
public event UnityAction OnDestroyed
{
add => _onDestroyed.AddListener(value);
remove => _onDestroyed.RemoveListener(value);
}
public SandPathBuildService PathBuildService
{
get => _pathService;
@@ -82,6 +89,8 @@ public class Enemy : MonoBehaviour
}
}
private void OnDestroy() => _onDestroyed?.Invoke();
public class OnEnemyDeathEventArgs
{
public int KillReward { get; set; }