[fix] BaritoneUtils not unpausing correctly (#1758)

* Fix not unpausing even though control is lost

Sometimes, we call unpause() even though the temporary process lost
control. We should still change the paused variable to false if it is
paused regardless.

Co-authored-by: theredstoner <huddy987@yahoo.com>
Co-authored-by: Xiaro <62033805+Xiaro@users.noreply.github.com>
This commit is contained in:
Hudson Shykowski 2020-12-23 15:21:49 -07:00 committed by GitHub
parent 43ad247470
commit 0a571361a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 12 deletions

View File

@ -15,26 +15,17 @@ object BaritoneUtils {
val isPathing get() = primary?.pathingBehavior?.isPathing ?: false val isPathing get() = primary?.pathingBehavior?.isPathing ?: false
val isActive val isActive
get() = primary?.customGoalProcess?.isActive ?: false get() = primary?.customGoalProcess?.isActive ?: false
|| primary?.pathingControlManager?.mostRecentInControl()?.let { || primary?.pathingControlManager?.mostRecentInControl()?.orElse(null)?.isActive ?: false
it.isPresent && it.get().isActive
} ?: false
fun pause() { fun pause() {
if (!paused) { if (!paused) {
primary?.pathingControlManager?.registerProcess(TemporaryPauseProcess)
paused = true paused = true
primary?.pathingControlManager?.registerProcess(TemporaryPauseProcess)
} }
} }
fun unpause() { fun unpause() {
if (paused) { paused = false
primary?.pathingControlManager?.mostRecentInControl()?.let {
if (it.isPresent && it.get() == TemporaryPauseProcess) /* Don't run if not paused lol */ {
paused = false
it.get().onLostControl()
}
}
}
} }
fun cancelEverything() = primary?.pathingBehavior?.cancelEverything() fun cancelEverything() = primary?.pathingBehavior?.cancelEverything()