Add a speed setting to Freecam, unclamp RegisteredValues
parent
f32cd7e20c
commit
a1cff649dd
|
@ -6,9 +6,6 @@ class FloatValue(
|
|||
name: String, value: Float,
|
||||
val min: Float = Float.MIN_VALUE, val max: Float = Float.MAX_VALUE
|
||||
) : RegisteredValue<Float>(name, value) {
|
||||
override fun valueChangeHook(orig: Float, new: Float) =
|
||||
new.coerceIn(min, max)
|
||||
|
||||
override fun convertValueFromString(representation: String): Float {
|
||||
return representation.toFloat()
|
||||
}
|
||||
|
|
|
@ -6,9 +6,6 @@ class IntegerValue(
|
|||
name: String, value: Int,
|
||||
val min: Int = Int.MIN_VALUE, val max: Int = Int.MAX_VALUE
|
||||
) : RegisteredValue<Int>(name, value) {
|
||||
override fun valueChangeHook(orig: Int, new: Int) =
|
||||
new.coerceIn(min, max)
|
||||
|
||||
override fun convertValueFromString(representation: String): Int {
|
||||
return representation.toInt()
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ class Freecam : Feature("Freecam", FeatureCategory.VISUAL) {
|
|||
private var origPitch = 0F
|
||||
|
||||
private val toggleKey by values.key("Toggle Key", GLFW_KEY_TAB)
|
||||
private val speed by values.float("Speed", 1.0f, 0.01f, 50.0f)
|
||||
|
||||
init {
|
||||
var isPlayerTicking = false
|
||||
|
@ -98,6 +99,7 @@ class Freecam : Feature("Freecam", FeatureCategory.VISUAL) {
|
|||
.multiply(movement.z)
|
||||
.add(lookVec.rotateY(-MathHelper.HALF_PI).multiply(movement.x))
|
||||
.add(0.0, movement.y, 0.0)
|
||||
.multiply(speed.toDouble())
|
||||
|
||||
view.move(MovementType.SELF, movement) // Update entity positional state properly by calling move()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue