AlicizaX/Client/Assets/Scripts/Hotfix/GameLogic/HotfixEntry.cs

67 lines
1.8 KiB
C#
Raw Normal View History

2025-01-23 19:06:48 +08:00
using AlicizaX.Runtime;
using UnityEngine;
using System;
using System.IO;
using System.Collections;
using System.Threading.Tasks;
using YooAsset;
using Cysharp.Threading.Tasks;
using Game.Config;
using Game.Config.Tables;
using Luban;
namespace GameLogic
{
public static class HotfixEntry
{
private static TablesComponent tablesComponent;
public static void Entrance(object[] objects)
{
Log.Info("HotFix Logic Entry!");
Log.Info("热更222!");
LoadConfig();
TestLog().Forget();
}
static async UniTaskVoid TestLog()
{
await UniTask.Delay(2000);
tablesComponent.SetTranslateText(TranslateText);
Log.Debug(GameApp.Config.GetConfig<TbAchievement>().FirstOrDefault);
}
static async void LoadConfig()
{
tablesComponent = new TablesComponent();
tablesComponent.Init(GameApp.Config);
await tablesComponent.LoadAsync(ConfigBufferLoader);
}
private static string TranslateText(string key, string content)
{
var localization = GameApp.Config.GetConfig<TbLocalization>().Get(key);
if (localization == null)
{
Debug.Log(key + "--" + content);
return key;
}
return localization.ChineseSimplified;
}
/// <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);
}
}
}