Io/zerospace converter #1
@@ -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<StarSystemSource> 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<string, FrontMatterValue> 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<string> ConnectedSystems,
|
||||
double X,
|
||||
double Y,
|
||||
string Body);
|
||||
|
||||
internal sealed record SystemMasterySource(
|
||||
|
||||
Reference in New Issue
Block a user