mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
dropped item can be picked up (at a weird distance)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user