no secondary click; tiki torch kinda spawns?

This commit is contained in:
minjaesong
2019-05-26 22:55:50 +09:00
parent 3f692da03c
commit 84a35abb37
16 changed files with 108 additions and 70 deletions

View File

@@ -404,7 +404,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
ItemCodex[itemOnGrip]?.endPrimaryUse(delta)
}
override fun worldSecondaryClickStart(delta: Float) {
// I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
/*override fun worldSecondaryClickStart(delta: Float) {
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
val consumptionSuccessful = ItemCodex[itemOnGrip]?.startSecondaryUse(delta) ?: false
if (consumptionSuccessful)
@@ -414,7 +415,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
override fun worldSecondaryClickEnd(delta: Float) {
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
ItemCodex[itemOnGrip]?.endSecondaryUse(delta)
}
}*/

View File

@@ -42,20 +42,27 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
// posY: bottom of the blockBox
// using the actor's hitbox
// TODO: obviously check for collision
for (x in posX until posX + blockBox.width) {
for (y in posY until posY + blockBox.height) {
world.setTileTerrain(x, y, blockBox.collisionType)
}
}
// set the position of this actor
worldBlockPos = Point2i(posX, posY)
this.isVisible = true
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
// actually add this actor into the world
Terrarum.ingame!!.addNewActor(this)
return true // TODO for the tests' sake, just get fucking spawned
// TODO TESTING RESULTS SO FAR: tiki torch does emit lights, but its body cannot be seen
}
/**

View File

@@ -25,10 +25,17 @@ class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
get() = AppLoader.resourcePool.getAsTextureRegion("itemplaceholder_48")
override var baseToolSize: Double? = baseMass
init {
equipPosition = EquipPosition.HAND_GRIP
}
override fun startPrimaryUse(delta: Float): Boolean {
val torch = FixtureTikiTorch()
//println("aroisetn")
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
// return true when placed, false when cannot be placed
}
}

View File

@@ -1,7 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameworld
import com.badlogic.gdx.graphics.Color
import net.torvald.aa.KDHeapifiedTree
import net.torvald.aa.KDTree
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.BlockCodex
@@ -52,7 +52,7 @@ object WorldSimulator {
private val ingame = Terrarum.ingame!!
private val world = ingame.world
private var actorsKDTree: KDHeapifiedTree? = null
private var actorsKDTree: KDTree? = null
fun resetForThisFrame() {
actorsKDTree = null
@@ -61,7 +61,7 @@ object WorldSimulator {
operator fun invoke(player: ActorHumanoid?, delta: Float) {
// build the kdtree that will be used during a single frame of updating
if (actorsKDTree == null)
actorsKDTree = KDHeapifiedTree(ingame.actorContainerActive.filter { it is ActorWBMovable })
actorsKDTree = KDTree(ingame.actorContainerActive.filter { it is ActorWBMovable })
//printdbg(this, "============================")