diff --git a/ZeroSpace/ZeroSpace.Build/Program.cs b/ZeroSpace/ZeroSpace.Build/Program.cs index 9c1ca60..69a3dff 100644 --- a/ZeroSpace/ZeroSpace.Build/Program.cs +++ b/ZeroSpace/ZeroSpace.Build/Program.cs @@ -571,6 +571,8 @@ static bool TryReadStarSystem( TryGetOptionalString(frontMatter, "occupationBuff"), TryGetOptionalString(frontMatter, "systemMastery"), connectedSystems, + GetDouble(frontMatter, "x"), + GetDouble(frontMatter, "y"), body); reason = string.Empty; return true; @@ -666,6 +668,8 @@ static string GenerateStarSystems(IReadOnlyList systems) builder.AppendLine($" OccupationBuff: {Literal(system.OccupationBuff)},"); builder.AppendLine($" SystemMastery: {Literal(system.SystemMastery)},"); builder.AppendLine($" ConnectedSystems: [{string.Join(", ", system.ConnectedSystems.Select(Literal))}],"); + builder.AppendLine($" X: {system.X.ToString("R", CultureInfo.InvariantCulture)},"); + builder.AppendLine($" Y: {system.Y.ToString("R", CultureInfo.InvariantCulture)},"); builder.AppendLine($" Body: {Literal(system.Body)});"); builder.AppendLine(); } @@ -738,6 +742,17 @@ static string BoolLiteral(bool value) return value ? "true" : "false"; } +static double GetDouble(IReadOnlyDictionary frontMatter, string key) +{ + if (frontMatter.TryGetValue(key, out var value) && + double.TryParse(value.Scalar, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var number)) + { + return number; + } + + return 0; +} + internal sealed class FrontMatterValue(string? scalar) { public string? Scalar { get; } = scalar; @@ -777,6 +792,8 @@ internal sealed record StarSystemSource( string? OccupationBuff, string? SystemMastery, IReadOnlyList ConnectedSystems, + double X, + double Y, string Body); internal sealed record SystemMasterySource(