mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
working crafting workbench
This commit is contained in:
@@ -13,25 +13,25 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"item@basegame:256": {
|
"item@basegame:256": {
|
||||||
"workbench": "",
|
"workbench": "basiccrafting",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
[1, 4, "basegame:48"]
|
[1, 4, "basegame:48"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"item@basegame:257": {
|
"item@basegame:257": {
|
||||||
"workbench": "",
|
"workbench": "basiccrafting",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
[1, 4, "basegame:49"]
|
[1, 4, "basegame:49"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"item@basegame:258": {
|
"item@basegame:258": {
|
||||||
"workbench": "",
|
"workbench": "basiccrafting",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
[1, 4, "basegame:50"]
|
[1, 4, "basegame:50"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"item@basegame:259": {
|
"item@basegame:259": {
|
||||||
"workbench": "",
|
"workbench": "basiccrafting",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
[1, 4, "basegame:51"]
|
[1, 4, "basegame:51"]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ id;classname
|
|||||||
12;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCopper
|
12;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerCopper
|
||||||
13;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerSteel
|
13;net.torvald.terrarum.modulebasegame.gameitems.SledgehammerSteel
|
||||||
|
|
||||||
|
16;net.torvald.terrarum.modulebasegame.gameitems.ItemWorkbench
|
||||||
|
|
||||||
256;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorOak
|
256;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorOak
|
||||||
257;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorEbony
|
257;net.torvald.terrarum.modulebasegame.gameitems.ItemSwingingDoorEbony
|
||||||
|
|||||||
|
@@ -21,6 +21,7 @@ import net.torvald.terrarum.blockproperties.BlockCodex
|
|||||||
import net.torvald.terrarum.blockproperties.WireCodex
|
import net.torvald.terrarum.blockproperties.WireCodex
|
||||||
import net.torvald.terrarum.gameactors.Actor
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
import net.torvald.terrarum.gameactors.ActorID
|
import net.torvald.terrarum.gameactors.ActorID
|
||||||
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||||
@@ -33,6 +34,7 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
|
|||||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||||
import net.torvald.unsafe.UnsafeHelper
|
import net.torvald.unsafe.UnsafeHelper
|
||||||
import net.torvald.util.CircularArray
|
import net.torvald.util.CircularArray
|
||||||
|
import org.dyn4j.geometry.Vector2
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -904,4 +906,22 @@ fun checkForSavegameDamage(skimmer: DiskSkimmer): Boolean {
|
|||||||
inline fun Disposable.tryDispose() {
|
inline fun Disposable.tryDispose() {
|
||||||
try { this.dispose() }
|
try { this.dispose() }
|
||||||
catch (_: Throwable) {}
|
catch (_: Throwable) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun distBetweenActors(a: ActorWithBody, b: ActorWithBody): Double {
|
||||||
|
val ww = INGAME.world.width * TILE_SIZED
|
||||||
|
val apos1 = a.centrePosVector
|
||||||
|
val apos2 = Vector2(apos1.x + ww, apos1.y)
|
||||||
|
val apos3 = Vector2(apos1.x - ww, apos1.y)
|
||||||
|
val bpos = b.centrePosVector
|
||||||
|
val dist = min(min(bpos.distanceSquared(apos1), bpos.distanceSquared(apos2)), bpos.distanceSquared(apos3))
|
||||||
|
return dist.sqrt()
|
||||||
|
}
|
||||||
|
fun distBetween(a: ActorWithBody, bpos: Vector2): Double {
|
||||||
|
val ww = INGAME.world.width * TILE_SIZED
|
||||||
|
val apos1 = a.centrePosVector
|
||||||
|
val apos2 = Vector2(apos1.x + ww, apos1.y)
|
||||||
|
val apos3 = Vector2(apos1.x - ww, apos1.y)
|
||||||
|
val dist = min(min(bpos.distanceSquared(apos1), bpos.distanceSquared(apos2)), bpos.distanceSquared(apos3))
|
||||||
|
return dist.sqrt()
|
||||||
}
|
}
|
||||||
@@ -113,6 +113,13 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
inputMouseY = newmy
|
inputMouseY = newmy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val inventoryCategoryAllowClickAndDrag = listOf(
|
||||||
|
GameItem.Category.TOOL,
|
||||||
|
GameItem.Category.WALL,
|
||||||
|
GameItem.Category.WIRE,
|
||||||
|
GameItem.Category.BLOCK
|
||||||
|
)
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
@@ -140,7 +147,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
// - not clicking anymore
|
// - not clicking anymore
|
||||||
// - using any item that is not fixture (blocks, picks)
|
// - using any item that is not fixture (blocks, picks)
|
||||||
if (!Terrarum.mouseDown ||
|
if (!Terrarum.mouseDown ||
|
||||||
GameItem.Category.MISC != ItemCodex.get(terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP))?.inventoryCategory) {
|
inventoryCategoryAllowClickAndDrag.contains(ItemCodex[terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)]?.inventoryCategory)) {
|
||||||
worldPrimaryClickLatched = false
|
worldPrimaryClickLatched = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
@JvmStatic val BLOCK = "block"
|
@JvmStatic val BLOCK = "block"
|
||||||
@JvmStatic val WALL = "wall"
|
@JvmStatic val WALL = "wall"
|
||||||
@JvmStatic val WIRE = "wire"
|
@JvmStatic val WIRE = "wire"
|
||||||
// @JvmStatic val FIXTURE = "fixture"
|
@JvmStatic val FIXTURE = "fixture"
|
||||||
@JvmStatic val MISC = "misc"
|
@JvmStatic val MISC = "misc"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,12 +389,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
*/
|
*/
|
||||||
fun mouseInInteractableRange(actor: ActorWithBody, action: () -> Long): Long {
|
fun mouseInInteractableRange(actor: ActorWithBody, action: () -> Long): Long {
|
||||||
val mousePos1 = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
val mousePos1 = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
||||||
val mousePos2 = Vector2(Terrarum.mouseX + INGAME.world.width * TILE_SIZED, Terrarum.mouseY)
|
|
||||||
val mousePos3 = Vector2(Terrarum.mouseX - INGAME.world.width * TILE_SIZED, Terrarum.mouseY)
|
|
||||||
val actorPos = actor.centrePosVector
|
|
||||||
val dist = min(min(actorPos.distanceSquared(mousePos1), actorPos.distanceSquared(mousePos2)), actorPos.distanceSquared(mousePos3))
|
|
||||||
val distMax = actor.actorValue.getAsDouble(AVKey.REACH)!! * (actor.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * actor.scale // perform some error checking here
|
val distMax = actor.actorValue.getAsDouble(AVKey.REACH)!! * (actor.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * actor.scale // perform some error checking here
|
||||||
if (dist <= distMax.sqr()) return action() else return -1
|
return if (distBetween(actor, mousePos1) <= distMax) action() else -1
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -410,16 +406,10 @@ fun mouseInInteractableRange(actor: ActorWithBody, action: () -> Long): Long {
|
|||||||
*/
|
*/
|
||||||
fun mouseInInteractableRangeTools(actor: ActorWithBody, item: GameItem?, reachMultiplierInTiles: (Int) -> Double = { it.toDouble() }, action: () -> Boolean): Boolean {
|
fun mouseInInteractableRangeTools(actor: ActorWithBody, item: GameItem?, reachMultiplierInTiles: (Int) -> Double = { it.toDouble() }, action: () -> Boolean): Boolean {
|
||||||
val mousePos1 = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
val mousePos1 = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
||||||
val mousePos2 = Vector2(Terrarum.mouseX + INGAME.world.width * TILE_SIZED, Terrarum.mouseY)
|
|
||||||
val mousePos3 = Vector2(Terrarum.mouseX - INGAME.world.width * TILE_SIZED, Terrarum.mouseY)
|
|
||||||
val actorPos = actor.centrePosVector
|
|
||||||
val dist = min(min(actorPos.distanceSquared(mousePos1), actorPos.distanceSquared(mousePos2)), actorPos.distanceSquared(mousePos3))
|
|
||||||
|
|
||||||
val reachBonus = (actor.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * actor.scale
|
val reachBonus = (actor.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * actor.scale
|
||||||
val distMax = actor.actorValue.getAsDouble(AVKey.REACH)!! * reachBonus // perform some error checking here
|
val distMax = actor.actorValue.getAsDouble(AVKey.REACH)!! * reachBonus // perform some error checking here
|
||||||
val toolDistMax = (TILE_SIZED * reachMultiplierInTiles(item?.material?.toolReach ?: Int.MAX_VALUE)) * reachBonus
|
val toolDistMax = (TILE_SIZED * reachMultiplierInTiles(item?.material?.toolReach ?: Int.MAX_VALUE)) * reachBonus
|
||||||
|
return if (distBetween(actor, mousePos1) <= min(toolDistMax, distMax)) action() else false
|
||||||
if (dist <= min(toolDistMax, distMax).sqr()) return action() else return false
|
|
||||||
}
|
}
|
||||||
//fun IntRange.pickRandom() = HQRNG().nextInt(this.last - this.first + 1) + this.first // count() on 200 million entries? Se on vitun hyvää idea
|
//fun IntRange.pickRandom() = HQRNG().nextInt(this.last - this.first + 1) + this.first // count() on 200 million entries? Se on vitun hyvää idea
|
||||||
//fun IntArray.pickRandom(): Int = this[HQRNG().nextInt(this.size)]
|
//fun IntArray.pickRandom(): Int = this[HQRNG().nextInt(this.size)]
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2023-09-20.
|
||||||
|
*/
|
||||||
|
open interface CraftingStation {
|
||||||
|
|
||||||
|
val tags: List<String>
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ class FixtureWallCalendar : FixtureBase {
|
|||||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/calendar.tga")
|
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/calendar.tga")
|
||||||
|
|
||||||
density = 600.0
|
density = 600.0
|
||||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 1)
|
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
|
||||||
|
|
||||||
makeNewSprite(TextureRegionPack(itemImage.texture, TILE_SIZE, TILE_SIZE)).let {
|
makeNewSprite(TextureRegionPack(itemImage.texture, TILE_SIZE, TILE_SIZE)).let {
|
||||||
it.setRowsAndFrames(1,1)
|
it.setRowsAndFrames(1,1)
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
|
import net.torvald.terrarum.BlockCodex
|
||||||
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIWallCalendar
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2023-09-20.
|
||||||
|
*/
|
||||||
|
class FixtureWorkbench : FixtureBase, CraftingStation {
|
||||||
|
|
||||||
|
@Transient override val tags = listOf("basiccrafting")
|
||||||
|
|
||||||
|
constructor() : super(
|
||||||
|
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 2, 1),
|
||||||
|
nameFun = { Lang["ITEM_WORKBENCH"] },
|
||||||
|
mainUI = UIWallCalendar()
|
||||||
|
) {
|
||||||
|
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/workbench.tga")
|
||||||
|
|
||||||
|
density = BlockCodex[Block.PLANK_NORMAL].density.toDouble()
|
||||||
|
setHitboxDimension(itemImage.texture.width, itemImage.texture.height, 0, 0)
|
||||||
|
|
||||||
|
makeNewSprite(TextureRegionPack(itemImage.texture, itemImage.texture.width, itemImage.texture.height)).let {
|
||||||
|
it.setRowsAndFrames(1,1)
|
||||||
|
}
|
||||||
|
|
||||||
|
actorValue[AVKey.BASEMASS] = 20.0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.BlockCodex
|
||||||
import net.torvald.terrarum.WireCodex
|
import net.torvald.terrarum.WireCodex
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,13 +73,20 @@ object PlayerBuilderSigrid {
|
|||||||
|
|
||||||
fun fillTestInventory(inventory: ActorInventory) {
|
fun fillTestInventory(inventory: ActorInventory) {
|
||||||
|
|
||||||
App.tileMaker.tags.forEach { t, _ ->
|
App.tileMaker.tags.forEach { (t, _) ->
|
||||||
inventory.add(t, 9995)
|
if (!BlockCodex[t].isActorBlock) {
|
||||||
try {
|
|
||||||
inventory.add("wall@$t", 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs
|
inventory.add(t, 9995)
|
||||||
}
|
try {
|
||||||
catch (e: Throwable) {
|
inventory.add(
|
||||||
System.err.println("[PlayerBuilder] $e")
|
"wall@$t",
|
||||||
|
9995
|
||||||
|
) // this code will try to add nonexisting wall items, do not get surprised with NPEs
|
||||||
|
}
|
||||||
|
catch (e: NullPointerException) { /* tHiS iS fInE */ }
|
||||||
|
catch (e: Throwable) {
|
||||||
|
System.err.println("[PlayerBuilder] $e")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +108,8 @@ object PlayerBuilderSigrid {
|
|||||||
|
|
||||||
inventory.add("item@basegame:11", 10) // calendar
|
inventory.add("item@basegame:11", 10) // calendar
|
||||||
|
|
||||||
|
inventory.add("item@basegame:16", 10) // workbench
|
||||||
|
|
||||||
// inventory.add("item@basegame:256", 995) // doors
|
// inventory.add("item@basegame:256", 995) // doors
|
||||||
// inventory.add("item@basegame:257", 995) // doors
|
// inventory.add("item@basegame:257", 995) // doors
|
||||||
// inventory.add("item@basegame:258", 995) // doors
|
// inventory.add("item@basegame:258", 995) // doors
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.gameitems
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2023-09-20.
|
||||||
|
*/
|
||||||
|
class ItemWorkbench(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureWorkbench") {
|
||||||
|
|
||||||
|
|
||||||
|
override val originalName = "ITEM_WORKBENCH"
|
||||||
|
override var baseMass = 20.0
|
||||||
|
override var stackable = true
|
||||||
|
override var inventoryCategory = Category.MISC
|
||||||
|
override val isUnique = false
|
||||||
|
override val isDynamic = false
|
||||||
|
override val materialId = ""
|
||||||
|
override val itemImage: TextureRegion
|
||||||
|
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/workbench.tga")
|
||||||
|
|
||||||
|
override var baseToolSize: Double? = baseMass
|
||||||
|
|
||||||
|
init {
|
||||||
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,8 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.App.gamepadLabelLEFTRIGHT
|
import net.torvald.terrarum.App.*
|
||||||
import net.torvald.terrarum.App.gamepadLabelStart
|
|
||||||
import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL
|
import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
@@ -13,6 +12,7 @@ import net.torvald.terrarum.gameitems.ItemID
|
|||||||
import net.torvald.terrarum.gameitems.isWall
|
import net.torvald.terrarum.gameitems.isWall
|
||||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameactors.CraftingStation
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
||||||
@@ -121,7 +121,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
// list of [Score, Ingredients, Recipe]
|
// list of [Score, Ingredients, Recipe]
|
||||||
recipes.map { recipe ->
|
recipes.map { recipe ->
|
||||||
// list of (Item, How many player has, How many the recipe requires)
|
// list of (Item, How many player has, How many the recipe requires)
|
||||||
val items = recipeToIngredientRecord(player, recipe, listOf(/*todo: nearby crafting stations*/))
|
val items = recipeToIngredientRecord(player, recipe, nearbyCraftingStations)
|
||||||
|
|
||||||
val score = items.fold(1L) { acc, item ->
|
val score = items.fold(1L) { acc, item ->
|
||||||
(item.howManyPlayerHas).times(16L) + 1L
|
(item.howManyPlayerHas).times(16L) + 1L
|
||||||
@@ -330,6 +330,16 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
addUIitem(buttonCraft)
|
addUIitem(buttonCraft)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nearbyCraftingStations = emptyList<String>(); protected set
|
||||||
|
|
||||||
|
fun getCraftingStationsWithinReach(): List<String> {
|
||||||
|
val reach = INGAME.actorNowPlaying!!.actorValue.getAsDouble(AVKey.REACH)!! * (INGAME.actorNowPlaying!!.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * INGAME.actorNowPlaying!!.scale
|
||||||
|
val nearbyCraftingStations = INGAME.findKNearestActors(INGAME.actorNowPlaying!!, 256) {
|
||||||
|
it is CraftingStation && (distBetweenActors(it, INGAME.actorNowPlaying!!) < reach)
|
||||||
|
}
|
||||||
|
return nearbyCraftingStations.flatMap { (it.get() as CraftingStation).tags }
|
||||||
|
}
|
||||||
|
|
||||||
private fun changeIngredient(old: InventoryPair, new: ItemID) {
|
private fun changeIngredient(old: InventoryPair, new: ItemID) {
|
||||||
itemListPlayer.removeFromForceHighlightList(oldSelectedItems)
|
itemListPlayer.removeFromForceHighlightList(oldSelectedItems)
|
||||||
|
|
||||||
@@ -391,6 +401,9 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
private var openingClickLatched = false
|
private var openingClickLatched = false
|
||||||
|
|
||||||
override fun show() {
|
override fun show() {
|
||||||
|
nearbyCraftingStations = getCraftingStationsWithinReach()
|
||||||
|
// printdbg(this, "Nearby crafting stations: $nearbyCraftingStations")
|
||||||
|
|
||||||
itemListPlayer.getInventory = { INGAME.actorNowPlaying!!.inventory }
|
itemListPlayer.getInventory = { INGAME.actorNowPlaying!!.inventory }
|
||||||
itemListUpdate()
|
itemListUpdate()
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ class UIItemCraftingCandidateGrid(
|
|||||||
craftingRecipes.clear()
|
craftingRecipes.clear()
|
||||||
CraftingRecipeCodex.props.forEach { (_, recipes) ->
|
CraftingRecipeCodex.props.forEach { (_, recipes) ->
|
||||||
recipes.forEach {
|
recipes.forEach {
|
||||||
// TODO check for nearby crafting stations
|
if (isCraftable((parentUI as UICrafting).getPlayerInventory(), it, (parentUI as UICrafting).nearbyCraftingStations)) craftingRecipes.add(it)
|
||||||
if (isCraftable((parentUI as UICrafting).getPlayerInventory(), it, listOf(/*todo: nearby crafting stations*/))) craftingRecipes.add(it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user