From 7e64db7e205e94e9e6f2359b21f5074e55de0e72 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 15 Jun 2026 16:21:31 +0100 Subject: [PATCH] Use typed faction keys in runtime commits --- .voidbot/state/aetheria.cc | Bin 102141 -> 103097 bytes Aetheria.State.Unity.Smoke/Program.cs | 9 +++++++-- .../AetheriaRuntimeCommitLogApplier.cs | 6 +++--- Aetheria.State/README.md | 4 ++++ Assets/Scripts/Gameplay/ActionGameManager.cs | 15 ++++++++++----- .../AetheriaRuntimeStateCommitDocument.cs | 9 +++++++++ 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 4ee5c06f2d8f90bc14785d9ceb84f3f7ed79f5c0..a044c130202bed399526be0d2718b9bf13c2ca12 100644 GIT binary patch delta 1781 zcmah~-)kII6n3&PBtlCmwzXjB0SQ6L&TeAt4~vzMkPusv8XJ^AA$Mo)&R+M1fW)UL-+QSH9$@`NVnAj*Hv_pg6a~TlcZP1^efw|@R84XMrS&+1s zOhxNdQ4vsR(o{o@A{`?XOkAgdj02$YyT5Ng+?v0{VRwj@3u>VW^sc3&Nx44!#Ib;VJzea zS#z3e*kGmsa|sKfpnxhtI8SpS17Zl5kzLq2(XI#*({i10M9L@+b&)n8N~ORvC9@<% zL(C$yBD$?e;5@cY1wj^ln33o+XIN23NJyl_-`oIB9b_@XP+)UByPi(&@wzsc9BMKV zAyKJayZw0k!L&s2MUo4%I{+CF$3ZQHATgQ#E~TKGrVAPkLe&^>)}-h+scOtrYBJol zb=DS&Fh@AqOeC4^%}(dXZRpgnc+=C$s}rE zGpIvAgcQt~Gw;yNQi}vl5;=kh`b7JmB8d&DmS|mn|H#6%57AcNUAk;*tLN=I-yGWB zycdlv&gE9fQLH62LE-;B{h9p=guS|zz16gzXP>e^|9Ra0x>~jH>XEC<`)yWipa0z< zINSz109ilC;zgxdtn`$<@a>RY{Jr8)JN(n|;_kjGRtx7igh&dmwS!VYZ)xn?B}Ih@ zD;%?Ab;^FeHem1mcGT8?Jp7`+v~P0&3hSmh;7Lfk6XPZ}_r3oaU3UfxXfDD_+tt7S znCRSSdWXH&I&)2Ls&nK?Z!8OxUse&61&kiF^j;W+DO?;zS6&GeYZ=}7q2vt@Mlkw} zALvo*T{u26vLMm73Kx*c2fVDYcD|&QF2=@scb@3HJ?@PhEv}ZyiItBGiO?bO&h2sU z-lK!Jik-ak))}vMaj19B-YuOREZ)xAUrHz3ee`Ab<~e)1xQhll{ac>whR;2l-CQ4R XdGGc@*&VeraoziBsECbMt1JHinX8Qp delta 1254 zcmY+EJ!lj`6vy2}LkwD|h}!6Dh1})5M2$u&)yOYvCb+ z3RZH(fnenqh=rgKtklB7&W}P4w6Yg06%^m@-kwQydvACD@BRP3xAW@Jz@PgA&mZ>< zmG7s!KU4T$^^gvZA;4^_?z~X}89zuXVb7MF7QNylH(*?JUQUshgJ`R$Im^uS#&DIaaDSM@5o|i4 z%Pb3&4_t&w+Yuc}%LOj60;(a+GMiSVs)ZV!i@|CpO~5kKN4wF0h>Rt(mb_3)V|C=( zY!q^2prVz4<7sl!UYbDhiA8BBxz3mNx2ChT*&Df=9QhR7*J-0>I9rd)FVwJRITSMT_mYw0Yzxz z|F+1H0a|^`X~s*an=DUHbt!UbwelhtVT#!0=zvR@m7G-bkD~aLsI03heTLM(u9&&; zfZBA9x7hr?7JOd&V)G||`1EA<&ax>(;+RB{FJO;2SqoSf_7~@Mm3)wf~-V zE-lVG&b{(v=fEju3~_02OAx#JY%H;&)P&#`l6_CUr6c4$DJ9oQEgh)6Zl|+pF diff --git a/Aetheria.State.Unity.Smoke/Program.cs b/Aetheria.State.Unity.Smoke/Program.cs index 146fe0dcc..8778c593a 100644 --- a/Aetheria.State.Unity.Smoke/Program.cs +++ b/Aetheria.State.Unity.Smoke/Program.cs @@ -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 || diff --git a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs index f6b426279..7fe9992a3 100644 --- a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs +++ b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs @@ -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()) .Select(relationship => new AetheriaFactionRelationshipState { - FactionKey = ReferenceKey("aetheria.corporation", relationship.CorporationLegacyId ?? ""), + FactionKey = ReferenceKey(relationship.FactionKey ?? "", "aetheria.corporation", relationship.CorporationLegacyId ?? ""), Relationship = relationship.Relationship ?? "", Standing = relationship.Standing }) diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index e984ffa91..4b6913688 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -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. diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index bc0157aa1..759863f26 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -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) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs index 892d5033b..bf2be8f61 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs @@ -168,6 +168,9 @@ namespace GameCult.Aetheria.State.Unity [Key(11)] public IReadOnlyList Children { get; set; } = Array.Empty(); + + [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]