示例#1
0
        private string GenerateName(bool library)
        {
            var variadicName = (currentAttribute.variadic == VFXVariadic.True && !library) ? "." + channels.ToString() : string.Empty;
            var n            = VFXBlockUtility.GetNameString(Composition) + " " + ObjectNames.NicifyVariableName(attribute) + variadicName;

            switch (SampleMode)
            {
            case CurveSampleMode.OverLife: n += " over Life"; break;

            case CurveSampleMode.BySpeed: n += " by Speed"; break;

            case CurveSampleMode.Random: n += $" Random from {(attribute == VFXAttribute.Color.name ? "Gradient" : "Curve")}"; break;

            case CurveSampleMode.RandomConstantPerParticle: n += $" Random from {(attribute == VFXAttribute.Color.name ? "Gradient" : "Curve")} (Constant per-particle)"; break;

            case CurveSampleMode.Custom: n += " Custom"; break;

            default:
                throw new NotImplementedException("Invalid CurveSampleMode");
            }

            if (library && attribute == VFXAttribute.Color.name)
            {
                n += " (Gradient)";
            }
            return(n);
        }
示例#2
0
        public static bool SanitizeAttribute(ref string attribName, ref VariadicChannelOptions channels, int version)
        {
            bool   settingsChanged             = false;
            string oldName                     = attribName;
            VariadicChannelOptions oldChannels = channels;

            if (version < 1 && channels == VariadicChannelOptions.XZ) // Enumerators have changed
            {
                channels        = VariadicChannelOptions.XYZ;
                settingsChanged = true;
            }

            if (version < 1 && VFXBlockUtility.ConvertSizeAttributeIfNeeded(ref attribName, ref channels))
            {
                Debug.Log(string.Format("Sanitizing attribute: Convert {0} with channel {2} to {1}", oldName, attribName, oldChannels));
                settingsChanged = true;
            }

            // Changes attribute to variadic version
            VariadicChannelOptions newChannels;

            if (VFXBlockUtility.ConvertToVariadicAttributeIfNeeded(ref attribName, out newChannels))
            {
                Debug.Log(string.Format("Sanitizing attribute: Convert {0} to variadic attribute {1} with channel {2}", oldName, attribName, newChannels));
                channels        = newChannels;
                settingsChanged = true;
            }

            return(settingsChanged);
        }
示例#3
0
        private string GetVariadicSource(VFXAttribute attribute, string randomString, string subScript = "")
        {
            string source = "";

            if (Random == RandomMode.Off)
            {
                source = GetRandomMacroString(Random, attribute, "Value" + subScript, randomString);
            }
            else
            {
                source = GetRandomMacroString(Random, attribute, "Min" + subScript, "Max" + subScript, randomString);
            }

            if (Composition == AttributeCompositionMode.Blend)
            {
                source = VFXBlockUtility.GetComposeString(Composition, attribute.name, source, "Blend" + subScript);
            }
            else
            {
                source = VFXBlockUtility.GetComposeString(Composition, attribute.name, source);
            }

            source += "\n";
            return(source);
        }
示例#4
0
        public override IEnumerable <Variant> ComputeVariants()
        {
            var compositions = new[] { AttributeCompositionMode.Add, AttributeCompositionMode.Overwrite, AttributeCompositionMode.Multiply, AttributeCompositionMode.Blend };
            var attributes = VFXAttribute.AllIncludingVariadicReadWritable.Except(new[] { VFXAttribute.Alive.name }).ToArray();
            var sampleModes = new[] { AttributeFromCurve.CurveSampleMode.OverLife, AttributeFromCurve.CurveSampleMode.BySpeed, AttributeFromCurve.CurveSampleMode.Random }.ToArray();

            foreach (var attribute in attributes)
            {
                foreach (var composition in compositions)
                {
                    foreach (var sampleMode in sampleModes)
                    {
                        if (attribute == VFXAttribute.Age.name && sampleMode == AttributeFromCurve.CurveSampleMode.OverLife)
                        {
                            continue;
                        }

                        if (attribute == VFXAttribute.Velocity.name && sampleMode == AttributeFromCurve.CurveSampleMode.BySpeed)
                        {
                            continue;
                        }

                        yield return(new Variant(
                                         new[]
                        {
                            new KeyValuePair <string, object>("attribute", attribute),
                            new KeyValuePair <string, object>("Composition", composition),
                            new KeyValuePair <string, object>("SampleMode", sampleMode)
                        },
                                         new[] { attribute, VFXBlockUtility.GetNameString(composition) }));
                    }
                }
            }
        }
