mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fix: moving platform is dragging player into the terrain again
This commit is contained in:
@@ -56,7 +56,7 @@ abstract class PhysContraption() : ActorWithBody() {
|
|||||||
val oldY = hitbox.startY
|
val oldY = hitbox.startY
|
||||||
|
|
||||||
// Set externalV to our contraption velocity so super translates the hitbox
|
// Set externalV to our contraption velocity so super translates the hitbox
|
||||||
externalV.set(contraptionVelocity.x, contraptionVelocity.y)
|
externalV.set(contraptionVelocity)
|
||||||
|
|
||||||
// super.updateImpl handles:
|
// super.updateImpl handles:
|
||||||
// - sprite updates
|
// - sprite updates
|
||||||
@@ -72,6 +72,7 @@ abstract class PhysContraption() : ActorWithBody() {
|
|||||||
// --- Step 1: Move existing riders BEFORE mount detection ---
|
// --- Step 1: Move existing riders BEFORE mount detection ---
|
||||||
// This keeps riders aligned with the contraption's new position so the
|
// This keeps riders aligned with the contraption's new position so the
|
||||||
// mount check doesn't fail when the contraption is moving fast.
|
// mount check doesn't fail when the contraption is moving fast.
|
||||||
|
val terrainDismounted = HashSet<ActorID>()
|
||||||
for (riderId in actorsRiding.toList()) {
|
for (riderId in actorsRiding.toList()) {
|
||||||
val rider = INGAME.getActorByID(riderId) as? ActorWithBody ?: continue
|
val rider = INGAME.getActorByID(riderId) as? ActorWithBody ?: continue
|
||||||
|
|
||||||
@@ -97,6 +98,7 @@ abstract class PhysContraption() : ActorWithBody() {
|
|||||||
rider.hitbox.setPositionY(oldRiderY)
|
rider.hitbox.setPositionY(oldRiderY)
|
||||||
actorsRiding.remove(rider.referenceID)
|
actorsRiding.remove(rider.referenceID)
|
||||||
rider.platformsRiding.remove(this.referenceID)
|
rider.platformsRiding.remove(this.referenceID)
|
||||||
|
terrainDismounted.add(rider.referenceID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,6 +158,7 @@ abstract class PhysContraption() : ActorWithBody() {
|
|||||||
|
|
||||||
for (actor in candidates) {
|
for (actor in candidates) {
|
||||||
if (actorsRiding.contains(actor.referenceID)) continue
|
if (actorsRiding.contains(actor.referenceID)) continue
|
||||||
|
if (terrainDismounted.contains(actor.referenceID)) continue
|
||||||
if (actor is ActorHumanoid && actor.downButtonHeld > 0) continue
|
if (actor is ActorHumanoid && actor.downButtonHeld > 0) continue
|
||||||
if (!isActorOnTop(actor)) continue
|
if (!isActorOnTop(actor)) continue
|
||||||
|
|
||||||
@@ -215,7 +218,6 @@ abstract class PhysContraption() : ActorWithBody() {
|
|||||||
actor.platformsRiding.remove(this.referenceID)
|
actor.platformsRiding.remove(this.referenceID)
|
||||||
|
|
||||||
// Conservation of momentum: add contraption velocity as impulse
|
// Conservation of momentum: add contraption velocity as impulse
|
||||||
actor.externalV.x += contraptionVelocity.x
|
actor.externalV += contraptionVelocity
|
||||||
actor.externalV.y += contraptionVelocity.y
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import kotlin.math.sin
|
|||||||
class ActorTestPlatform : ActorMovingPlatform(8) {
|
class ActorTestPlatform : ActorMovingPlatform(8) {
|
||||||
|
|
||||||
/** Movement pattern index (0-3). */
|
/** Movement pattern index (0-3). */
|
||||||
private val pattern: Int = (0..1).random()
|
private val pattern: Int = (0..3).random()
|
||||||
|
|
||||||
/** Speed in pixels per tick (2.0 to 4.0). */
|
/** Speed in pixels per tick (2.0 to 4.0). */
|
||||||
private val speed: Double = 2.0 + Math.random() * 2.0
|
private val speed: Double = 2.0 + Math.random() * 2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user