Resolve blueprint factions by typed key
This commit is contained in:
parent
7f87373886
commit
3a57b9b7d6
5 changed files with 27 additions and 6 deletions
Binary file not shown.
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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<Weapon>()).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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue