Bind legacy links through catalog boundary
This commit is contained in:
parent
1872b2ec0b
commit
168a8cc517
7 changed files with 26 additions and 36 deletions
|
|
@ -54,8 +54,6 @@ public class CultCache
|
|||
public CultCache(bool readOnly = false)
|
||||
{
|
||||
ReadOnly = readOnly;
|
||||
DatabaseLinkBase.Cache = this;
|
||||
|
||||
foreach (var type in typeof(DatabaseEntry).GetAllChildClasses())
|
||||
{
|
||||
_types[type] = new HashSet<DatabaseEntry>();
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a8fce60db4f3e614c8d19c3da4cede0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue