
package moe.nightfall.instrumentality.animations

import moe.nightfall.instrumentality.PoseBoneTransform

import scala.collection.mutable.MutableList

/**
 * Adds the PBTs together.
 * Created on 26/07/15.
 */
class OverlayAnimation(val subAnimations: MutableList[Animation]) extends Animation {

    def this(subAnimations: Animation*) = this(MutableList(subAnimations: _*))

    override def getBoneTransform(boneName: String): Option[PoseBoneTransform] = {
        val result = new PoseBoneTransform
        subAnimations foreach { ia =>
            val opt = ia.getBoneTransform(boneName)
            if (opt.isDefined) {
                result += opt.get
            }
        }

        return Some(result)
    }

    override def update(deltaTime: Double) = subAnimations.foreach(_.update(deltaTime))
}
