/**
 * Copyright(c) Live2D Inc. All rights reserved.
 *
 * Use of this source code is governed by the Live2D Open Software license
 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
 */
using Live2D.Cubism.Core;
namespace Live2D.Cubism.Framework
{
    /// 
    /// Extensions for s.
    /// 
    public static class CubismParameterExtensionMethods
    {
        /// 
        /// Additively blends a value in.
        /// 
        /// .
        /// Value to blend in.
        /// Blend weight.
        public static void AddToValue(this CubismParameter parameter, float value, float weight = 1f)
        {
            parameter.Value += (value * weight);
        }
        /// 
        /// Multiply blends a value in.
        /// 
        /// .
        /// Value to blend in.
        /// Blend weight.
        public static void MultiplyValueBy(this CubismParameter parameter, float value, float weight = 1f)
        {
            parameter.Value *= (1f + ((value - 1f) * weight));
        }
        /// 
        /// Blends a value in.
        /// 
        /// .
        /// Value to blend in.
        /// Blend mode to use.
        public static void BlendToValue(this CubismParameter self, CubismParameterBlendMode mode, float value)
        {
            if (mode == CubismParameterBlendMode.Additive)
            {
                self.AddToValue(value);
                return;
            }
            if (mode == CubismParameterBlendMode.Multiply)
            {
                self.MultiplyValueBy(value);
                return;
            }
            self.Value = value;
        }
        /// 
        /// Blends the same value into multiple s.
        /// 
        /// .
        /// Value to blend in.
        /// Blend mode to use.
        public static void BlendToValue(this CubismParameter[] self, CubismParameterBlendMode mode, float value)
        {
            if (mode == CubismParameterBlendMode.Additive)
            {
                for (var i = 0; i < self.Length; ++i)
                {
                    self[i].AddToValue(value);
                }
                return;
            }
            if (mode == CubismParameterBlendMode.Multiply)
            {
                for (var i = 0; i < self.Length; ++i)
                {
                    self[i].MultiplyValueBy(value);
                }
                return;
            }
            for (var i = 0; i < self.Length; ++i)
            {
                self[i].Value = value;
            }
        }
    }
}