Refactor station modules into typed runtime models
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using SpaceGame.Api.Shared.Runtime;
|
||||
|
||||
@@ -115,6 +116,8 @@ public sealed class ItemDefinition
|
||||
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 float Volume { get; set; } = 1f;
|
||||
public int Version { get; set; }
|
||||
public string FactoryName { get; set; } = string.Empty;
|
||||
@@ -190,8 +193,41 @@ public sealed class ModuleProductionDefinition
|
||||
public List<RecipeInputDefinition> Wares { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class ModuleDefinition
|
||||
public class ModuleDefinition
|
||||
{
|
||||
public ModuleDefinition()
|
||||
{
|
||||
}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
protected ModuleDefinition(ModuleDefinition source)
|
||||
{
|
||||
Id = source.Id;
|
||||
Name = source.Name;
|
||||
Description = source.Description;
|
||||
Type = source.Type;
|
||||
ModuleType = source.ModuleType;
|
||||
Product = source.Product;
|
||||
Products = [.. source.Products];
|
||||
ProductionMode = source.ProductionMode;
|
||||
Radius = source.Radius;
|
||||
Hull = source.Hull;
|
||||
WorkforceNeeded = source.WorkforceNeeded;
|
||||
Version = source.Version;
|
||||
Macro = source.Macro;
|
||||
MakerRace = source.MakerRace;
|
||||
ExplosionDamage = source.ExplosionDamage;
|
||||
Price = source.Price;
|
||||
Owners = [.. source.Owners];
|
||||
Cargo = source.Cargo;
|
||||
WorkForce = source.WorkForce;
|
||||
Docks = [.. source.Docks];
|
||||
Shields = [.. source.Shields];
|
||||
Turrets = [.. source.Turrets];
|
||||
Production = [.. source.Production];
|
||||
Construction = source.Construction;
|
||||
}
|
||||
|
||||
public required string Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
@@ -226,6 +262,32 @@ public sealed class ModuleDefinition
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ProductionModuleDefinition : ModuleDefinition
|
||||
{
|
||||
[SetsRequiredMembers]
|
||||
internal ProductionModuleDefinition(ModuleDefinition source)
|
||||
: base(source)
|
||||
{
|
||||
ProductItemIds = [.. source.Products];
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> ProductItemIds { get; init; } = [];
|
||||
}
|
||||
|
||||
public sealed class StorageModuleDefinition : ModuleDefinition
|
||||
{
|
||||
[SetsRequiredMembers]
|
||||
internal StorageModuleDefinition(ModuleDefinition source, StorageKind storageKind, float storageCapacity)
|
||||
: base(source)
|
||||
{
|
||||
StorageKind = storageKind;
|
||||
StorageCapacity = storageCapacity;
|
||||
}
|
||||
|
||||
public StorageKind StorageKind { get; init; }
|
||||
public float StorageCapacity { get; init; }
|
||||
}
|
||||
|
||||
public sealed class ModuleRecipeDefinition
|
||||
{
|
||||
public required string ModuleId { get; set; }
|
||||
@@ -277,6 +339,8 @@ public sealed class ShipDefinition
|
||||
public float SpoolTime { get; set; }
|
||||
public float CargoCapacity { get; set; }
|
||||
public string? CargoKind { get; set; }
|
||||
[JsonIgnore]
|
||||
public StorageKind? CargoStorageKind { get; set; }
|
||||
public required string Color { get; set; }
|
||||
public required string HullColor { get; set; }
|
||||
public float Size { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user