| using System; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
|   | 
| public partial class GuideConfig : ConfigBase<int, GuideConfig> | 
| { | 
|     public static Dictionary<string, List<int>> winToGuidesDic = new Dictionary<string, List<int>>(); | 
|   | 
|     public static Dictionary<int, List<int>> typeToGuidesDic = new Dictionary<int, List<int>>(); | 
|   | 
|     public static Dictionary<int, List<int>> guideGroupDict = new Dictionary<int, List<int>>(); | 
|     static Dictionary<int, int> preGuideDict = new Dictionary<int, int>(); | 
|     protected override void OnConfigParseCompleted() | 
|     { | 
|         base.OnConfigParseCompleted(); | 
|   | 
|         List<int> list = null; | 
|         if (!winToGuidesDic.TryGetValue(WinName, out list)) | 
|         { | 
|             list = new List<int>(); | 
|             winToGuidesDic.Add(WinName, list); | 
|         } | 
|         list.Add(ID); | 
|   | 
|         List<int> list2 = null; | 
|         if (!typeToGuidesDic.TryGetValue(TriggerType, out list2)) | 
|         { | 
|             list2 = new List<int>(); | 
|             typeToGuidesDic.Add(TriggerType, list2); | 
|         } | 
|         list2.Add(ID); | 
|   | 
|         preGuideDict[ID] = PreGuideId; | 
|     } | 
|   | 
|   | 
|     public static List<int> GetGuideListByWinName(string winName) | 
|     { | 
|         List<int> list = null; | 
|         if (winToGuidesDic.TryGetValue(winName, out list)) | 
|         { | 
|             return list; | 
|         } | 
|         return null; | 
|     } | 
|   | 
|     public static List<int> GetGuideListByType(int type) | 
|     { | 
|         List<int> list = null; | 
|         if (typeToGuidesDic.TryGetValue(type, out list)) | 
|         { | 
|             return list; | 
|         } | 
|         return null; | 
|     } | 
|   | 
|   | 
|   | 
|   | 
|     // 汇总引导组 | 
|     public static List<int> GetGuideList(int guideID) | 
|     { | 
|         if (guideGroupDict.IsNullOrEmpty()) | 
|         { | 
|             BuildGuideGroupDict(); | 
|         } | 
|   | 
|         if (guideGroupDict.ContainsKey(guideID)) | 
|         { | 
|             return guideGroupDict[guideID]; | 
|         } | 
|         else | 
|         { | 
|             Debug.LogError($"guideID:{guideID} 没有找到引导组"); | 
|         } | 
|         return null; | 
|     } | 
|      | 
|     private static void BuildGuideGroupDict() | 
|     { | 
|         foreach (var id in preGuideDict.Keys) | 
|         { | 
|             int currentId = id; | 
|             int rootId = FindRootGuideId(currentId); | 
|   | 
|             if (!guideGroupDict.ContainsKey(rootId)) | 
|             { | 
|                 guideGroupDict[rootId] = new List<int>(); | 
|             } | 
|   | 
|             if (!guideGroupDict[rootId].Contains(currentId)) | 
|             { | 
|                 guideGroupDict[rootId].Add(currentId); | 
|             } | 
|         } | 
|     } | 
|   | 
|     private static int FindRootGuideId(int id) | 
|     { | 
|         int currentId = id; | 
|         while (preGuideDict.ContainsKey(currentId) && preGuideDict[currentId] != 0) | 
|         { | 
|             currentId = preGuideDict[currentId]; | 
|         } | 
|         return currentId; | 
|     } | 
| } |