From bf838c34902a0cd12d89c718801a3b2446ad3a45 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 01 八月 2025 16:59:23 +0800
Subject: [PATCH] 18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建 配置新增静态构造 即访问即加载

---
 Main/Config/ConfigBase.cs |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/Main/Config/ConfigBase.cs b/Main/Config/ConfigBase.cs
index 93f9299..6c9806c 100644
--- a/Main/Config/ConfigBase.cs
+++ b/Main/Config/ConfigBase.cs
@@ -7,13 +7,21 @@
 
 public class ConfigBase<U, T> where T : ConfigBase<U, T>, new()
 {
+    static ConfigBase()
+    {
+        if (isInit)
+        {
+            return;
+        }
+        LazyInit();
+    }
+
     private static Dictionary<U, T> m_dic = new Dictionary<U, T>();
 
     public static Dictionary<U, T> dic
     {
         get
         {
-            LazyInit();
             return m_dic;
         }
     }
@@ -22,8 +30,6 @@
 
     public static T Get(U id)
     {
-        LazyInit();
-
         if (m_dic.ContainsKey(id))
         {
             return m_dic[id];
@@ -38,14 +44,8 @@
         isInit = false;
     }
 
-    public static void ForceInit()
-    {
-        ConfigManager.Instance.LoadConfigByType(typeof(T));
-    }
-
     public static List<U> GetKeys()
     {
-        LazyInit();
         List<U> result = new List<U>();
         result.AddRange(m_dic.Keys);
         return result;
@@ -54,7 +54,6 @@
 
     public static List<T> GetValues()
     {
-        LazyInit();
         List<T> result = new List<T>();
         result.AddRange(m_dic.Values);
         return result;
@@ -62,8 +61,6 @@
 
     public static bool HasKey(U key)
     {
-        LazyInit();
-
         return m_dic.ContainsKey(key);
     }
 
@@ -80,7 +77,6 @@
     {
         if (isInit)
         {
-            Debug.LogError("閲嶅鍔犺浇琛ㄦ牸  绫诲瀷 " + typeof(T).Name);
             return;
         }
 

--
Gitblit v1.8.0