Exemplo n.º 1
0
        private void WriteParticle(UniqueID uid, IAether particle)
        {
            string particleName = Engine.GetParticleName(particle);

            uid.Save(this);

            bool isParticleSerialized = serialisedParticles.Contains(uid);

            writer.Write(isParticleSerialized);
            if (!isParticleSerialized)
            {
                if (!uid.Equals(UniqueID.Unknown))
                {
                    serialisedParticles.Add(uid);
                }

                writer.Write(particleName); //name
                Type   particleType = particle.GetType();
                string typeName     = particleType.FullName + ", " + particleType.Assembly.GetName().Name;
                writer.Write(typeName); //type
                IAetherSerialization serialisableParticle = particle as IAetherSerialization;
                bool isSerialisableParticle = serialisableParticle != null;
                writer.Write(isSerialisableParticle); //mark whether Particle has data to serialize
                if (isSerialisableParticle)
                {
                    serialisableParticle.Save(this);
                }
            }

            return;
        }
Exemplo n.º 2
0
        private void WriteParticle(UniqueID uid, IAether particle)
        {
            string particleName = Engine.GetParticleName(particle);

            if (serialisedParticles.Contains(uid))
            {
                writer.WriteStartElement("AetherParticleRef");
                writer.WriteStartAttribute("UID"); uid.Save(this); writer.WriteEndAttribute();
                if (particleName != String.Empty)
                {
                    writer.WriteAttributeString("Name", particleName);
                }
                writer.WriteEndElement();
                return;
            }
            else
            {
                Type particleType = particle.GetType();
                if (!uid.Equals(UniqueID.Unknown))
                {
                    serialisedParticles.Add(uid);
                }
                writer.WriteStartElement("AetherParticle");
                writer.WriteStartAttribute("UID"); uid.Save(this); writer.WriteEndAttribute();
                if (particleName != String.Empty)
                {
                    writer.WriteAttributeString("Name", particleName);
                }
                string typeName = particleType.FullName + ", " + particleType.Assembly.GetName().Name;
                writer.WriteAttributeString("Type", typeName);
                IAetherSerialization serialisableParticle = particle as IAetherSerialization;
                if (serialisableParticle != null)
                {
                    serialisableParticle.Save(this);
                }
                writer.WriteEndElement();
            }

            return;
        }