398 lines
13 KiB
C#
398 lines
13 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.Json.Serialization;
|
|
using SpaceGame.Api.Shared.Runtime;
|
|
|
|
namespace SpaceGame.Api.Definitions;
|
|
|
|
public sealed class ConstructionDefinition
|
|
{
|
|
public string? RecipeId { get; set; }
|
|
public string FacilityCategory { get; set; } = "station";
|
|
public List<string> RequiredModules { get; set; } = [];
|
|
public List<RecipeInputDefinition> Requirements { get; set; } = [];
|
|
public float CycleTime { get; set; }
|
|
public float BatchSize { get; set; } = 1f;
|
|
public float ProductsPerHour { get; set; }
|
|
public float MaxEfficiency { get; set; } = 1f;
|
|
public int Priority { get; set; }
|
|
}
|
|
|
|
public sealed class ItemPriceDefinition
|
|
{
|
|
public float Min { get; set; }
|
|
public float Max { get; set; }
|
|
public float Avg { get; set; }
|
|
}
|
|
|
|
public sealed class ItemEffectDefinition
|
|
{
|
|
public required string Type { get; set; }
|
|
public float Product { get; set; }
|
|
}
|
|
|
|
public sealed class ItemProductionDefinition
|
|
{
|
|
public float Time { get; set; }
|
|
public float Amount { get; set; }
|
|
public string Method { get; set; } = "default";
|
|
public string Name { get; set; } = "Universal";
|
|
public List<RecipeInputDefinition> Wares { get; set; } = [];
|
|
public List<ItemEffectDefinition> Effects { get; set; } = [];
|
|
}
|
|
|
|
public sealed class BalanceDefinition
|
|
{
|
|
public float SimulationSpeedMultiplier { get; set; } = 1f;
|
|
public float YPlane { get; set; }
|
|
public float ArrivalThreshold { get; set; }
|
|
public float MiningRate { get; set; }
|
|
public float MiningCycleSeconds { get; set; }
|
|
public float TransferRate { get; set; }
|
|
public float DockingDuration { get; set; }
|
|
public float UndockingDuration { get; set; }
|
|
public float UndockDistance { get; set; }
|
|
}
|
|
|
|
public sealed class StarDefinition
|
|
{
|
|
public string Kind { get; set; } = "main-sequence";
|
|
public required string Color { get; set; }
|
|
public required string Glow { get; set; }
|
|
public float Size { get; set; }
|
|
public float OrbitRadius { get; set; }
|
|
public float OrbitSpeed { get; set; }
|
|
public float OrbitPhaseAtEpoch { get; set; }
|
|
}
|
|
|
|
public sealed class MoonDefinition
|
|
{
|
|
public required string Label { get; set; }
|
|
public float Size { get; set; }
|
|
public required string Color { get; set; }
|
|
public float OrbitRadius { get; set; }
|
|
public float OrbitSpeed { get; set; }
|
|
public float OrbitPhaseAtEpoch { get; set; }
|
|
public float OrbitInclination { get; set; }
|
|
public float OrbitLongitudeOfAscendingNode { get; set; }
|
|
}
|
|
|
|
public sealed class SolarSystemDefinition
|
|
{
|
|
public required string Id { get; set; }
|
|
public required string Label { get; set; }
|
|
public required float[] Position { get; set; }
|
|
public required List<StarDefinition> Stars { get; set; }
|
|
public required AsteroidFieldDefinition AsteroidField { get; set; }
|
|
public required List<ResourceNodeDefinition> ResourceNodes { get; set; }
|
|
public required List<PlanetDefinition> Planets { get; set; }
|
|
}
|
|
|
|
public sealed class AsteroidFieldDefinition
|
|
{
|
|
public int DecorationCount { get; set; }
|
|
public float RadiusOffset { get; set; }
|
|
public float RadiusVariance { get; set; }
|
|
public float HeightVariance { get; set; }
|
|
}
|
|
|
|
public sealed class ResourceNodeDefinition
|
|
{
|
|
public string SourceKind { get; set; } = "local-space";
|
|
public string? AnchorReference { get; set; }
|
|
public float Angle { get; set; }
|
|
public float RadiusOffset { get; set; }
|
|
public float InclinationDegrees { get; set; }
|
|
public int? AnchorPlanetIndex { get; set; }
|
|
public int? AnchorMoonIndex { get; set; }
|
|
public float OreAmount { get; set; }
|
|
public required string ItemId { get; set; }
|
|
public int ShardCount { get; set; }
|
|
}
|
|
|
|
public sealed class ItemDefinition
|
|
{
|
|
public required string Id { get; set; }
|
|
public required string Name { get; set; }
|
|
public string Description { get; set; } = string.Empty;
|
|
[JsonIgnore]
|
|
public StorageKind? CargoKind { get; set; }
|
|
public float Volume { get; set; } = 1f;
|
|
public int Version { get; set; }
|
|
public string FactoryName { get; set; } = string.Empty;
|
|
public string Icon { get; set; } = string.Empty;
|
|
public string Group { get; set; } = string.Empty;
|
|
public ItemPriceDefinition? Price { get; set; }
|
|
public List<string> Illegal { get; set; } = [];
|
|
public List<ItemProductionDefinition> Production { get; set; } = [];
|
|
public ConstructionDefinition? Construction { get; set; }
|
|
[JsonPropertyName("transport")]
|
|
public string Transport
|
|
{
|
|
get => CargoKind?.ToDataValue() ?? string.Empty;
|
|
set => CargoKind = value.ToNullableStorageKind();
|
|
}
|
|
}
|
|
|
|
public sealed class RecipeOutputDefinition
|
|
{
|
|
public required string ItemId { get; set; }
|
|
public float Amount { get; set; }
|
|
}
|
|
|
|
public sealed class RecipeInputDefinition
|
|
{
|
|
public string ItemId { get; set; } = string.Empty;
|
|
public float Amount { get; set; }
|
|
[JsonPropertyName("ware")]
|
|
public string Ware
|
|
{
|
|
set => ItemId = value;
|
|
}
|
|
}
|
|
|
|
public sealed class ModuleConstructionDefinition
|
|
{
|
|
public required List<RecipeInputDefinition> Requirements { get; set; }
|
|
public float ProductionTime { get; set; }
|
|
}
|
|
|
|
public sealed class ModuleDockDefinition
|
|
{
|
|
public int Capacity { get; set; }
|
|
public required string Size { get; set; }
|
|
}
|
|
|
|
public sealed class ModuleCargoDefinition
|
|
{
|
|
public float Max { get; set; }
|
|
public required string Type { get; set; }
|
|
}
|
|
|
|
public sealed class ModuleWorkForceDefinition
|
|
{
|
|
public float Capacity { get; set; }
|
|
public float Max { get; set; }
|
|
public string Race { get; set; } = string.Empty;
|
|
}
|
|
|
|
public sealed class ModuleMountDefinition
|
|
{
|
|
public required string Group { get; set; }
|
|
public required string Size { get; set; }
|
|
public bool Hittable { get; set; }
|
|
public List<string> Types { get; set; } = [];
|
|
}
|
|
|
|
public sealed class ModuleProductionDefinition
|
|
{
|
|
public float Time { get; set; }
|
|
public float Amount { get; set; }
|
|
public string Method { get; set; } = "default";
|
|
public string Name { get; set; } = "Universal";
|
|
public List<RecipeInputDefinition> Wares { get; set; } = [];
|
|
}
|
|
|
|
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;
|
|
public required string Type { get; set; }
|
|
[JsonIgnore]
|
|
public ModuleType ModuleType { get; set; }
|
|
[JsonIgnore]
|
|
public string? Product { get; set; }
|
|
public List<string> Products { get; set; } = [];
|
|
public string ProductionMode { get; set; } = "passive";
|
|
public float Radius { get; set; } = 12f;
|
|
public float Hull { get; set; } = 100f;
|
|
public float WorkforceNeeded { get; set; }
|
|
public int Version { get; set; }
|
|
public string Macro { get; set; } = string.Empty;
|
|
public string MakerRace { get; set; } = string.Empty;
|
|
public int ExplosionDamage { get; set; }
|
|
public ItemPriceDefinition? Price { get; set; }
|
|
public List<string> Owners { get; set; } = [];
|
|
public ModuleCargoDefinition? Cargo { get; set; }
|
|
public ModuleWorkForceDefinition? WorkForce { get; set; }
|
|
public List<ModuleDockDefinition> Docks { get; set; } = [];
|
|
public List<ModuleMountDefinition> Shields { get; set; } = [];
|
|
public List<ModuleMountDefinition> Turrets { get; set; } = [];
|
|
public List<ModuleProductionDefinition> Production { get; set; } = [];
|
|
public ModuleConstructionDefinition? Construction { get; set; }
|
|
[JsonPropertyName("product")]
|
|
public List<string> ProductIds
|
|
{
|
|
get => Products;
|
|
set => Products = value ?? [];
|
|
}
|
|
}
|
|
|
|
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; }
|
|
public float Duration { get; set; }
|
|
public required List<RecipeInputDefinition> Inputs { get; set; }
|
|
}
|
|
|
|
public sealed class RecipeDefinition
|
|
{
|
|
public required string Id { get; set; }
|
|
public required string Label { get; set; }
|
|
public required string FacilityCategory { get; set; }
|
|
public float Duration { get; set; }
|
|
public int Priority { get; set; }
|
|
public List<string> RequiredModules { get; set; } = [];
|
|
public List<RecipeInputDefinition> Inputs { get; set; } = [];
|
|
public List<RecipeOutputDefinition> Outputs { get; set; } = [];
|
|
public string? ShipOutputId { get; set; }
|
|
}
|
|
|
|
public sealed class PlanetDefinition
|
|
{
|
|
public required string Label { get; set; }
|
|
public string PlanetType { get; set; } = "terrestrial";
|
|
public string Shape { get; set; } = "sphere";
|
|
public List<MoonDefinition> Moons { get; set; } = [];
|
|
public float OrbitRadius { get; set; }
|
|
public float OrbitSpeed { get; set; }
|
|
public float OrbitEccentricity { get; set; }
|
|
public float OrbitInclination { get; set; }
|
|
public float OrbitLongitudeOfAscendingNode { get; set; }
|
|
public float OrbitArgumentOfPeriapsis { get; set; }
|
|
public float OrbitPhaseAtEpoch { get; set; }
|
|
public float Size { get; set; }
|
|
public required string Color { get; set; }
|
|
public float Tilt { get; set; }
|
|
public bool HasRing { get; set; }
|
|
}
|
|
|
|
public sealed class ShipDefinition
|
|
{
|
|
public required string Id { get; set; }
|
|
public required string Label { get; set; }
|
|
public required string Kind { get; set; }
|
|
public required string Class { get; set; }
|
|
public float Speed { get; set; }
|
|
public float WarpSpeed { get; set; }
|
|
public float FtlSpeed { get; set; }
|
|
public float SpoolTime { get; set; }
|
|
public float CargoCapacity { get; set; }
|
|
[JsonIgnore]
|
|
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; }
|
|
public float MaxHealth { get; set; }
|
|
public List<string> Capabilities { get; set; } = [];
|
|
public ConstructionDefinition? Construction { get; set; }
|
|
}
|
|
|
|
public sealed class ScenarioDefinition
|
|
{
|
|
public required List<InitialStationDefinition> InitialStations { get; set; }
|
|
public required List<ShipFormationDefinition> ShipFormations { get; set; }
|
|
public required List<PatrolRouteDefinition> PatrolRoutes { get; set; }
|
|
public required MiningDefaultsDefinition MiningDefaults { get; set; }
|
|
}
|
|
|
|
public sealed class InitialStationDefinition
|
|
{
|
|
public required string SystemId { get; set; }
|
|
public string Label { get; set; } = "Orbital Station";
|
|
public string Color { get; set; } = "#8df0d2";
|
|
public string Objective { get; set; } = "general";
|
|
public List<string> StartingModules { get; set; } = [];
|
|
public string? FactionId { get; set; }
|
|
public int? PlanetIndex { get; set; }
|
|
public int? LagrangeSide { get; set; }
|
|
public float[]? Position { get; set; }
|
|
}
|
|
|
|
public sealed class ShipFormationDefinition
|
|
{
|
|
public required string ShipId { get; set; }
|
|
public int Count { get; set; }
|
|
public required float[] Center { get; set; }
|
|
public required string SystemId { get; set; }
|
|
public string? FactionId { get; set; }
|
|
public Dictionary<string, float> StartingInventory { get; set; } = new(StringComparer.Ordinal);
|
|
}
|
|
|
|
public sealed class PatrolRouteDefinition
|
|
{
|
|
public required string SystemId { get; set; }
|
|
public required List<float[]> Points { get; set; }
|
|
}
|
|
|
|
public sealed class MiningDefaultsDefinition
|
|
{
|
|
public required string NodeSystemId { get; set; }
|
|
public required string RefinerySystemId { get; set; }
|
|
}
|