Project_WL/AgentScripts/WL_MonsterRuntimeProbe.cs

201 lines
10 KiB
C#
Raw Permalink Normal View History

WL 리뉴얼 세션 2026-09-06~07 (#760~#800) — 전투·배경·UI·타격감 (조직 PD 로그 #746~#800 · 대화로그 §14~§24) - 전투: Knight@Attack1~3_S 3콤보(4 컨트롤러·클래스별 서브클립) · 타겟팅 4규칙(정면 우선·재타겟·즉시 공격·어그로 금지 · WLTargetingSettings) · 대쉬 후 공격(Stander@Chase_Start · DashDriver · 5 m · 사정거리+0.8 · 근거리 적 우선) · 공격 이동 FrameTable(발 접지 실측 표 · AttackRootMotion) · 충돌 반경/투사체 0.3 배(WLCollisionTuning) · 무적(임시)·펫 금지(WLGameplaySettings) - 검기: NamuFX Slash_B 배리언트 Effect_WLSwingArc 원 피팅 정합 배치 + 캘리브레이션(SlashArcMeasure · SlashTrailSettings) · 찌르기 Effect_WLStab 대기 · 램프 리본(BladeTrail · WL_BladeRibbon.shader · T_WL_BladeRibbonRamp) 보존(drawRibbon 0) - 타격감: Assets/WL/Feel(WLHitFeel · 히트스톱 0.03 · 셰이크 0.10 m · 몹 펀치 1.12 · Actor.Get_Damage 훅 1줄 · 원본 RealCamera 셰이크 결함 대체) - 배경/맵: LMHPOLY Demo_01~10 → WL_Nature01~10(프리팹·씬·NavMesh·스포너·BattleMapConfig) · 물(ToonWaterU) · 포스트 블룸 0.9/0.3 · 잔디(BruteForce·드레싱) 제거 · 마젠타 머티리얼 URP 변환 - UI: 세로 HUD(WL_HUD · 하단 5메뉴 폭 전체 · 채팅/전투 패드 숨김 · WLIngameUiOverride) · Title/TitleInfo 1080×1920 Expand + 배경 높이 fit(WLBackgroundFit) · 로딩 SortOrder_5(WLRawImageAspectSync · 초점표 8장) · Loading1~8 ASTC 6×6 - 도구: AgentScripts/*(LightProbe · WL_MapSwitch · WL760~WL800 프로브/집행/검증 · 상단 사용법 주석) · 에디터 락 프로토콜 파일(staging) - 제외(별도 커밋 예정): Assets/LMHPOLY(703 MB) · Assets/Feel(422 MB) · Assets/Shinabro(300 MB) — 에셋 스토어/구 WL 팩 원본 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 23:24:25 +00:00
// PD 지시 #757 — Play 중 스포너·몬스터·Stage UI 검증 프로브 (읽기 전용)
// 실행: unity command run_script --file AgentScripts/WL_MonsterRuntimeProbe.cs --entry WL_MonsterRuntimeProbe.Run
// CLAUDE.md §1 준수: using 금지 · 네임스페이스 풀어 쓰기
public static class WL_MonsterRuntimeProbe
{
const string kLogPath = "AgentScripts/staging/WL_Monsters/RUNTIME_LOG.txt";
static System.Text.StringBuilder s;
public static string Run()
{
s = new System.Text.StringBuilder();
L("===== 런타임 검증 t=" + UnityEngine.Time.realtimeSinceStartup.ToString("F1") + "s =====");
L("playing=" + UnityEngine.Application.isPlaying + " timeScale=" + UnityEngine.Time.timeScale);
// 씬
var sb = new System.Text.StringBuilder();
for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; i++)
{
var sc = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);
if (sb.Length > 0) sb.Append(", ");
sb.Append(sc.name + "(" + (sc.isLoaded ? "loaded" : "loading") + ")");
}
L("씬: " + sb);
// 게임 모드 · 맵
if (InGameInfo.Ins != null)
{
L("GameMode = " + InGameInfo.Ins.Get_GameMode() + " (Stage 여야 함)");
L("MyChoiceMapData.n_MapID = " + MyValue.MyChoiceMapData.n_MapID);
}
else L("[경고] InGameInfo 인스턴스 없음");
// 로딩 UI
if (LoadingUI.isIns && LoadingUI.Ins.go != null)
L("LoadingUI 활성 = " + LoadingUI.Ins.go.activeInHierarchy + " (false 여야 로딩 종료)");
// Stage HUD
if (NewGameUI.isIns)
{
var ng = NewGameUI.Ins;
var g = new System.Text.StringBuilder();
for (int i = 0; i < ng.gos.Length; i++) g.Append("gos[" + i + "]=" + (ng.gos[i] == null ? "null" : ng.gos[i].activeInHierarchy.ToString()) + " ");
for (int i = 0; i < ng.gos_ingame.Length; i++) g.Append("gos_ingame[" + i + "]=" + (ng.gos_ingame[i] == null ? "null" : ng.gos_ingame[i].activeInHierarchy.ToString()) + " ");
for (int i = 0; i < ng.gos_etc.Length; i++) g.Append("gos_etc[" + i + "]=" + (ng.gos_etc[i] == null ? "null" : ng.gos_etc[i].activeInHierarchy.ToString()) + " ");
L("NewGameUI: " + g);
}
// 스포너
var mgrs = UnityEngine.Object.FindObjectsByType<MobControlMgr>(UnityEngine.FindObjectsSortMode.None);
L("MobControlMgr 씬 내 = " + mgrs.Length + "개 (기대 19)");
int done = 0;
var notDone = new System.Text.StringBuilder();
for (int i = 0; i < mgrs.Length; i++)
{
if (mgrs[i].Get_LoadComplete()) done++;
else { if (notDone.Length > 0) notDone.Append(","); notDone.Append(mgrs[i].SpawnerID); }
}
L("로드 완료 스포너 = " + done + "/" + mgrs.Length + (notDone.Length > 0 ? " 미완료ID: " + notDone : ""));
// Lv 라벨
int lvOk = 0, lvUnknown = 0;
var lvs = new System.Text.StringBuilder();
for (int i = 0; i < mgrs.Length; i++)
{
var t = mgrs[i].text_lv;
if (t == null) continue;
if (t.text.Contains("?")) lvUnknown++; else lvOk++;
if (lvs.Length > 0) lvs.Append(" ");
lvs.Append(mgrs[i].SpawnerID + ":" + t.text);
}
L("Lv 라벨 정상 " + lvOk + " · 미해결(???) " + lvUnknown);
L("라벨값: " + lvs);
// 몬스터
var mobs = UnityEngine.Object.FindObjectsByType<MobActor>(UnityEngine.FindObjectsSortMode.None);
int alive = 0;
for (int i = 0; i < mobs.Length; i++) if (mobs[i].isActiveAndEnabled) alive++;
L("MobActor 생성 총수 = " + mobs.Length + " · 활성 = " + alive + " (테이블 n_MaxMonsterCount 합계 175 기대)");
// 플레이어
if (MyValue.bMyPC && MyValue.MyPC != null)
{
var pc = MyValue.MyPC;
L("플레이어 위치 = " + pc.transform.position.ToString("F2") + " scale=" + pc.transform.localScale.ToString("F2"));
var anim = pc.GetComponentInChildren<UnityEngine.Animator>(true);
if (anim != null)
{
L("Animator controller = " + (anim.runtimeAnimatorController == null ? "null" : anim.runtimeAnimatorController.name));
L(" lying 보유=" + anim.HasState(0, UnityEngine.Animator.StringToHash("lying"))
+ " getup 보유=" + anim.HasState(0, UnityEngine.Animator.StringToHash("getup")));
var st = anim.GetCurrentAnimatorStateInfo(0);
L(" 현재 상태 hash=" + st.shortNameHash + " normTime=" + st.normalizedTime.ToString("F2"));
}
// 가장 가까운 몬스터
float best = float.MaxValue; MobActor near = null;
for (int i = 0; i < mobs.Length; i++)
{
if (!mobs[i].isActiveAndEnabled) continue;
float d = UnityEngine.Vector3.Distance(pc.transform.position, mobs[i].transform.position);
if (d < best) { best = d; near = mobs[i]; }
}
L("가장 가까운 활성 몬스터 = " + (near == null ? "없음" : near.name + " " + best.ToString("F1") + "m @" + near.transform.position.ToString("F1")));
}
else L("[경고] MyPC 없음");
Flush();
return "OK — " + kLogPath;
}
// 전투 확인용: 가장 가까운 몬스터의 HP 를 찍는다
public static string Mob()
{
s = new System.Text.StringBuilder();
var mobs = UnityEngine.Object.FindObjectsByType<MobActor>(UnityEngine.FindObjectsSortMode.None);
int alive = 0; for (int i = 0; i < mobs.Length; i++) if (mobs[i].isActiveAndEnabled) alive++;
L("t=" + UnityEngine.Time.realtimeSinceStartup.ToString("F1") + " 총 " + mobs.Length + " 활성 " + alive);
if (MyValue.bMyPC && MyValue.MyPC != null)
{
var pc = MyValue.MyPC;
L("PC pos=" + pc.transform.position.ToString("F2") + " HP=" + Num(pc, "Get_HP"));
float best = float.MaxValue; MobActor near = null;
for (int i = 0; i < mobs.Length; i++)
{
if (!mobs[i].isActiveAndEnabled) continue;
float d = UnityEngine.Vector3.Distance(pc.transform.position, mobs[i].transform.position);
if (d < best) { best = d; near = mobs[i]; }
}
if (near != null)
L("근접몹 " + near.name + " d=" + best.ToString("F1") + " HP=" + Num(near, "Get_HP") + " active=" + near.isActiveAndEnabled);
}
var txt = s.ToString();
System.IO.File.AppendAllText(kLogPath, txt);
return txt;
}
// 지정 스포너를 내려다보는 임시 카메라로 렌더 (몬스터 군집 캡처용 · 저장은 Assets 밖)
public static string Shot(string arg)
{
var parts = arg.Split(':');
int id = int.Parse(parts[0]);
string tag = parts.Length > 1 ? parts[1] : ("spawner" + id);
float height = parts.Length > 2 ? float.Parse(parts[2]) : 18f;
float back = parts.Length > 3 ? float.Parse(parts[3]) : 18f;
var mgrs = UnityEngine.Object.FindObjectsByType<MobControlMgr>(UnityEngine.FindObjectsSortMode.None);
MobControlMgr target = null;
for (int i = 0; i < mgrs.Length; i++) if (mgrs[i].SpawnerID == id) { target = mgrs[i]; break; }
if (target == null) return "SpawnerID " + id + " 없음";
int alive = 0;
var mobs = UnityEngine.Object.FindObjectsByType<MobActor>(UnityEngine.FindObjectsSortMode.None);
for (int i = 0; i < mobs.Length; i++)
if (mobs[i].isActiveAndEnabled && UnityEngine.Vector3.Distance(mobs[i].transform.position, target.transform.position) <= target.MobGenRange + 5f) alive++;
var src = UnityEngine.Camera.main;
int w = 1280, h = 720;
var rt = new UnityEngine.RenderTexture(w, h, 24, UnityEngine.RenderTextureFormat.ARGB32);
var go = new UnityEngine.GameObject("__wlShotCam");
var c = go.AddComponent<UnityEngine.Camera>();
if (src != null) c.CopyFrom(src);
c.targetTexture = rt; c.enabled = false; c.orthographic = false; c.fieldOfView = 60f;
var dir = new UnityEngine.Vector3(-0.707f, 0f, 0.707f); // CamRot_Portal 315도 방향
go.transform.position = target.transform.position - dir * back + UnityEngine.Vector3.up * height;
go.transform.LookAt(target.transform.position);
c.Render();
var prev = UnityEngine.RenderTexture.active;
UnityEngine.RenderTexture.active = rt;
var tex = new UnityEngine.Texture2D(w, h, UnityEngine.TextureFormat.RGB24, false);
tex.ReadPixels(new UnityEngine.Rect(0, 0, w, h), 0, 0); tex.Apply();
UnityEngine.RenderTexture.active = prev;
var d = "Screenshots_WL/monsters";
System.IO.Directory.CreateDirectory(d);
var path = d + "/" + tag + ".png";
System.IO.File.WriteAllBytes(path, UnityEngine.ImageConversion.EncodeToPNG(tex));
UnityEngine.Object.DestroyImmediate(go); UnityEngine.Object.DestroyImmediate(tex);
rt.Release(); UnityEngine.Object.DestroyImmediate(rt);
return "saved " + path + " SpawnerID=" + id + " @" + target.transform.position.ToString("F1")
+ " 반경내 활성몹=" + alive + " 라벨=" + (target.text_lv == null ? "-" : target.text_lv.text);
}
static string Num(object o, string method)
{
if (o == null) return "-";
var m = o.GetType().GetMethod(method, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (m == null || m.GetParameters().Length != 0) return "(no " + method + ")";
try { return System.Convert.ToString(m.Invoke(o, null)); } catch (System.Exception e) { return "err:" + e.Message; }
}
static void L(string t) { s.AppendLine(t); }
static void Flush()
{
var dir = System.IO.Path.GetDirectoryName(kLogPath);
if (!System.IO.Directory.Exists(dir)) System.IO.Directory.CreateDirectory(dir);
System.IO.File.WriteAllText(kLogPath, s.ToString());
}
}