Bind legacy links through catalog boundary

This commit is contained in:
Meta Vens 2026-06-13 06:45:07 +01:00
commit 168a8cc517
7 changed files with 26 additions and 36 deletions

View file

@ -68,7 +68,7 @@ public abstract class DatabaseEntry
public class DatabaseLink<T> : DatabaseLinkBase where T : DatabaseEntry
{
[IgnoreMember]
public T Value => Cache.Get<T>(LinkID);
public T Value => ResolveLegacyCatalog<T>(LinkID);
}
[MessagePackObject]
@ -78,10 +78,27 @@ public class DatabaseLinkBase
public Guid LinkID;
[IgnoreMember]
public static CultCache Cache;
private static CultCache LegacyCatalogCache { get; set; }
protected static T ResolveLegacyCatalog<T>(Guid linkId) where T : DatabaseEntry
{
if (LegacyCatalogCache == null)
throw new InvalidOperationException("Legacy DatabaseLink resolution is not bound. Open LegacyCatalogBoundary before reading legacy catalog object graphs.");
return LegacyCatalogCache.Get<T>(linkId);
}
public static void BindLegacyCatalog(CultCache cache)
{
if (cache == null) throw new ArgumentNullException(nameof(cache));
if (!cache.ReadOnly)
throw new InvalidOperationException("Legacy DatabaseLink resolution requires a read-only catalog cache.");
LegacyCatalogCache = cache;
}
}
public interface ITintInspector
{
float3 TintColor { get; }
}
}