From 99a11d2bb19d74f6cc8584ac16838062af4fb301 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 03 四月 2026 11:24:07 +0800
Subject: [PATCH] webgl 优化

---
 Main/System/Battle/BattleManager.cs |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index f32cf2d..3835e4c 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -12,6 +12,8 @@
 
     //  鍚屾椂鍙兘鏈変竴鍦烘垬鏂楀湪杩涜 guid, battlefield
     protected Dictionary<string, BattleField> battleFields = new Dictionary<string, BattleField>();
+    // 缂撳瓨key鍒楄〃锛岄伩鍏峈un()姣忓抚鍒嗛厤
+    private List<string> _runKeysCache = new List<string>();
 
     public float[] speedGear; //鎴樻枟鍊嶆暟瀵瑰簲鐨勫疄闄呴�熺巼
     public int speedIndex
@@ -631,10 +633,13 @@
     public void Run()
     {
 
-        List<string> keys = new List<string>(battleFields.Keys);
-        for (int i = keys.Count - 1; i >= 0; i--)
+        _runKeysCache.Clear();
+        foreach (var key in battleFields.Keys)
+            _runKeysCache.Add(key);
+        for (int i = _runKeysCache.Count - 1; i >= 0; i--)
         {
-            var battleField = battleFields[keys[i]];
+            if (!battleFields.TryGetValue(_runKeysCache[i], out var battleField))
+                continue;
             try
             {
                 battleField?.Run();

--
Gitblit v1.8.0