Project_WL/AgentScripts/WL_StartWakeAnimSetup.cs

164 lines
7.9 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 지시 #750 — pcanim_lobby.controller 에 기상 연출 상태 2개(lying / getup)를 추가한다.
// 2단계 실행: unity command run_script --file AgentScripts/WL_StartWakeAnimSetup.cs --entry WL_StartWakeAnimSetup.Run
// CLAUDE.md §1 준수: using 금지 · 네임스페이스 풀어 쓰기
//
// 전제
// · 아래 2개 FBX 를 Assets/Res_Addr/Animations/Animation/Common_PlatformAnim/ 에 복사해 둘 것
// C:\WL\Project_WL\Assets\Shinabro\Platform_Animation\Animation\98_Damage\Stander@LyingFront.FBX
// C:\WL\Project_WL\Assets\Shinabro\Platform_Animation\Animation\98_Damage\Stander@LyingFront_WakeUp.FBX
// (.meta 도 함께 — animationType: 3 = Humanoid 이고 힘민지 플레이어 클립과 같은 Shinabro Stander 팩이라
// Humanoid 재타게팅으로 호환된다. GUID: 092d5d11… / 6c185e22…)
// · 2026-09-06 #757 확장: 시작 맵을 e_MapType == Stage 로 바꾸면 PCActor.Set_Obj (PCActor.cs:267-286) 가
// pcanim_lobby 가 아니라 ClassConfig 의 s_AnimationController(클래스별 컨트롤러)를 로드한다.
// StartWakeSequence 는 lying/getup 상태를 가진 컨트롤러가 붙을 때까지 기다리므로
// 클래스 컨트롤러 전부에 같은 상태 2개를 추가해야 연출이 스킵되지 않는다.
// 대상 목록은 코드 상수가 아니라 ClassConfig.json(SOT)에서 읽는다 (C45).
//
// 되돌리기: 실행 전 *.controller 를 git 으로 커밋해 두면 checkout 로 복구된다 (상태 추가일 뿐이라 남겨도 무해).
public static class WL_StartWakeAnimSetup
{
const bool kDryRun = false; // 🔴 먼저 true 로 실행해 로그를 검토할 것
const string kLobbyController = "Assets/Res_Addr/Animations/pcanim_lobby.controller";
const string kClassConfig = "Assets/ResWork/Table/Export/ClassConfig.json";
const string kClipDir = "Assets/Res_Addr/Animations/Animation/Common_PlatformAnim";
const string kLyingFbx = kClipDir + "/Stander@LyingFront.FBX";
const string kWakeFbx = kClipDir + "/Stander@LyingFront_WakeUp.FBX";
const string kLyingState = "lying";
const string kGetUpState = "getup";
static System.Text.StringBuilder s_log = new System.Text.StringBuilder();
const string kLogPath = "AgentScripts/staging/WL_Monsters/WAKEANIM_LOG.txt";
public static void Run()
{
s_log.Length = 0;
Log("===== WL_StartWakeAnimSetup dryRun=" + kDryRun + " =====");
// 대상 컨트롤러 = 로비 + ClassConfig.json 의 s_AnimationController 전부 (C45 — SOT 직접 읽기)
var targets = new System.Collections.Generic.List<string>();
targets.Add(kLobbyController);
if (!System.IO.File.Exists(kClassConfig)) { Log("[오류] 테이블 없음: " + kClassConfig); Flush(); return; }
var json = System.IO.File.ReadAllText(kClassConfig);
var rx = new System.Text.RegularExpressions.Regex("\"s_AnimationController\"\\s*:\\s*\"([^\"]+)\"");
foreach (System.Text.RegularExpressions.Match m in rx.Matches(json))
{
var p = m.Groups[1].Value;
if (!targets.Contains(p)) targets.Add(p);
}
Log("대상 컨트롤러 " + targets.Count + "개 (로비 1 + ClassConfig " + (targets.Count - 1) + ")");
var lyingClip = FirstClip(kLyingFbx);
var wakeClip = FirstClip(kWakeFbx);
if (lyingClip == null || wakeClip == null)
{
Log("[오류] 클립을 못 찾았다. FBX 2개를 " + kClipDir + " 에 복사하고 임포트했는지 확인할 것.");
Flush(); return;
}
Log("lying 클립 = " + lyingClip.name + " length=" + lyingClip.length.ToString("F3")
+ " loop=" + lyingClip.isLooping + " humanMotion=" + lyingClip.humanMotion);
Log("getup 클립 = " + wakeClip.name + " length=" + wakeClip.length.ToString("F3")
+ " loop=" + wakeClip.isLooping + " humanMotion=" + wakeClip.humanMotion);
if (!lyingClip.humanMotion || !wakeClip.humanMotion)
Log("[경고] Humanoid 클립이 아니다 — 재타게팅이 되지 않는다.");
int changed = 0, already = 0;
for (int c = 0; c < targets.Count; c++)
{
var path = targets[c];
var ctrl = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEditor.Animations.AnimatorController>(path);
if (ctrl == null) { Log("[오류] 컨트롤러 없음: " + path); continue; }
if (ctrl.layers == null || ctrl.layers.Length == 0) { Log("[오류] 레이어 없음: " + path); continue; }
var sm = ctrl.layers[0].stateMachine;
bool hasLying = HasState(sm, kLyingState);
bool hasGetUp = HasState(sm, kGetUpState);
if (hasLying && hasGetUp)
{
already++;
Log(" [유지] " + System.IO.Path.GetFileName(path) + " 상태 " + sm.states.Length + "개 · lying/getup 이미 있음");
continue;
}
if (kDryRun)
{
Log(" [예정] " + System.IO.Path.GetFileName(path) + " 상태 " + sm.states.Length + "개 → 추가: "
+ (hasLying ? "" : kLyingState + " ") + (hasGetUp ? "" : kGetUpState));
continue;
}
if (!hasLying)
{
var s = sm.AddState(kLyingState);
s.motion = lyingClip; s.speed = 1f; s.writeDefaultValues = false;
}
if (!hasGetUp)
{
var s = sm.AddState(kGetUpState);
s.motion = wakeClip; s.speed = 1f; s.writeDefaultValues = false;
}
// 전이(transition)는 만들지 않는다 — 힘민지는 Animator.Play(stateName) 직접 호출 방식이라
// 전이가 있으면 오히려 의도치 않은 자동 이동이 생긴다 (Actor.AnimationPlay, Actor.cs:2020).
UnityEditor.EditorUtility.SetDirty(ctrl);
changed++;
Log(" [추가] " + System.IO.Path.GetFileName(path) + " 최종 상태 " + sm.states.Length + "개 (기본상태 = "
+ (sm.defaultState == null ? "null" : sm.defaultState.name) + " · 변경 안 함)");
}
if (!kDryRun)
{
UnityEditor.AssetDatabase.SaveAssets();
UnityEditor.AssetDatabase.Refresh();
}
Log("완료 — 변경 " + changed + "개 · 이미 보유 " + already + "개 · 대상 " + targets.Count + "개 (dryRun=" + kDryRun + ")");
Flush();
}
static void Log(string s) { s_log.AppendLine(s); }
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_log.ToString());
UnityEngine.Debug.Log("[WakeAnim] 로그: " + kLogPath);
}
static UnityEngine.AnimationClip FirstClip(string fbxPath)
{
var all = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(fbxPath);
if (all == null) return null;
UnityEngine.AnimationClip best = null;
for (int i = 0; i < all.Length; i++)
{
var c = all[i] as UnityEngine.AnimationClip;
if (c == null) continue;
if (c.name.StartsWith("__preview__")) continue;
if (best == null) best = c;
}
return best;
}
static bool HasState(UnityEditor.Animations.AnimatorStateMachine sm, string name)
{
for (int i = 0; i < sm.states.Length; i++)
if (sm.states[i].state != null && sm.states[i].state.name == name) return true;
return false;
}
static string StateNames(UnityEditor.Animations.AnimatorStateMachine sm)
{
var sb = new System.Text.StringBuilder();
for (int i = 0; i < sm.states.Length; i++)
{
if (sm.states[i].state == null) continue;
if (sb.Length > 0) sb.Append(", ");
sb.Append(sm.states[i].state.name);
}
return sb.ToString();
}
}