From dfe911cae4451f4df04316145fe1f67d433c62f4 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 04 十二月 2025 10:38:25 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts

---
 Main/System/Battle/BattleResources/BattleCacheManager.cs |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/Main/System/Battle/BattleResources/BattleCacheManager.cs b/Main/System/Battle/BattleResources/BattleCacheManager.cs
index e0c36b4..79682a6 100644
--- a/Main/System/Battle/BattleResources/BattleCacheManager.cs
+++ b/Main/System/Battle/BattleResources/BattleCacheManager.cs
@@ -259,4 +259,117 @@
         
         return $"Spine: {spineTotal}, Audio: {audioTotal}";
     }
+    
+    // ===== 缂栬緫鍣ㄨ皟璇曟帴鍙� =====
+#if UNITY_EDITOR
+    // 缂栬緫鍣ㄦā寮忎笅鐨勮祫婧愬紩鐢ㄨ皟璇曠被
+    public class ResourceReferenceDebug
+    {
+        public BattleResCache.CachedResource CachedResource;
+        public Dictionary<string, HashSet<string>> BattlefieldOwners;
+        
+        public int RefCount
+        {
+            get
+            {
+                int count = 0;
+                foreach (var owners in BattlefieldOwners.Values)
+                {
+                    count += owners.Count;
+                }
+                return count;
+            }
+        }
+        
+        // 绉佹湁鏋勯�犲嚱鏁帮紝鍙兘鐢� DebugAPI 璋冪敤
+        internal ResourceReferenceDebug()
+        {
+        }
+    }
+    
+    public static class DebugAPI
+    {
+        public static Dictionary<string, ResourceReferenceDebug> GetSpineCache()
+        {
+            var result = new Dictionary<string, ResourceReferenceDebug>();
+            foreach (var kvp in globalSpineCache)
+            {
+                // 鐩存帴鍦ㄨ繖閲岃祴鍊硷紝涓嶉�氳繃鏋勯�犲嚱鏁颁紶閫掔鏈夌被
+                result[kvp.Key] = new ResourceReferenceDebug
+                {
+                    CachedResource = kvp.Value.CachedResource,
+                    BattlefieldOwners = kvp.Value.BattlefieldOwners
+                };
+            }
+            return result;
+        }
+        
+        public static Dictionary<string, ResourceReferenceDebug> GetAudioCache()
+        {
+            var result = new Dictionary<string, ResourceReferenceDebug>();
+            foreach (var kvp in globalAudioCache)
+            {
+                result[kvp.Key] = new ResourceReferenceDebug
+                {
+                    CachedResource = kvp.Value.CachedResource,
+                    BattlefieldOwners = kvp.Value.BattlefieldOwners
+                };
+            }
+            return result;
+        }
+        
+        public static int GetTotalSpineCount() => globalSpineCache.Count;
+        public static int GetTotalAudioCount() => globalAudioCache.Count;
+        
+        public static HashSet<string> GetAllBattleGuids()
+        {
+            var guids = new HashSet<string>();
+            foreach (var refInfo in globalSpineCache.Values)
+            {
+                foreach (var guid in refInfo.BattlefieldOwners.Keys)
+                {
+                    guids.Add(guid);
+                }
+            }
+            foreach (var refInfo in globalAudioCache.Values)
+            {
+                foreach (var guid in refInfo.BattlefieldOwners.Keys)
+                {
+                    guids.Add(guid);
+                }
+            }
+            return guids;
+        }
+        
+        public static void ClearAllCache()
+        {
+            globalSpineCache.Clear();
+            globalAudioCache.Clear();
+            Debug.Log("BattleCacheManager: All cache cleared (Editor only)");
+        }
+    }
+    
+    // 璧勬簮寮曠敤瑙嗗浘绫伙紙渚涚紪杈戝櫒浣跨敤锛�
+    public class ResourceReferenceView
+    {
+        public string ResourceKey;
+        public string ResourcePath;
+        public bool IsLoaded;
+        public int TotalRefCount;
+        public Dictionary<string, int> BattlefieldRefCounts = new Dictionary<string, int>();
+        
+        public ResourceReferenceView(string key, ResourceReferenceDebug refInfo)
+        {
+            ResourceKey = key;
+            ResourcePath = refInfo.CachedResource.Identifier.Directory + "/" + refInfo.CachedResource.Identifier.AssetName;
+            IsLoaded = refInfo.CachedResource.Asset != null;
+            TotalRefCount = refInfo.RefCount;
+            
+            foreach (var kvp in refInfo.BattlefieldOwners)
+            {
+                BattlefieldRefCounts[kvp.Key] = kvp.Value.Count;
+            }
+        }
+    }
+#endif
 }
\ No newline at end of file

--
Gitblit v1.8.0