Files
Continentis/Assets/Scripts/Global/CardDatabase.cs
SoulliesOfficial 9b1b5ca93f initial
2025-10-03 00:02:43 -04:00

35 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Continentis.MainGame.Card;
using SoulliesFramework.General;
using UnityEngine;
namespace Continentis
{
public class CardDatabase : Singleton<CardDatabase>
{
public Dictionary<string, CardData> cardDatabase;
protected override void Awake()
{
Initialize(true);
}
public async Task<IList<CardData>> CollectAllCardData()
{
IList<CardData> dataList = await AssetLoader.LoadAssetsWithLabelAsync<CardData>("CardData");
cardDatabase = new Dictionary<string, CardData>();
foreach (CardData data in dataList)
{
if (!cardDatabase.TryAdd(data.cardIdentifier, data))
{
Debug.LogWarning($"CardDatabase: Duplicate card ID found: {data.cardIdentifier}");
}
}
Debug.Log($"CardDatabase: Collected {cardDatabase.Count} cards.");
return dataList;
}
}
}