Skip to content

Commit

Permalink
Fixed amount in minute for liquids and gas
Browse files Browse the repository at this point in the history
  • Loading branch information
andev0 committed Aug 19, 2024
1 parent 4788487 commit 749c54e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Tools/SatisfactoryRecipeExporter/ExportedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ type Descriptor = {

// For resolving recipe complexity.
resourceSinkPoints: number;

form: ResourceForm;
};

type Resource = Omit<Descriptor, "isResourceInUse" | "resourceSinkPoints">;
type Resource = Omit<Descriptor, "isResourceInUse" | "resourceSinkPoints" | "form">;

type ResourceForm = "INVALID" | "SOLID" | "LIQUID" | "GAS";
17 changes: 16 additions & 1 deletion src/Tools/SatisfactoryRecipeExporter/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ let descriptorsMap = new Map<string, Descriptor>(satisfactory

formFrequency.set(docsDescriptor.mForm, (formFrequency.get(docsDescriptor.mForm) ?? 0) + 1);

let form = docsDescriptor.mForm.replace("RF_", "") as ResourceForm;

// mDisplayName and mDescription are empty here for buildings and should be filled by
// building class later.
return {
Expand All @@ -124,6 +126,7 @@ let descriptorsMap = new Map<string, Descriptor>(satisfactory
iconPath: `${iconPath}${iconName}.png`,
isResourceInUse: false, // Will be set after parsing recipes.
resourceSinkPoints: +docsDescriptor.mResourceSinkPoints,
form: form,
};
})
.map(descriptor => [descriptor.id, descriptor]));
Expand Down Expand Up @@ -161,13 +164,25 @@ let recipes: Recipe[] = satisfactory
let resource = descriptorsMap.get(ingredient.id);

ingredientsComplexity = Math.max(ingredientsComplexity, resource?.resourceSinkPoints ?? 0);

if (resource?.form == "LIQUID" || resource?.form == "GAS")
{
// Because liquids are in cubic meters, I guess.
ingredient.amount /= 1000;
}
}

for (const product of products)
{
let resource = descriptorsMap.get(product.id);

productsComplexity = Math.max(productsComplexity, resource?.resourceSinkPoints ?? 0);

if (resource?.form == "LIQUID" || resource?.form == "GAS")
{
// Because liquids are in cubic meters, I guess.
product.amount /= 1000;
}
}

// Products which can't be sinked are usually very late-game ones or just should be together.
Expand Down Expand Up @@ -308,7 +323,7 @@ fs.writeFileSync(
.filter(descriptor => descriptor.isResourceInUse)
.map<Resource>(descriptor =>
{
let { isResourceInUse, resourceSinkPoints, ...resource } = descriptor;
let { isResourceInUse, resourceSinkPoints, form, ...resource } = descriptor;
return resource;
})
})
Expand Down

0 comments on commit 749c54e

Please sign in to comment.