feat: improving ui
This commit is contained in:
@@ -55,7 +55,13 @@ public sealed record StationDelta(
|
||||
public sealed record StationActionProgressSnapshot(
|
||||
string Lane,
|
||||
string Label,
|
||||
float Progress);
|
||||
float Progress,
|
||||
float TimeRemainingSeconds,
|
||||
float CycleSeconds,
|
||||
IReadOnlyList<RecipeEntrySnapshot> Inputs,
|
||||
IReadOnlyList<RecipeEntrySnapshot> Outputs);
|
||||
|
||||
public sealed record RecipeEntrySnapshot(string ItemId, float Amount);
|
||||
|
||||
public sealed record StationStorageUsageSnapshot(
|
||||
string StorageClass,
|
||||
|
||||
@@ -216,6 +216,7 @@ public sealed class ModuleDefinition
|
||||
[JsonPropertyName("product")]
|
||||
public List<string> ProductIds
|
||||
{
|
||||
get => Products;
|
||||
set => Products = value ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,12 +542,18 @@ public sealed partial class SimulationEngine
|
||||
{
|
||||
var recipe = SelectProductionRecipe(world, station, laneKey);
|
||||
var timer = GetStationProductionTimer(station, laneKey);
|
||||
var duration = MathF.Max(recipe?.Duration ?? 0.1f, 0.1f);
|
||||
var progress = Math.Clamp(timer / duration, 0f, 1f);
|
||||
return recipe is null || timer <= 0.01f
|
||||
? null
|
||||
: new StationActionProgressSnapshot(
|
||||
laneKey,
|
||||
recipe.Label,
|
||||
Math.Clamp(timer / MathF.Max(recipe.Duration, 0.1f), 0f, 1f));
|
||||
progress,
|
||||
duration * (1f - progress),
|
||||
duration,
|
||||
recipe.Inputs.Select(i => new RecipeEntrySnapshot(i.ItemId, i.Amount)).ToList(),
|
||||
recipe.Outputs.Select(o => new RecipeEntrySnapshot(o.ItemId, o.Amount)).ToList());
|
||||
})
|
||||
.Where(snapshot => snapshot is not null)
|
||||
.Cast<StationActionProgressSnapshot>()
|
||||
|
||||
@@ -131,14 +131,41 @@ public sealed partial class SimulationEngine
|
||||
|
||||
var expansionPressure = GetFactionExpansionPressure(world, station.FactionId);
|
||||
var fleetPressure = FactionCommanderHasDirective(world, station.FactionId, "produce-military-ships") ? 1f : 0f;
|
||||
priority += recipe.Id switch
|
||||
priority += GetStationRecipePriorityAdjustment(station, recipe, expansionPressure, fleetPressure);
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
private static float GetStationRecipePriorityAdjustment(StationRuntime station, RecipeDefinition recipe, float expansionPressure, float fleetPressure)
|
||||
{
|
||||
var outputItemIds = recipe.Outputs
|
||||
.Select(output => output.ItemId)
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
if (outputItemIds.Contains("hullparts"))
|
||||
{
|
||||
"ship-parts-integration" => HasStationModules(station, "module_gen_prod_advancedelectronics_01", "module_gen_build_l_01")
|
||||
return HasStationModules(station, "module_gen_prod_advancedelectronics_01", "module_gen_build_l_01")
|
||||
? -140f * MathF.Max(expansionPressure, fleetPressure)
|
||||
: 280f * MathF.Max(expansionPressure, fleetPressure),
|
||||
"hull-fabrication" => 180f * expansionPressure,
|
||||
"equipment-assembly" => 170f * expansionPressure,
|
||||
"gun-assembly" => 160f * expansionPressure,
|
||||
: 280f * MathF.Max(expansionPressure, fleetPressure);
|
||||
}
|
||||
|
||||
if (outputItemIds.Contains("refinedmetals"))
|
||||
{
|
||||
return 180f * expansionPressure;
|
||||
}
|
||||
|
||||
if (outputItemIds.Overlaps(["advancedelectronics", "dronecomponents", "engineparts", "fieldcoils", "missilecomponents", "shieldcomponents", "smartchips"]))
|
||||
{
|
||||
return 170f * expansionPressure;
|
||||
}
|
||||
|
||||
if (outputItemIds.Overlaps(["turretcomponents", "weaponcomponents"]))
|
||||
{
|
||||
return 160f * expansionPressure;
|
||||
}
|
||||
|
||||
return recipe.Id switch
|
||||
{
|
||||
"command-bridge-module-assembly" or "reactor-core-module-assembly" or "capacitor-bank-module-assembly" or "ion-drive-module-assembly" or "ftl-core-module-assembly" or "gun-turret-module-assembly"
|
||||
=> 220f * MathF.Max(expansionPressure, fleetPressure),
|
||||
"frigate-construction" => 320f * MathF.Max(expansionPressure, fleetPressure),
|
||||
@@ -149,8 +176,6 @@ public sealed partial class SimulationEngine
|
||||
=> -120f * expansionPressure,
|
||||
_ => 0f,
|
||||
};
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
private static bool RecipeAppliesToStation(StationRuntime station, RecipeDefinition recipe)
|
||||
|
||||
Reference in New Issue
Block a user