Use typed catalog for galaxy factions

This commit is contained in:
Meta Vens 2026-06-13 13:00:15 +01:00
commit 8b6c9e4294
5 changed files with 71 additions and 24 deletions

Binary file not shown.

View file

@ -93,10 +93,12 @@ consumers, exposes typed behavior payload read models, and can read the
published Eve catalog surface. It does not deserialize legacy `DatabaseEntry`
objects and does not write state. Unity can use this as the first package
boundary once CultLib/Eve runtime packaging is available.
`Galaxy` now consumes this package-owned runtime catalog for name generation,
so generated zone names come from `aetheria.name_file.v2` records instead of
legacy `NameFile` documents. Faction selection still uses legacy `Faction`
objects until that domain model has a typed runtime replacement.
`Galaxy` now consumes this package-owned runtime catalog for faction selection
and name generation, so generated sectors use typed corporation and
`aetheria.name_file.v2` records instead of legacy `Faction`/`NameFile`
catalog documents. It still projects typed corporations into temporary
`Faction` DTOs because the surrounding simulation has not yet been rebuilt
around typed corporation records.
`Aetheria.State.Smoke` writes and reopens full typed player settings plus a
typed loadout template in addition to world, catalog, run state, zone state, and

View file

@ -33,8 +33,8 @@ public class Galaxy
private HashSet<Guid> _containedFactions;
private GalaxyZone[] _exitPath;
private Dictionary<Faction, MarkovNameGenerator> _nameGenerators = new Dictionary<Faction, MarkovNameGenerator>();
private readonly ItemManager _itemManager;
private readonly AetheriaRuntimeCatalogSnapshot _runtimeCatalog;
private readonly Faction[] _allFactions;
public GalaxyZone[] ExitPath
{
@ -50,20 +50,18 @@ public class Galaxy
SectorGenerationSettings settings,
SectorBackgroundSettings background,
NameGeneratorSettings nameGeneratorSettings,
ItemManager itemManager,
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
Action<string> log,
Action<string> progressCallback = null,
uint seed = 0)
{
_itemManager = itemManager;
_runtimeCatalog = runtimeCatalog ?? throw new InvalidOperationException("Galaxy generation requires the typed Aetheria runtime catalog.");
_allFactions = ProjectFactions(_runtimeCatalog);
IsPrelude = false;
Background = background;
Log = log;
var factions = itemManager.GetCatalogEntries<Faction>();
var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed);
Factions = factions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
Factions = _allFactions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
foreach (var f in Factions) FactionRelationships[f] = FactionRelationship.Neutral;
Zones = GenerateZones(settings.ZoneCount, ref random, progressCallback);
@ -93,14 +91,19 @@ public class Galaxy
public Faction ResolveFaction(string name)
{
return _itemManager.GetCatalogEntries<Faction>().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
var faction = _allFactions.FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
if (faction == null)
{
throw new InvalidOperationException($"Typed catalog has no faction matching '{name}'.");
}
return faction;
}
public Galaxy(
TutorialGenerationSettings settings,
SectorBackgroundSettings background,
NameGeneratorSettings nameGeneratorSettings,
ItemManager itemManager,
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
PlayerSettings playerSettings,
DirectoryInfo narrativeDirectory,
@ -108,8 +111,8 @@ public class Galaxy
Action<string> progressCallback = null,
uint seed = 0)
{
_itemManager = itemManager;
_runtimeCatalog = runtimeCatalog ?? throw new InvalidOperationException("Galaxy generation requires the typed Aetheria runtime catalog.");
_allFactions = ProjectFactions(_runtimeCatalog);
IsPrelude = true;
Background = background;
@ -215,6 +218,48 @@ public class Galaxy
return outputSamples.Select(v => new GalaxyZone {Position = v}).ToArray();
}
private static Faction[] ProjectFactions(AetheriaRuntimeCatalogSnapshot runtimeCatalog)
{
var factions = runtimeCatalog.Corporations
.Select(ProjectFaction)
.ToArray();
if (factions.Length == 0)
{
throw new InvalidOperationException("Typed catalog has no factions for galaxy generation.");
}
return factions;
}
private static Faction ProjectFaction(AetheriaRuntimeCorporation corporation)
{
return new Faction
{
ID = ParseLegacyId(corporation.LegacyId, nameof(corporation.LegacyId), corporation.Name),
Name = corporation.Name,
ShortName = corporation.ShortName,
Description = corporation.Description,
GeonameFile = ParseLegacyId(corporation.GeonameFileLegacyId, nameof(corporation.GeonameFileLegacyId), corporation.Name),
BossHull = ParseOptionalLegacyId(corporation.BossHullLegacyId),
InfluenceDistance = corporation.InfluenceDistance,
};
}
private static Guid ParseLegacyId(string legacyId, string fieldName, string ownerName)
{
if (Guid.TryParse(legacyId, out var parsed) && parsed != Guid.Empty)
{
return parsed;
}
throw new InvalidOperationException($"Typed catalog corporation {ownerName} has invalid {fieldName} '{legacyId}'.");
}
private static Guid ParseOptionalLegacyId(string legacyId)
{
return Guid.TryParse(legacyId, out var parsed) ? parsed : Guid.Empty;
}
private void PlaceFactionsMain(int bossCount, Action<string> progressCallback = null)
{
progressCallback?.Invoke("Finding Chokepoints");

View file

@ -117,7 +117,6 @@ public class MainMenu : MonoBehaviour
Settings.SectorGenerationSettings,
Settings.SectorBackgroundSettings,
Settings.NameGeneratorSettings,
ActionGameManager.ItemManager,
ActionGameManager.RuntimeCatalog,
Debug.Log,
setState);
@ -144,7 +143,6 @@ public class MainMenu : MonoBehaviour
Settings.TutorialGenerationSettings,
Settings.TutorialBackgroundSettings,
Settings.NameGeneratorSettings,
ActionGameManager.ItemManager,
ActionGameManager.RuntimeCatalog,
ActionGameManager.PlayerSettings,
ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"),

