Files
2026-03-06 09:44:00 +08:00

124 lines
3.9 KiB
C#

// using System;
// using Fantasy;
// using Fantasy.Async;
// using SimpleJSON;
// using UnityEngine;
//
// namespace NBF
// {
// public class Game : MonoBehaviour
// {
// public static Game Instance { get; private set; }
//
//
// private static Scene _scene;
// public static Scene Main => _scene;
//
// private static cfg.Tables _tables;
// public static cfg.Tables Tables => _tables;
// private static event Action OnInitialized;
// public static event Action OnUpdate;
// public static event Action OnLateUpdate;
// public static event Action OnFixedUpdate;
// public static event Action OnApplicationQuitAction;
// public static event Action OnApplicationPauseAction;
//
//
// public static void SetInitCallback(GameObject root, Action callback = null)
// {
// if (Instance != null) return;
// root.AddComponent<Game>();
// OnInitialized += callback;
// // NBC_Fantasy_EntitySystemRegistrar
// }
//
// private void Awake()
// {
// Instance = this;
// }
//
// private void Start()
// {
// StartAsync().Coroutine();
// }
//
// private void Update()
// {
// OnUpdate?.Invoke();
// }
//
// private void LateUpdate()
// {
// OnLateUpdate?.Invoke();
// }
//
// private void FixedUpdate()
// {
// OnFixedUpdate?.Invoke();
// }
//
// private void OnApplicationQuit()
// {
// OnApplicationQuitAction?.Invoke();
// }
//
// private void OnApplicationPause(bool pauseStatus)
// {
// OnApplicationPauseAction?.Invoke();
// }
//
// private void OnDestroy()
// {
// _scene?.Dispose();
// }
//
// private async FTask StartAsync()
// {
// // 1. 初始化 Fantasy 框架
// await Fantasy.Platform.Unity.Entry.Initialize();
//
// // 2. 创建一个 Scene (客户端场景)
// // Scene 是 Fantasy 框架的核心容器,所有功能都在 Scene 下运行
// // SceneRuntimeMode.MainThread 表示在 Unity 主线程运行
// _scene = await Scene.Create(SceneRuntimeMode.MainThread);
//
// LoadData();
//
// OnInitialized?.Invoke();
// }
//
//
// #region Config
//
// private void LoadData()
// {
// // 一行代码可以加载所有配置。 cfg.Tables 包含所有表的一个实例字段。
// _tables = new cfg.Tables(LoadJson);
// }
//
// private static JSONNode LoadJson(string file)
// {
// //var json = File.ReadAllText($"{your_json_dir}/{file}.json", System.Text.Encoding.UTF8);
// //Assets/ResRaw/config/tb/tbbait.json
// //var jsonAsset = Assets.Load<TextAsset>($"Assets/ResRaw/config/tb/{file}.json");
// // return JSON.Parse(jsonAsset.text);
// return string.Empty;
// }
// #endregion
//
//
// // 判断是否是系统程序集(可选优化)
// private static bool IsSystemAssembly(System.Reflection.Assembly assembly)
// {
// string assemblyName = assembly.FullName;
// return assemblyName.StartsWith("System") ||
// assemblyName.StartsWith("Microsoft.") ||
// assemblyName.StartsWith("UnityEngine") ||
// assemblyName.StartsWith("UnityEditor") ||
// assemblyName.StartsWith("mscorlib") ||
// assemblyName.StartsWith("netstandard") ||
// assemblyName.StartsWith("nunit.") ||
// assemblyName.StartsWith("Unity.");
// }
// }
// }