Refactor runtime bootstrap and ship control flows
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SpaceGame.Api.Shared.Runtime;
|
||||
using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
|
||||
|
||||
namespace SpaceGame.Api.Universe.Bootstrap;
|
||||
|
||||
public sealed class StaticDataProvider : IStaticDataProvider
|
||||
{
|
||||
private const string MilitaryShipCategory = "military";
|
||||
private const string ConstructionShipCategory = "construction";
|
||||
private const string TransportShipCategory = "transport";
|
||||
private const string MiningShipCategory = "mining";
|
||||
private readonly string _dataRoot;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter() },
|
||||
};
|
||||
|
||||
public StaticDataProvider(IOptions<StaticDataOptions> staticDataOptions)
|
||||
@@ -163,7 +170,7 @@ public sealed class StaticDataProvider : IStaticDataProvider
|
||||
recipes.Add(new RecipeDefinition
|
||||
{
|
||||
Id = $"{ship.Id}-{production.Method}-construction",
|
||||
Label = $"{ship.Label} Construction",
|
||||
Label = $"{ship.Name} Construction",
|
||||
FacilityCategory = "shipyard",
|
||||
Duration = production.Time,
|
||||
Priority = InferShipRecipePriority(ship),
|
||||
@@ -224,12 +231,12 @@ public sealed class StaticDataProvider : IStaticDataProvider
|
||||
};
|
||||
|
||||
private static int InferShipRecipePriority(ShipDefinition ship) =>
|
||||
ship.Kind switch
|
||||
GetShipCategory(ship) switch
|
||||
{
|
||||
"military" => 170,
|
||||
"construction" => 140,
|
||||
"transport" => 120,
|
||||
"mining" => 110,
|
||||
MilitaryShipCategory => 170,
|
||||
ConstructionShipCategory => 140,
|
||||
TransportShipCategory => 120,
|
||||
MiningShipCategory => 110,
|
||||
_ => 100,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user