Traveller/scripts/loot/LootListManager.cs
2024-06-16 22:44:50 +08:00

47 lines
1.3 KiB
C#

using System.Collections.Generic;
namespace ColdMint.scripts.loot;
/// <summary>
/// <para>LootListManager</para>
/// <para>战利品表管理器</para>
/// </summary>
public static class LootListManager
{
private static Dictionary<string, LootList> LootListDictionary { get; } = [];
/// <summary>
/// <para>Register loot table</para>
/// <para>注册战利品表</para>
/// </summary>
/// <param name="lootList"></param>
public static bool RegisterLootList(LootList lootList)
{
var id = lootList.Id;
if (id is "") return false;
return LootListDictionary.TryAdd(id, lootList);
}
/// <summary>
/// <para>Remove loot list</para>
/// <para>移除战利品表</para>
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static bool UnregisterLootList(string id)
{
return LootListDictionary.Remove(id);
}
/// <summary>
/// <para>Generate an loot data.</para>
/// <para>获取掉落物品</para>
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static IEnumerable<LootDatum> GenerateLootData(string id)
{
if (!LootListDictionary.TryGetValue(id, out var list)) return [];
return list.GenerateLootData();
}
}