mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
auto-generated crafting recipes for walls
This commit is contained in:
@@ -2,31 +2,31 @@
|
||||
"basegame:160": {
|
||||
"workbench": "",
|
||||
"ingredients": [
|
||||
[4, 2, "$ROCK"]
|
||||
[2, 1, "$ROCK"]
|
||||
]
|
||||
},
|
||||
"basegame:161": {
|
||||
"workbench": "",
|
||||
"ingredients": [
|
||||
[4, 2, "basegame:48"]
|
||||
[2, 1, "basegame:48"]
|
||||
]
|
||||
},
|
||||
"basegame:162": {
|
||||
"workbench": "",
|
||||
"ingredients": [
|
||||
[4, 2, "basegame:49"]
|
||||
[2, 1, "basegame:49"]
|
||||
]
|
||||
},
|
||||
"basegame:163": {
|
||||
"workbench": "",
|
||||
"ingredients": [
|
||||
[4, 2, "basegame:50"]
|
||||
[2, 1, "basegame:50"]
|
||||
]
|
||||
},
|
||||
"basegame:164": {
|
||||
"workbench": "",
|
||||
"ingredients": [
|
||||
[4, 2, "basegame:51"]
|
||||
[2, 1, "basegame:51"]
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,16 @@ class CraftingCodex {
|
||||
|
||||
@Transient internal val props = HashMap<ItemID, ArrayList<CraftingRecipe>>() // the key ItemID and value.product must be equal
|
||||
|
||||
fun addRecipe(recipe: CraftingRecipe) {
|
||||
val product = recipe.product
|
||||
if (props.containsKey(product)) {
|
||||
props[product]?.add(recipe)
|
||||
}
|
||||
else {
|
||||
props[product] = arrayListOf(recipe)
|
||||
}
|
||||
}
|
||||
|
||||
fun addFromJson(json: JsonValue, moduleName: String, fileName:String) {
|
||||
|
||||
if (moduleName.filter { it.code in 33..127 } .length < 5)
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.blockproperties.BlockProp
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.BlockBase
|
||||
import net.torvald.terrarum.modulebasegame.imagefont.WatchFont
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -42,7 +43,7 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
ModMgr.GameCraftingRecipeLoader.invoke(moduleName)
|
||||
|
||||
println("Crafting Recipes: ")
|
||||
Terrarum.craftingCodex.props.forEach { item, recipes ->
|
||||
CraftingRecipeCodex.props.forEach { item, recipes ->
|
||||
println("$item ->")
|
||||
recipes.forEach {
|
||||
print(" ")
|
||||
@@ -71,6 +72,19 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
}
|
||||
}
|
||||
|
||||
// crafting recipes: tile -> 2x wall
|
||||
BlockCodex.getAll().filter { it.isWallable && it.isSolid && !it.isActorBlock }.forEach { tile ->
|
||||
CraftingRecipeCodex.addRecipe(CraftingCodex.CraftingRecipe(
|
||||
"",
|
||||
arrayOf(CraftingCodex.CraftingIngredients(
|
||||
tile.id, CraftingCodex.CraftingItemKeyMode.VERBATIM, 1
|
||||
)),
|
||||
2,
|
||||
"wall@"+tile.id,
|
||||
moduleName
|
||||
))
|
||||
}
|
||||
|
||||
println("\n[Basegame.EntryPoint] Welcome back!")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user