62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using System;
|
|
using BrewMonster.Scripts;
|
|
using Cysharp.Threading.Tasks;
|
|
using ModelRenderer.Scripts.GameData;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
public class ElementDataManProvider : IAutoInitialize
|
|
{
|
|
private static ElementDataManProvider _instance;
|
|
private elementdataman _elementDataMan;
|
|
|
|
public static elementdataman GetElementDataMan()
|
|
{
|
|
return _instance._elementDataMan;
|
|
}
|
|
|
|
public async void Initialize()
|
|
{
|
|
await InitializeInternal();
|
|
}
|
|
|
|
public async UniTask InitializeInternal()
|
|
{
|
|
_elementDataMan = new();
|
|
_instance = this;
|
|
|
|
try
|
|
{
|
|
while (!AddressableManager.Instance.IsInitialized())
|
|
{
|
|
await UniTask.DelayFrame(1);
|
|
}
|
|
var result = await _elementDataMan.load_data();
|
|
//TODO: this is for testing. move it to other place
|
|
itemdataman.load_data("",false);
|
|
if (result == -1)
|
|
{
|
|
BMLogger.LogError("ElementDataManProvider: Failed to load element data");
|
|
}
|
|
else
|
|
{
|
|
BMLogger.Log("ElementDataManProvider: Successfully loaded element data");
|
|
// Build suite equip tab now that data is loaded
|
|
// 数据加载完成后构建套装装备表
|
|
BrewMonster.Network.EC_Game.BuildSuiteEquipTab();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BMLogger.LogError($"ElementDataManProvider: Failed to load element data: {ex} - {ex.StackTrace}");
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_elementDataMan = null;
|
|
_instance = null;
|
|
}
|
|
}
|
|
} |