TH1/Unity/Assets/Scripts/TH1_Logic/Editor/DumpMapConfigEditor.cs
2026-05-27 22:46:45 +08:00

106 lines
3.8 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.

// 临时调试工具dump MatchLevelData 里某个关卡的 PlayerSettlements 详情
// 用完可以删
using System.Text;
using TH1_Logic.MatchConfig;
using UnityEditor;
using UnityEngine;
namespace Logic.Editor
{
public static class DumpMapConfigEditor
{
[MenuItem("Tools/Debug/Dump 关卡2配置(Normal)")]
private static void DumpId2()
{
DumpId(2);
}
[MenuItem("Tools/Debug/Dump 关卡6配置(Normal)")]
private static void DumpId6()
{
DumpId(6);
}
[MenuItem("Tools/Debug/Dump 关卡7配置(Normal)")]
private static void DumpId7()
{
DumpId(7);
}
[MenuItem("Tools/Debug/Dump 全部关卡列表")]
private static void DumpAllIds()
{
MatchConfigManager.Instance.Init();
var data = MatchConfigManager.Instance.LevelData;
if (data == null || data.LevelConfigs == null)
{
Debug.LogError("[DumpMapConfig] LevelData 为空");
return;
}
var sb = new StringBuilder();
sb.Append("[DumpMapConfig] 全部关卡 id => MatchSettlement / PlayerSettlements.Count:\n");
foreach (var kv in data.LevelConfigs)
{
var cfg = kv.Value;
sb.Append($" id={kv.Key} MatchSettlement={cfg?.MatchSettlement} ");
sb.Append($"PlayerSettlements.Count={cfg?.PlayerSettlements?.Count ?? -1}");
sb.Append($" GameMode={cfg?.GameMode}");
sb.Append($" MapName={cfg?.MapName}");
sb.Append('\n');
}
Debug.Log(sb.ToString());
}
private static void DumpId(uint id)
{
MatchConfigManager.Instance.Init();
var cfg = MatchConfigManager.Instance.GetMatchConfig(id);
if (cfg == null)
{
Debug.LogError($"[DumpMapConfig] 找不到 id={id} 的关卡");
return;
}
var sb = new StringBuilder();
sb.Append($"[DumpMapConfig] id={id}\n");
sb.Append($" GameMode={cfg.GameMode}\n");
sb.Append($" MatchSettlement={cfg.MatchSettlement}\n");
sb.Append($" IsCustomMap={cfg.IsCustomMap} MapName={cfg.MapName}\n");
sb.Append($" PlayerCount={cfg.PlayerCount} AIDiff={cfg.AIDiff}\n");
if (cfg.PlayerSettlements == null)
{
sb.Append(" PlayerSettlements = null ← 这种情况会 fallback 到 OtherDie+Param1=-1\n");
}
else
{
sb.Append($" PlayerSettlements.Count = {cfg.PlayerSettlements.Count}\n");
for (int i = 0; i < cfg.PlayerSettlements.Count; i++)
{
var s = cfg.PlayerSettlements[i];
if (s == null)
{
sb.Append($" [{i}] null\n");
continue;
}
sb.Append($" [{i}] SettlementType={s.SettlementType} Tasks.Count={s.Tasks?.Count ?? -1}\n");
if (s.Tasks != null)
{
for (int j = 0; j < s.Tasks.Count; j++)
{
var t = s.Tasks[j];
if (t == null) { sb.Append($" Task[{j}] null\n"); continue; }
sb.Append($" Task[{j}] Type={t.TaskType} ");
sb.Append($"P1={t.Param1} P2={t.Param2} P3={t.Param3} P4={t.Param4} ");
sb.Append($"Order={t.Order}\n");
}
}
}
}
Debug.Log(sb.ToString());
}
}
}