WorldEntry.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //-----------------------------------------------------------------------------
  2. // WorldEntry.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using Microsoft.Xna.Framework;
  9. using Microsoft.Xna.Framework.Content;
  10. namespace RolePlaying.Data
  11. {
  12. /// <summary>
  13. /// A description of a piece of content, including the name of the map it's on.
  14. /// </summary>
  15. public class WorldEntry<T> : MapEntry<T> where T : ContentObject
  16. {
  17. /// <summary>
  18. /// The name of the map where the content is added.
  19. /// </summary>
  20. private string mapContentName;
  21. /// <summary>
  22. /// The name of the map where the content is added.
  23. /// </summary>
  24. public string MapContentName
  25. {
  26. get { return mapContentName; }
  27. set { mapContentName = value; }
  28. }
  29. /// <summary>
  30. /// Reads a WorldEntry object from the content pipeline.
  31. /// </summary>
  32. public class WorldEntryReader : ContentTypeReader<WorldEntry<T>>
  33. {
  34. /// <summary>
  35. /// Reads a WorldEntry object from the content pipeline.
  36. /// </summary>
  37. protected override WorldEntry<T> Read(ContentReader input,
  38. WorldEntry<T> existingInstance)
  39. {
  40. WorldEntry<T> desc = existingInstance;
  41. if (desc == null)
  42. {
  43. desc = new WorldEntry<T>();
  44. }
  45. input.ReadRawObject<MapEntry<T>>(desc as MapEntry<T>);
  46. desc.MapContentName = input.ReadString();
  47. return desc;
  48. }
  49. }
  50. }
  51. }