mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
fix: code for staircase climbing would interfere with hold-left/right-and-jump manoeuvre
This commit is contained in:
@@ -11,6 +11,11 @@ import java.net.URL
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.ThreadPoolExecutor
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-10-03.
|
||||
@@ -35,14 +40,18 @@ object CheckUpdate {
|
||||
|
||||
var ret: String? = null
|
||||
var fail: Throwable? = null
|
||||
try {
|
||||
// check the http connection before we do anything to the fs
|
||||
val client = HttpClient.newBuilder().build()
|
||||
val request = HttpRequest.newBuilder().uri(URI.create(url)).build()
|
||||
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
|
||||
ret = if (response.statusCode() >= 400) null else response.body()
|
||||
|
||||
printdbg(this, "HTTP ${response.statusCode()}")
|
||||
try {
|
||||
val callable = Callable {
|
||||
// check the http connection before we do anything to the fs
|
||||
val client = HttpClient.newBuilder().build()
|
||||
val request = HttpRequest.newBuilder().uri(URI.create(url)).build()
|
||||
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
|
||||
ret = if (response.statusCode() >= 400) null else response.body()
|
||||
printdbg(this, "HTTP ${response.statusCode()}")
|
||||
}
|
||||
val exec = Executors.newSingleThreadExecutor()
|
||||
exec.submit(callable).get(5L, TimeUnit.SECONDS)
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
fail = e
|
||||
|
||||
@@ -1207,6 +1207,8 @@ open class ActorWithBody : Actor {
|
||||
IMPORTANT AF NOTE: things are ASYMMETRIC!
|
||||
*/
|
||||
|
||||
val canUseStairs = option and COLLIDING_LR != 0 && (externalV + (controllerV ?: Vector2())).y.absoluteValue < 1.0
|
||||
|
||||
if (option.popcnt() == 1) {
|
||||
val (x1, x2, y1, y2) = hitbox.getWallDetection(option)
|
||||
|
||||
@@ -1215,7 +1217,12 @@ open class ActorWithBody : Actor {
|
||||
val tyStart = y1/*.plus(HALF_PIXEL)*/.floorToInt()
|
||||
val tyEnd = y2/*.plus(HALF_PIXEL)*/.floorToInt()
|
||||
|
||||
return isCollidingInternalStairs(txStart, tyStart, txEnd, tyEnd, option == COLLIDING_BOTTOM).first == 2
|
||||
return isCollidingInternalStairs(txStart, tyStart, txEnd, tyEnd, option == COLLIDING_BOTTOM).first.let { status ->
|
||||
if (canUseStairs)
|
||||
status == 2
|
||||
else
|
||||
status > 0
|
||||
}
|
||||
}
|
||||
else if (option == COLLIDING_ALLSIDE) {
|
||||
return isWalled(hitbox, COLLIDING_LEFT) || isWalled(hitbox, COLLIDING_RIGHT) ||
|
||||
|
||||
@@ -482,6 +482,8 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
* @author minjaesong
|
||||
*/
|
||||
private fun walkHorizontal(left: Boolean, absAxisVal: Float) {
|
||||
// Heading flag
|
||||
walkHeading = if (left) LEFT else RIGHT
|
||||
|
||||
|
||||
if (avAcceleration.isNaN()) {
|
||||
@@ -489,30 +491,33 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
}
|
||||
|
||||
|
||||
if (left && walledLeft || !left && walledRight) return
|
||||
if (left && walledLeft || !left && walledRight) {
|
||||
walkHStop()
|
||||
|
||||
controllerV?.x = 0.0
|
||||
}
|
||||
else {
|
||||
isWalkingH = true
|
||||
|
||||
readonly_totalX =
|
||||
readonly_totalX =
|
||||
if (absAxisVal == AXIS_KEYBOARD)
|
||||
avAcceleration * applyVelo(walkCounterX) * (if (left) -1f else 1f)
|
||||
else
|
||||
avAcceleration * applyVelo(walkCounterX) * (if (left) -1f else 1f) * absAxisVal
|
||||
|
||||
if (absAxisVal != AXIS_KEYBOARD)
|
||||
controllerV?.x?.let { controllerV!!.x = controllerV!!.x.plus(readonly_totalX).bipolarClamp(avSpeedCap * absAxisVal) }
|
||||
else
|
||||
controllerV?.x?.let { controllerV!!.x = controllerV!!.x.plus(readonly_totalX).bipolarClamp(avSpeedCap) }
|
||||
if (absAxisVal != AXIS_KEYBOARD)
|
||||
controllerV?.x?.let {
|
||||
controllerV!!.x = controllerV!!.x.plus(readonly_totalX).bipolarClamp(avSpeedCap * absAxisVal)
|
||||
}
|
||||
else
|
||||
controllerV?.x?.let { controllerV!!.x = controllerV!!.x.plus(readonly_totalX).bipolarClamp(avSpeedCap) }
|
||||
|
||||
if (walkCounterX <= WALK_FRAMES_TO_MAX_ACCEL) {
|
||||
walkCounterX += 1
|
||||
|
||||
if (walkCounterX <= WALK_FRAMES_TO_MAX_ACCEL) {
|
||||
walkCounterX += 1
|
||||
}
|
||||
}
|
||||
|
||||
isWalkingH = true
|
||||
|
||||
|
||||
|
||||
// Heading flag
|
||||
walkHeading = if (left) LEFT else RIGHT
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user