Isolate legacy catalog boundary
This commit is contained in:
parent
d3f07df8cc
commit
fd6aa1d280
6 changed files with 56 additions and 40 deletions
|
|
@ -23,7 +23,6 @@ using UnityEngine.EventSystems;
|
|||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
using float3 = Unity.Mathematics.float3;
|
||||
using Path = System.IO.Path;
|
||||
using quaternion = Unity.Mathematics.quaternion;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
|
|
@ -37,33 +36,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
get => _gameDataDirectory ??= new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
}
|
||||
|
||||
public static string AetheriaStateFilePath => Path.Combine(GameDataDirectory.FullName, "aetheria-world.cc");
|
||||
public static string LegacyAetherDatabasePath => Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack");
|
||||
|
||||
private static CultCache _legacyCultCache;
|
||||
|
||||
public static CultCache LegacyCultCache
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_legacyCultCache != null) return _legacyCultCache;
|
||||
|
||||
_legacyCultCache = new CultCache();
|
||||
_legacyCultCache.AddBackingStore(
|
||||
new SingleFileMessagePackBackingStore(LegacyAetherDatabasePath));
|
||||
|
||||
// Particularly heavy objects should be stored in / retrieved from MsgPack files as it's much tighter than JSON
|
||||
// Such as NameFiles, which are just huge collections of geonames used to condition Markov chains
|
||||
_legacyCultCache.AddBackingStore(new MultiFileMessagePackBackingStore(GameDataDirectory.FullName), typeof(NameFile));
|
||||
|
||||
_legacyCultCache.PullAllBackingStores();
|
||||
|
||||
return _legacyCultCache;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use LegacyCultCache only for migration-era catalog reads. Live state belongs in GameData/aetheria-world.cc through Aetheria.State.")]
|
||||
public static CultCache CultCache => LegacyCultCache;
|
||||
public static string AetheriaStateFilePath => LegacyCatalogBoundary.GetStateFilePath(GameDataDirectory);
|
||||
public static string LegacyAetherDatabasePath => LegacyCatalogBoundary.GetLegacyCatalogPath(GameDataDirectory);
|
||||
|
||||
private static PlayerSettings _playerSettings;
|
||||
public static PlayerSettings PlayerSettings
|
||||
|
|
@ -261,7 +235,10 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
Debug.Log($"Aetheria typed state file: {AetheriaStateFilePath}");
|
||||
Debug.Log($"Aetheria legacy item catalog: {LegacyAetherDatabasePath}");
|
||||
ItemManager = new ItemManager(LegacyCultCache, Settings.GameplaySettings, Debug.Log);
|
||||
ItemManager = new ItemManager(
|
||||
LegacyCatalogBoundary.GetCatalogCache(GameDataDirectory),
|
||||
Settings.GameplaySettings,
|
||||
Debug.Log);
|
||||
ZoneRenderer.ItemManager = ItemManager;
|
||||
|
||||
// If hiding minimap asteroids, turn them off to start with
|
||||
|
|
|
|||
27
Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs
Normal file
27
Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.IO;
|
||||
|
||||
public static class LegacyCatalogBoundary
|
||||
{
|
||||
private static CultCache _catalogCache;
|
||||
|
||||
public static string GetStateFilePath(DirectoryInfo gameDataDirectory)
|
||||
{
|
||||
return Path.Combine(gameDataDirectory.FullName, "aetheria-world.cc");
|
||||
}
|
||||
|
||||
public static string GetLegacyCatalogPath(DirectoryInfo gameDataDirectory)
|
||||
{
|
||||
return Path.Combine(gameDataDirectory.FullName, "AetherDB.msgpack");
|
||||
}
|
||||
|
||||
public static CultCache GetCatalogCache(DirectoryInfo gameDataDirectory)
|
||||
{
|
||||
if (_catalogCache != null) return _catalogCache;
|
||||
|
||||
_catalogCache = new CultCache();
|
||||
_catalogCache.AddBackingStore(new SingleFileMessagePackBackingStore(GetLegacyCatalogPath(gameDataDirectory)));
|
||||
_catalogCache.AddBackingStore(new MultiFileMessagePackBackingStore(gameDataDirectory.FullName), typeof(NameFile));
|
||||
_catalogCache.PullAllBackingStores();
|
||||
return _catalogCache;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs.meta
Normal file
11
Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f32bcbdbd7db4a3595f11f4540b90a3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -118,7 +118,7 @@ public class MainMenu : MonoBehaviour
|
|||
Settings.SectorGenerationSettings,
|
||||
Settings.SectorBackgroundSettings,
|
||||
Settings.NameGeneratorSettings,
|
||||
ActionGameManager.LegacyCultCache,
|
||||
LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory),
|
||||
Debug.Log,
|
||||
setState);
|
||||
Observable.NextFrame().Subscribe(_ =>
|
||||
|
|
@ -144,7 +144,7 @@ public class MainMenu : MonoBehaviour
|
|||
Settings.TutorialGenerationSettings,
|
||||
Settings.TutorialBackgroundSettings,
|
||||
Settings.NameGeneratorSettings,
|
||||
ActionGameManager.LegacyCultCache,
|
||||
LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory),
|
||||
ActionGameManager.PlayerSettings,
|
||||
ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"),
|
||||
Debug.Log,
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddProperty("Quantity", () => simpleCommodity.Quantity.ToString());
|
||||
|
||||
var sheet = AddStatSheet();
|
||||
var manufacturer = ActionGameManager.LegacyCultCache.Get<Faction>(data.Manufacturer);
|
||||
var manufacturer = LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory).Get<Faction>(data.Manufacturer);
|
||||
sheet.AddStat("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
sheet.AddStat("Mass", () => ActionGameManager.PlayerSettings.Format(GameManager.ItemManager.GetMass(item)));
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ local CultCache, and legacy UI paths should be migration-only or deleted.
|
|||
## Current Mechanism
|
||||
|
||||
- Unity client/runtime lives under `Assets/`. Gameplay still reads the legacy
|
||||
item/name catalog through `ActionGameManager.LegacyCultCache`, but local run
|
||||
saves, loadouts, player settings files, zone files, and generated keyboard
|
||||
layout caches no longer write bespoke durable files.
|
||||
item/name catalog through `LegacyCatalogBoundary`, but `ActionGameManager` no
|
||||
longer owns a global legacy cache. Local run saves, loadouts, player settings
|
||||
files, zone files, and generated keyboard layout caches no longer write
|
||||
bespoke durable files.
|
||||
- Shared domain state is still partly built around `DatabaseEntry`, GUID
|
||||
identity, MessagePack attributes, and static cache references. Newtonsoft,
|
||||
JsonKnownTypes, RethinkDB, LiteNetLib client transport, and the broken
|
||||
|
|
@ -65,8 +66,8 @@ local CultCache, and legacy UI paths should be migration-only or deleted.
|
|||
## Current Authority Map
|
||||
|
||||
- Owner: `Aetheria.State` owns the new typed state spine for durable state.
|
||||
`DatabaseEntry` plus old `CultCache` still own legacy catalog reads inside the
|
||||
Unity runtime until catalog migration lands.
|
||||
`LegacyCatalogBoundary` is the only named owner for old MessagePack catalog
|
||||
reads inside the Unity runtime until catalog migration lands.
|
||||
- Inputs: Unity gameplay code, legacy catalog files, typed state documents, and
|
||||
CultMesh server state.
|
||||
- Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy
|
||||
|
|
@ -80,9 +81,9 @@ local CultCache, and legacy UI paths should be migration-only or deleted.
|
|||
generated keyboard layout caches, and server-side `DatabaseCache` paths.
|
||||
- Shared paths: manual gameplay edits, editor edits, server updates, file load,
|
||||
file save, and migration all need to converge on one typed commit primitive.
|
||||
- Deletion line: no new behavior should be added to the old `DatabaseEntry`,
|
||||
legacy `CultCache`, or MessagePack catalog paths except bounded migration
|
||||
readers that emit typed `Aetheria.State` documents.
|
||||
- Deletion line: no new behavior should be added to `LegacyCatalogBoundary`, the
|
||||
old `DatabaseEntry`, legacy `CultCache`, or MessagePack catalog paths except
|
||||
bounded migration readers that emit typed `Aetheria.State` documents.
|
||||
|
||||
## Target Authority Map
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue