refactor(backend): simplify cargo kind loading

This commit is contained in:
2026-03-27 15:18:42 -04:00
parent e8fb033a01
commit 3237735b08
11 changed files with 35 additions and 82 deletions

View File

@@ -114,10 +114,8 @@ public sealed class ItemDefinition
public required string Id { get; set; }
public required string Name { get; set; }
public string Description { get; set; } = string.Empty;
public string Type { get; set; } = "material";
public string CargoKind { get; set; } = string.Empty;
[JsonIgnore]
public StorageKind? CargoStorageKind { get; set; }
public StorageKind? CargoKind { get; set; }
public float Volume { get; set; } = 1f;
public int Version { get; set; }
public string FactoryName { get; set; } = string.Empty;
@@ -130,7 +128,8 @@ public sealed class ItemDefinition
[JsonPropertyName("transport")]
public string Transport
{
set => CargoKind = value;
get => CargoKind?.ToDataValue() ?? string.Empty;
set => CargoKind = value.ToNullableStorageKind();
}
}
@@ -338,9 +337,14 @@ public sealed class ShipDefinition
public float FtlSpeed { get; set; }
public float SpoolTime { get; set; }
public float CargoCapacity { get; set; }
public string? CargoKind { get; set; }
[JsonIgnore]
public StorageKind? CargoStorageKind { get; set; }
public StorageKind? CargoKind { get; set; }
[JsonPropertyName("cargoKind")]
public string? SerializedCargoKind
{
get => CargoKind?.ToDataValue();
set => CargoKind = value.ToNullableStorageKind();
}
public required string Color { get; set; }
public required string HullColor { get; set; }
public float Size { get; set; }