mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
trying to fix phys engine platform tile bug
This commit is contained in:
@@ -1281,24 +1281,39 @@ open class ActorWithBody : Actor {
|
||||
* Very straightforward for the actual solid tiles, not so much for the platforms
|
||||
*/
|
||||
private fun shouldICollideWithThis(tile: ItemID) =
|
||||
// regular solid block
|
||||
// regular solid block
|
||||
(BlockCodex[tile].isSolid)
|
||||
|
||||
// the location and size of the platform in world coord
|
||||
protected var platformsToIgnore: Hitbox? = null
|
||||
|
||||
private fun standingOnIgnoredPlatform(): Boolean = platformsToIgnore.let {
|
||||
return if (it != null)
|
||||
hitbox.startX >= it.startX && hitbox.endX <= it.endX - PHYS_EPSILON_DIST &&
|
||||
it.startY <= hitbox.endY && hitbox.endY <= it.endY - PHYS_EPSILON_DIST
|
||||
else false
|
||||
}
|
||||
|
||||
/**
|
||||
* If this tile should be treated as "collidable"
|
||||
*
|
||||
* Just like "shouldICollideWithThis" but it's intended to work with feet tiles
|
||||
*/
|
||||
private fun shouldICollideWithThisFeet(tile: ItemID) =
|
||||
// regular solid block
|
||||
// regular solid block
|
||||
(BlockCodex[tile].isSolid) ||
|
||||
// platforms, moving downward AND not "going down"
|
||||
(this is ActorHumanoid && BlockCodex[tile].isPlatform &&
|
||||
externalV.y + (controllerV?.y ?: 0.0) >= 0.0 &&
|
||||
!this.isDownDown && this.axisY <= 0f) ||
|
||||
// platforms, moving downward
|
||||
(this !is ActorHumanoid && BlockCodex[tile].isPlatform &&
|
||||
externalV.y + (controllerV?.y ?: 0.0) >= 0.0)
|
||||
// or platforms that are not on the "ignored list" (the list is updated on the update())
|
||||
(this is ActorHumanoid && BlockCodex[tile].isPlatform && !standingOnIgnoredPlatform())
|
||||
|
||||
/*
|
||||
// platforms, moving downward AND not "going down"
|
||||
(this is ActorHumanoid && BlockCodex[tile].isPlatform &&
|
||||
externalV.y + (controllerV?.y ?: 0.0) >= 0.0 &&
|
||||
!this.isDownDown && this.axisY <= 0f) ||
|
||||
// platforms, moving downward
|
||||
(this !is ActorHumanoid && BlockCodex[tile].isPlatform &&
|
||||
externalV.y + (controllerV?.y ?: 0.0) >= 0.0)
|
||||
*/
|
||||
// TODO: as for the platform, only apply it when it's a feet tile
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user