using Northbound.Data; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; namespace Northbound { [RequireComponent(typeof(EnemyUnit))] [RequireComponent(typeof(EnemyAIController))] [RequireComponent(typeof(NavMeshAgent))] [RequireComponent(typeof(NetworkObject))] public class CreepDataComponent : MonoBehaviour { [Header("Data Reference")] [Tooltip("ScriptableObject containing creep data")] public CreepData creepData; [Header("Auto-Apply Settings")] [Tooltip("Automatically apply stats from creepData on Awake")] public bool autoApplyOnAwake = true; private void Awake() { if (autoApplyOnAwake && creepData != null) { ApplyCreepData(); } } public void ApplyCreepData() { if (creepData == null) { Debug.LogWarning("[CreepDataComponent] creepData is null", this); return; } EnemyUnit enemyUnit = GetComponent(); if (enemyUnit != null) { enemyUnit.maxHealth = creepData.maxHp; } EnemyAIController aiController = GetComponent(); if (aiController != null) { aiController.moveSpeed = creepData.moveSpeed; aiController.attackDamage = creepData.atkDamage; aiController.attackRange = creepData.atkRange; aiController.attackInterval = creepData.atkIntervalSec; } NavMeshAgent navAgent = GetComponent(); if (navAgent != null) { navAgent.speed = creepData.moveSpeed; } } } }