WorldEntryWriter.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // WorldEntryWriter.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using Microsoft.Xna.Framework;
  13. using Microsoft.Xna.Framework.Graphics;
  14. using Microsoft.Xna.Framework.Content.Pipeline;
  15. using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
  16. using Microsoft.Xna.Framework.Content.Pipeline.Processors;
  17. using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
  18. using RolePlaying.Data;
  19. #endregion
  20. namespace RolePlaying.Processors
  21. {
  22. /// <summary>
  23. /// This class will be instantiated by the XNA Framework Content Pipeline
  24. /// to write the specified data type into binary .xnb format.
  25. ///
  26. /// This should be part of a Content Pipeline Extension Library project.
  27. /// </summary>
  28. [ContentTypeWriter]
  29. public class WorldEntryWriter<T> : RolePlayingGameWriter<WorldEntry<T>>
  30. where T : ContentObject
  31. {
  32. MapEntryWriter<T> mapEntryWriter = null;
  33. protected override void Initialize(ContentCompiler compiler)
  34. {
  35. mapEntryWriter = compiler.GetTypeWriter(typeof(MapEntry<T>))
  36. as MapEntryWriter<T>;
  37. base.Initialize(compiler);
  38. }
  39. protected override void Write(ContentWriter output, WorldEntry<T> value)
  40. {
  41. output.WriteRawObject<MapEntry<T>>(value as MapEntry<T>,
  42. mapEntryWriter);
  43. output.Write(value.MapContentName);
  44. }
  45. }
  46. }