Expose legacy catalog as read port

This commit is contained in:
Meta Vens 2026-06-13 07:41:21 +01:00
commit c9f6002ff2
9 changed files with 42 additions and 34 deletions

View file

@ -234,7 +234,7 @@ public class ActionGameManager : MonoBehaviour
Debug.Log($"Aetheria typed state file: {AetheriaStateFilePath}");
Debug.Log($"Aetheria legacy item catalog: {LegacyAetherDatabasePath}");
ItemManager = new ItemManager(
LegacyCatalogBoundary.GetCatalogCache(GameDataDirectory),
LegacyCatalogBoundary.GetCatalog(GameDataDirectory),
Settings.GameplaySettings,
Debug.Log);
ZoneRenderer.ItemManager = ItemManager;

View file

@ -14,7 +14,7 @@ public static class LegacyCatalogBoundary
return Path.Combine(gameDataDirectory.FullName, "AetherDB.msgpack");
}
public static LegacyCatalogCache GetCatalogCache(DirectoryInfo gameDataDirectory)
public static ILegacyCatalogReader GetCatalog(DirectoryInfo gameDataDirectory)
{
if (_catalogCache != null) return _catalogCache;

View file

@ -78,21 +78,21 @@ public class DatabaseLinkBase
public Guid LinkID;
[IgnoreMember]
private static LegacyCatalogCache CatalogCache { get; set; }
private static ILegacyCatalogReader Catalog { get; set; }
protected static T ResolveLegacyCatalog<T>(Guid linkId) where T : DatabaseEntry
{
if (CatalogCache == null)
if (Catalog == null)
throw new InvalidOperationException("Legacy DatabaseLink resolution is not bound. Open LegacyCatalogBoundary before reading legacy catalog object graphs.");
return CatalogCache.Get<T>(linkId);
return Catalog.Get<T>(linkId);
}
public static void BindLegacyCatalog(LegacyCatalogCache cache)
public static void BindLegacyCatalog(ILegacyCatalogReader catalog)
{
if (cache == null) throw new ArgumentNullException(nameof(cache));
if (catalog == null) throw new ArgumentNullException(nameof(catalog));
CatalogCache = cache;
Catalog = catalog;
}
}

View file

@ -10,7 +10,14 @@ using System.Reflection;
using MessagePack;
using UniRx;
public class LegacyCatalogCache
public interface ILegacyCatalogReader
{
DatabaseEntry Get(Guid guid);
T Get<T>(Guid guid) where T : DatabaseEntry;
IEnumerable<T> GetAll<T>() where T : DatabaseEntry;
}
public class LegacyCatalogCache : ILegacyCatalogReader
{
private readonly object addLock = new object();

View file

@ -32,7 +32,7 @@ public class Galaxy
private HashSet<Guid> _containedFactions;
private GalaxyZone[] _exitPath;
private Dictionary<Faction, MarkovNameGenerator> _nameGenerators = new Dictionary<Faction, MarkovNameGenerator>();
private readonly LegacyCatalogCache _cache;
private readonly ILegacyCatalogReader _catalog;
public GalaxyZone[] ExitPath
{
@ -48,16 +48,16 @@ public class Galaxy
SectorGenerationSettings settings,
SectorBackgroundSettings background,
NameGeneratorSettings nameGeneratorSettings,
LegacyCatalogCache cache,
ILegacyCatalogReader catalog,
Action<string> log,
Action<string> progressCallback = null,
uint seed = 0)
{
_cache = cache;
_catalog = catalog;
IsPrelude = false;
Background = background;
Log = log;
var factions = cache.GetAll<Faction>();
var factions = catalog.GetAll<Faction>();
var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed);
Factions = factions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
foreach (var f in Factions) FactionRelationships[f] = FactionRelationship.Neutral;
@ -81,7 +81,7 @@ public class Galaxy
CalculateFactionInfluence(progressCallback);
GenerateNames(cache, nameGeneratorSettings, ref random, progressCallback);
GenerateNames(catalog, nameGeneratorSettings, ref random, progressCallback);
progressCallback?.Invoke("Done!");
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
@ -89,21 +89,21 @@ public class Galaxy
public Faction ResolveFaction(string name)
{
return _cache.GetAll<Faction>().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
return _catalog.GetAll<Faction>().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
}
public Galaxy(
TutorialGenerationSettings settings,
SectorBackgroundSettings background,
NameGeneratorSettings nameGeneratorSettings,
LegacyCatalogCache cache,
ILegacyCatalogReader catalog,
PlayerSettings playerSettings,
DirectoryInfo narrativeDirectory,
Action<string> log,
Action<string> progressCallback = null,
uint seed = 0)
{
_cache = cache;
_catalog = catalog;
IsPrelude = true;
Background = background;
@ -189,7 +189,7 @@ public class Galaxy
CalculateFactionInfluence(progressCallback);
GenerateNames(cache, nameGeneratorSettings, ref random, progressCallback);
GenerateNames(catalog, nameGeneratorSettings, ref random, progressCallback);
// progressCallback?.Invoke("Weaving Narrative");
// var processor = new StoryProcessor(playerSettings, narrativeDirectory, this, ref random, Log);
@ -280,7 +280,7 @@ public class Galaxy
}
}
private void GenerateNames(LegacyCatalogCache cache,
private void GenerateNames(ILegacyCatalogReader catalog,
NameGeneratorSettings nameGeneratorSettings,
ref Random random,
Action<string> progressCallback = null)
@ -290,7 +290,7 @@ public class Galaxy
progressCallback?.Invoke($"Feeding Markov Chains: {i + 1} / {Factions.Length}");
//if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao
var faction = Factions[i];
_nameGenerators[faction] = new MarkovNameGenerator(ref random, cache.Get<NameFile>(faction.GeonameFile).Names, nameGeneratorSettings);
_nameGenerators[faction] = new MarkovNameGenerator(ref random, catalog.Get<NameFile>(faction.GeonameFile).Names, nameGeneratorSettings);
}
// Generate zone name using the owner's name generator, otherwise assign catalogue ID

