40 lines
1.2 KiB
C#
Raw Normal View History

2024-10-17 03:20:22 +08:00
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using GameConfig;
// using HotScripts.GameLauncher;
using JNGame.Runtime.System;
using Luban;
using SHFrame;
using UnityEngine;
using YooAsset;
namespace HotScripts.GameScripts.Luban
{
public class LubanManager : SystemBase
{
private Tables _tables;
public Tables Tables => _tables;
public override async Task OnInit()
{
await UniTask.DelayFrame(1);
Log.Debug($"配置文件 初始化中");
// App.EventLauncher.DispatchEvent(HotLauncherEvent.InitSystem,$"配置文件 初始化中");
_tables = new Tables(LoadByteBuf);
Log.Debug($"配置文件 初始化完成 {Tables.TbGMap.DataList[0].MapName}");
}
/// <summary>
/// 加载二进制配置。
/// </summary>
/// <param name="file">FileName</param>
/// <returns>ByteBuf</returns>
private ByteBuf LoadByteBuf(string file)
{
var handle = YooAssets.LoadAssetSync<TextAsset>(file);
return new ByteBuf((handle.AssetObject as TextAsset)?.bytes);
}
}
}