mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 06:24:06 +09:00
still have no idea how to make this work
This commit is contained in:
37
src/net/torvald/terrarum/gameactors/ActorMovingPlatform.kt
Normal file
37
src/net/torvald/terrarum/gameactors/ActorMovingPlatform.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.ActorID
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2022-02-28.
|
||||
*/
|
||||
open class ActorMovingPlatform() : ActorWithBody() {
|
||||
|
||||
protected var tilewiseWidth = 3
|
||||
@Transient protected val actorsRiding = ArrayList<ActorID>() // saving actorID due to serialisation issues
|
||||
|
||||
init {
|
||||
physProp = PhysProperties.PHYSICS_OBJECT
|
||||
|
||||
setHitboxDimension(TILE_SIZE * tilewiseWidth, TILE_SIZE, 0, 0)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make the actor its externalV controlled by this platform
|
||||
*/
|
||||
fun mount(actor: ActorWithBody) {
|
||||
actorsRiding.add(actor.referenceID)
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the actor its externalV no longer controlled by this platform
|
||||
*/
|
||||
fun dismount(actor: ActorWithBody) {
|
||||
actorsRiding.remove(actor.referenceID)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -281,6 +281,13 @@ open class ActorWithBody : Actor {
|
||||
|
||||
var isPickedUp = false
|
||||
|
||||
/**
|
||||
* Redundant entry for ActorMovingPlatform.actorsRiding. This field must be modified by the platforms!
|
||||
*
|
||||
* Also see [net.torvald.terrarum.modulebasegame.gameactors.ActorMovingPlatform.actorsRiding]
|
||||
*/
|
||||
@Transient protected val platformsRiding = ArrayList<ActorID>()
|
||||
|
||||
/**
|
||||
* Gravitational Constant G. Load from gameworld.
|
||||
* [m / s^2]
|
||||
@@ -1064,7 +1071,7 @@ open class ActorWithBody : Actor {
|
||||
val x2 = hitbox.endX - A_PIXEL
|
||||
val y1 = hitbox.startY
|
||||
val y2 = hitbox.endY - A_PIXEL
|
||||
// this commands and the commands on isWalled WILL NOT match (1 px gap on endX/Y). THIS IS INTENDED!
|
||||
// this commands and the commands on isWalled WILL NOT match (1 px gap on endX/Y). THIS IS INTENTIONAL!
|
||||
|
||||
val txStart = x1.plus(HALF_PIXEL).floorInt()
|
||||
val txEnd = x2.plus(HALF_PIXEL).floorInt()
|
||||
|
||||
Reference in New Issue
Block a user