KStarbound/src/main/kotlin/ru/dbotthepony/kstarbound/defs/MovementParameters.kt

107 lines
5.8 KiB
Kotlin

package ru.dbotthepony.kstarbound.defs
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableSet
import ru.dbotthepony.kstarbound.io.json.builder.JsonAlias
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
import ru.dbotthepony.kstarbound.util.KOptional
import ru.dbotthepony.kvector.vector.Vector2d
@JsonFactory
data class MovementParameters(
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(),
@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(),
val ambulatingGroundFriction: KOptional<Double> = KOptional.empty(),
val groundForce: KOptional<Double> = KOptional.empty(),
val airForce: KOptional<Double> = KOptional.empty(),
val liquidForce: KOptional<Double> = KOptional.empty(),
val airJumpProfile: JumpProfile = JumpProfile(),
val liquidJumpProfile: JumpProfile = JumpProfile(),
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(),
) {
fun merge(other: MovementParameters): MovementParameters {
return MovementParameters(
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),
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),
ambulatingGroundFriction = ambulatingGroundFriction.or(other.ambulatingGroundFriction),
groundForce = groundForce.or(other.groundForce),
airForce = airForce.or(other.airForce),
liquidForce = liquidForce.or(other.liquidForce),
airJumpProfile = airJumpProfile.merge(other.airJumpProfile),
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),
)
}
}