NLDClient-yudde/ProjectNLD/Assets/Editor/LevelCheckers/LevelFileRoadChecker.cs

46 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using UnityEngine;
using PhxhSDK.Editor.FileChecker.Data;
using Gameplay.Level;
using PhxhSDK.Phxh;
using System.Collections.Generic;
namespace PhxhSDK.Editor.FileChecker
{
/// <summary>
/// 关卡文件路线检查器
/// 检查关卡json文件的路线配置是否正确
/// </summary>
public class LevelFileRoadChecker : BaseLevelChecker
{
public override string CheckerName => "关卡文件路线检查";
public override string RecommendedHandling => "修改关卡文件路线配置";
public override CheckerTabType belongTab => CheckerTabType.Level;
public override bool HasAutoProgress => false;
private HashSet<int> setId = new();
public override string CheckLevel(string filePath, TextAsset textAsset)
{
string res = string.Empty;
if (null == textAsset)
return "文件加载失败";
LevelData levelData = JsonHelper.LoadJsonFromText<LevelData>(textAsset.text);
if(null == levelData)
return $"关卡json反序列化为{nameof(LevelData)}失败";
setId.Clear();
foreach (var patrolRoadData in levelData.patrolRoadData)
{
if(!setId.Add(patrolRoadData.id))
res += $"关卡路线id重复id:{patrolRoadData.id}\n";
}
if (res.Equals(string.Empty))
return null;
else
return res;
}
}
}