mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
修改luban模板配置,支持异步加载配置实例,客户端使用UniTask异步加载配置,避免WebGL不支持原生Task
修改luban模板配置,支持异步加载配置实例,客户端使用UniTask异步加载配置,避免WebGL不支持原生Task
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Bright.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using GameBase;
|
||||
using GameConfig;
|
||||
@@ -34,7 +33,7 @@ public class ConfigLoader:Singleton<ConfigLoader>
|
||||
/// <summary>
|
||||
/// 异步加载配置。
|
||||
/// </summary>
|
||||
public async Task LoadAsync()
|
||||
public async UniTask LoadAsync()
|
||||
{
|
||||
_tables = new Tables();
|
||||
await _tables.LoadAsync(LoadByteBufAsync);
|
||||
@@ -46,7 +45,7 @@ public class ConfigLoader:Singleton<ConfigLoader>
|
||||
/// </summary>
|
||||
/// <param name="file">FileName</param>
|
||||
/// <returns>ByteBuf</returns>
|
||||
private async Task<ByteBuf> LoadByteBufAsync(string file)
|
||||
private async UniTask<ByteBuf> LoadByteBufAsync(string file)
|
||||
{
|
||||
#if false
|
||||
GameTickWatcher gameTickWatcher = new GameTickWatcher();
|
||||
|
@@ -6,7 +6,8 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace GameConfig
|
||||
@@ -21,17 +22,32 @@ public sealed class Tables
|
||||
|
||||
public Tables() { }
|
||||
|
||||
public async Task LoadAsync(System.Func<string, Task<ByteBuf>> loader)
|
||||
public async UniTask LoadAsync(System.Func<string, UniTask<ByteBuf>> loader)
|
||||
{
|
||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||
TbItem = new item.TbItem(await loader("item_tbitem"));
|
||||
tables.Add("item.TbItem", TbItem);
|
||||
TbSkill = new Battle.TbSkill(await loader("battle_tbskill"));
|
||||
tables.Add("Battle.TbSkill", TbSkill);
|
||||
TbBuff = new Battle.TbBuff(await loader("battle_tbbuff"));
|
||||
tables.Add("Battle.TbBuff", TbBuff);
|
||||
TbBuffAttr = new Battle.TbBuffAttr(await loader("battle_tbbuffattr"));
|
||||
tables.Add("Battle.TbBuffAttr", TbBuffAttr);
|
||||
List<UniTask> list = new List<UniTask>();
|
||||
list.Add(UniTask.Create(async () =>
|
||||
{
|
||||
TbItem = new item.TbItem(await loader("item_tbitem"));
|
||||
tables.Add("item.TbItem", TbItem);
|
||||
}));
|
||||
list.Add(UniTask.Create(async () =>
|
||||
{
|
||||
TbSkill = new Battle.TbSkill(await loader("battle_tbskill"));
|
||||
tables.Add("Battle.TbSkill", TbSkill);
|
||||
}));
|
||||
list.Add(UniTask.Create(async () =>
|
||||
{
|
||||
TbBuff = new Battle.TbBuff(await loader("battle_tbbuff"));
|
||||
tables.Add("Battle.TbBuff", TbBuff);
|
||||
}));
|
||||
list.Add(UniTask.Create(async () =>
|
||||
{
|
||||
TbBuffAttr = new Battle.TbBuffAttr(await loader("battle_tbbuffattr"));
|
||||
tables.Add("Battle.TbBuffAttr", TbBuffAttr);
|
||||
}));
|
||||
|
||||
await UniTask.WhenAll(list);
|
||||
|
||||
TbItem.Resolve(tables);
|
||||
TbSkill.Resolve(tables);
|
||||
|
Reference in New Issue
Block a user