コード例 #1
0
        public override VFXExpressionMapper GetExpressionMapper(VFXDeviceTarget target)
        {
            if (target == VFXDeviceTarget.CPU)
            {
                var mapper = VFXExpressionMapper.FromBlocks(activeFlattenedChildrenWithImplicit);

                var mapperFromContext = new VFXExpressionMapper();
                mapperFromContext.AddExpressionsFromSlotContainer(this, -1);

                if (loopDuration != LoopMode.Infinite)
                {
                    var expression = mapperFromContext.FromNameAndId("LoopDuration", -1);
                    if (loopDuration == LoopMode.Random)
                    {
                        expression = RandomFromVector2(expression);
                    }
                    mapper.AddExpression(expression, "LoopDuration", -1);
                }

                if (loopCount != LoopMode.Infinite)
                {
                    var expression = mapperFromContext.FromNameAndId("LoopCount", -1);
                    if (loopCount == LoopMode.Random)
                    {
                        expression = new VFXExpressionCastFloatToInt(RandomFromVector2(expression));
                    }
                    mapper.AddExpression(expression, "LoopCount", -1);
                }

                if (delayBeforeLoop != DelayMode.None)
                {
                    var expression = mapperFromContext.FromNameAndId("DelayBeforeLoop", -1);
                    if (delayBeforeLoop == DelayMode.Random)
                    {
                        expression = RandomFromVector2(expression);
                    }
                    mapper.AddExpression(expression, "DelayBeforeLoop", -1);
                }

                if (delayAfterLoop != DelayMode.None)
                {
                    var expression = mapperFromContext.FromNameAndId("DelayAfterLoop", -1);
                    if (delayAfterLoop == DelayMode.Random)
                    {
                        expression = RandomFromVector2(expression);
                    }
                    mapper.AddExpression(expression, "DelayAfterLoop", -1);
                }
                return(mapper);
            }

            return(null);
        }
コード例 #2
0
        protected override IEnumerable <VFXExpression> ApplyPatchInputExpression(IEnumerable <VFXExpression> inputExpression)
        {
            var minIndex    = inputExpression.Select(o => Array.IndexOf(kExpectedTypeOrdering, VFXExpression.TypeToType(o.valueType))).Min();
            var unifiedType = VFXExpression.GetVFXValueTypeFromType(kExpectedTypeOrdering[minIndex]);

            foreach (var expression in inputExpression)
            {
                if (expression.valueType == unifiedType)
                {
                    yield return(expression);

                    continue;
                }

                var currentExpression = expression;
                if (VFXExpression.IsFloatValueType(unifiedType))
                {
                    if (VFXExpression.IsUIntValueType(expression.valueType))
                    {
                        currentExpression = new VFXExpressionCastUintToFloat(currentExpression);
                    }
                    else if (VFXExpression.IsIntValueType(expression.valueType))
                    {
                        currentExpression = new VFXExpressionCastIntToFloat(currentExpression);
                    }
                    currentExpression = VFXOperatorUtility.CastFloat(currentExpression, unifiedType, identityValueFloat);
                }
                else if (VFXExpression.IsIntValueType(unifiedType))
                {
                    if (VFXExpression.IsUIntValueType(currentExpression.valueType))
                    {
                        currentExpression = new VFXExpressionCastUintToInt(currentExpression);
                    }
                    else if (VFXExpression.IsFloatValueType(currentExpression.valueType))
                    {
                        currentExpression = new VFXExpressionCastFloatToInt(VFXOperatorUtility.ExtractComponents(currentExpression).First());
                    }
                }
                else if (VFXExpression.IsUIntValueType(unifiedType))
                {
                    if (VFXExpression.IsIntValueType(currentExpression.valueType))
                    {
                        currentExpression = new VFXExpressionCastIntToUint(currentExpression);
                    }
                    else if (VFXExpression.IsFloatValueType(expression.valueType))
                    {
                        currentExpression = new VFXExpressionCastFloatToUint(VFXOperatorUtility.ExtractComponents(expression).First());
                    }
                }
                yield return(currentExpression);
            }
        }