Skip to content

Commit 2683c5b

Browse files
committed
update breaks regardless if active request is null or not and return for each if break stage mask doesnt match as other breaks could have a different config
1 parent 1938a2f commit 2683c5b

File tree

1 file changed

+13
-8
lines changed
  • common/src/main/kotlin/com/lambda/interaction/request/breaking

1 file changed

+13
-8
lines changed

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object BreakManager : RequestHandler<BreakRequest>(
6767
TickEvent.Input.Pre,
6868
TickEvent.Player.Post,
6969
// ToDo: Post interact
70-
onOpen = { activeRequest?.let { processRequest(it) } }
70+
onOpen = { processRequest(activeRequest) }
7171
), PositionBlocking {
7272
private var primaryBreak: BreakInfo?
7373
get() = breakInfos[0]
@@ -125,6 +125,8 @@ object BreakManager : RequestHandler<BreakRequest>(
125125
}
126126
}
127127
activeRequest = null
128+
breaks = mutableListOf()
129+
instantBreaks = mutableListOf()
128130
breaksThisTick = 0
129131
}
130132

@@ -198,21 +200,23 @@ object BreakManager : RequestHandler<BreakRequest>(
198200
* @see processNewBreaks
199201
* @see updateBreakProgress
200202
*/
201-
private fun SafeContext.processRequest(request: BreakRequest) {
203+
private fun SafeContext.processRequest(breakRequest: BreakRequest?) {
202204
pendingBreaks.cleanUp()
203205

204-
if (request.fresh) populateFrom(request)
206+
breakRequest?.let { request ->
207+
if (request.fresh) populateFrom(request)
205208

206-
if (performInstantBreaks(request)) {
207-
processNewBreaks(request)
209+
if (performInstantBreaks(request)) {
210+
processNewBreaks(request)
211+
}
208212
}
209213

210214
// Reversed so that the breaking order feels natural to the user as the primary break is always the
211215
// last break to be started
212216
run {
213217
breakInfos
214218
.filterNotNull()
215-
.filter { !it.isRedundant }
219+
.filter { !it.isRedundant && it.updatedThisTick }
216220
.also {
217221
rotationRequest = it.firstOrNull { info -> info.breakConfig.rotateForBreak }
218222
?.let { info ->
@@ -223,8 +227,9 @@ object BreakManager : RequestHandler<BreakRequest>(
223227
.asReversed()
224228
.forEach { info ->
225229
if (info.updatedProgressThisTick) return@forEach
226-
if (!info.context.requestDependencies(request)) return@run
227-
if ((!rotated && info.isPrimary) || tickStage !in info.breakConfig.breakStageMask) return@run
230+
if (!info.context.requestDependencies(info.request)) return@run
231+
if (tickStage !in info.breakConfig.breakStageMask) return@forEach
232+
if ((!rotated && info.isPrimary)) return@run
228233

229234
updateBreakProgress(info)
230235
}

0 commit comments

Comments
 (0)