Skip to content

Commit a12bcaa

Browse files
committed
Better build settings
1 parent 97b1cb1 commit a12bcaa

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.lambda.config.groups
22

33
interface BuildConfig {
4+
val breakCoolDown: Int
5+
val placeCooldown: Int
46
val collectDrops: Boolean
57
val breakWeakBlocks: Boolean
68
val pathing: Boolean
7-
val interactLimit: Int
8-
val breakInstantAtOnce: Boolean
9+
val breaksPerTick: Int
910
val rotateForBreak: Boolean
1011
val swingHand: Boolean
1112
}

common/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ class BuildSettings(
66
c: Configurable,
77
vis: () -> Boolean = { true }
88
) : BuildConfig {
9+
override val breakCoolDown by c.setting("Break Cooldown", 0, 0..20, 1, "Delay between breaking blocks", " ticks", vis)
10+
override val placeCooldown by c.setting("Place Cooldown", 0, 0..20, 1, "Delay between placing blocks", " ticks", vis)
911
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis)
1012
override val breakWeakBlocks by c.setting("Break Weak Blocks", false, "Break blocks that dont have structural integrity (e.g: grass)", vis)
1113
override val pathing by c.setting("Pathing", true, "Path to blocks", vis)
12-
override val interactLimit by c.setting("Interaction Limit", 15, 1..100, 1, "Max interactions per tick", " i/t", vis)
13-
override val breakInstantAtOnce by c.setting("Break Instant At Once", true, "Break all instant blocks at once", vis)
14+
override val breaksPerTick by c.setting("Instant Breaks Per Tick", 10, 1..30, 1, "Maximum instant block breaks per tick", "", vis)
1415
override val rotateForBreak by c.setting("Rotate For Break", false, "Rotate towards block while breaking", vis)
1516
override val swingHand by c.setting("Swing Hand", true, "Swing hand on interactions", vis)
1617
}

common/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RotationSettings(
1212
override var rotationMode by c.setting("Mode", RotationMode.SYNC, "SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera", vis)
1313
override val keepTicks by c.setting("Keep Rotation", 3, 1..10, 1, "Ticks to keep rotation", " ticks", vis)
1414
override val resetTicks by c.setting("Reset Rotation", 3, 1..10, 1, "Ticks before rotation is reset", " ticks", vis)
15-
override var instant by c.setting("Instant Rotation", false, "Instantly rotate", vis)
15+
override var instant by c.setting("Instant Rotation", true, "Instantly rotate", vis)
1616
override var mean by c.setting("Mean", 20.0, 1.0..80.0, 0.1, "Average rotation speed") { vis() && !instant }
1717
override var derivation by c.setting("Standard Deviation", 5.0, 0.0..20.0, 0.1, "Spread of rotation speeds") { vis() && !instant }
1818

common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import com.lambda.interaction.construction.DynamicBlueprint
1111
import com.lambda.interaction.construction.StaticBlueprint.Companion.toBlueprint
1212
import com.lambda.interaction.construction.context.BreakContext
1313
import com.lambda.interaction.construction.context.PlaceContext
14-
import com.lambda.interaction.construction.result.BreakResult
15-
import com.lambda.interaction.construction.result.BuildResult
16-
import com.lambda.interaction.construction.result.PlaceResult
17-
import com.lambda.interaction.construction.result.Resolvable
14+
import com.lambda.interaction.construction.result.*
1815
import com.lambda.interaction.construction.simulation.BuildSimulator
1916
import com.lambda.interaction.construction.simulation.BuildSimulator.simulate
2017
import com.lambda.interaction.construction.verify.TargetState
@@ -50,7 +47,8 @@ class BuildStructure @Ta5kBuilder constructor(
5047
private val blueprint: Blueprint,
5148
private val finishOnDone: Boolean = true,
5249
private val pathing: Boolean = TaskFlow.build.pathing,
53-
private val collectDrops: Boolean = TaskFlow.build.collectDrops,
50+
val collectDrops: Boolean = TaskFlow.build.collectDrops,
51+
private val cancelOnUnsolvable: Boolean = true,
5452
) : Task<Unit>() {
5553
private var lastTask: Task<*>? = null
5654

@@ -72,33 +70,29 @@ class BuildStructure @Ta5kBuilder constructor(
7270
val instantResults = results.filterIsInstance<BreakResult.Success>()
7371
.filter { it.context.instantBreak }
7472
.sorted()
75-
.take(TaskFlow.build.interactLimit)
73+
.take(TaskFlow.build.breaksPerTick)
7674

77-
if (TaskFlow.build.breakInstantAtOnce && instantResults.isNotEmpty()) {
78-
// cancelSubTasks()
75+
if (TaskFlow.build.breaksPerTick > 1 && instantResults.isNotEmpty()) {
7976
instantResults.forEach {
80-
it.resolve.start(this@BuildStructure, false)
77+
it.resolve.start(this@BuildStructure, pauseParent = false)
8178
}
8279
lastTask = instantResults.last().resolve
8380
return@listener
8481
}
8582

8683
results.minOrNull()?.let { result ->
87-
if (!pathing && result is BuildResult.OutOfReach) return@let
84+
if (!pathing && result is Navigable) return@let
8885

8986
if (result !is Resolvable) {
9087
if (result is BuildResult.Done) {
9188
checkDone()
92-
} else {
89+
} else if (cancelOnUnsolvable) {
9390
failure("Failed to resolve build result: $result")
9491
return@listener
9592
}
9693
return@listener
9794
}
98-
// if (lastTask?.isCompleted == false) return@listener
99-
10095
lastTask = result.resolve
101-
// cancelSubTasks()
10296

10397
LOG.info("Resolving: $result")
10498
result.resolve.start(this@BuildStructure)
@@ -120,12 +114,14 @@ class BuildStructure @Ta5kBuilder constructor(
120114
finishOnDone: Boolean = true,
121115
collectDrops: Boolean = TaskFlow.build.collectDrops,
122116
pathing: Boolean = TaskFlow.build.pathing,
117+
cancelOnUnsolvable: Boolean = true,
123118
blueprint: () -> Blueprint,
124119
) = BuildStructure(
125120
blueprint(),
126121
finishOnDone,
127122
pathing,
128123
collectDrops,
124+
cancelOnUnsolvable
129125
)
130126

131127
@Ta5kBuilder

0 commit comments

Comments
 (0)