RolePlayingGameWriter.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // RolePlayingGameWriter.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. #endregion
  19. namespace RolePlaying.Processors
  20. {
  21. public abstract class RolePlayingGameWriter<T> : ContentTypeWriter<T>
  22. {
  23. const string DATA_ASSEMBLY = "RolePlaying.Data";
  24. public override string GetRuntimeReader(TargetPlatform targetPlatform)
  25. {
  26. Type type = typeof(T);
  27. string readerText = type.FullName;
  28. string shortTypeName = type.Name;
  29. if (shortTypeName.EndsWith("`1"))
  30. {
  31. // build the name of a templated type
  32. shortTypeName = shortTypeName.Substring(0, shortTypeName.Length - 2);
  33. readerText = readerText.Insert(readerText.IndexOf("`1") + 2, "+" +
  34. shortTypeName + "Reader");
  35. }
  36. else
  37. {
  38. // build the name of a non-templated type
  39. readerText += "+" + shortTypeName + "Reader";
  40. }
  41. readerText += $", {DATA_ASSEMBLY}";
  42. System.Diagnostics.Debug.WriteLine("Reader: " + readerText);
  43. return readerText;
  44. }
  45. public override string GetRuntimeType(TargetPlatform targetPlatform)
  46. {
  47. Type type = typeof(T);
  48. string typeText = type.FullName + $", {DATA_ASSEMBLY}";
  49. System.Diagnostics.Debug.WriteLine("Type: " + typeText);
  50. return typeText;
  51. }
  52. }
  53. }