From 5e4c574228c7cfadab0931a798d43b085bfb8844 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 26 十二月 2025 18:30:13 +0800
Subject: [PATCH] 125 战斗 休息状态 未加载/被清空预加载资源的问题
---
Main/System/Battle/BattleResources/BattlePreloadManager.cs | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/Main/System/Battle/BattleResources/BattlePreloadManager.cs b/Main/System/Battle/BattleResources/BattlePreloadManager.cs
index b2fa301..b0ee233 100644
--- a/Main/System/Battle/BattleResources/BattlePreloadManager.cs
+++ b/Main/System/Battle/BattleResources/BattlePreloadManager.cs
@@ -38,6 +38,39 @@
allSpineResources.AddRange(blueTeamInfo.SpineResources);
allAudioResources.AddRange(redTeamInfo.AudioResources);
allAudioResources.AddRange(blueTeamInfo.AudioResources);
+
+ // 妫�鏌ユ槸鍚︿负鍚屼竴鎴樺満鐨勯噸澶嶆敞鍐岋紙姣斿闃熶紞鍙樻洿锛夆�斺�斿鏋滅孩闃熷彂鐢熷彉鏇达紝闇�瑕佸己鍒跺嵏杞戒箣鍓嶇殑甯搁┗璧勬簮
+ if (cacheManager.HasBattleRegistered(battleGuid))
+ {
+ var existingRedOwners = cacheManager.GetRegisteredOwners(battleGuid, true); // 鍙瘮杈冨父椹伙紙绾㈤槦锛�
+ var newRedOwners = new HashSet<string>();
+ foreach (var r in redTeamInfo.SpineResources) if (!string.IsNullOrEmpty(r.OwnerId)) newRedOwners.Add(r.OwnerId);
+ foreach (var r in redTeamInfo.AudioResources) if (!string.IsNullOrEmpty(r.OwnerId)) newRedOwners.Add(r.OwnerId);
+
+ bool different = false;
+ if (existingRedOwners.Count != newRedOwners.Count) different = true;
+ else
+ {
+ foreach (var o in existingRedOwners) if (!newRedOwners.Contains(o)) { different = true; break; }
+ }
+
+ if (different)
+ {
+ // 璁$畻鍝簺 Owner 琚Щ闄わ紝鍙嵏杞借繖浜� Owner 寮曠敤瀵瑰簲鐨勮祫婧愪互鎻愰珮鎬ц兘
+ var removedOwners = new HashSet<string>(existingRedOwners);
+ removedOwners.ExceptWith(newRedOwners);
+
+ if (removedOwners.Count > 0)
+ {
+ Debug.Log($"BattlePreloadManager: Detected red-team change for {battleGuid}. Removed owners: {removedOwners.Count}. Unloading affected resources only.");
+ cacheManager.UnregisterBattlefieldOwners(battleGuid, removedOwners);
+ }
+ else
+ {
+ Debug.Log($"BattlePreloadManager: Detected red-team change for {battleGuid}, but no owners were removed (only additions). No unload necessary.");
+ }
+ }
+ }
cacheManager.RegisterBattlefieldResources(battleGuid, allSpineResources, allAudioResources);
--
Gitblit v1.8.0