using Darkmatter.Core; using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; using VContainer; namespace Darkmatter.Presentation { public class EnemyMotor : MonoBehaviour, IEnemyPawn { [SerializeField] private NavMeshAgent enemyAI; [SerializeField] private Transform playerTransform; [SerializeField] private List patrolPoints = new List(); [Inject] private EnemyConfigSO enemyConfig; public Transform PlayerTarget => playerTransform; public NavMeshAgent EnemyAI => enemyAI; public List PatrolPoints => patrolPoints; public float Health { get; set; } = 100; public bool isDead { get; set; } = false; public event Action OnHealthDecreased; public void Die() { isDead = true; enemyAI.enabled = false; Invoke(nameof(Hide), 8f); } private void Hide() { this.gameObject.SetActive(false); } public Vector3 ReturnMyPos() { return this.transform.position; } public void SetDestination(Vector3 destination) { enemyAI.SetDestination(destination); } public void TakeDamage(float damage) { Health -= damage; OnHealthDecreased?.Invoke(Health); } private void OnDrawGizmos() { Gizmos.color = Color.yellow; Gizmos.DrawWireSphere(transform.position, enemyConfig.visionRange); Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, enemyConfig.attackRange); } } }