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 = KOptional.empty(), val gravityMultiplier: KOptional = KOptional.empty(), val liquidBuoyancy: KOptional = KOptional.empty(), val airBuoyancy: KOptional = KOptional.empty(), val bounceFactor: KOptional = KOptional.empty(), val stopOnFirstBounce: KOptional = KOptional.empty(), val enableSurfaceSlopeCorrection: KOptional = KOptional.empty(), val slopeSlidingFactor: KOptional = KOptional.empty(), val maxMovementPerStep: KOptional = KOptional.empty(), val maximumCorrection: KOptional = KOptional.empty(), val speedLimit: KOptional = KOptional.empty(), @JsonAlias("collisionPoly") val standingPoly: KOptional> = KOptional.empty(), @JsonAlias("collisionPoly") val crouchingPoly: KOptional> = KOptional.empty(), val stickyCollision: KOptional = KOptional.empty(), val stickyForce: KOptional = KOptional.empty(), val walkSpeed: KOptional = KOptional.empty(), val runSpeed: KOptional = KOptional.empty(), val flySpeed: KOptional = KOptional.empty(), val airFriction: KOptional = KOptional.empty(), val liquidFriction: KOptional = KOptional.empty(), val minimumLiquidPercentage: KOptional = KOptional.empty(), val liquidImpedance: KOptional = KOptional.empty(), val normalGroundFriction: KOptional = KOptional.empty(), val ambulatingGroundFriction: KOptional = KOptional.empty(), val groundForce: KOptional = KOptional.empty(), val airForce: KOptional = KOptional.empty(), val liquidForce: KOptional = KOptional.empty(), val airJumpProfile: JumpProfile = JumpProfile(), val liquidJumpProfile: JumpProfile = JumpProfile(), val fallStatusSpeedMin: KOptional = KOptional.empty(), val fallThroughSustainFrames: KOptional = KOptional.empty(), val maximumPlatformCorrection: KOptional = KOptional.empty(), val maximumPlatformCorrectionVelocityFactor: KOptional = KOptional.empty(), val physicsEffectCategories: KOptional> = KOptional.empty(), val groundMovementMinimumSustain: KOptional = KOptional.empty(), val groundMovementMaximumSustain: KOptional = KOptional.empty(), val groundMovementCheckDistance: KOptional = KOptional.empty(), val collisionEnabled: KOptional = KOptional.empty(), val frictionEnabled: KOptional = KOptional.empty(), val gravityEnabled: KOptional = KOptional.empty(), val pathExploreRate: KOptional = 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), ) } }