diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 113659591..7b27f0535 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index f8fc3ae62..5ec061f9a 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -102,6 +102,10 @@ Unity runtime commit DTOs now also carry typed `FactionKey` for loadout entities, run entity snapshots, and faction relationship state. The old `CorporationLegacyId` fields remain compatibility-only for older pending commits; current Unity projection does not write them. +`EntityConstructionBlueprint` also carries `FactionKey` now. Loadout restore and +entity construction resolve factions by typed key first, with the old GUID +field kept as compatibility for construction callers that have not yet been +lowered. Run checkpoint commit DTOs carry typed `OrbitKey`, `ParentOrbitKey`, and `BodyKey` for zone orbit/body snapshots. The old `OrbitLegacyId`, `ParentLegacyId`, and `BodyLegacyId` fields remain compatibility-only for older diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index c1b961cb6..4019c2fc5 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -203,7 +203,8 @@ public class ActionGameManager : MonoBehaviour }; blueprint.Name = entity.Name; - blueprint.Faction = ParseLegacyGuidFromReferenceKey(entity.FactionKey, "aetheria.corporation"); + blueprint.FactionKey = entity.FactionKey ?? ""; + blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation"); blueprint.Hull = hull; blueprint.Equipment = CreateEquippableSlots(entity.Equipment); blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays); @@ -472,7 +473,7 @@ public class ActionGameManager : MonoBehaviour { Name = blueprint.Name ?? "", Kind = blueprint is ShipConstructionBlueprint ? "ship" : blueprint is OrbitalEntityConstructionBlueprint ? "orbital" : "entity", - FactionKey = CorporationKey(blueprint.Faction), + FactionKey = ReferenceKey(blueprint.FactionKey ?? "", "aetheria.corporation", LegacyId(blueprint.Faction)), Hull = ProjectLoadoutItem(blueprint.Hull), Equipment = ProjectSlots(blueprint.Equipment), CargoBays = ProjectSlots(blueprint.CargoBays), diff --git a/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs b/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs index 3de04d8be..edb11cd6b 100644 --- a/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs +++ b/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs @@ -30,6 +30,7 @@ public static class EntityConstructionBlueprintProjector blueprint.Hull = entity.Hull; blueprint.Name = entity.Name; blueprint.Faction = entity.Faction?.ID ?? Guid.Empty; + blueprint.FactionKey = entity.Faction?.FactionKey ?? CorporationKey(blueprint.Faction); blueprint.Equipment = entity.Equipment.Select(e => (e.Position, e.EquippableItem)).ToArray(); blueprint.CargoBays = entity.CargoBays.Select(e => (e.Position, e.EquippableItem)).ToArray(); blueprint.DockingBays = entity.DockingBays.Select(e => (e.Position, e.EquippableItem)).ToArray(); @@ -77,7 +78,7 @@ public static class EntityConstructionBlueprintProjector private static void Restore(ItemManager itemManager, Zone zone, EntityConstructionBlueprint blueprint, Entity entity, bool instantiate = false) { entity.Name = blueprint.Name; - entity.Faction = zone?.Galaxy?.ResolveFaction(blueprint.Faction); + entity.Faction = ResolveFaction(zone?.Galaxy, blueprint); entity.Children = blueprint.Children.Select(c => { var child = InstantiateFromBlueprint(itemManager, zone, c, instantiate); @@ -110,6 +111,18 @@ public static class EntityConstructionBlueprintProjector return (items.Select(i => i.GetBehavior()).ToList(), items.ToList()); }).ToArray(); } + + private static Faction ResolveFaction(Galaxy galaxy, EntityConstructionBlueprint blueprint) + { + return galaxy == null + ? null + : galaxy.ResolveFactionByKey(blueprint.FactionKey) ?? galaxy.ResolveFaction(blueprint.Faction); + } + + private static string CorporationKey(Guid id) + { + return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}"; + } } public class ShipConstructionBlueprint : EntityConstructionBlueprint @@ -140,6 +153,7 @@ public abstract class EntityConstructionBlueprint public EntityConstructionBlueprint[] Children; public EntitySettings Settings; public Guid Faction; + public string FactionKey; public int[][] WeaponGroups; private int _price; diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index f6212ee5e..b48bed494 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -915,9 +915,11 @@ First Aetheria surfaces to publish: - 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. - - Done: move entity faction restore to `Galaxy.ResolveFaction`, so legacy - `Faction` catalog entries no longer decide runtime faction references - after generation. + - Done: move entity faction restore to `Galaxy.ResolveFactionByKey` through + `EntityConstructionBlueprint.FactionKey`, so typed loadout readback and + entity construction resolve corporation identity by typed key first. The + old blueprint `Faction` GUID remains compatibility/fallback for callers + that have not yet been lowered. - Done: move package and canonical manufacturer/corporation/name-file lookup to typed keys (`ManufacturerKey`, `CorporationKey`, `GeonameFileKey`, and `NameFileKey`), and move loadout manufacturer-distance weighting to