Use typed faction keys in runtime commits

This commit is contained in:
Meta Vens 2026-06-15 16:21:31 +01:00
commit 7e64db7e20
6 changed files with 33 additions and 10 deletions

Binary file not shown.

View file

@ -177,7 +177,7 @@ try
{
Name = "Unity Smoke Ship",
Kind = "ship",
CorporationLegacyId = "smoke:faction",
FactionKey = "aetheria.corporation:legacy:smoke:faction",
Hull = new AetheriaRuntimeLoadoutItemCommit
{
ItemKey = "aetheria.item_definition:legacy:smoke:hull",
@ -252,7 +252,7 @@ try
{
new AetheriaRuntimeFactionRelationshipCommit
{
CorporationLegacyId = "smoke:faction",
FactionKey = "aetheria.corporation:legacy:smoke:faction",
Relationship = "Friendly",
Standing = 3
}
@ -334,6 +334,7 @@ try
PositionZ = 3.0,
DirectionX = 0.0,
DirectionY = 1.0,
FactionKey = "aetheria.corporation:legacy:smoke:faction",
VelocityX = 4.0,
VelocityY = -2.0,
TargetEntityIndex = 0,
@ -678,6 +679,7 @@ try
settings.Input.ActionBarInputs.Length == 1 &&
loadout?.Name == "Unity Smoke Loadout" &&
loadout.RootEntity.Hull.ItemKey == "aetheria.item_definition:legacy:smoke:hull" &&
loadout.RootEntity.FactionKey == "aetheria.corporation:legacy:smoke:faction" &&
loadout.RootEntity.Equipment.Length == 1 &&
loadout.RootEntity.Equipment[0].Position.X == 1 &&
!loadout.RootEntity.Equipment[0].Item.Enabled &&
@ -713,6 +715,7 @@ try
zone.Bodies[0].Asteroids[0].MiningAccumulators[0].MinerEntityKey == "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" &&
zone.Bodies[0].Asteroids[0].MiningAccumulators[0].Amount == 0.75 &&
entity?.Equipment.Length == 1 &&
entity.FactionKey == "aetheria.corporation:legacy:smoke:faction" &&
entity.Equipment[0].Quality == 0.9 &&
entity.Equipment[0].Durability == 0.8 &&
entity.Equipment[0].Quantity == 1 &&
@ -830,6 +833,7 @@ try
packageSettings.ActionBarInputs.Count != 1 ||
packageLoadouts.Count != 1 ||
packageLoadouts[0].RootEntity.Hull.ItemKey != "aetheria.item_definition:legacy:smoke:hull" ||
packageLoadouts[0].RootEntity.FactionKey != "aetheria.corporation:legacy:smoke:faction" ||
packageLoadouts[0].RootEntity.Equipment[0].X != 1 ||
packageLoadouts[0].RootEntity.Equipment[0].Item.Enabled ||
packageLoadouts[0].RootEntity.CargoContents[0].Items[0].Item.Quantity != 5 ||
@ -854,6 +858,7 @@ try
packageZones[0].Bodies[0].AsteroidMiningAccumulatorCount != 1 ||
packageEntities.Count != 1 ||
packageEntities[0].Name != "Unity Smoke Ship" ||
packageEntities[0].FactionKey != "aetheria.corporation:legacy:smoke:faction" ||
packageEntities[0].Equipment[0].Quality != 0.9 ||
packageEntities[0].Equipment[0].Durability != 0.8 ||
packageEntities[0].Equipment[0].Quantity != 1 ||

View file

@ -144,7 +144,7 @@ public static class AetheriaRuntimeCommitLogApplier
{
Name = entity.Name ?? "",
Kind = entity.Kind ?? "",
FactionKey = ReferenceKey("aetheria.corporation", entity.CorporationLegacyId ?? ""),
FactionKey = ReferenceKey(entity.FactionKey ?? "", "aetheria.corporation", entity.CorporationLegacyId ?? ""),
Hull = ToLoadoutItem(entity.Hull),
Equipment = ToItemSlots(entity.Equipment),
CargoBays = ToItemSlots(entity.CargoBays),
@ -463,7 +463,7 @@ public static class AetheriaRuntimeCommitLogApplier
TractorPower = entity.TractorPower,
Heatstroke = entity.Heatstroke,
Hypothermia = entity.Hypothermia,
FactionKey = ReferenceKey("aetheria.corporation", entity.CorporationLegacyId ?? ""),
FactionKey = ReferenceKey(entity.FactionKey ?? "", "aetheria.corporation", entity.CorporationLegacyId ?? ""),
HullItemKey = entity.HullItemKey ?? "",
Equipment = ToEntityItemSlots(entity.Equipment),
CargoBays = ToEntityItemSlots(entity.CargoBays),
@ -680,7 +680,7 @@ public static class AetheriaRuntimeCommitLogApplier
return (relationships ?? Array.Empty<AetheriaRuntimeFactionRelationshipCommit>())
.Select(relationship => new AetheriaFactionRelationshipState
{
FactionKey = ReferenceKey("aetheria.corporation", relationship.CorporationLegacyId ?? ""),
FactionKey = ReferenceKey(relationship.FactionKey ?? "", "aetheria.corporation", relationship.CorporationLegacyId ?? ""),
Relationship = relationship.Relationship ?? "",
Standing = relationship.Standing
})

View file

@ -98,6 +98,10 @@ Unity runtime commit DTOs carry typed `ItemKey`/`HullItemKey` fields only for
loadout items, action-bar targets, body resources, entity hulls, and active
consumables; the commit applier no longer reconstructs item keys from legacy
item GUID fields.
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.
The package runtime catalog snapshot indexes items by canonical item key; Unity
gameplay, HUD, inventory, trade, ship, and zone helper lookups use `ItemKey`
directly instead of deriving `ItemId` and searching by legacy GUID.

View file

@ -472,7 +472,7 @@ public class ActionGameManager : MonoBehaviour
{
Name = blueprint.Name ?? "",
Kind = blueprint is ShipConstructionBlueprint ? "ship" : blueprint is OrbitalEntityConstructionBlueprint ? "orbital" : "entity",
CorporationLegacyId = blueprint.Faction == Guid.Empty ? "" : blueprint.Faction.ToString("D"),
FactionKey = CorporationKey(blueprint.Faction),
Hull = ProjectLoadoutItem(blueprint.Hull),
Equipment = ProjectSlots(blueprint.Equipment),
CargoBays = ProjectSlots(blueprint.CargoBays),
@ -598,7 +598,7 @@ public class ActionGameManager : MonoBehaviour
.OrderBy(pair => pair.Key.ID)
.Select(pair => new AetheriaRuntimeFactionRelationshipCommit
{
CorporationLegacyId = pair.Key.ID == Guid.Empty ? "" : pair.Key.ID.ToString("D"),
FactionKey = CorporationKey(pair.Key.ID),
Relationship = pair.Value.ToString(),
Standing = (int)pair.Value
})
@ -818,7 +818,7 @@ public class ActionGameManager : MonoBehaviour
TractorPower = entity.TractorPower,
Heatstroke = entity.Heatstroke,
Hypothermia = entity.Hypothermia,
CorporationLegacyId = entity.Faction?.ID.ToString("D") ?? "",
FactionKey = CorporationKey(entity.Faction?.ID ?? Guid.Empty),
HullItemKey = entity.Hull?.ItemKey ?? "",
Equipment = ProjectEquippedSlots(entity.Equipment),
CargoBays = ProjectEquippedSlots(entity.CargoBays),
@ -1265,6 +1265,11 @@ public class ActionGameManager : MonoBehaviour
return id == Guid.Empty ? "" : id.ToString("D");
}
private static string CorporationKey(Guid id)
{
return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}";
}
private static int ZoneIndex(GalaxyZone zone)
{
return CurrentGalaxy?.Zones == null || zone == null ? -1 : Array.IndexOf(CurrentGalaxy.Zones, zone);
@ -1312,7 +1317,7 @@ public class ActionGameManager : MonoBehaviour
return new AetheriaRuntimeEntityLoadoutSnapshot(
entity.Name ?? "",
entity.Kind ?? "",
ReferenceKey("aetheria.corporation", entity.CorporationLegacyId ?? ""),
ReferenceKey(entity.FactionKey ?? "", "aetheria.corporation", entity.CorporationLegacyId ?? ""),
CreateRuntimeLoadoutItemSnapshot(entity.Hull),
CreateRuntimeLoadoutItemSlotSnapshots(entity.Equipment),
CreateRuntimeLoadoutItemSlotSnapshots(entity.CargoBays),
@ -1362,7 +1367,7 @@ public class ActionGameManager : MonoBehaviour
private static string ReferenceKey(string prefix, string legacyId)
{
return string.IsNullOrWhiteSpace(legacyId) ? "" : $"{prefix}:{legacyId}";
return string.IsNullOrWhiteSpace(legacyId) ? "" : $"{prefix}:legacy:{legacyId}";
}
private static string ReferenceKey(string typedKey, string prefix, string legacyId)

View file

@ -168,6 +168,9 @@ namespace GameCult.Aetheria.State.Unity
[Key(11)]
public IReadOnlyList<AetheriaRuntimeEntityLoadoutCommit> Children { get; set; } = Array.Empty<AetheriaRuntimeEntityLoadoutCommit>();
[Key(12)]
public string FactionKey { get; set; } = "";
}
[MessagePackObject]
@ -279,6 +282,9 @@ namespace GameCult.Aetheria.State.Unity
[Key(2)]
public double Standing { get; set; }
[Key(3)]
public string FactionKey { get; set; } = "";
}
[MessagePackObject]
@ -610,6 +616,9 @@ namespace GameCult.Aetheria.State.Unity
[Key(35)]
public string HullItemKey { get; set; } = "";
[Key(36)]
public string FactionKey { get; set; } = "";
}
[MessagePackObject]