Пример #1
0
        public static E[] FindEffects <E>(VisualEffectName handle,
                                          EffectResource resource) where E : Effect
        {
            VisualEffectType eType   = GetEffectType <E>();
            byte             bType   = (byte)eType;
            List <E>         effects = new List <E>();

            EffectResource.EffectSection effectSection = FindEffectSection(eType, resource);
            if (effectSection == null)
            {
                return(null);
            }
            VisualEffect visualEffect = FindVisualEffect(handle, resource);
            int          indexCount   = visualEffect.Descriptions.Count;

            VisualEffect.Description veIndex;
            for (int i = 0; i < indexCount; i++)
            {
                veIndex = visualEffect.Descriptions[i] as VisualEffect.Description;
                if (veIndex.ComponentType == bType)
                {
                    effects.Add(effectSection.Items[veIndex.ComponentIndex] as E);
                }
            }
            return(effects.ToArray());
        }
Пример #2
0
 public static Effect FindEffect(VisualEffectType eType, int eIndex, EffectResource resource)
 {
     EffectResource.EffectSection eSection = FindEffectSection(eType, resource);
     if (eSection == null)
     {
         return(null);
     }
     return(eSection.Items[eIndex] as Effect);
 }
Пример #3
0
        public void CreateEffectBuilders(EffectResourceBuilder resBuilder, EffectResource resource)
        {
            // Find and Clone Individual Effects
            IndexBuilder     iBldr;
            EffectBuilder    eBldr;
            VisualEffectType eType;

            s3piwrappers.Effects.Effect effect;
            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
                {
                    effect = EffectHelper.FindEffect(eType, iBldr.ComponentIndex, resource);
                    if (effect != null)
                    {
                        EffectResource.EffectSection eSection = null;
                        if (resBuilder != null)
                        {
                            eSection = resBuilder.GetEffectSection(eType);
                        }
                        eBldr.Effect = EffectHelper.CloneSectionData(effect, null, eSection)
                                       as s3piwrappers.Effects.Effect;
                        this.mEffectBuilders.Add(eBldr);
                        iBldr.SetEffectBuilder(eBldr);
                    }
                }
            }
        }
Пример #4
0
        public static void SetAllEffectReferences(string oldEffectName, string newEffectName,
                                                  EffectResource resource)
        {
            oldEffectName = CreateSafeEffectName(oldEffectName, true);
            newEffectName = CreateSafeEffectName(newEffectName, false);
            int i;

            EffectResource.EffectSection metaSection = FindEffectSection(VisualEffectType.Metaparticle, resource);
            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 = FindEffectSection(VisualEffectType.Sequence, resource);
            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.ToLowerInvariant() == oldEffectName)
                        {
                            seqEffect.Elements[j].EffectName = newEffectName;
                        }
                    }
                }
            }
        }
Пример #5
0
 public Effect GetEffect(VisualEffectType eType, int eIndex)
 {
     EffectResource.EffectSection section = GetEffectSection(eType);
     return(section.Items[eIndex] as Effect);
 }
Пример #6
0
        public static string[] GetSurfaceStrings(VisualEffectName handle, EffectResource resource)
        {
            byte pEffectType = (byte)VisualEffectType.Particle;
            byte mEffectType = (byte)VisualEffectType.Metaparticle;
            byte dEffectType = (byte)VisualEffectType.Distribute;

            EffectResource.EffectSection pEffects = FindEffectSection(VisualEffectType.Particle, resource);
            EffectResource.EffectSection mEffects = FindEffectSection(VisualEffectType.Metaparticle, resource);
            EffectResource.EffectSection dEffects = FindEffectSection(VisualEffectType.Distribute, resource);

            List <string>             surfaceStrings = new List <string>();
            DataList <Effect.Surface> surfaces;
            VisualEffect visualEffect = FindVisualEffect(handle, resource);

            VisualEffect.Description index;
            Effect.Surface           surface;
            int i, j, count, indexCount = visualEffect.Descriptions.Count;

            for (i = 0; i < indexCount; i++)
            {
                index = visualEffect.Descriptions[i] as VisualEffect.Description;
                if (index.ComponentType == pEffectType)
                {
                    ParticleEffect particle = pEffects.Items[index.ComponentIndex] as ParticleEffect;
                    surfaces = particle.Surfaces;
                    count    = surfaces.Count;
                    for (j = 0; j < count; j++)
                    {
                        surface = surfaces[j];
                        if (!string.IsNullOrEmpty(surface.String01))
                        {
                            surfaceStrings.Add(string.Format("{0:X4}(P).Surfaces[{1}].String01:{2}", i, j, surface.String01));
                        }
                        if (!string.IsNullOrEmpty(surface.String02))
                        {
                            surfaceStrings.Add(string.Format("{0:X4}(P).Surfaces[{1}].String02:{2}", i, j, surface.String02));
                        }
                    }
                }
                if (index.ComponentType == mEffectType)
                {
                    MetaparticleEffect metaparticle = mEffects.Items[index.ComponentIndex] as MetaparticleEffect;
                    surfaces = metaparticle.Surfaces;
                    count    = surfaces.Count;
                    for (j = 0; j < count; j++)
                    {
                        surface = metaparticle.Surfaces[j];
                        if (!string.IsNullOrEmpty(surface.String01))
                        {
                            surfaceStrings.Add(string.Format("{0:X4}(M).Surfaces[{1}].String01:{2}", i, j, surface.String01));
                        }
                        if (!string.IsNullOrEmpty(surface.String02))
                        {
                            surfaceStrings.Add(string.Format("{0:X4}(M).Surfaces[{1}].String02:{2}", i, j, surface.String02));
                        }
                    }
                }
                if (index.ComponentType == dEffectType)
                {
                    DistributeEffect distribute = dEffects.Items[index.ComponentIndex] as DistributeEffect;
                    surfaces = distribute.Surfaces;
                    count    = surfaces.Count;
                    for (j = 0; j < count; j++)
                    {
                        surface = surfaces[j];
                        if (!string.IsNullOrEmpty(surface.String01))
                        {
                            surfaceStrings.Add(string.Format("{0:X4}(D).Surfaces[{1}].String01:{2}", i, j, surface.String01));
                        }
                        if (!string.IsNullOrEmpty(surface.String02))
                        {
                            surfaceStrings.Add(string.Format("{0:X4}(D).Surfaces[{1}].String02:{2}", i, j, surface.String02));
                        }
                    }
                }
            }
            return(surfaceStrings.ToArray());
        }