Inheritance: EmitterSaveBase
        public void InvertZ()
        {
            for (int i = 0; i < emitters.Count; i++)
            {
                EmitterSave emitter = emitters[i];

                emitter.InvertHandedness();
            }
        }
        public static EmitterSaveList FromEmitterList(IEnumerable <Emitter> emittersToSave)
        {
            EmitterSaveList emitterSaveList = new EmitterSaveList();

            foreach (Emitter emitter in emittersToSave)
            {
                EmitterSave emitterSave = EmitterSave.FromEmitter(emitter);
                emitterSaveList.emitters.Add(emitterSave);
            }

            return(emitterSaveList);
        }
        /// <summary>
        /// Returns a List of files referenced by this.
        /// </summary>
        /// <param name="relativeType">Whether the files should be absolute or relative.</param>
        /// <returns>The list of referenced files.</returns>
        public List <string> GetReferencedFiles(RelativeType relativeType)
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                throw new InvalidOperationException("The EmitterSaveList's " +
                                                    "Name is null.  You must set this to the file associated with " +
                                                    "this instance.");
            }

            List <string> referencedFiles = new List <string>();

            for (int i = 0; i < this.emitters.Count; i++)
            {
                EmitterSave emitterSave = this.emitters[i];
                if (!string.IsNullOrEmpty(emitterSave.EmissionSettings.Texture))
                {
                    referencedFiles.Add(emitterSave.EmissionSettings.Texture);
                }

                if (!string.IsNullOrEmpty(emitterSave.EmissionSettings.AnimationChains))
                {
                    referencedFiles.Add(emitterSave.EmissionSettings.AnimationChains);
                }

                // Justin Johnson, 04/2015 - Retired particle blueprint system
                //if (emitterSave.ParticleBlueprint != null)
                //{
                //    emitterSave.ParticleBlueprint.GetReferencedFiles(referencedFiles);
                //}
            }

            string directory = FileManager.GetDirectory(this.Name);

            if (relativeType == RelativeType.Absolute)
            {
                for (int i = 0; i < referencedFiles.Count; i++)
                {
                    if (FileManager.IsRelative(referencedFiles[i]))
                    {
                        referencedFiles[i] = directory + referencedFiles[i];
                    }
                }
            }

            return(referencedFiles);
        }
Exemple #4
0
        public static EmitterSave FromEmitter(Emitter emitterToCreateFrom)
		{
            EmitterSave emitterToReturn = new EmitterSave();

			emitterToReturn.X = (float)emitterToCreateFrom.Position.X;
			emitterToReturn.Y = (float)emitterToCreateFrom.Position.Y;
			emitterToReturn.Z = (float)emitterToCreateFrom.Position.Z;

			emitterToReturn.ScaleX = emitterToCreateFrom.ScaleX;
			emitterToReturn.ScaleY = emitterToCreateFrom.ScaleY;
			emitterToReturn.ScaleZ = emitterToCreateFrom.ScaleZ;

            emitterToReturn.RotationX = emitterToCreateFrom.RotationX;
            emitterToReturn.RotationY = emitterToCreateFrom.RotationY;
            emitterToReturn.RotationZ = emitterToCreateFrom.RotationZ;

			emitterToReturn.AreaEmissionType = FlatRedBall.Graphics.GraphicalEnumerations.TranslateAreaEmissionType(
                emitterToCreateFrom.AreaEmission);

            emitterToReturn.RemovalEvent =
                FlatRedBall.Graphics.Particle.Emitter.TranslateRemovalEvent( emitterToCreateFrom.RemovalEvent);

            if (emitterToCreateFrom.Parent != null)
            {
                emitterToReturn.ParentSpriteName = emitterToCreateFrom.Parent.Name;
            }

			emitterToReturn.Name = emitterToCreateFrom.Name;

            // Justin Johnson, 04/2015 - retiring particle blueprints
            //emitterToReturn.ParticleBlueprint = SpriteSave.FromSprite(emitterToCreateFrom.ParticleBlueprint);

            // I don't think that we need to manually set the texture - the SprietSave should do it on its own
            //particleBlueprint.spriteTexture = FRB.File.FileManager.MakeRelativeToPath(
            //    particleBlueprint.spriteTexture, relativeTo);

            emitterToReturn.BoundedEmission = emitterToCreateFrom.BoundedEmission;
            emitterToReturn.EmissionBoundary = Polygon.PolygonSave.FromPolygon(emitterToCreateFrom.EmissionBoundary);

            emitterToReturn.EmissionSettings = EmissionSettingsSave.FromEmissionSettings(emitterToCreateFrom.EmissionSettings);

            emitterToReturn.SecondFrequency = emitterToCreateFrom.SecondFrequency;
            emitterToReturn.NumberPerEmission = emitterToCreateFrom.NumberPerEmission;
            emitterToReturn.TimedEmission = emitterToCreateFrom.TimedEmission;

            emitterToReturn.RemovalEvent = 
                Emitter.TranslateRemovalEvent(emitterToCreateFrom.RemovalEvent);
            emitterToReturn.SecondsLasting = emitterToCreateFrom.SecondsLasting;

            emitterToReturn.RelativeX = emitterToCreateFrom.RelativePosition.X;
            emitterToReturn.RelativeY = emitterToCreateFrom.RelativePosition.Y;
            emitterToReturn.RelativeZ = emitterToCreateFrom.RelativePosition.Z;

            emitterToReturn.ParentVelocityChangesEmissionVelocity = emitterToCreateFrom.ParentVelocityChangesEmissionVelocity;
			emitterToReturn.RotationChangesParticleRotation = emitterToCreateFrom.RotationChangesParticleRotation;
			emitterToReturn.RotationChangesParticleAcceleration = emitterToCreateFrom.RotationChangesParticleAcceleration;

            // TODO:  Need to add support for saving off instructions.

			//particleInstructionArray = emitterToCreateFrom.ParticleBlueprint.instructionArray.Clone();

			// each instruction will reference the blueprint Sprite.  When serialized, the referenced Sprite
			// will be attempted to be saved.  This will throw an error (and also would take up a lot of memory if succeeded)
			//foreach(FrbInstruction frbi in particleInstructionArray)
			//	frbi.referenceObject = null;

            return emitterToReturn;
        }
        /// <summary>
        /// Disposes of the currently displaying 
        /// emitter and creates a new one from the supplied 
        /// save object. Requires an absolute path so it knows where
        /// to load sprites and other paths from.
        /// </summary>
        /// <param name="emitterSave">The emitter save to inflate into an emitter runtime object.</param>
        /// <param name="absolutePath">The base path to use when loading sprite textures or other resources.</param>
        public void DisplayEmitter(EmitterSave emitterSave, string absolutePath)
        {
            if (previewEmitter != null)
            {
                SpriteManager.RemoveEmitter(previewEmitter);
            }

            FileManager.RelativeDirectory = absolutePath;
            previewEmitter = emitterSave.ToEmitter(ContentManagerName);
            SpriteManager.AddEmitter(previewEmitter);
        }
