package ru.dbotthepony.kstarbound.defs.actor.player

import ru.dbotthepony.kstarbound.json.builder.JsonFactory

@JsonFactory
class ActorMovementModifiers(
	val groundMovementModifier: Double = 1.0,
	val liquidMovementModifier: Double = 1.0,
	val speedModifier: Double = 1.0,
	val airJumpModifier: Double = 1.0,
	val liquidJumpModifier: Double = 1.0,
	val runningSuppressed: Boolean = false,
	val jumpingSuppressed: Boolean = false,
	val facingSuppressed: Boolean = false,
	val movementSuppressed: Boolean = false,
) {
	fun combine(other: ActorMovementModifiers): ActorMovementModifiers {
		return ActorMovementModifiers(
			groundMovementModifier = groundMovementModifier * other.groundMovementModifier,
			liquidMovementModifier = liquidMovementModifier * other.liquidMovementModifier,
			speedModifier = speedModifier * other.speedModifier,
			airJumpModifier = airJumpModifier * other.airJumpModifier,
			liquidJumpModifier = liquidJumpModifier * other.liquidJumpModifier,
			runningSuppressed = runningSuppressed || other.runningSuppressed,
			jumpingSuppressed = jumpingSuppressed || other.jumpingSuppressed,
			facingSuppressed = facingSuppressed || other.facingSuppressed,
			movementSuppressed = movementSuppressed || other.movementSuppressed,
		)
	}

	companion object {
		val EMPTY = ActorMovementModifiers()
	}
}
