Skip to content

Commit

Permalink
Display power generation recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
andev0 committed Sep 8, 2024
1 parent d3753f1 commit 08b2434
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
15 changes: 13 additions & 2 deletions src/RecipeSelectionModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,17 @@ export class RecipeSelectionModal extends EventTarget
this._selectedRecipe.recipe.products
);

this._selectedRecipePower.innerText = `${this._selectedRecipe.madeIn.powerConsumption} MW`;
this._selectedRecipePowerText.innerText = `${this._selectedRecipe.madeIn.powerConsumption} MW`;

// Power generators showing "0 MW" is not intuitive.
if (this._selectedRecipe.recipe.id.startsWith("Power_"))
{
this._selectedRecipePower.classList.add("hidden");
}
else
{
this._selectedRecipePower.classList.remove("hidden");
}

this._selectedRecipeDisplay.classList.remove("hidden");

Expand Down Expand Up @@ -632,7 +642,8 @@ export class RecipeSelectionModal extends EventTarget
private _selectedRecipeMachine = this._selectedRecipeDisplay.querySelector("#selected-recipe-machine>.machine>img.icon") as HTMLImageElement;
private _selectedRecipeInput = this._selectedRecipeDisplay.querySelector("#selected-recipe-input") as HTMLDivElement;
private _selectedRecipeOutput = this._selectedRecipeDisplay.querySelector("#selected-recipe-output") as HTMLDivElement;
private _selectedRecipePower = this._selectedRecipeDisplay.querySelector("#selected-recipe-power>.text") as HTMLDivElement;
private _selectedRecipePower = this._selectedRecipeDisplay.querySelector("#selected-recipe-power") as HTMLDivElement;
private _selectedRecipePowerText = this._selectedRecipePower.querySelector(".text") as HTMLDivElement;

private _confirmRecipeButton = this._modalContainer.querySelector("#confirm-recipe") as HTMLDivElement;
private _discardRecipeButton = this._modalContainer.querySelector("#discard-recipe") as HTMLDivElement;
Expand Down
7 changes: 6 additions & 1 deletion src/Sankey/NodeResourceDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export class NodeResourceDisplay
this.createOverclockDisplay(recipeContainer);
this.createInputsDisplay(recipeContainer, recipe);
this.createOutputsDisplay(recipeContainer, recipe);
this.createPowerDisplay(recipeContainer, machine.powerConsumption);

// Recipes with id beginning with "Power_" are created by parsing tool for power production.
if (!recipe.id.startsWith("Power_"))
{
this.createPowerDisplay(recipeContainer, machine.powerConsumption);
}

this._displayContainer.appendChild(recipeContainer);

Expand Down
1 change: 1 addition & 0 deletions src/Tools/SatisfactoryRecipeExporter/DocsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type DocsPowerGenerator = DocsBuilding & {
mFuel: DocsFuel[];
mSupplementalToPowerRatio: string;
mPowerProduction: string;
mFuelResourceForm: string;
};

type DocsFuel = {
Expand Down
14 changes: 11 additions & 3 deletions src/Tools/SatisfactoryRecipeExporter/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,12 @@ let powerGenerators: Building[] = satisfactory
fixCubicMeters(byproduct, byproductDescriptor);
}

let resourceForm = docsPowerGenerator.mFuelResourceForm.replace("RF_", "") as ResourceForm;

for (const fuelType of fuelTypes)
{
if (fuelType.energyValue === 0 || fuelType.form !== resourceForm) continue;

let productionDuration = fuelType.energyValue / powerProduct.amount;

if (fuelType.form === "LIQUID" || fuelType.form === "GAS")
Expand All @@ -356,11 +360,15 @@ let powerGenerators: Building[] = satisfactory
amount: 1,
};

// Crutches to make the recipe more universal and compatible with others when
// displaying amounts.
let powerProduction = powerProduct.amount / (60 / productionDuration);

let recipe: BuildingRecipe = {
id: `Power_${docsPowerGenerator.ClassName}_${fuelType.id}`,
displayName: `Power ${docsPowerGenerator.mDisplayName} with ${fuelType.displayName}`,
displayName: `${fuelType.displayName} (burning)`,
ingredients: [fuelIngredient],
products: [powerProduct],
products: [{ id: powerProduct.id, amount: powerProduction }],
manufacturingDuration: productionDuration,
};

Expand All @@ -378,7 +386,7 @@ let powerGenerators: Building[] = satisfactory

if (byproduct != undefined)
{
recipe.ingredients.push(byproduct);
recipe.products.push(byproduct);
}

recipes.push(recipe);
Expand Down

0 comments on commit 08b2434

Please sign in to comment.