From 699cc4dd74874bf79651003f4177b429d4a2a7d7 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 5 Sep 2023 13:45:02 +0900 Subject: [PATCH] another failed experiment --- .../basegame/weathers/WeatherOvercast.json | 4 +-- .../terrarum/gameactors/ActorWithBody.kt | 25 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/assets/mods/basegame/weathers/WeatherOvercast.json b/assets/mods/basegame/weathers/WeatherOvercast.json index 6913b91cc..03a77944b 100644 --- a/assets/mods/basegame/weathers/WeatherOvercast.json +++ b/assets/mods/basegame/weathers/WeatherOvercast.json @@ -18,12 +18,12 @@ "cumulonimbus": { "filename": "cloud_large.png", "tw": 2048, "th": 1024, "probability": 0.4, "baseScale": 4.0, "scaleVariance": 0.3333333, - "altLow": 590, "altHigh":60 + "altLow": 1080, "altHigh":1800 }, "nimbostratus": { "filename": "cloud_wide.png", "tw": 4096, "th": 1024, "probability": 1.0, "baseScale": 8.0, "scaleVariance": 0.1, - "altLow": 600, "altHigh": 700 + "altLow": 1100, "altHigh": 1500 } }, "atmoTurbidity": 9.5 diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index e2a255c9c..549b99063 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -1108,6 +1108,7 @@ open class ActorWithBody : Actor { } private fun Hitbox.getWallDetection(option: Int): List { + val SOME_PIXEL = 1.0 // it really does NOT work if the value is not 1.0 val x1: Double val x2: Double val y1: Double @@ -1116,23 +1117,23 @@ open class ActorWithBody : Actor { COLLIDING_TOP -> { x1 = this.startX x2 = this.endX - PHYS_EPSILON_DIST - y1 = this.startY - A_PIXEL + y1 = this.startY - SOME_PIXEL y2 = y1 } COLLIDING_BOTTOM -> { x1 = this.startX x2 = this.endX - PHYS_EPSILON_DIST - y1 = this.endY - PHYS_EPSILON_DIST + A_PIXEL + y1 = this.endY - PHYS_EPSILON_DIST + SOME_PIXEL y2 = y1 } COLLIDING_LEFT -> { - x1 = this.startX - A_PIXEL + x1 = this.startX - SOME_PIXEL x2 = x1 y1 = this.startY y2 = this.endY - PHYS_EPSILON_DIST } COLLIDING_RIGHT -> { - x1 = this.endX - PHYS_EPSILON_DIST + A_PIXEL + x1 = this.endX - PHYS_EPSILON_DIST + SOME_PIXEL x2 = x1 y1 = this.startY y2 = this.endY - PHYS_EPSILON_DIST @@ -1242,6 +1243,8 @@ open class ActorWithBody : Actor { private fun isCollidingInternalStairs(pxStart: Int, pyStart: Int, pxEnd: Int, pyEnd: Int, feet: Boolean = false): Pair { if (world == null) return 0 to 0 + val cornerSize = minOf((pyEnd - pyStart) / 3, (pxEnd - pyStart) / 3) + val ys = if (gravitation.y >= 0) pyEnd downTo pyStart else pyStart..pyEnd val yheight = (ys.last - ys.first).absoluteValue var stairHeight = 0 @@ -1260,7 +1263,19 @@ open class ActorWithBody : Actor { val isFeetTileHeight = (ty == feetY) var hasFloor = false - for (x in pxStart..pxEnd) { + // octagonal shape + val xs = /*if (y < cornerSize) { + val sub = cornerSize - y + (pxStart + sub)..(pxEnd - sub) + } + else if (y > pyEnd - cornerSize) { + val sub = y - (pyEnd - cornerSize) + (pxStart + sub)..(pxEnd - sub) + } + else*/ + pxStart..pxEnd + + for (x in xs) { val tx = (x / TILE_SIZED).floorToInt() // round down toward negative infinity val tile = world!!.getTileFromTerrain(tx, ty)