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)));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue