Project_WL/Assets/WL/Mobs/WLMobLineup.cs

86 lines
5.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ─────────────────────────────────────────────────────────────────────────────
// WLMobLineup.cs — 기본 몬스터 구성(라인업) — 몹 ID → 새 몹 프리팹 · 크기 (#907 · 2026-10-17)
//
// PD 원문: 「RPG Monster BUNDLE PBR 몬스터 에셋을 추가했어. 우리 게임의 기본 몬스터 구성을 이 에셋으로 구성해줘.
// (기존 Suriyun 몬스터 에셋 활용 유무는 잠시 보류)」
// ■ 원리 — 원본 table_monsterlist.Start 가 프리팹 경로를 붙이기 직전에 Apply 를 부른다: 라인업에 있는 몹 ID 면
// 표의 s_MonsterPrefab(Assets/Res_Addr/Mobs/ 아래 · 확장자 없이) · f_DefaultScale 을 라인업 값으로 바꾼다. 표 파일은 그대로(되돌리기 = enabled 0).
// ■ 값 = Resources/WL/WLMobLineup.json (C45) — 같은 파일의 원본 프리팹 · 클립 이름 · 판정 시점은 에디터 생성기(Editor/WLMobBuilder)가 읽는다.
// 🔴 Debug.LogError 금지(원본 ErrorLogHook 팝업) — 예외는 LastLog 로만.
// ─────────────────────────────────────────────────────────────────────────────
using UnityEngine;
namespace WL.Mobs
{
[System.Serializable]
public class WLMobLineupEntry
{
public int monsterId;
public string role = "";
public string prefab = ""; // 표 s_MonsterPrefab 대체 — Assets/Res_Addr/Mobs/ 아래 경로(확장자 없이)
public float scale; // 표 f_DefaultScale 대체(0 = 표 값)
// ── 아래는 에디터 생성기(WLMobBuilder) 입력 ──
public string source = ""; // 번들 원본 프리팹
public string run = "", idle = "", attack = "", hit = "", die = "", stun = "", casting = "", castingEnd = ""; // 원본 몹 상태 8개에 넣을 번들 클립 이름
public float attackEvent = -1f; // 공격 판정(Projectile) 시점 0~1 · -1 = 자동(모델이 앞으로 가장 멀리 뻗는 순간)
public float skillEvent = -1f; // 스킬 판정(SkillEvent) 시점 0~1 · -1 = 자동
public float attackExit = 0.9f; // 공격 · 스킬 끝 → 대기 전이 시작 시점 0~1
public float hitExit = 0.85f; // 피격 → 대기 전이 시작 시점 0~1
public float colliderWidthScale = 0.8f; // 피격 박스 가로 · 깊이 = 모델 크기 × 이 값
public float agentRadiusRatio = 0.3f; // 길찾기 반경 = 모델 가로 · 깊이 중 큰 값 × 이 값
}
[System.Serializable]
public class WLMobLineupJson
{
public int enabled = 1;
public string templatePrefab = ""; // 루트 컴포넌트(MobActor · NavMeshAgent · 콜라이더 · 리지드바디)를 가져올 기존 몹 프리팹
public string generatedFolder = ""; // 클립 복사본 · 컨트롤러 출력 폴더
public float transitionSeconds = 0.15f; // 공격 · 피격 → 대기 전이 시간(초)
public WLMobLineupEntry[] mobs = new WLMobLineupEntry[0];
public string note = "";
}
public static class WLMobLineup
{
public const string ResourcesPath = "WL/WLMobLineup";
public static int Applied; public static string LastLog = "";
static WLMobLineupJson s_cfg;
public static WLMobLineupJson Cfg
{
get
{
if (s_cfg != null) return s_cfg;
s_cfg = new WLMobLineupJson();
var ta = Resources.Load<TextAsset>(ResourcesPath);
if (ta == null) { LastLog = "설정 없음 " + ResourcesPath; return s_cfg; }
try { JsonUtility.FromJsonOverwrite(ta.text, s_cfg); } catch (System.Exception ex) { LastLog = "설정 파싱 실패 — " + ex.Message; }
return s_cfg;
}
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void Reset() { s_cfg = null; Applied = 0; }
/// <summary>원본 table_monsterlist.Start — 경로를 붙이기 직전. 라인업 몹이면 프리팹 · 기본 크기를 바꾼다.</summary>
public static void Apply(MonsterTableData d)
{
try
{
var c = Cfg;
if (d == null || c.enabled == 0 || c.mobs == null) return;
foreach (var e in c.mobs)
{
if (e == null || e.monsterId != d.n_MonsterID) continue;
if (!string.IsNullOrEmpty(e.prefab)) d.s_MonsterPrefab = e.prefab;
if (e.scale > 0f) d.f_DefaultScale = e.scale;
Applied++; LastLog = d.n_MonsterID + " → " + d.s_MonsterPrefab + " × " + d.f_DefaultScale;
return;
}
}
catch (System.Exception ex) { LastLog = "실패 — " + ex.Message; }
}
}
}