MapEntryWriter.cs 1.7 KB

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