Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "animdata.h"
  8. #include "dmxloader/dmxelement.h"
  9. //#include "tier1/utlvector.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. BEGIN_DMXELEMENT_UNPACK ( CAnimData )
  13. DMXELEMENT_UNPACK_FIELD_UTLSTRING( "name", "", m_pStateName )
  14. DMXELEMENT_UNPACK_FIELD_UTLSTRING( "animalias", "", m_pAnimAlias )
  15. DMXELEMENT_UNPACK_FIELD( "textureanimsequencesheetnumber", "0", int, m_TextureAnimSheetSeqNumber )
  16. DMXELEMENT_UNPACK_FIELD( "animationrate", "1", float, m_AnimationRate )
  17. END_DMXELEMENT_UNPACK( CAnimData, s_AnimDataUnpack )
  18. //-----------------------------------------------------------------------------
  19. // Constructor, Destructor
  20. //-----------------------------------------------------------------------------
  21. CAnimData::CAnimData( )
  22. {
  23. m_pStateName = "";
  24. m_pAnimAlias = "";
  25. m_TextureAnimSheetSeqNumber = 0;
  26. m_AnimationRate = 1.0;
  27. }
  28. CAnimData::~CAnimData( )
  29. {
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Populate with data from file.
  33. //-----------------------------------------------------------------------------
  34. bool CAnimData::Unserialize( CDmxElement *pElement )
  35. {
  36. pElement->UnpackIntoStructure( this, s_AnimDataUnpack );
  37. CDmxAttribute *pAnimAttr = pElement->GetAttribute( "colorlog" );
  38. if ( pAnimAttr )
  39. {
  40. CDmxElement *pAnim = pAnimAttr->GetValue< CDmxElement * >();
  41. if ( !m_ColorAnim.Unserialize( pAnim ))
  42. return false;
  43. }
  44. pAnimAttr = pElement->GetAttribute( "centerlog" );
  45. if ( pAnimAttr )
  46. {
  47. CDmxElement *pAnim = pAnimAttr->GetValue< CDmxElement * >();
  48. if ( !m_CenterPosAnim.Unserialize( pAnim ) )
  49. return false;
  50. }
  51. pAnimAttr = pElement->GetAttribute( "scalelog" );
  52. if ( pAnimAttr )
  53. {
  54. CDmxElement *pAnim = pAnimAttr->GetValue< CDmxElement * >();
  55. if ( !m_ScaleAnim.Unserialize( pAnim ) )
  56. return false;
  57. }
  58. pAnimAttr = pElement->GetAttribute( "rotationlog" );
  59. if ( pAnimAttr )
  60. {
  61. CDmxElement *pAnim = pAnimAttr->GetValue< CDmxElement * >();
  62. if ( !m_RotationAnim.Unserialize( pAnim ) )
  63. return false;
  64. }
  65. pAnimAttr = pElement->GetAttribute( "fontlog" );
  66. if ( pAnimAttr )
  67. {
  68. CDmxElement *pAnim = pAnimAttr->GetValue< CDmxElement * >();
  69. if ( !m_FontAnim.Unserialize( pAnim ) )
  70. return false;
  71. }
  72. return true;
  73. }
  74. //-----------------------------------------------------------------------------
  75. // Return true if this anim is done playing.
  76. //-----------------------------------------------------------------------------
  77. bool CAnimData::IsDone( DmeTime_t time )
  78. {
  79. if ( m_ColorAnim.IsDone( time ) &&
  80. m_CenterPosAnim.IsDone( time ) &&
  81. m_ScaleAnim.IsDone( time ) &&
  82. m_RotationAnim.IsDone( time ) &&
  83. m_FontAnim.IsDone( time ) )
  84. {
  85. return true;
  86. }
  87. return false;
  88. }