コード例 #1
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            var roundType = RoundType.GetFirstValue(mutable);

            foreach (var entry in Scope.GetEntries(mutable))
            {
                foreach (var subEntry in Operand.GetEntries(entry))
                {
                    float inputValue = Operand.GetValue(subEntry);
                    float outputValue;

                    if (roundType == RoundTypeEnum.Nearest)
                    {
                        outputValue = Mathf.Round(inputValue);
                    }
                    else if (roundType == RoundTypeEnum.Down)
                    {
                        outputValue = Mathf.Floor(inputValue);
                    }
                    else if (roundType == RoundTypeEnum.Up)
                    {
                        outputValue = Mathf.Ceil(inputValue);
                    }
                    else if (roundType == RoundTypeEnum.Truncate)
                    {
                        outputValue = (float)Math.Truncate(inputValue);
                    }
                    else
                    {
                        throw new NotImplementedException("No handler set for RoundType of " + roundType + ".");
                    }

                    WriteValue(outputValue, subEntry);
                }
            }

            return(mutable);
        }