Refactor station modules into typed runtime models
This commit is contained in:
@@ -115,6 +115,14 @@ public enum ModuleType
|
||||
Storage,
|
||||
}
|
||||
|
||||
public enum StorageKind
|
||||
{
|
||||
Condensate,
|
||||
Container,
|
||||
Liquid,
|
||||
Solid,
|
||||
}
|
||||
|
||||
public static class CommanderKind
|
||||
{
|
||||
public const string Faction = "faction";
|
||||
@@ -209,20 +217,54 @@ public static class SimulationEnumMappings
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(moduleType), moduleType, null),
|
||||
};
|
||||
|
||||
public static ModuleType ToModuleType(this string value) => value.Trim() switch
|
||||
public static ModuleType ToModuleType(this string value)
|
||||
{
|
||||
"buildmodule" => ModuleType.BuildModule,
|
||||
"connectionmodule" => ModuleType.ConnectionModule,
|
||||
"defencemodule" => ModuleType.DefenceModule,
|
||||
"dockarea" => ModuleType.DockArea,
|
||||
"habitation" => ModuleType.Habitation,
|
||||
"pier" => ModuleType.Pier,
|
||||
"processingmodule" => ModuleType.ProcessingModule,
|
||||
"production" => ModuleType.Production,
|
||||
"storage" => ModuleType.Storage,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unsupported module type."),
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "Module type is required.");
|
||||
}
|
||||
|
||||
return value.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"buildmodule" => ModuleType.BuildModule,
|
||||
"connectionmodule" => ModuleType.ConnectionModule,
|
||||
"defencemodule" => ModuleType.DefenceModule,
|
||||
"dockarea" => ModuleType.DockArea,
|
||||
"habitation" => ModuleType.Habitation,
|
||||
"pier" => ModuleType.Pier,
|
||||
"processingmodule" => ModuleType.ProcessingModule,
|
||||
"production" => ModuleType.Production,
|
||||
"storage" => ModuleType.Storage,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unsupported module type."),
|
||||
};
|
||||
}
|
||||
|
||||
public static string ToDataValue(this StorageKind storageKind) => storageKind switch
|
||||
{
|
||||
StorageKind.Condensate => "condensate",
|
||||
StorageKind.Container => "container",
|
||||
StorageKind.Liquid => "liquid",
|
||||
StorageKind.Solid => "solid",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(storageKind), storageKind, null),
|
||||
};
|
||||
|
||||
public static StorageKind ToStorageKind(this string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "Storage kind is required.");
|
||||
}
|
||||
|
||||
return value.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"condensate" => StorageKind.Condensate,
|
||||
"container" => StorageKind.Container,
|
||||
"liquid" => StorageKind.Liquid,
|
||||
"solid" => StorageKind.Solid,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unsupported storage kind."),
|
||||
};
|
||||
}
|
||||
|
||||
public static string ToContractValue(this SpatialNodeKind kind) => kind switch
|
||||
{
|
||||
SpatialNodeKind.Star => "star",
|
||||
|
||||
Reference in New Issue
Block a user