コード例 #1
0
        private void setLimit(ChangeModes c, float f, KSPActionParam p)
        {
            foreach (PartModule m in this.part.Modules)
                if (m is ModuleEngines)
                {
                    ModuleEngines me = (ModuleEngines)m;
                    if (!me.isOperational)
                        continue;
                    if (c == ChangeModes.DECREASE && me.thrustPercentage == 0f || c == ChangeModes.INCREASE && me.thrustPercentage == 100f) // 1.0.1: Fix for engines going >100 or <0
                        continue;

                    if (c == ChangeModes.DECREASE)
                        me.thrustPercentage -= f;
                    else if (c == ChangeModes.INCREASE)
                        me.thrustPercentage += f;
                    else
                        me.thrustPercentage = f;
                }
                else if (m is ModuleEnginesFX && m.isEnabled) // Squad, y u have separate module for NASA engines? :c
                {
                    ModuleEnginesFX me = (ModuleEnginesFX)m;
                    if (!me.isOperational)
                        continue;
                    if (c == ChangeModes.DECREASE && me.thrustPercentage == 0f || c == ChangeModes.INCREASE && me.thrustPercentage == 100f) // 1.0.1: Fix for engines going >100 or <0
                        continue;

                    if (c == ChangeModes.DECREASE)
                        me.thrustPercentage -= f;
                    else if (c == ChangeModes.INCREASE)
                        me.thrustPercentage += f;
                    else
                        me.thrustPercentage = f;
                }

        }
コード例 #2
0
        // tween for the audio mixer parameters.
        /// <param name = "mixer">The audio mixer container</param>
        /// <param name = "nameParamMixer">the name of the parameter you want to change</param>
        /// <param name = "timeOrVelocity">the time of tween</param>
        /// <param name = "isAutoKill">Does the tween have to destroy itself when it ends?</param>
        /// <param name = "functionEnum">the function to soften the tween</param>
        /// <param name = "values">The values ​​that the tween must reach</param>

        public static TweenContainer MixerParamTween(this AudioMixer mixer, string nameParamMixer, float timeOrVelocity, bool isAutoKill, FunctionEnum functionEnum, ChangeModes changeMode, params float[] values)
        {
            if (mixer == null)
            {
                return(null);
            }

            void SetNewValue(Vector4 newValue)
            {
                if (mixer != null)
                {
                    mixer.GetFloat(nameParamMixer, out float currentValue);
                    currentValue += newValue.x;
                    mixer.SetFloat(nameParamMixer, currentValue);
                }
                else
                {
                    LogManager.LogWarning("The tween is is referring to object that is not exist", "Tween");
                }
            }

            Vector4 GetInitValue()
            {
                float result = 0;

                if (mixer != null)
                {
                    mixer.GetFloat(nameParamMixer, out result);
                }
                else
                {
                    LogManager.LogWarning("The tween is is referring to object that is not exist", "Tween");
                }
                return(new Vector4(result, 0, 0, 0));
            }

            AnimationCurveInfo curve = new(functionEnum);

            Vector4[] finalValues = ArrayExtend.ConvertNumbersAndVectors <Vector4>(values);

            return(TweenContainer.CreateTween(GetInitValue, timeOrVelocity, SetNewValue, isAutoKill, curve, changeMode, finalValues));
        }
コード例 #3
0
        // tween for the transform scale
        /// <param name = "transform">The transform container</param>
        /// <param name = "timeOrVelocity">the time of tween</param>
        /// <param name = "isAutoKill">Does the tween have to destroy itself when it ends?</param>
        /// <param name = "AxisCombined">the spcific axis for changes</param>
        /// <param name = "functionEnum">the function to soften the tween</param>
        /// <param name = "values">The values ​​that the tween must reach</param>
        public static TweenContainer ScaleTween(this Transform transform, float timeOrVelocity, bool isAutoKill, AxisCombined axisCombined, FunctionEnum functionEnum, ChangeModes changeMode, params Vector3[] values)
        {
            if (transform == null)
            {
                return(null);
            }

            void SetNewValue(Vector4 newValue)
            {
                if (transform != null)
                {
                    transform.SetScale(newValue, ChangeTypeEnum.Modify, axisCombined);
                }
                else
                {
                    LogManager.LogWarning("The tween is is referring to object that is not exist", "Tween");
                }
            }

            Vector4 GetInitValue()
            {
                if (transform != null)
                {
                    return(transform.localScale);
                }
                else
                {
                    LogManager.LogWarning("The tween is is referring to object that is not exist", "Tween");
                    return(default);
コード例 #4
0
 // tween for the audio mixer parameters.
 /// <param name = "mixer">The audio mixer container</param>
 /// <param name = "nameParamMixer">the name of the parameter you want to change</param>
 /// <param name = "timeOrVelocity">the time of tween</param>
 /// <param name = "isAutoKill">Does the tween have to destroy itself when it ends?</param>
 /// <param name = "values">The values ​​that the tween must reach</param>
 public static TweenContainer MixerParamTween(this AudioMixer mixer, string nameParamMixer, float timeOrVelocity, bool isAutoKill, ChangeModes changeMode, params float[] values)
 {
     return(MixerParamTween(mixer, nameParamMixer, timeOrVelocity, isAutoKill, FunctionEnum.EaseIn_Quadratic, changeMode, values));
 }
コード例 #5
0
 // tween for the transform scale
 /// <param name = "transform">The transform container</param>
 /// <param name = "timeOrVelocity">the time of tween</param>
 /// <param name = "isAutoKill">Does the tween have to destroy itself when it ends?</param>
 /// <param name = "AxisCombined">the spcific axis for changes</param>
 /// <param name = "values">The values ​​that the tween must reach</param>
 public static TweenContainer ScaleTween(this Transform transform, float timeOrVelocity, bool isAutoKill, AxisCombined axisCombined, ChangeModes changeMode, params Vector3[] scaleVectors)
 {
     return(ScaleTween(transform, timeOrVelocity, isAutoKill, axisCombined, FunctionEnum.EaseIn_Quadratic, changeMode, scaleVectors));
 }