dropped item can be picked up (at a weird distance)

This commit is contained in:
minjaesong
2021-10-02 17:50:27 +09:00
parent 6fda6bafe4
commit f6b0b447a4
5 changed files with 51 additions and 8 deletions

View File

@@ -17,7 +17,11 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
*/
open class DroppedItem : ActorWithBody {
private var itemID: ItemID = ""
companion object {
const val NO_PICKUP_TIME = 1f
}
var itemID: ItemID = ""; private set
@Transient private var textureRegion: TextureRegion? = null // deserialiser won't call setter of the fields
@@ -25,6 +29,10 @@ open class DroppedItem : ActorWithBody {
protected constructor()
private var timeSinceSpawned = 0f
fun canBePickedUp() = timeSinceSpawned > NO_PICKUP_TIME
constructor(itemID: ItemID, topLeftX: Int, topLeftY: Int) : super(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT) {
this.itemID = itemID
@@ -97,6 +105,7 @@ open class DroppedItem : ActorWithBody {
override fun update(delta: Float) {
super.update(delta)
timeSinceSpawned += delta
// TODO merge into the already existing droppeditem with isStationary==true if one is detected
}
}