Add base movement parameters
This commit is contained in:
parent
2aac9f405d
commit
087c4616b6
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound
|
||||
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.kstarbound.defs.MovementParameters
|
||||
import ru.dbotthepony.kstarbound.defs.player.PlayerMovementParameters
|
||||
import java.util.concurrent.ForkJoinPool
|
||||
import java.util.concurrent.ForkJoinTask
|
||||
@ -9,7 +10,10 @@ import kotlin.reflect.KMutableProperty0
|
||||
object GlobalDefaults {
|
||||
private val LOGGER = LogManager.getLogger()
|
||||
|
||||
var defaultMovementParameters = PlayerMovementParameters()
|
||||
var playerMovementParameters = PlayerMovementParameters()
|
||||
private set
|
||||
|
||||
var movementParameters = MovementParameters()
|
||||
private set
|
||||
|
||||
private object EmptyTask : ForkJoinTask<Unit>() {
|
||||
@ -44,7 +48,8 @@ object GlobalDefaults {
|
||||
fun load(log: ILoadingLog, executor: ForkJoinPool): List<ForkJoinTask<*>> {
|
||||
val tasks = ArrayList<ForkJoinTask<*>>()
|
||||
|
||||
tasks.add(load("/default_actor_movement.config", ::defaultMovementParameters, executor))
|
||||
tasks.add(load("/default_actor_movement.config", ::playerMovementParameters, executor))
|
||||
tasks.add(load("/default_movement.config", ::movementParameters, executor))
|
||||
|
||||
return listOf(executor.submit {
|
||||
val line = log.line("Loading global defaults...")
|
||||
|
@ -0,0 +1,97 @@
|
||||
package ru.dbotthepony.kstarbound.defs
|
||||
|
||||
import com.google.common.collect.ImmutableSet
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonImplementation
|
||||
import ru.dbotthepony.kstarbound.util.KOptional
|
||||
|
||||
@JsonImplementation(BaseMovementParameters.Impl::class)
|
||||
interface BaseMovementParameters {
|
||||
val mass: KOptional<Float>
|
||||
val gravityMultiplier: KOptional<Float>
|
||||
val liquidBuoyancy: KOptional<Float>
|
||||
val airBuoyancy: KOptional<Float>
|
||||
val bounceFactor: KOptional<Float>
|
||||
|
||||
// If set to true, during an update that has more than one internal movement
|
||||
// step, the movement will stop on the first bounce.
|
||||
val stopOnFirstBounce: KOptional<Boolean>
|
||||
|
||||
// Cheat when sliding on the ground, by trying to correct upwards before
|
||||
// other directions (within a set limit). Allows smooth sliding along
|
||||
// horizontal ground without losing horizontal speed.
|
||||
val enableSurfaceSlopeCorrection: KOptional<Boolean>
|
||||
val slopeSlidingFactor: KOptional<Float>
|
||||
val maxMovementPerStep: KOptional<Float>
|
||||
val maximumCorrection: KOptional<Float>
|
||||
val speedLimit: KOptional<Float>
|
||||
|
||||
val stickyCollision: KOptional<Boolean>
|
||||
val stickyForce: KOptional<Float>
|
||||
|
||||
val airFriction: KOptional<Float>
|
||||
val liquidFriction: KOptional<Float>
|
||||
val groundFriction: KOptional<Float>
|
||||
|
||||
val collisionEnabled: KOptional<Boolean>
|
||||
val frictionEnabled: KOptional<Boolean>
|
||||
val gravityEnabled: KOptional<Boolean>
|
||||
|
||||
val maximumPlatformCorrection: KOptional<Float>
|
||||
val maximumPlatformCorrectionVelocityFactor: KOptional<Float>
|
||||
|
||||
val physicsEffectCategories: KOptional<ImmutableSet<String>>
|
||||
|
||||
@JsonFactory
|
||||
data class Impl(
|
||||
override val mass: KOptional<Float> = KOptional.empty(),
|
||||
override val gravityMultiplier: KOptional<Float> = KOptional.empty(),
|
||||
override val liquidBuoyancy: KOptional<Float> = KOptional.empty(),
|
||||
override val airBuoyancy: KOptional<Float> = KOptional.empty(),
|
||||
override val bounceFactor: KOptional<Float> = KOptional.empty(),
|
||||
override val stopOnFirstBounce: KOptional<Boolean> = KOptional.empty(),
|
||||
override val enableSurfaceSlopeCorrection: KOptional<Boolean> = KOptional.empty(),
|
||||
override val slopeSlidingFactor: KOptional<Float> = KOptional.empty(),
|
||||
override val maxMovementPerStep: KOptional<Float> = KOptional.empty(),
|
||||
override val maximumCorrection: KOptional<Float> = KOptional.empty(),
|
||||
override val speedLimit: KOptional<Float> = KOptional.empty(),
|
||||
override val stickyCollision: KOptional<Boolean> = KOptional.empty(),
|
||||
override val stickyForce: KOptional<Float> = KOptional.empty(),
|
||||
override val airFriction: KOptional<Float> = KOptional.empty(),
|
||||
override val liquidFriction: KOptional<Float> = KOptional.empty(),
|
||||
override val groundFriction: KOptional<Float> = KOptional.empty(),
|
||||
override val collisionEnabled: KOptional<Boolean> = KOptional.empty(),
|
||||
override val frictionEnabled: KOptional<Boolean> = KOptional.empty(),
|
||||
override val gravityEnabled: KOptional<Boolean> = KOptional.empty(),
|
||||
override val maximumPlatformCorrection: KOptional<Float> = KOptional.empty(),
|
||||
override val maximumPlatformCorrectionVelocityFactor: KOptional<Float> = KOptional.empty(),
|
||||
override val physicsEffectCategories: KOptional<ImmutableSet<String>> = KOptional.empty(),
|
||||
) : BaseMovementParameters {
|
||||
fun merge(other: Impl): Impl {
|
||||
return Impl(
|
||||
mass = mass.or(other.mass),
|
||||
gravityMultiplier = gravityMultiplier.or(other.gravityMultiplier),
|
||||
liquidBuoyancy = liquidBuoyancy.or(other.liquidBuoyancy),
|
||||
airBuoyancy = airBuoyancy.or(other.airBuoyancy),
|
||||
bounceFactor = bounceFactor.or(other.bounceFactor),
|
||||
stopOnFirstBounce = stopOnFirstBounce.or(other.stopOnFirstBounce),
|
||||
enableSurfaceSlopeCorrection = enableSurfaceSlopeCorrection.or(other.enableSurfaceSlopeCorrection),
|
||||
slopeSlidingFactor = slopeSlidingFactor.or(other.slopeSlidingFactor),
|
||||
maxMovementPerStep = maxMovementPerStep.or(other.maxMovementPerStep),
|
||||
maximumCorrection = maximumCorrection.or(other.maximumCorrection),
|
||||
speedLimit = speedLimit.or(other.speedLimit),
|
||||
stickyCollision = stickyCollision.or(other.stickyCollision),
|
||||
stickyForce = stickyForce.or(other.stickyForce),
|
||||
airFriction = airFriction.or(other.airFriction),
|
||||
liquidFriction = liquidFriction.or(other.liquidFriction),
|
||||
groundFriction = groundFriction.or(other.groundFriction),
|
||||
collisionEnabled = collisionEnabled.or(other.collisionEnabled),
|
||||
frictionEnabled = frictionEnabled.or(other.frictionEnabled),
|
||||
gravityEnabled = gravityEnabled.or(other.gravityEnabled),
|
||||
maximumPlatformCorrection = maximumPlatformCorrection.or(other.maximumPlatformCorrection),
|
||||
maximumPlatformCorrectionVelocityFactor = maximumPlatformCorrectionVelocityFactor.or(other.maximumPlatformCorrectionVelocityFactor),
|
||||
physicsEffectCategories = physicsEffectCategories.or(other.physicsEffectCategories),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ru.dbotthepony.kstarbound.defs
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFlat
|
||||
import ru.dbotthepony.kstarbound.util.KOptional
|
||||
import ru.dbotthepony.kvector.vector.Vector2d
|
||||
|
||||
@JsonFactory
|
||||
data class MovementParameters(
|
||||
@JsonFlat
|
||||
val base: BaseMovementParameters.Impl = BaseMovementParameters.Impl(),
|
||||
|
||||
val discontinuityThreshold: KOptional<Float> = KOptional.empty(),
|
||||
val collisionPoly: KOptional<ImmutableList<Vector2d>> = KOptional.empty(),
|
||||
val ignorePlatformCollision: KOptional<Boolean> = KOptional.empty(),
|
||||
val restDuration: KOptional<Int> = KOptional.empty(),
|
||||
) : BaseMovementParameters by base {
|
||||
fun merge(other: MovementParameters): MovementParameters {
|
||||
return MovementParameters(
|
||||
base = base.merge(other.base),
|
||||
discontinuityThreshold = discontinuityThreshold.or(other.discontinuityThreshold),
|
||||
collisionPoly = collisionPoly.or(other.collisionPoly),
|
||||
ignorePlatformCollision = ignorePlatformCollision.or(other.ignorePlatformCollision),
|
||||
restDuration = restDuration.or(other.restDuration),
|
||||
)
|
||||
}
|
||||
}
|
@ -2,38 +2,28 @@ package ru.dbotthepony.kstarbound.defs.player
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.google.common.collect.ImmutableSet
|
||||
import ru.dbotthepony.kstarbound.defs.BaseMovementParameters
|
||||
import ru.dbotthepony.kstarbound.defs.JumpProfile
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonAlias
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFlat
|
||||
import ru.dbotthepony.kstarbound.util.KOptional
|
||||
import ru.dbotthepony.kvector.vector.Vector2d
|
||||
|
||||
@JsonFactory
|
||||
data class PlayerMovementParameters(
|
||||
val mass: KOptional<Double> = KOptional.empty(),
|
||||
val gravityMultiplier: KOptional<Double> = KOptional.empty(),
|
||||
val liquidBuoyancy: KOptional<Double> = KOptional.empty(),
|
||||
val airBuoyancy: KOptional<Double> = KOptional.empty(),
|
||||
val bounceFactor: KOptional<Double> = KOptional.empty(),
|
||||
val stopOnFirstBounce: KOptional<Boolean> = KOptional.empty(),
|
||||
val enableSurfaceSlopeCorrection: KOptional<Boolean> = KOptional.empty(),
|
||||
val slopeSlidingFactor: KOptional<Double> = KOptional.empty(),
|
||||
val maxMovementPerStep: KOptional<Double> = KOptional.empty(),
|
||||
val maximumCorrection: KOptional<Double> = KOptional.empty(),
|
||||
val speedLimit: KOptional<Double> = KOptional.empty(),
|
||||
@JsonFlat
|
||||
val base: BaseMovementParameters.Impl = BaseMovementParameters.Impl(),
|
||||
|
||||
@JsonAlias("collisionPoly")
|
||||
val standingPoly: KOptional<ImmutableList<Vector2d>> = KOptional.empty(),
|
||||
@JsonAlias("collisionPoly")
|
||||
val crouchingPoly: KOptional<ImmutableList<Vector2d>> = KOptional.empty(),
|
||||
|
||||
val stickyCollision: KOptional<Boolean> = KOptional.empty(),
|
||||
val stickyForce: KOptional<Double> = KOptional.empty(),
|
||||
val walkSpeed: KOptional<Double> = KOptional.empty(),
|
||||
val runSpeed: KOptional<Double> = KOptional.empty(),
|
||||
val flySpeed: KOptional<Double> = KOptional.empty(),
|
||||
val airFriction: KOptional<Double> = KOptional.empty(),
|
||||
val liquidFriction: KOptional<Double> = KOptional.empty(),
|
||||
|
||||
val minimumLiquidPercentage: KOptional<Double> = KOptional.empty(),
|
||||
val liquidImpedance: KOptional<Double> = KOptional.empty(),
|
||||
val normalGroundFriction: KOptional<Double> = KOptional.empty(),
|
||||
@ -47,41 +37,21 @@ data class PlayerMovementParameters(
|
||||
|
||||
val fallStatusSpeedMin: KOptional<Double> = KOptional.empty(),
|
||||
val fallThroughSustainFrames: KOptional<Int> = KOptional.empty(),
|
||||
val maximumPlatformCorrection: KOptional<Double> = KOptional.empty(),
|
||||
val maximumPlatformCorrectionVelocityFactor: KOptional<Double> = KOptional.empty(),
|
||||
val physicsEffectCategories: KOptional<ImmutableSet<String>> = KOptional.empty(),
|
||||
|
||||
val groundMovementMinimumSustain: KOptional<Double> = KOptional.empty(),
|
||||
val groundMovementMaximumSustain: KOptional<Double> = KOptional.empty(),
|
||||
val groundMovementCheckDistance: KOptional<Double> = KOptional.empty(),
|
||||
|
||||
val collisionEnabled: KOptional<Boolean> = KOptional.empty(),
|
||||
val frictionEnabled: KOptional<Boolean> = KOptional.empty(),
|
||||
val gravityEnabled: KOptional<Boolean> = KOptional.empty(),
|
||||
|
||||
val pathExploreRate: KOptional<Double> = KOptional.empty(),
|
||||
) {
|
||||
) : BaseMovementParameters by base {
|
||||
fun merge(other: PlayerMovementParameters): PlayerMovementParameters {
|
||||
return PlayerMovementParameters(
|
||||
mass = mass.or(other.mass),
|
||||
gravityMultiplier = gravityMultiplier.or(other.gravityMultiplier),
|
||||
liquidBuoyancy = liquidBuoyancy.or(other.liquidBuoyancy),
|
||||
airBuoyancy = airBuoyancy.or(other.airBuoyancy),
|
||||
bounceFactor = bounceFactor.or(other.bounceFactor),
|
||||
stopOnFirstBounce = stopOnFirstBounce.or(other.stopOnFirstBounce),
|
||||
enableSurfaceSlopeCorrection = enableSurfaceSlopeCorrection.or(other.enableSurfaceSlopeCorrection),
|
||||
slopeSlidingFactor = slopeSlidingFactor.or(other.slopeSlidingFactor),
|
||||
maxMovementPerStep = maxMovementPerStep.or(other.maxMovementPerStep),
|
||||
maximumCorrection = maximumCorrection.or(other.maximumCorrection),
|
||||
speedLimit = speedLimit.or(other.speedLimit),
|
||||
base = base.merge(other.base),
|
||||
standingPoly = standingPoly.or(other.standingPoly),
|
||||
crouchingPoly = crouchingPoly.or(other.crouchingPoly),
|
||||
stickyCollision = stickyCollision.or(other.stickyCollision),
|
||||
stickyForce = stickyForce.or(other.stickyForce),
|
||||
walkSpeed = walkSpeed.or(other.walkSpeed),
|
||||
runSpeed = runSpeed.or(other.runSpeed),
|
||||
flySpeed = flySpeed.or(other.flySpeed),
|
||||
airFriction = airFriction.or(other.airFriction),
|
||||
liquidFriction = liquidFriction.or(other.liquidFriction),
|
||||
minimumLiquidPercentage = minimumLiquidPercentage.or(other.minimumLiquidPercentage),
|
||||
liquidImpedance = liquidImpedance.or(other.liquidImpedance),
|
||||
normalGroundFriction = normalGroundFriction.or(other.normalGroundFriction),
|
||||
@ -93,15 +63,9 @@ data class PlayerMovementParameters(
|
||||
liquidJumpProfile = liquidJumpProfile.merge(other.liquidJumpProfile),
|
||||
fallStatusSpeedMin = fallStatusSpeedMin.or(other.fallStatusSpeedMin),
|
||||
fallThroughSustainFrames = fallThroughSustainFrames.or(other.fallThroughSustainFrames),
|
||||
maximumPlatformCorrection = maximumPlatformCorrection.or(other.maximumPlatformCorrection),
|
||||
maximumPlatformCorrectionVelocityFactor = maximumPlatformCorrectionVelocityFactor.or(other.maximumPlatformCorrectionVelocityFactor),
|
||||
physicsEffectCategories = physicsEffectCategories.or(other.physicsEffectCategories),
|
||||
groundMovementMinimumSustain = groundMovementMinimumSustain.or(other.groundMovementMinimumSustain),
|
||||
groundMovementMaximumSustain = groundMovementMaximumSustain.or(other.groundMovementMaximumSustain),
|
||||
groundMovementCheckDistance = groundMovementCheckDistance.or(other.groundMovementCheckDistance),
|
||||
collisionEnabled = collisionEnabled.or(other.collisionEnabled),
|
||||
frictionEnabled = frictionEnabled.or(other.frictionEnabled),
|
||||
gravityEnabled = gravityEnabled.or(other.gravityEnabled),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user