View file

@ -31,7 +31,7 @@ public class ItemManager
// private Guid _forceLoadZone;
// public GlobalData GlobalData => _globalData ?? (_globalData = ItemData.GetAll<GlobalData>().FirstOrDefault());
public LegacyCatalogCache ItemData { get; }
public ILegacyCatalogReader ItemData { get; }
public GameplaySettings GameplaySettings { get; }
// public double Time
@ -47,7 +47,7 @@ public class ItemManager
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
public ItemManager(LegacyCatalogCache itemData, GameplaySettings settings, Action<string> logger)
public ItemManager(ILegacyCatalogReader itemData, GameplaySettings settings, Action<string> logger)
{
ItemData = itemData;
GameplaySettings = settings;

View file

@ -117,7 +117,7 @@ public class MainMenu : MonoBehaviour
Settings.SectorGenerationSettings,
Settings.SectorBackgroundSettings,
Settings.NameGeneratorSettings,
LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory),
LegacyCatalogBoundary.GetCatalog(ActionGameManager.GameDataDirectory),
Debug.Log,
setState);
Observable.NextFrame().Subscribe(_ =>
@ -143,7 +143,7 @@ public class MainMenu : MonoBehaviour
Settings.TutorialGenerationSettings,
Settings.TutorialBackgroundSettings,
Settings.NameGeneratorSettings,
LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory),
LegacyCatalogBoundary.GetCatalog(ActionGameManager.GameDataDirectory),
ActionGameManager.PlayerSettings,
ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"),
Debug.Log,

View file

@ -390,7 +390,7 @@ public class PropertiesPanel : MonoBehaviour
AddProperty("Quantity", () => simpleCommodity.Quantity.ToString());
var sheet = AddStatSheet();
var manufacturer = LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory).Get<Faction>(data.Manufacturer);
var manufacturer = LegacyCatalogBoundary.GetCatalog(ActionGameManager.GameDataDirectory).Get<Faction>(data.Manufacturer);
sheet.AddStat("Manufacturer", () => manufacturer?.Name ?? "GameCult");
sheet.AddStat("Mass", () => ActionGameManager.PlayerSettings.Format(GameManager.ItemManager.GetMass(item)));

View file

@ -32,13 +32,14 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
`GameData/KeyboardLayouts/*.msgpack` authority paths are disabled or deleted.
The old `SavedGame`/`SavedZone` DTOs and `Galaxy` save-loader constructor are
deleted.
- `LegacyCatalogBoundary` opens `LegacyCatalogCache` as a pull-only catalog
cache. Old MessagePack backing stores may hydrate in-memory domain objects
for the current Unity runtime, but this path cannot push or delete legacy
files. The legacy backing-store write/realtime APIs and public cache mutation
methods have been deleted; only backing-store pull hydration can populate it.
The backing-store serializer methods are also deleted, so the legacy cache
interface exposes deserialization only.
- `LegacyCatalogBoundary` opens `LegacyCatalogCache` as the only concrete
pull-only catalog cache. Runtime consumers receive `ILegacyCatalogReader`,
so old MessagePack backing stores may hydrate in-memory domain objects for
the current Unity runtime, but this path cannot push or delete legacy files.
The legacy backing-store write/realtime APIs and public cache mutation methods
have been deleted; only backing-store pull hydration can populate it. The
backing-store serializer methods are also deleted, so the legacy cache
implementation exposes deserialization only.
- `DatabaseLink<T>.Value` can resolve legacy links only after
`LegacyCatalogBoundary` binds the pull-only catalog cache. Legacy catalog
construction no longer grabs global `DatabaseLinkBase` authority.
@ -93,8 +94,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
- Owner: `Aetheria.State` owns the new typed state spine for durable state.
`LegacyCatalogBoundary` is the only named owner for old MessagePack catalog
reads and legacy `DatabaseLink<T>` resolution inside the Unity runtime until
catalog migration lands. The legacy cache no longer has a public mutation
surface.
catalog migration lands. Runtime code receives `ILegacyCatalogReader`, not the
concrete cache. The legacy cache no longer has a public mutation surface.
- Inputs: Unity gameplay code, legacy catalog files, typed state documents, and
CultMesh server state.
- Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy