Io/zerospace converter #1
@@ -571,6 +571,8 @@ static bool TryReadStarSystem(
|
|||||||
TryGetOptionalString(frontMatter, "occupationBuff"),
|
TryGetOptionalString(frontMatter, "occupationBuff"),
|
||||||
TryGetOptionalString(frontMatter, "systemMastery"),
|
TryGetOptionalString(frontMatter, "systemMastery"),
|
||||||
connectedSystems,
|
connectedSystems,
|
||||||
|
GetDouble(frontMatter, "x"),
|
||||||
|
GetDouble(frontMatter, "y"),
|
||||||
body);
|
body);
|
||||||
reason = string.Empty;
|
reason = string.Empty;
|
||||||
return true;
|
return true;
|
||||||
@@ -666,6 +668,8 @@ static string GenerateStarSystems(IReadOnlyList<StarSystemSource> systems)
|
|||||||
builder.AppendLine($" OccupationBuff: {Literal(system.OccupationBuff)},");
|
builder.AppendLine($" OccupationBuff: {Literal(system.OccupationBuff)},");
|
||||||
builder.AppendLine($" SystemMastery: {Literal(system.SystemMastery)},");
|
builder.AppendLine($" SystemMastery: {Literal(system.SystemMastery)},");
|
||||||
builder.AppendLine($" ConnectedSystems: [{string.Join(", ", system.ConnectedSystems.Select(Literal))}],");
|
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($" Body: {Literal(system.Body)});");
|
||||||
builder.AppendLine();
|
builder.AppendLine();
|
||||||
}
|
}
|
||||||
@@ -738,6 +742,17 @@ static string BoolLiteral(bool value)
|
|||||||
return value ? "true" : "false";
|
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)
|
internal sealed class FrontMatterValue(string? scalar)
|
||||||
{
|
{
|
||||||
public string? Scalar { get; } = scalar;
|
public string? Scalar { get; } = scalar;
|
||||||
@@ -777,6 +792,8 @@ internal sealed record StarSystemSource(
|
|||||||
string? OccupationBuff,
|
string? OccupationBuff,
|
||||||
string? SystemMastery,
|
string? SystemMastery,
|
||||||
IReadOnlyList<string> ConnectedSystems,
|
IReadOnlyList<string> ConnectedSystems,
|
||||||
|
double X,
|
||||||
|
double Y,
|
||||||
string Body);
|
string Body);
|
||||||
|
|
||||||
internal sealed record SystemMasterySource(
|
internal sealed record SystemMasterySource(
|
||||||
|
|||||||
Reference in New Issue
Block a user