diff options
author | Linnea Gräf <nea@nea.moe> | 2024-07-24 02:22:30 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-07-24 02:22:30 +0200 |
commit | c7143936d7a1bf3ae49362049541b2d23b11ab8c (patch) | |
tree | 4e905377b8abf56d1a9e253543a6d3a251f9da82 /src/main/kotlin/moe/nea/firmament/repo/BetterRepoRecipeCache.kt | |
parent | 4585a11434f44fa0900351825eb3ca38ce64f187 (diff) | |
download | firmament-c7143936d7a1bf3ae49362049541b2d23b11ab8c.tar.gz firmament-c7143936d7a1bf3ae49362049541b2d23b11ab8c.tar.bz2 firmament-c7143936d7a1bf3ae49362049541b2d23b11ab8c.zip |
Add essence upgrade recipes
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/repo/BetterRepoRecipeCache.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/repo/BetterRepoRecipeCache.kt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/repo/BetterRepoRecipeCache.kt b/src/main/kotlin/moe/nea/firmament/repo/BetterRepoRecipeCache.kt new file mode 100644 index 0000000..9ccf72d --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/repo/BetterRepoRecipeCache.kt @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.repo + +import io.github.moulberry.repo.IReloadable +import io.github.moulberry.repo.NEURepository +import io.github.moulberry.repo.data.NEURecipe +import moe.nea.firmament.util.SkyblockId + +class BetterRepoRecipeCache(val essenceRecipeProvider: EssenceRecipeProvider) : IReloadable { + var usages: Map<SkyblockId, Set<NEURecipe>> = mapOf() + var recipes: Map<SkyblockId, Set<NEURecipe>> = mapOf() + + override fun reload(repository: NEURepository) { + val usages = mutableMapOf<SkyblockId, MutableSet<NEURecipe>>() + val recipes = mutableMapOf<SkyblockId, MutableSet<NEURecipe>>() + val baseRecipes = repository.items.items.values + .asSequence() + .flatMap { it.recipes } + val extraRecipes = essenceRecipeProvider.recipes + (baseRecipes + extraRecipes) + .forEach { recipe -> + recipe.allInputs.forEach { usages.getOrPut(SkyblockId(it.itemId), ::mutableSetOf).add(recipe) } + recipe.allOutputs.forEach { recipes.getOrPut(SkyblockId(it.itemId), ::mutableSetOf).add(recipe) } + } + this.usages = usages + this.recipes = recipes + } +} |