Beispiel #1
0
        public static void CloneVisualEffect(VisualEffectName handle,
                                             EffectResourceBuilder source, EffectResourceBuilder dest)
        {
            VisualEffectBuilder builder = source.mVisualEffectSection.Items[(int)handle.Index] as VisualEffectBuilder;

            dest.mVisualEffectSection.Items.Add(item: builder.Clone(dest.OnResourceChanged, dest));
        }
Beispiel #2
0
 public VisualEffectHandleContainer(VisualEffectName handle, EffectResource owner)
 {
     this.Handle = handle;
     this.Owner  = owner;
     //this.Dependents = new List<MetaparticleEffect>();
     this.OriginalName = handle.EffectName;
 }
Beispiel #3
0
 public VisualEffectBuilder(VisualEffectName handle, VisualEffect basis, EffectResource resource)
     : base(0, null, basis)
 {
     this.mEffectName = handle.EffectName;
     this.CastIndices();
     this.CreateEffectBuilders(resource);
 }
Beispiel #4
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());
        }
Beispiel #5
0
        public static VisualEffect FindVisualEffect(string name, EffectResource resource)
        {
            VisualEffectName handle = FindVisualEffectHandle(name, resource);

            if (handle == null)
            {
                return(null);
            }
            return(resource.VisualEffectSections.Items[(int)handle.Index] as VisualEffect);
        }
Beispiel #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);
                }
            }
        }
Beispiel #7
0
 private void LocateSeqReferences(VisualEffectName handle, EffectResource resource,
     List<VisualEffectHandleContainer> references)
 {
     SequenceEffect[] seqEffects = EffectHelper.FindEffects<SequenceEffect>(handle, resource);
     if (seqEffects != null && seqEffects.Length > 0)
     {
         int i, j, k;
         VisualEffectName dep;
         SequenceEffect seqEffect;
         string effectName;
         bool flag = false;
         for (i = 0; i < seqEffects.Length; i++)
         {
             seqEffect = seqEffects[i];
             for (j = 0; j < seqEffect.Elements.Count; j++)
             {
                 // compensate for variations in casing
                 effectName = seqEffect.Elements[j].EffectName.ToLowerInvariant();
                 for (k = 0; k < references.Count && !flag; k++)
                 {
                     if (references[k].OriginalName == effectName)
                     {
                         //references[j].Dependents.Add(seqEffects[i]);
                         flag = true;
                     }
                 }
                 if (!flag)
                 {
                     dep = EffectHelper.FindVisualEffectHandle(effectName, resource);
                     if (dep != null)
                     {
                         references.Add(new VisualEffectHandleContainer(
                             new VisualEffectName(0, null, dep), resource));
                         this.LocateSeqReferences(dep, resource, references);
                     }
                 }
                 flag = false;
             }
         }
     }
 }
Beispiel #8
0
 private void LocateMetaReferences(VisualEffectName handle, EffectResource resource,
     List<VisualEffectHandleContainer> references)
 {
     MetaparticleEffect[] metaEffects = EffectHelper.FindEffects<MetaparticleEffect>(handle, resource);
     if (metaEffects != null && metaEffects.Length > 0)
     {
         int i, j;
         VisualEffectName dep;
         string effectName;
         bool flag = false;
         for (i = 0; i < metaEffects.Length; i++)
         {
             // compensate for variations in casing
             effectName = metaEffects[i].ComponentName.ToLowerInvariant();
             for (j = 0; j < references.Count && !flag; j++)
             {
                 if (references[j].OriginalName == effectName)
                 {
                     //references[j].Dependents.Add(metaEffects[i]);
                     flag = true;
                 }
             }
             if (!flag)
             {
                 dep = EffectHelper.FindVisualEffectHandle(effectName, resource);
                 if (dep != null)
                 {
                     references.Add(new VisualEffectHandleContainer(
                         new VisualEffectName(0, null, dep), resource));
                     this.LocateMetaReferences(dep, resource, references);
                 }
             }
             flag = false;
             // compensate for variations in casing
             effectName = metaEffects[i].ComponentType.ToLowerInvariant();
             for (j = 0; j < references.Count && !flag; j++)
             {
                 if (references[j].OriginalName == effectName)
                 {
                     //references[j].Dependents.Add(metaEffects[i]);
                     flag = true;
                 }
             }
             if (!flag)
             {
                 dep = EffectHelper.FindVisualEffectHandle(effectName, resource);
                 if (dep != null)
                 {
                     references.Add(new VisualEffectHandleContainer(
                         new VisualEffectName(0, null, dep), resource));
                     this.LocateMetaReferences(dep, resource, references);
                 }
             }
             flag = false;
         }
     }
 }
Beispiel #9
0
        public void AddVisualEffect(VisualEffectName handle, EffectResource resource)
        {
            VisualEffect visualEffect = EffectHelper.FindVisualEffect(handle, resource);

            this.mVisualEffectSection.Items.Add(item: new VisualEffectBuilder(handle, visualEffect, resource));
        }
Beispiel #10
0
 public static VisualEffect FindVisualEffect(VisualEffectName handle, EffectResource resource)
 {
     return(resource.VisualEffectSections.Items[(int)handle.Index] as VisualEffect);
 }
Beispiel #11
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());
        }