-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathAutomationConfig.kt
More file actions
94 lines (84 loc) · 3.91 KB
/
AutomationConfig.kt
File metadata and controls
94 lines (84 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lambda.config
import com.lambda.config.configurations.AutomationConfigs
import com.lambda.config.groups.BreakSettings
import com.lambda.config.groups.BuildSettings
import com.lambda.config.groups.EatSettings
import com.lambda.config.groups.HotbarSettings
import com.lambda.config.groups.InteractSettings
import com.lambda.config.groups.InventorySettings
import com.lambda.config.groups.RotationSettings
import com.lambda.context.Automated
import com.lambda.event.events.onStaticRender
import com.lambda.interaction.construction.simulation.result.Drawable
import com.lambda.module.Module
import com.lambda.util.NamedEnum
open class AutomationConfig(
override val name: String,
configuration: Configuration = AutomationConfigs
) : Configurable(configuration), Automated {
enum class Group(override val displayName: String) : NamedEnum {
Build("Build"),
Break("Break"),
Interact("Interact"),
Rotation("Rotation"),
Inventory("Inventory"),
Hotbar("Hotbar"),
Eat("Eat"),
Render("Render"),
Debug("Debug")
}
override val buildConfig = BuildSettings(this, Group.Build)
override val breakConfig = BreakSettings(this, Group.Break)
override val interactConfig = InteractSettings(this, Group.Interact)
override val rotationConfig = RotationSettings(this, Group.Rotation)
override val inventoryConfig = InventorySettings(this, Group.Inventory)
override val hotbarConfig = HotbarSettings(this, Group.Hotbar)
override val eatConfig = EatSettings(this, Group.Eat)
companion object {
context(module: Module)
fun MutableAutomationConfig.setDefaultAutomationConfig(
name: String = module.name,
edits: (AutomationConfig.() -> Unit)? = null
) {
defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
}
fun MutableAutomationConfig.setDefaultAutomationConfig(
name: String,
edits: (AutomationConfig.() -> Unit)? = null
) {
defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
}
object DEFAULT : AutomationConfig("Default") {
val renders by setting("Render", false).group(Group.Render)
val avoidDesync by setting("Avoid Desync", true, "Cancels incoming inventory update packets if they match previous actions").group(Group.Debug)
val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidDesync }.group(Group.Debug)
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree").group(Group.Debug)
val shrinkFactor by setting("Shrink Factor", 0.001, 0.0..1.0, 0.001).group(Group.Debug)
val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager").group(Group.Debug)
@Volatile
var drawables = listOf<Drawable>()
init {
onStaticRender {
if (renders)
with(it) { drawables.forEach { with(it) { buildRenderer() } } }
}
}
}
}
}