Skip to content

Commit b03a3d9

Browse files
committed
Add RotationMode.NONE
1 parent 9329c6f commit b03a3d9

File tree

3 files changed

+16
-43
lines changed

3 files changed

+16
-43
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ interface RotationConfig {
4242
*/
4343
val resetTicks: Int
4444

45+
val rotate: Boolean get() = rotationMode != RotationMode.NONE
46+
4547
interface Instant : RotationConfig {
4648
override val turnSpeed get() = 360.0
4749
override val keepTicks get() = 1

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

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,28 @@ class RotationSettings(
2626
c: Configurable,
2727
vis: () -> Boolean = { true },
2828
) : RotationConfig {
29-
/**
30-
* The rotation mode
31-
*/
32-
override var rotationMode by c.setting(
33-
"Mode",
34-
RotationMode.SYNC,
35-
"SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera",
36-
vis
37-
)
29+
override var rotationMode by c.setting("Mode", RotationMode.SYNC, "SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera, NONE - No rotation", vis)
3830

39-
/**
40-
* How many ticks to keep the rotation before resetting
41-
*/
42-
override val keepTicks by c.setting("Keep Rotation", 3, 0..10, 1, "Ticks to keep rotation", " ticks", vis)
31+
/** How many ticks to keep the rotation before resetting */
32+
override val keepTicks by c.setting("Keep Rotation", 3, 0..10, 1, "Ticks to keep rotation", " ticks") { rotate && vis() }
4333

44-
/**
45-
* How many ticks to wait before resetting the rotation
46-
*/
47-
override val resetTicks by c.setting("Reset Rotation", 3, 1..10, 1, "Ticks before rotation is reset", " ticks", vis)
34+
/** How many ticks to wait before resetting the rotation */
35+
override val resetTicks by c.setting("Reset Rotation", 3, 1..10, 1, "Ticks before rotation is reset", " ticks") { rotate && vis() }
4836

49-
/**
50-
* Whether the rotation is instant
51-
*/
52-
var instant by c.setting("Instant Rotation", true, "Instantly rotate", vis)
37+
/** Whether the rotation is instant */
38+
var instant by c.setting("Instant Rotation", true, "Instantly rotate") { rotate && vis() }
5339

5440
/**
5541
* The mean (average/base) value used to calculate rotation speed.
5642
* This value represents the center of the distribution.
5743
*/
58-
private var mean by c.setting(
59-
"Mean",
60-
40.0,
61-
1.0..120.0,
62-
0.1,
63-
"Average rotation speed",
64-
unit = "°"
65-
) { vis() && !instant }
44+
private var mean by c.setting("Mean", 40.0, 1.0..120.0, 0.1, "Average rotation speed", unit = "°") { rotate && vis() && !instant }
6645

6746
/**
6847
* The standard deviation for the Gaussian distribution used to calculate rotation speed.
6948
* This value represents the spread of rotation speed.
7049
*/
71-
private var spread by c.setting(
72-
"Spread",
73-
10.0,
74-
0.0..60.0,
75-
0.1,
76-
"Spread of rotation speeds",
77-
unit = "°"
78-
) { vis() && !instant }
50+
private var spread by c.setting("Spread", 10.0, 0.0..60.0, 0.1, "Spread of rotation speeds", unit = "°") { rotate && vis() && !instant }
7951

8052
/**
8153
* We must always provide turn speed to the interpolator because the player's yaw might exceed the -180 to 180 range.

common/src/main/kotlin/com/lambda/interaction/RotationManager.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ object RotationManager : Loadable {
6969
var lastCtx: RotationContext? = null
7070

7171
listen<RotationEvent.Update>(priority, alwaysListen) { event ->
72-
val rotationContext = builder.onUpdate?.invoke(this, event.context)
73-
74-
rotationContext?.let {
75-
event.context = it
72+
builder.onUpdate?.invoke(this, event.context)?.let { context ->
73+
if (!context.config.rotate) return@let
74+
event.context = context
75+
lastCtx = context
7676
}
77-
78-
lastCtx = rotationContext
7977
}
8078

8179
listen<RotationEvent.Post> { event ->
80+
if (!event.context.config.rotate) return@listen
8281
if (event.context == lastCtx) {
8382
builder.onReceive?.invoke(this, event.context)
8483
}

0 commit comments

Comments
 (0)