Files
Northbound/Assets/Scripts/CreepDataComponent.cs
dal4segno 02f5aa869a 임시 건설 UI 생성
기타 불필요 디버깅 로그 제거
2026-02-03 20:23:36 +09:00

61 lines
1.8 KiB
C#

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<EnemyUnit>();
if (enemyUnit != null)
{
enemyUnit.maxHealth = creepData.maxHp;
}
EnemyAIController aiController = GetComponent<EnemyAIController>();
if (aiController != null)
{
aiController.moveSpeed = creepData.moveSpeed;
aiController.attackDamage = creepData.atkDamage;
aiController.attackRange = creepData.atkRange;
aiController.attackInterval = creepData.atkIntervalSec;
}
NavMeshAgent navAgent = GetComponent<NavMeshAgent>();
if (navAgent != null)
{
navAgent.speed = creepData.moveSpeed;
}
}
}
}