2026-06-13 14:36:54 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using GameCult.Aetheria.State.Unity;
|
|
|
|
|
|
2026-06-14 09:19:53 +01:00
|
|
|
public interface IRuntimeItemCatalogReader
|
2026-06-13 14:36:54 +01:00
|
|
|
{
|
2026-06-14 04:35:51 +01:00
|
|
|
AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid);
|
2026-06-13 14:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
2026-06-14 09:19:53 +01:00
|
|
|
public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
|
2026-06-13 14:36:54 +01:00
|
|
|
{
|
2026-06-14 04:35:51 +01:00
|
|
|
private readonly Dictionary<Guid, AetheriaRuntimeCatalogItem> _typedItems;
|
2026-06-13 14:36:54 +01:00
|
|
|
|
|
|
|
|
public AetheriaRuntimeItemCatalog(AetheriaRuntimeCatalogSnapshot catalog)
|
|
|
|
|
{
|
|
|
|
|
if (catalog == null) throw new ArgumentNullException(nameof(catalog));
|
|
|
|
|
|
2026-06-14 04:35:51 +01:00
|
|
|
_typedItems = catalog.Items
|
|
|
|
|
.Where(item => Guid.TryParse(item.LegacyId, out _))
|
|
|
|
|
.ToDictionary(item => Guid.Parse(item.LegacyId), item => item);
|
2026-06-13 14:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
2026-06-14 04:35:51 +01:00
|
|
|
public AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid)
|
|
|
|
|
{
|
|
|
|
|
_typedItems.TryGetValue(guid, out var item);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2026-06-13 14:36:54 +01:00
|
|
|
}
|