데이터 파이프라인 개선 및 포탈 로직 생성
csv import 시 자동으로 완전한 프리팹이 생성될 수 있도록 함.
This commit is contained in:
62
Assets/Scripts/MonsterDataComponent.cs
Normal file
62
Assets/Scripts/MonsterDataComponent.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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 MonsterDataComponent : MonoBehaviour
|
||||
{
|
||||
[Header("Data Reference")]
|
||||
[Tooltip("ScriptableObject containing monster data")]
|
||||
public MonsterData monsterData;
|
||||
|
||||
[Header("Auto-Apply Settings")]
|
||||
[Tooltip("Automatically apply stats from monsterData on Awake")]
|
||||
public bool autoApplyOnAwake = true;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (autoApplyOnAwake && monsterData != null)
|
||||
{
|
||||
ApplyMonsterData();
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyMonsterData()
|
||||
{
|
||||
if (monsterData == null)
|
||||
{
|
||||
Debug.LogWarning("[MonsterDataComponent] monsterData is null", this);
|
||||
return;
|
||||
}
|
||||
|
||||
EnemyUnit enemyUnit = GetComponent<EnemyUnit>();
|
||||
if (enemyUnit != null)
|
||||
{
|
||||
enemyUnit.maxHealth = monsterData.maxHp;
|
||||
}
|
||||
|
||||
EnemyAIController aiController = GetComponent<EnemyAIController>();
|
||||
if (aiController != null)
|
||||
{
|
||||
aiController.moveSpeed = monsterData.moveSpeed;
|
||||
aiController.attackDamage = monsterData.atkDamage;
|
||||
aiController.attackRange = monsterData.atkRange;
|
||||
aiController.attackInterval = monsterData.atkIntervalSec;
|
||||
}
|
||||
|
||||
NavMeshAgent navAgent = GetComponent<NavMeshAgent>();
|
||||
if (navAgent != null)
|
||||
{
|
||||
navAgent.speed = monsterData.moveSpeed;
|
||||
}
|
||||
|
||||
Debug.Log($"[MonsterDataComponent] Applied data for {monsterData.id} ({monsterData.memo})", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user