show recipes visually instead of describing them in text
This commit is contained in:
@@ -81,6 +81,33 @@ computeShipyardRequiredMaterials(const GameConfig& config,
|
||||
}
|
||||
return requiredMaterials;
|
||||
}
|
||||
|
||||
double computeShipyardProductionTimeSeconds(
|
||||
const GameConfig& config, const std::string& recipeId,
|
||||
const std::optional<ShipLayoutConfig>& shipLayout)
|
||||
{
|
||||
const ShipDef* shipDef = config.ships.findShipDef(recipeId);
|
||||
if (!shipDef)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double seconds = shipDef->schematic.productionTimeSeconds;
|
||||
if (shipLayout.has_value())
|
||||
{
|
||||
for (const PlacedModule& pm : shipLayout->placedModules)
|
||||
{
|
||||
const ModuleDef* modDef = config.modules.findModuleDef(pm.moduleId);
|
||||
if (!modDef)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
seconds += modDef->productionTimeSeconds;
|
||||
}
|
||||
}
|
||||
return seconds;
|
||||
}
|
||||
|
||||
bool hasInputsToStart(const GameConfig& config, const Building& b)
|
||||
{
|
||||
if (b.type == BuildingType::Shipyard)
|
||||
|
||||
@@ -44,6 +44,12 @@ std::map<std::string, int> computeShipyardRequiredMaterials(
|
||||
const GameConfig& config, const std::string& recipeId,
|
||||
const std::optional<ShipLayoutConfig>& shipLayout);
|
||||
|
||||
// The ship's base production time plus that of every module in the configured layout
|
||||
// (REQ-MOD-PRODUCTION-TIME), over a stored configuration as above.
|
||||
double computeShipyardProductionTimeSeconds(
|
||||
const GameConfig& config, const std::string& recipeId,
|
||||
const std::optional<ShipLayoutConfig>& shipLayout);
|
||||
|
||||
// True when a production cycle could start right now, ignoring output-buffer space.
|
||||
bool hasInputsToStart(const GameConfig& config, const Building& b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user