WorldObject.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // WorldObject.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 Microsoft.Xna.Framework;
  12. using Microsoft.Xna.Framework.Content;
  13. #endregion
  14. namespace RolePlayingGameData
  15. {
  16. /// <summary>
  17. /// Common base class for all objects that are visible in the world.
  18. /// </summary>
  19. public abstract class WorldObject : ContentObject
  20. {
  21. #region Description
  22. /// <summary>
  23. /// The name of the object.
  24. /// </summary>
  25. private string name;
  26. /// <summary>
  27. /// The name of the object.
  28. /// </summary>
  29. public string Name
  30. {
  31. get { return name; }
  32. set { name = value; }
  33. }
  34. #endregion
  35. #region Content Type Reader
  36. /// <summary>
  37. /// Read a WorldObject object from the content pipeline.
  38. /// </summary>
  39. public class WorldObjectReader : ContentTypeReader<WorldObject>
  40. {
  41. /// <summary>
  42. /// Read a WorldObject object from the content pipeline.
  43. /// </summary>
  44. protected override WorldObject Read(ContentReader input,
  45. WorldObject existingInstance)
  46. {
  47. // we cannot create this object, so there must be an existing instance
  48. if (existingInstance == null)
  49. {
  50. throw new ArgumentNullException("existingInstance");
  51. }
  52. existingInstance.AssetName = input.AssetName;
  53. existingInstance.Name = input.ReadString();
  54. return existingInstance;
  55. }
  56. }
  57. #endregion
  58. }
  59. }