From 3b895f5ab8d619719e8e67795db093cd83dcc66c Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 29 八月 2025 15:21:05 +0800
Subject: [PATCH] logic engine update

---
 Assets/Launch/Common/LogicEngine.cs |   71 +++++++++++++++++++++--------------
 1 files changed, 43 insertions(+), 28 deletions(-)

diff --git a/Assets/Launch/Common/LogicEngine.cs b/Assets/Launch/Common/LogicEngine.cs
index e4e4b49..0901b81 100644
--- a/Assets/Launch/Common/LogicEngine.cs
+++ b/Assets/Launch/Common/LogicEngine.cs
@@ -1,49 +1,64 @@
 锘縰sing System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using System;
 
+public class LogicEngine : SingletonMonobehaviour<LogicEngine>
+{
+    public Action OnUpdate;
 
-    public class LogicEngine : SingletonMonobehaviour<LogicEngine>
+    List<LogicUpdate> logicUpdates = new List<LogicUpdate>();
+    public void Register(LogicUpdate logicUpdate)
     {
-        List<LogicUpdate> logicUpdates = new List<LogicUpdate>();
-        public void Register(LogicUpdate logicUpdate)
+        if (!logicUpdates.Contains(logicUpdate))
         {
-            if (!logicUpdates.Contains(logicUpdate))
+            logicUpdates.Add(logicUpdate);
+        }
+    }
+
+    public void UnRegister(LogicUpdate logicUpdate)
+    {
+        if (logicUpdates.Contains(logicUpdate))
+        {
+            logicUpdates.Remove(logicUpdate);
+        }
+    }
+
+    void Update()
+    {
+        if (null != OnUpdate)
+        {
+            try
             {
-                logicUpdates.Add(logicUpdate);
+                OnUpdate();
+            }
+            catch (System.Exception ex)
+            {
+                Debug.LogError(ex);
             }
         }
-
-        public void UnRegister(LogicUpdate logicUpdate)
+            
+        for (var i = logicUpdates.Count - 1; i >= 0; i--)
         {
-            if (logicUpdates.Contains(logicUpdate))
+            var item = logicUpdates[i];
+            if (item.destroyDirty)
             {
-                logicUpdates.Remove(logicUpdate);
+                logicUpdates.RemoveAt(i);
             }
-        }
-
-        void Update()
-        {
-            for (var i = logicUpdates.Count - 1; i >= 0; i--)
+            else
             {
-                var item = logicUpdates[i];
-                if (item.destroyDirty)
+                try
                 {
-                    logicUpdates.RemoveAt(i);
+                    item.Update();
                 }
-                else
+                catch (System.Exception ex)
                 {
-                    try
-                    {
-                        item.Update();
-                    }
-                    catch (System.Exception ex)
-                    {
-                        Debug.LogError(ex);
-                    }
+                    Debug.LogError(ex);
                 }
             }
-
         }
 
-    }
\ No newline at end of file
+            
+    }
+
+}
\ No newline at end of file

--
Gitblit v1.8.0