Require typed faction keys in runtime state
This commit is contained in:
parent
a16b0559d4
commit
d496d2d04b
6 changed files with 55 additions and 43 deletions
|
|
@ -235,7 +235,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
blueprint.Name = entity.Name;
|
||||
blueprint.FactionKey = entity.FactionKey ?? "";
|
||||
blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation");
|
||||
blueprint.Hull = hull;
|
||||
blueprint.Equipment = CreateEquippableSlots(entity.Equipment);
|
||||
blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays);
|
||||
|
|
@ -277,7 +276,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
blueprint.Name = entity.Name ?? "";
|
||||
blueprint.FactionKey = entity.FactionKey ?? "";
|
||||
blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation");
|
||||
blueprint.Hull = hull;
|
||||
blueprint.Equipment = CreateEquippableSlots(entity.Equipment);
|
||||
blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays);
|
||||
|
|
@ -559,7 +557,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
Name = blueprint.Name ?? "",
|
||||
Kind = blueprint is ShipConstructionBlueprint ? "ship" : blueprint is OrbitalEntityConstructionBlueprint ? "orbital" : "entity",
|
||||
FactionKey = ReferenceKey(blueprint.FactionKey ?? "", "aetheria.corporation", LegacyId(blueprint.Faction)),
|
||||
FactionKey = blueprint.FactionKey ?? "",
|
||||
Hull = ProjectLoadoutItem(blueprint.Hull),
|
||||
Equipment = ProjectSlots(blueprint.Equipment),
|
||||
CargoBays = ProjectSlots(blueprint.CargoBays),
|
||||
|
|
@ -687,7 +685,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
.OrderBy(pair => pair.Key.ID)
|
||||
.Select(pair => new AetheriaRuntimeFactionRelationshipCommit
|
||||
{
|
||||
FactionKey = CorporationKey(pair.Key.ID),
|
||||
FactionKey = pair.Key.FactionKey ?? "",
|
||||
Relationship = pair.Value.ToString(),
|
||||
Standing = (int)pair.Value
|
||||
})
|
||||
|
|
@ -958,7 +956,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
TractorPower = entity.TractorPower,
|
||||
Heatstroke = entity.Heatstroke,
|
||||
Hypothermia = entity.Hypothermia,
|
||||
FactionKey = CorporationKey(entity.Faction?.ID ?? Guid.Empty),
|
||||
FactionKey = entity.Faction?.FactionKey ?? "",
|
||||
HullItemKey = entity.Hull?.ItemKey ?? "",
|
||||
Equipment = ProjectEquippedSlots(entity.Equipment),
|
||||
CargoBays = ProjectEquippedSlots(entity.CargoBays),
|
||||
|
|
@ -1396,16 +1394,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
.ToArray() ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
|
||||
}
|
||||
|
||||
private static string LegacyId(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : id.ToString("D");
|
||||
}
|
||||
|
||||
private static string CorporationKey(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}";
|
||||
}
|
||||
|
||||
private static string OrbitKey(Guid id)
|
||||
{
|
||||
return id == Guid.Empty ? "" : $"aetheria.orbit:legacy:{id:D}";
|
||||
|
|
@ -1559,18 +1547,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private static string ReferenceKey(string prefix, string legacyId)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(legacyId) ? "" : $"{prefix}:legacy:{legacyId}";
|
||||
}
|
||||
|
||||
private static string ReferenceKey(string typedKey, string prefix, string legacyId)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(typedKey)
|
||||
? typedKey
|
||||
: ReferenceKey(prefix, legacyId);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit() => QueueRunCheckpoint("application-quit");
|
||||
|
||||
private void QueueRunCheckpoint(string reason)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,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.FactionKey = entity.Faction?.FactionKey ?? "";
|
||||
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();
|
||||
|
|
@ -116,12 +115,7 @@ public static class EntityConstructionBlueprintProjector
|
|||
{
|
||||
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}";
|
||||
: galaxy.ResolveFactionByKey(blueprint.FactionKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +146,6 @@ public abstract class EntityConstructionBlueprint
|
|||
public (int2 position, ItemInstance item)[][] DockingBayContents;
|
||||
public EntityConstructionBlueprint[] Children;
|
||||
public EntitySettings Settings;
|
||||
public Guid Faction;
|
||||
public string FactionKey;
|
||||
public int[][] WeaponGroups;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue