FindRoot keys on GameData/Aetheria.cc. ShipAuthoringStore.RequireShipId is the one ID rule (Validate and create), refusing Windows device names and a trailing dot, naming no value. The add-on's one preference is Game folder; _aetheria_repo, the repo preference and the dotnet-run invocation are deleted. Smokes take SMOKE_GAME_FOLDER. Not yet built or tested at this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using GameCult.Caching;
|
|
|
|
// Opens GameData/Aetheria.cc through AetheriaStores, the game's own store composition. The catalog attaches read-only
|
|
// unless a command writes it, so a command that only reads cannot write.
|
|
public sealed class AetherDb
|
|
{
|
|
public string Root { get; }
|
|
public CultCache Cache { get; }
|
|
|
|
private AetherDb(string root, bool catalogWritable, bool withRun)
|
|
{
|
|
Root = root;
|
|
var gameData = Path.Combine(root, "GameData");
|
|
Cache = AetheriaStores.Open(
|
|
Path.Combine(gameData, "Aetheria.cc"),
|
|
runPath: withRun ? Path.Combine(gameData, "run.cc") : null,
|
|
catalogWritable: catalogWritable);
|
|
}
|
|
|
|
// With no root given, walks up from the working directory to the game folder: the first folder whose GameData holds Aetheria.cc
|
|
public static AetherDb Open(bool catalogWritable = false, bool withRun = false, string root = null) =>
|
|
new AetherDb(root ?? FindRoot(), catalogWritable, withRun);
|
|
|
|
public static string FindRoot()
|
|
{
|
|
for (var dir = new DirectoryInfo(Environment.CurrentDirectory); dir != null; dir = dir.Parent)
|
|
if (File.Exists(Path.Combine(dir.FullName, "GameData", "Aetheria.cc")))
|
|
return dir.FullName;
|
|
throw new DirectoryNotFoundException("Run from a folder whose GameData holds Aetheria.cc.");
|
|
}
|
|
}
|