示例#5
0
        public override void Sanitize(int version)
        {
            if (VFXBlockUtility.SanitizeAttribute(ref attribute, ref channels, version))
            {
                Invalidate(InvalidationCause.kSettingChanged);
            }

            base.Sanitize(version);
        }
示例#6
0
 public override IEnumerable <Variant> ComputeVariants()
 {
     return(new[] { PositionSequential.SequentialShape.Circle, PositionSequential.SequentialShape.Line, PositionSequential.SequentialShape.ThreeDimensional }
            .Select(x => new Variant(
                        new[]
     {
         new KeyValuePair <string, object>("compositionPosition", AttributeCompositionMode.Overwrite),
         new KeyValuePair <string, object>("shape", x)
     }, new[] { "position", VFXBlockUtility.GetNameString(AttributeCompositionMode.Overwrite) })));
 }
示例#7
0
        private string ComposeName(string variadicName)
        {
            string attributeName = ObjectNames.NicifyVariableName(attribute) + variadicName;

            switch (Source)
            {
            case ValueSource.Slot: return(VFXBlockUtility.GetNameString(Composition) + " " + attributeName + " " + VFXBlockUtility.GetNameString(Random));

            case ValueSource.Source: return("Inherit Source " + attributeName + " (" + VFXBlockUtility.GetNameString(Composition) + ")");

            default: return("NOT IMPLEMENTED : " + Source);
            }
        }
示例#8
0
        public sealed override IEnumerable <Variant> ComputeVariants()
        {
            var attributes   = VFXAttribute.AllIncludingVariadicReadWritable;
            var randoms      = new[] { RandomMode.Off, RandomMode.Uniform, RandomMode.PerComponent };
            var sources      = new[] { SetAttribute.ValueSource.Slot, SetAttribute.ValueSource.Source };
            var compositions = new[] { AttributeCompositionMode.Overwrite, AttributeCompositionMode.Add, AttributeCompositionMode.Multiply, AttributeCompositionMode.Blend };

            foreach (var attribute in attributes)
            {
                var attributeRefSize = VFXExpressionHelper.GetSizeOfType(VFXAttribute.Find(attribute).type);
                foreach (var random in randoms)
                {
                    foreach (var source in sources)
                    {
                        foreach (var composition in compositions)
                        {
                            if (random != RandomMode.Off && source == SetAttribute.ValueSource.Source)
                            {
                                continue;
                            }

                            if (composition != AttributeCompositionMode.Overwrite && source == SetAttribute.ValueSource.Source)
                            {
                                continue;
                            }

                            if (composition != AttributeCompositionMode.Overwrite && attribute == VFXAttribute.Alive.name)
                            {
                                continue;
                            }

                            if (random == RandomMode.PerComponent && attributeRefSize == 1)
                            {
                                continue;
                            }

                            yield return(new Variant(
                                             new[]
                            {
                                new KeyValuePair <string, object>("attribute", attribute),
                                new KeyValuePair <string, object>("Random", random),
                                new KeyValuePair <string, object>("Source", source),
                                new KeyValuePair <string, object>("Composition", composition)
                            },
                                             new[] { attribute, VFXBlockUtility.GetNameString(composition) }));
                        }
                    }
                }
            }
        }
