Beispiel #1
0
        ////TODO: add parameters to control ramp up&down

        /// <inheritdoc />
        public override float ReadValue(ref InputBindingCompositeContext context)
        {
            var negativeMagnitude = context.EvaluateMagnitude(negative);
            var positiveMagnitude = context.EvaluateMagnitude(positive);

            var negativeIsPressed = negativeMagnitude > 0;
            var positiveIsPressed = positiveMagnitude > 0;

            if (negativeIsPressed == positiveIsPressed)
            {
                switch (whichSideWins)
                {
                case WhichSideWins.Negative:
                    positiveIsPressed = false;
                    break;

                case WhichSideWins.Positive:
                    negativeIsPressed = false;
                    break;

                case WhichSideWins.Neither:
                    return(midPoint);
                }
            }

            var mid = midPoint;

            if (negativeIsPressed)
            {
                return(mid - (mid - minValue) * negativeMagnitude);
            }

            return(mid + (maxValue - mid) * positiveMagnitude);
        }
 public override float EvaluateMagnitude(ref InputBindingCompositeContext context)
 {
     if (context.ReadValueAsButton(modifier))
     {
         return(context.EvaluateMagnitude(binding));
     }
     return(default);
 public override float EvaluateMagnitude(ref InputBindingCompositeContext context)
 {
     if (ModifiersArePressed(ref context))
     {
         return(context.EvaluateMagnitude(binding));
     }
     return(default);