AlicizaX/Client/Assets/Scripts/Hotfix/GameLogic/HotfixEntry.cs
2025-03-04 18:40:14 +08:00

69 lines
1.9 KiB
C#

using AlicizaX.Runtime;
using UnityEngine;
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using YooAsset;
using Cysharp.Threading.Tasks;
using Game.Config;
using Game.Config.Tables;
using Luban;
using UnityEngine.SceneManagement;
namespace GameLogic
{
public interface ITestEvent : IEvent
{
}
public static class HotfixEntry
{
private static TablesComponent tablesComponent;
private static List<Assembly> _hotfixAssembly;
public static List<Assembly> HotfixAssembly => _hotfixAssembly;
public static void Entrance(object[] objects)
{
Log.Info("HotFix Logic Entry!");
LoadConfig();
_hotfixAssembly = (List<Assembly>)objects[0];
new GameObject().AddComponent<TestMono>();
GameApp.Scene.LoadScene("Map1000", LoadSceneMode.Additive, false, 100, CallBack, false, ProgressCallBack);
}
private static void ProgressCallBack(float obj)
{
Log.Info(obj);
}
private static void CallBack(SceneHandle obj)
{
}
static async void LoadConfig()
{
tablesComponent = new TablesComponent();
tablesComponent.Init(GameApp.Config);
await tablesComponent.LoadAsync(ConfigBufferLoader);
}
/// <summary>
/// 加载二进制配置表
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
private static async Task<ByteBuf> ConfigBufferLoader(string file)
{
var textAsset = await GameApp.Resource.LoadAssetAsync<TextAsset>(file);
byte[] bytes = textAsset.bytes;
GameApp.Resource.UnloadAsset(textAsset);
return ByteBuf.Wrap(bytes);
}
}
}