Skip to content

Commit 9f6c8dd

Browse files
committed
more BreakManager documentation
1 parent 832a2a4 commit 9f6c8dd

File tree

1 file changed

+26
-1
lines changed
  • common/src/main/kotlin/com/lambda/interaction/request/breaking

1 file changed

+26
-1
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ object BreakManager : RequestHandler<BreakRequest>(
151151
}
152152
}
153153

154+
/**
155+
* Attempts to accept and process the request, if there is not already an [activeRequest].
156+
* If the request is processed and all breaks completed, the [activeRequest] is cleared.
157+
*
158+
* @see processRequest
159+
*/
154160
override fun SafeContext.handleRequest(request: BreakRequest) {
155161
if (activeRequest != null || PlaceManager.activeThisTick) return
156162

@@ -164,6 +170,16 @@ object BreakManager : RequestHandler<BreakRequest>(
164170
}
165171
}
166172

173+
/**
174+
* If the request is fresh, local variables are populated through the [processRequest] method.
175+
* It then attempts to perform as many breaks within this tick as possible from the [instantBreaks] collection.
176+
* The [breakInfos] are then updated if the dependencies are present, E.G. if the user has rotations enabled,
177+
* or the player needs to swap to a different hotbar slot.
178+
*
179+
* @see performInstantBreaks
180+
* @see processNewBreaks
181+
* @see updateBreakProgress
182+
*/
167183
private fun SafeContext.processRequest(request: BreakRequest) {
168184
pendingBreaks.cleanUp()
169185

@@ -194,6 +210,15 @@ object BreakManager : RequestHandler<BreakRequest>(
194210
}
195211
}
196212

213+
/**
214+
* Filters and sorts the requests [BreakContext]s, and iterates over the [breakInfos] collection looking for matches
215+
* in positions. If a match is found, the [BreakInfo] is updated with the new context. Otherwise, the break is cancelled.
216+
* The [instantBreaks] and [breaks] collections are then populated with the new appropriate contexts, and the [maxBreaksThisTick]
217+
* value is set.
218+
*
219+
* @see canAccept
220+
* @see cancelBreak
221+
*/
197222
private fun SafeContext.populateFrom(request: BreakRequest) {
198223
// Sanitize and sort the new breaks
199224
val newBreaks = request.contexts
@@ -404,7 +429,7 @@ object BreakManager : RequestHandler<BreakRequest>(
404429
}
405430

406431
/**
407-
* Nullifies the break. If the block is not broken, the [BreakInfo.internalOnBreak] callback gets triggered
432+
* Nullifies the break. If the block is not broken, the [BreakInfo.internalOnCancel] callback gets triggered
408433
*/
409434
private fun BreakInfo.nullify() {
410435
type.nullify()

0 commit comments

Comments
 (0)