View file

@ -92,12 +92,13 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
that only needs a domain lookup. The item properties UI no longer uses
`ItemManager` for manufacturer display; it resolves the manufacturer through
the package-owned `ActionGameManager.RuntimeCatalog` typed snapshot.
- `Galaxy` generation no longer accepts `ILegacyCatalogReader`. Sector and
tutorial generation still receive `ItemManager` for legacy `Faction` objects,
but name generation now receives the package-owned typed runtime catalog and
resolves full name arrays from `aetheria.name_file.v2` records. `ActionGameManager`
now has a private legacy catalog boot helper that feeds only `ItemManager`;
menu/generation paths no longer receive the legacy reader directly.
- `Galaxy` generation no longer accepts `ILegacyCatalogReader` or `ItemManager`.
Sector and tutorial generation receive the package-owned typed runtime
catalog. `Galaxy` projects typed corporation records into temporary legacy
`Faction` DTOs for the existing simulation shape and resolves full name
arrays from `aetheria.name_file.v2` records. `ActionGameManager` still has a
private legacy catalog boot helper that feeds `ItemManager` for item/entity
systems; menu/generation paths no longer receive the legacy reader directly.
- `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.
@ -177,8 +178,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
- The old IMGUI DB inspector under `Assets/Scripts/CultCache/Editor/` has been
deleted. `NameTools` can still clean/generate names, but legacy NameFile
`.msgpack` export is disabled.
- Galaxy name generation no longer reads legacy `NameFile` entries through
`ItemManager`; it requires the typed runtime catalog opened from
- Galaxy generation no longer reads legacy `Faction` or `NameFile` entries
through `ItemManager`; it requires the typed runtime catalog opened from
`GameData/aetheria-world.cc`.
- MessagePack is no longer used as a runtime object-cloning shortcut for
`EntitySettings`, and UI/player-settings startup no longer registers the old
@ -385,8 +386,9 @@ First Aetheria surfaces to publish:
- Done: add a Unity-facing typed catalog read facade and smoke proving it can
read the materialized `.cc` catalog plus Eve surface without the legacy
catalog reader.
- Done: move `Galaxy` name generation to the typed runtime catalog; legacy
`NameFile` entries no longer decide generated zone names.
- Done: move `Galaxy` faction selection and name generation to the typed
runtime catalog; legacy `Faction`/`NameFile` catalog entries no longer
decide generated sector factions or zone names.
- Replace `ActionGameManager` cache bootstrap with the new state runtime.
- Convert domain references from GUID/base-class patterns to typed record
refs.