mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
moving platforms can 'steal' actors
This commit is contained in:
@@ -133,7 +133,19 @@ abstract class PhysContraption() : ActorWithBody() {
|
||||
INGAME.actorNowPlaying?.let { candidates.add(it) }
|
||||
|
||||
for (actor in candidates) {
|
||||
if (!actorsRiding.contains(actor.referenceID) && actor.platformsRiding.isEmpty() && isActorOnTop(actor)) {
|
||||
if (actorsRiding.contains(actor.referenceID)) continue
|
||||
if (!isActorOnTop(actor)) continue
|
||||
|
||||
// If already riding another contraption, only steal if this
|
||||
// surface is strictly above (smaller Y) to prevent oscillation.
|
||||
if (actor.platformsRiding.isNotEmpty()) {
|
||||
val currentPlatform = INGAME.getActorByID(actor.platformsRiding[0]) as? PhysContraption
|
||||
if (currentPlatform != null && hitbox.startY >= currentPlatform.hitbox.startY) continue
|
||||
// Transfer: remove from old contraption without velocity impulse
|
||||
currentPlatform?.actorsRiding?.remove(actor.referenceID)
|
||||
actor.platformsRiding.clear()
|
||||
}
|
||||
|
||||
mount(actor)
|
||||
snapRiderToSurface(actor)
|
||||
// Landing on the contraption kills all vertical velocity.
|
||||
@@ -146,7 +158,6 @@ abstract class PhysContraption() : ActorWithBody() {
|
||||
actor.walledBottom = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Geometry check: is this actor positioned on top of the contraption such that
|
||||
|
||||
Reference in New Issue
Block a user