Пример #1
0
        public void CreateEffectBuilders(EffectResource resource)
        {
            // Find and Clone Individual Effects
            IndexBuilder     iBldr;
            EffectBuilder    eBldr;
            VisualEffectType eType;
            int i, index, count = this.mIndexBuilders.Count;

            this.mEffectBuilders = new List <EffectBuilder>(count);
            for (i = 0; i < count; i++)
            {
                iBldr = this.mIndexBuilders[i] as IndexBuilder;
                eType = iBldr.EffectType;
                if (eType == (VisualEffectType)0)
                {
                    string header = "Effect: " + this.mEffectName + "; Index: " + i.ToString("X2")
                                    + "; BlockIndex: " + iBldr.ComponentIndex.ToString("X4");
                    System.Diagnostics.Debug.WriteLine(header + "; Unrecognized VisualEffectType (0); Assuming Particle (1)");
                    eType = VisualEffectType.Particle;
                }
                eBldr = new EffectBuilder(eType, iBldr.ComponentIndex);
                index = this.mEffectBuilders.IndexOf(eBldr);
                if (index >= 0)
                {
                    iBldr.SetEffectBuilder(this.mEffectBuilders[index]);
                }
                else
                {
                    eBldr.Effect = EffectHelper.FindEffect(eType, iBldr.ComponentIndex, resource);
                    this.mEffectBuilders.Add(eBldr);
                    iBldr.SetEffectBuilder(eBldr);
                }
            }
        }
Пример #2
0
        private void FlushEffectBuilders()
        {
            EffectResource.EffectSection eSection;
            EffectBuilder        eBuilder;
            List <EffectBuilder> eBuilders;
            int i, j, eCount, veCount = this.mVisualEffectSection.Items.Count /*this.mVisualEffectBuilders.Count/**/;

            for (i = 0; i < veCount; i++)
            {
                eBuilders = (this.mVisualEffectSection.Items[i] as VisualEffectBuilder).EffectBuilders;
                //eBuilders = (this.mVisualEffectBuilders[i] as VisualEffectBuilder).EffectBuilders;
                eCount = eBuilders.Count;
                for (j = 0; j < eCount; j++)
                {
                    eBuilder = eBuilders[j];
                    // Check if the Effect Builder already exists
                    eSection = GetEffectSection(eBuilder.EffectType);
                    if (eBuilder.EffectIndex <= eSection.Items.Count &&
                        eBuilder.Effect.Equals(eSection.Items[(int)eBuilder.EffectIndex]))
                    {
                        continue;
                    }
                    // Effect doesn't exist; flush it to the section
                    eSection.Items.Add(item: EffectHelper.CloneSectionData(eBuilder.Effect, null, eSection));
                    eBuilder.EffectIndex = eSection.Items.Count - 1;
                }
            }
        }
Пример #3
0
        public EffectBuilder Clone(EventHandler handler, ISection section)
        {
            EffectBuilder builder = new EffectBuilder(this.EffectType, this.mEffectIndex);

            builder.Effect = EffectHelper.CloneSectionData(this.Effect, handler, section) as Effect;
            return(builder);
        }
Пример #4
0
        public static void CloneVisualEffect(string name,
                                             EffectResourceBuilder source, EffectResourceBuilder dest)
        {
            name = EffectHelper.CreateSafeEffectName(name, true);
            int index = source.mVisualEffectHandleList.BinarySearch(name);

            if (index >= 0)
            {
                CloneVisualEffect(source.mVisualEffectHandleList[index], source, dest);
            }
        }
Пример #5
0
        public void SetAllEffectReferences(string oldEffectName, string newEffectName)
        {
            oldEffectName = EffectHelper.CreateSafeEffectName(oldEffectName, true);
            newEffectName = EffectHelper.CreateSafeEffectName(newEffectName, false);
            int i;

            EffectResource.EffectSection metaSection = GetEffectSection(VisualEffectType.Metaparticle);
            if (metaSection != null)
            {
                MetaparticleEffect metaEffect;
                int metaCount = metaSection.Items.Count;
                for (i = 0; i < metaCount; i++)
                {
                    metaEffect = metaSection.Items[i] as MetaparticleEffect;
                    if (metaEffect.ComponentName.ToLowerInvariant() == oldEffectName)
                    {
                        metaEffect.ComponentName = newEffectName;
                    }
                    if (metaEffect.ComponentType.ToLowerInvariant() == oldEffectName)
                    {
                        metaEffect.ComponentType = newEffectName;
                    }
                }
            }
            EffectResource.EffectSection seqSection = GetEffectSection(VisualEffectType.Sequence);
            if (seqSection != null)
            {
                SequenceEffect seqEffect;
                int            seqCount = seqSection.Items.Count;
                for (i = 0; i < seqCount; i++)
                {
                    seqEffect = seqSection.Items[i] as SequenceEffect;
                    for (int j = 0; j < seqEffect.Elements.Count; j++)
                    {
                        if (seqEffect.Elements[j].EffectName == oldEffectName)
                        {
                            seqEffect.Elements[j].EffectName = newEffectName;
                        }
                    }
                }
            }
        }
Пример #6
0
        private void FlushEffectNames()
        {
            VisualEffectBuilder builder;
            VisualEffectName    handle;
            string effectName;
            int    num, count = this.mVisualEffectSection.Items.Count /*this.mVisualEffectBuilders.Count/**/;

            this.mVisualEffectHandleList = new VisualEffectHandleList(base.OnResourceChanged);
            for (int i = 0; i < count; i++)
            {
                builder = this.mVisualEffectSection.Items[i] as VisualEffectBuilder;
                //builder = this.mVisualEffectBuilders[i] as VisualEffectBuilder;
                effectName = EffectHelper.CreateSafeEffectName(builder.EffectName, true);
                num        = this.mVisualEffectHandleList.BinarySearch(effectName);
                if (num < 0)
                {
                    handle            = new VisualEffectName(0, base.OnResourceChanged);
                    handle.EffectName = effectName;
                    handle.Index      = (uint)i;
                    this.mVisualEffectHandleList.Insert(~num, handle);
                }
            }
        }
Пример #7
0
        private VisualEffectBuilder Clone(string name, EventHandler handler,
                                          EffectResourceBuilder dest, bool safe)
        {
            MemoryStream s = new MemoryStream();

            this.UnParse(s);
            s.Position = 0L;
            VisualEffectBuilder builder;

            if (dest == null)
            {
                builder = new VisualEffectBuilder(0, handler, base.mSection, s);
            }
            else
            {
                builder = new VisualEffectBuilder(0, handler, dest.VisualEffects, s);
            }
            //builder.mEffectName = new VisualEffectHandle(0, handler, this.mEffectName);
            builder.mEffectName = safe ? EffectHelper.CreateSafeEffectName(name, true) : name;
            builder.CloneEffectBuilders(this.mEffectBuilders, handler, dest);

            return(builder);
        }
Пример #8
0
        public void AddVisualEffect(VisualEffectName handle, EffectResource resource)
        {
            VisualEffect visualEffect = EffectHelper.FindVisualEffect(handle, resource);

            this.mVisualEffectSection.Items.Add(item: new VisualEffectBuilder(handle, visualEffect, resource));
        }