From aa6455f23e172af86644c0859ddb25d758073aa3 Mon Sep 17 00:00:00 2001
From: ALEXTANG <574809918@qq.com>
Date: Mon, 3 Apr 2023 20:42:54 +0800
Subject: [PATCH] Update GameModule
Update GameModule
---
Assets/TEngine/Runtime/GameMain.cs | 18 ----
Assets/TEngine/Runtime/GameModule.cs | 94 +++++++++++++++++++
.../{GameMain.cs.meta => GameModule.cs.meta} | 0
3 files changed, 94 insertions(+), 18 deletions(-)
delete mode 100644 Assets/TEngine/Runtime/GameMain.cs
create mode 100644 Assets/TEngine/Runtime/GameModule.cs
rename Assets/TEngine/Runtime/{GameMain.cs.meta => GameModule.cs.meta} (100%)
diff --git a/Assets/TEngine/Runtime/GameMain.cs b/Assets/TEngine/Runtime/GameMain.cs
deleted file mode 100644
index 9b2600f5..00000000
--- a/Assets/TEngine/Runtime/GameMain.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class GameMain : MonoBehaviour
-{
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-}
diff --git a/Assets/TEngine/Runtime/GameModule.cs b/Assets/TEngine/Runtime/GameModule.cs
new file mode 100644
index 00000000..d8a93ebb
--- /dev/null
+++ b/Assets/TEngine/Runtime/GameModule.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using TEngine;
+using UnityEngine;
+
+///
+/// 游戏模块
+///
+public class GameModule:MonoBehaviour
+{
+ #region BaseComponents
+ ///
+ /// 获取游戏基础组件。
+ ///
+ public static RootComponent Base { get; private set; }
+
+ ///
+ /// 获取调试组件。
+ ///
+ public static DebuggerComponent Debugger { get; private set; }
+
+ ///
+ /// 获取有限状态机组件。
+ ///
+ public static FsmComponent Fsm { get; private set; }
+
+ ///
+ /// 获取对象池组件。
+ ///
+ public static ObjectPoolComponent ObjectPool { get; private set; }
+
+ ///
+ /// 获取资源组件。
+ ///
+ public static ResourceComponent Resource { get; private set; }
+
+ ///
+ /// 获取配置组件。
+ ///
+ public static SettingComponent Setting { get; private set; }
+
+ ///
+ /// 获取界面组件。
+ ///
+ public static UIComponent UI { get; private set; }
+
+ #endregion
+
+ ///
+ /// 初始化系统框架模块
+ ///
+ public static void InitFrameWorkComponents()
+ {
+ Base = Get();
+ Debugger = Get();
+ Fsm = Get();
+ ObjectPool = Get();
+ Resource = Get();
+ Setting = Get();
+ UI = Get();
+ }
+
+ public static void InitCustomComponents()
+ {
+
+ }
+
+ private static readonly Dictionary s_Components = new Dictionary();
+
+ public static T Get()where T : GameFrameworkComponent
+ {
+ Type type = typeof(T);
+
+ if (s_Components.ContainsKey(type))
+ {
+ return s_Components[type] as T;
+ }
+
+ T component = TEngine.GameEntry.GetComponent();
+
+ Log.Assert(condition:component != null,$"{typeof(T)} is null");
+
+ s_Components.Add(type,component);
+
+ return component;
+ }
+
+ public void Start()
+ {
+ Log.Info("GameModule Active");
+ InitFrameWorkComponents();
+ InitCustomComponents();
+ }
+}
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameMain.cs.meta b/Assets/TEngine/Runtime/GameModule.cs.meta
similarity index 100%
rename from Assets/TEngine/Runtime/GameMain.cs.meta
rename to Assets/TEngine/Runtime/GameModule.cs.meta