remoteplayerdamagedebug.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. class RemotePlayerDamageDebug
  2. {
  3. const int MAX_DAMAGE_RECORDS = 5;
  4. PlayerBase m_Player;
  5. bool m_ChangedSinceSerialization;
  6. ref array<ref DamageData> m_DamageList = new array<ref DamageData>;
  7. void RemotePlayerDamageDebug(PlayerBase player)
  8. {
  9. m_Player = player;
  10. }
  11. void AddDamage(float value_global, float value_blood, float value_shock)
  12. {
  13. m_ChangedSinceSerialization = true;
  14. DamageData damage_data = new DamageData( value_global, value_blood, value_shock );
  15. m_DamageList.InsertAt(damage_data,0);
  16. if( m_DamageList.Count() > MAX_DAMAGE_RECORDS )
  17. {
  18. m_DamageList.RemoveOrdered(MAX_DAMAGE_RECORDS);
  19. }
  20. }
  21. void InsertDamageObject(DamageData damage_object)
  22. {
  23. m_DamageList.Insert(damage_object);
  24. }
  25. PlayerBase GetPlayer()
  26. {
  27. return m_Player;
  28. }
  29. void Get(array<ref DamageData> damage_list)
  30. {
  31. for(int i = 0; i < m_DamageList.Count(); i++)
  32. {
  33. damage_list.Insert(m_DamageList.Get(i));
  34. }
  35. }
  36. void GetReversed(array<ref DamageData> damage_list)
  37. {
  38. int index = m_DamageList.Count() - 1;
  39. for(; index >= 0; index--)
  40. {
  41. damage_list.Insert(m_DamageList.Get(index));
  42. }
  43. }
  44. void Serialize(array<ref RemotePlayerDamageDebug> list)
  45. {
  46. if( m_ChangedSinceSerialization )
  47. {
  48. list.Insert(this);
  49. }
  50. m_ChangedSinceSerialization = false;
  51. }
  52. void Debug()
  53. {
  54. string output;
  55. for(int i = 0; i < m_DamageList.Count(); i++)
  56. {
  57. output = output + m_DamageList.Get(i).ToString() + ", ";
  58. }
  59. PrintString("damage values for player " + m_Player.ToString()+":" + output);
  60. }
  61. }