Exemple #6
0
        public static EmitterSave FromEmitter(Emitter emitterToCreateFrom)
        {
            EmitterSave emitterToReturn = new EmitterSave();

            emitterToReturn.X = (float)emitterToCreateFrom.Position.X;
            emitterToReturn.Y = (float)emitterToCreateFrom.Position.Y;
            emitterToReturn.Z = (float)emitterToCreateFrom.Position.Z;

            emitterToReturn.ScaleX = emitterToCreateFrom.ScaleX;
            emitterToReturn.ScaleY = emitterToCreateFrom.ScaleY;
            emitterToReturn.ScaleZ = emitterToCreateFrom.ScaleZ;

            emitterToReturn.RotationX = emitterToCreateFrom.RotationX;
            emitterToReturn.RotationY = emitterToCreateFrom.RotationY;
            emitterToReturn.RotationZ = emitterToCreateFrom.RotationZ;

            emitterToReturn.AreaEmissionType = FlatRedBall.Graphics.GraphicalEnumerations.TranslateAreaEmissionType(
                emitterToCreateFrom.AreaEmission);

            emitterToReturn.RemovalEvent =
                FlatRedBall.Graphics.Particle.Emitter.TranslateRemovalEvent(emitterToCreateFrom.RemovalEvent);

            if (emitterToCreateFrom.Parent != null)
            {
                emitterToReturn.ParentSpriteName = emitterToCreateFrom.Parent.Name;
            }

            emitterToReturn.Name = emitterToCreateFrom.Name;

            // Justin Johnson, 04/2015 - retiring particle blueprints
            //emitterToReturn.ParticleBlueprint = SpriteSave.FromSprite(emitterToCreateFrom.ParticleBlueprint);

            // I don't think that we need to manually set the texture - the SprietSave should do it on its own
            //particleBlueprint.spriteTexture = FRB.File.FileManager.MakeRelativeToPath(
            //    particleBlueprint.spriteTexture, relativeTo);

            emitterToReturn.BoundedEmission  = emitterToCreateFrom.BoundedEmission;
            emitterToReturn.EmissionBoundary = Polygon.PolygonSave.FromPolygon(emitterToCreateFrom.EmissionBoundary);

            emitterToReturn.EmissionSettings = EmissionSettingsSave.FromEmissionSettings(emitterToCreateFrom.EmissionSettings);

            emitterToReturn.SecondFrequency   = emitterToCreateFrom.SecondFrequency;
            emitterToReturn.NumberPerEmission = emitterToCreateFrom.NumberPerEmission;
            emitterToReturn.TimedEmission     = emitterToCreateFrom.TimedEmission;

            emitterToReturn.RemovalEvent =
                Emitter.TranslateRemovalEvent(emitterToCreateFrom.RemovalEvent);
            emitterToReturn.SecondsLasting = emitterToCreateFrom.SecondsLasting;

            emitterToReturn.RelativeX = emitterToCreateFrom.RelativePosition.X;
            emitterToReturn.RelativeY = emitterToCreateFrom.RelativePosition.Y;
            emitterToReturn.RelativeZ = emitterToCreateFrom.RelativePosition.Z;

            emitterToReturn.ParentVelocityChangesEmissionVelocity = emitterToCreateFrom.ParentVelocityChangesEmissionVelocity;
            emitterToReturn.RotationChangesParticleRotation       = emitterToCreateFrom.RotationChangesParticleRotation;
            emitterToReturn.RotationChangesParticleAcceleration   = emitterToCreateFrom.RotationChangesParticleAcceleration;

            // TODO:  Need to add support for saving off instructions.

            //particleInstructionArray = emitterToCreateFrom.ParticleBlueprint.instructionArray.Clone();

            // each instruction will reference the blueprint Sprite.  When serialized, the referenced Sprite
            // will be attempted to be saved.  This will throw an error (and also would take up a lot of memory if succeeded)
            //foreach(FrbInstruction frbi in particleInstructionArray)
            //	frbi.referenceObject = null;

            return(emitterToReturn);
        }