示例#9
0
        public override void Sanitize(int version)
        {
            string newAttrib;
            VariadicChannelOptions channel;

            // Changes attribute to variadic version
            if (VFXBlockUtility.ConvertToVariadicAttributeIfNeeded(attribute, out newAttrib, out channel))
            {
                Debug.Log(string.Format("Sanitizing SetAttribute: Convert {0} to variadic attribute {1} with channel {2}", attribute, newAttrib, channel));
                attribute = newAttrib;
                channels  = channel;
                Invalidate(InvalidationCause.kSettingChanged);
            }

            base.Sanitize(version);
        }
        public override void Sanitize(int version)
        {
            if (VFXBlockUtility.SanitizeAttribute(ref attribute, ref channels, version))
            {
                Invalidate(InvalidationCause.kSettingChanged);
            }

            base.Sanitize(version);
            if (version <= 1 && inputSlots.Any(o => o.spaceable))
            {
                //Space has been added with on a few specific attributes, automatically copying space from context
                var contextSpace = GetParent().space;
                foreach (var slot in inputSlots.Where(o => o.spaceable))
                {
                    slot.space = contextSpace;
                }
                Debug.Log(string.Format("Sanitizing attribute {0} : settings space to {1} (retrieved from context)", attribute, contextSpace));
            }
        }
        private string ComputeName(bool libraryName)
        {
            if (!attributeIsValid)
            {
                return(string.Empty);
            }
            if (Source != ValueSource.Slot && Source != ValueSource.Source)
            {
                throw new NotImplementedException(Source.ToString());
            }

            var builder = new StringBuilder(24);

            if (Source == ValueSource.Slot)
            {
                builder.AppendFormat("{0} ", VFXBlockUtility.GetNameString(Composition));
            }
            else
            {
                builder.Append("Inherit Source ");
            }

            builder.Append(ObjectNames.NicifyVariableName(attribute));
            if (!libraryName && currentAttribute.variadic == VFXVariadic.True)
            {
                builder.AppendFormat(".{0}", channels.ToString());
            }

            if (Source == ValueSource.Slot)
            {
                if (Random != RandomMode.Off)
                {
                    builder.AppendFormat(" {0}", VFXBlockUtility.GetNameString(Random));
                }
            }
            else
            {
                builder.AppendFormat(" ({0})", VFXBlockUtility.GetNameString(Composition));
            }

            return(builder.ToString());
        }
示例#12
0
        public override IEnumerable <Variant> ComputeVariants()
        {
            var compositions = new[] { AttributeCompositionMode.Add, AttributeCompositionMode.Overwrite, AttributeCompositionMode.Multiply, AttributeCompositionMode.Blend };
            var attributes   = VFXAttribute.AllIncludingVariadicReadWritable.Except(new[] { VFXAttribute.Alive.name }).ToArray();
            var sampleModes  = Enum.GetValues(typeof(AttributeFromMap.AttributeMapSampleMode)).OfType <AttributeFromMap.AttributeMapSampleMode>().ToArray();

            foreach (var attribute in attributes)
            {
                foreach (var composition in compositions)
                {
                    foreach (var sampleMode in sampleModes)
                    {
                        yield return(new Variant(
                                         new[]
                        {
                            new KeyValuePair <string, object>("attribute", attribute),
                            new KeyValuePair <string, object>("Composition", composition),
                            new KeyValuePair <string, object>("SampleMode", sampleMode)
                        },
                                         new[] { attribute, VFXBlockUtility.GetNameString(composition) }));
                    }
                }
            }
        }
示例#13
0
 public override IEnumerable <Variant> ComputeVariants()
 {
     return(new[] { AttributeCompositionMode.Overwrite }
            .Select(x => new Variant(new[] { new KeyValuePair <string, object>("compositionPosition", x) }, new[] { VFXBlockUtility.GetNameString(x) })));
 }
示例#14
0
 public override IEnumerable <Variant> ComputeVariants()
 {
     return(Enum.GetValues(typeof(AttributeCompositionMode))
            .OfType <AttributeCompositionMode>()
            .Select(x => new Variant(new[] { new KeyValuePair <string, object>("composition", x) }, new[] { "velocity", VFXBlockUtility.GetNameString(x) })));
 }