/ContentSystem/Rendering/Helpers/EmitterData.cs
C# | 96 lines | 57 code | 6 blank | 33 comment | 2 complexity | ff5f46a69edfab4812fb7432642587aa MD5 | raw file
Possible License(s): Apache-2.0
- using System.Collections.Generic;
- using System.IO;
- using Delta.Engine.Dynamic;
- using Delta.Utilities;
-
- namespace Delta.ContentSystem.Rendering.Helpers
- {
- /// <summary>
- /// Emitter data class, used for EffectData, which just contains a list of
- /// emitters. Please note that this class can be derived for additional
- /// functionality and each of the modifiers stored here can also be
- /// any class using the IEffectModifier interface.
- /// </summary>
- public class EmitterData : ISaveLoadBinary
- {
- #region Name (Public)
- /// <summary>
- /// The name of the Emitter.
- /// </summary>
- public string Name
- {
- get;
- set;
- }
- #endregion
-
- #region Modifiers (Public)
- /// <summary>
- /// The list of modifiers for this emitter.
- /// </summary>
- public List<IEffectModifier> Modifiers
- {
- get;
- private set;
- }
- #endregion
-
- #region Constructors
- /// <summary>
- /// Create a new emitter data instance.
- /// </summary>
- public EmitterData()
- {
- Modifiers = new List<IEffectModifier>();
- Name = "Emitter";
- }
- #endregion
-
- #region ISaveLoadBinary Members
- /// <summary>
- /// Load the emitter data and all the modifiers.
- /// </summary>
- /// <param name="reader">BinaryReader for reading the data</param>
- public void Load(BinaryReader reader)
- {
- // Load the name and number of modifiers.
- Name = reader.ReadString();
- int numberOfModifiers = reader.ReadInt32();
- // Iterate through the modifiers...
- for (int index = 0; index < numberOfModifiers; index++)
- {
- // Load the modifier data via the Factory and add it to the list.
- Modifiers.Add(Factory.Load<IEffectModifier>(reader));
- } // for
- }
-
- /// <summary>
- /// Save the emitter data and all the modifiers.
- /// </summary>
- /// <param name="writer">BinaryWriter for the stream to write into</param>
- public void Save(BinaryWriter writer)
- {
- // Save the name and number of modifiers.
- writer.Write(Name);
- writer.Write(Modifiers.Count);
- // Iterate through the modifiers...
- for (int index = 0; index < Modifiers.Count; index++)
- {
- // And save them via the Factory.
- Factory.Save(writer, Modifiers[index]);
- } // for
- }
- #endregion
-
- #region ToString (Public)
- /// <summary>
- /// To string helper method to print out the name of this emitter instance.
- /// </summary>
- /// <returns>String representing this EmitterData instance (name)</returns>
- public override string ToString()
- {
- return base.ToString() + " " + Name;
- }
- #endregion
- }
- }