remoteplayerstatdebug.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. enum eRemoteStatType
  2. {
  3. NONE,
  4. DAMAGE_SYSTEM = 1,
  5. PLAYER_STATS = 2,
  6. OTHER = 4,
  7. }
  8. class RemotePlayerStatDebug
  9. {
  10. PlayerBase m_Player;
  11. ref array<ref StatDebugObject> m_Stats = new array<ref StatDebugObject>;
  12. string m_Name;
  13. vector m_Pos;
  14. void RemotePlayerStatDebug(PlayerBase player)
  15. {
  16. m_Player = player;
  17. Init();
  18. }
  19. void Init()
  20. {
  21. UpdatePlayerStatsValues();
  22. InjectDamageSystemValues();
  23. m_Pos = m_Player.GetWorldPosition();
  24. m_Name = m_Player.GetIdentity().GetName();
  25. }
  26. PlayerBase GetPlayer()
  27. {
  28. return m_Player;
  29. }
  30. void UpdatePlayerStatsValues()
  31. {
  32. m_Player.GetPlayerStats().GetDebugInfo(m_Stats, 0);
  33. }
  34. void InjectDamageSystemValues()
  35. {
  36. m_Stats.Insert( new StatDebugObject("Health", m_Player.GetHealth("",""), eRemoteStatType.DAMAGE_SYSTEM) );
  37. m_Stats.Insert( new StatDebugObject("Blood", m_Player.GetHealth("","Blood"), eRemoteStatType.DAMAGE_SYSTEM) );
  38. m_Stats.Insert( new StatDebugObject("Shock", m_Player.GetHealth("","Shock"), eRemoteStatType.DAMAGE_SYSTEM) );
  39. }
  40. void SerializeNames(array<string> names, eRemoteDebugType type)
  41. {
  42. for(int i = 0; i < m_Stats.Count(); i++)
  43. {
  44. if( type == eRemoteDebugType.ALL )
  45. {
  46. names.Insert(m_Stats.Get(i).GetName());
  47. }
  48. else if( type == eRemoteDebugType.DAMAGE_ONLY )
  49. {
  50. StatDebugObject obj = m_Stats.Get(i);
  51. eRemoteStatType debug_type = obj.GetType();
  52. if(debug_type == eRemoteStatType.DAMAGE_SYSTEM)
  53. {
  54. names.Insert(m_Stats.Get(i).GetName());
  55. }
  56. }
  57. }
  58. }
  59. void SerializeValues(array<string> values, eRemoteDebugType type)
  60. {
  61. for(int i = 0; i < m_Stats.Count(); i++)
  62. {
  63. if( type == eRemoteDebugType.ALL )
  64. {
  65. values.Insert(m_Stats.Get(i).GetValue());
  66. }
  67. else if( type == eRemoteDebugType.DAMAGE_ONLY )
  68. {
  69. StatDebugObject obj = m_Stats.Get(i);
  70. eRemoteStatType debug_type = obj.GetType();
  71. if(debug_type == eRemoteStatType.DAMAGE_SYSTEM)
  72. {
  73. values.Insert(m_Stats.Get(i).GetValue());
  74. }
  75. }
  76. }
  77. }
  78. void Debug()
  79. {
  80. for(int i = 0; i < m_Stats.Count(); i++)
  81. {
  82. m_Stats.Get(i).Debug();
  83. }
  84. }
  85. }