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.

162 lines
5.4 KiB

  1. //===== Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ====
  2. //
  3. // Dme version of QC $BoneFlexDriver
  4. //
  5. //===========================================================================//
  6. // Valve includes
  7. #include "datamodel/dmelementfactoryhelper.h"
  8. #include "mdlobjects/dmeBoneFlexDriver.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //===========================================================================//
  12. // CDmeBoneFlexDriverControl
  13. //===========================================================================//
  14. //-----------------------------------------------------------------------------
  15. // Expose this class to the scene database
  16. //-----------------------------------------------------------------------------
  17. IMPLEMENT_ELEMENT_FACTORY( DmeBoneFlexDriverControl, CDmeBoneFlexDriverControl );
  18. //-----------------------------------------------------------------------------
  19. //
  20. //-----------------------------------------------------------------------------
  21. void CDmeBoneFlexDriverControl::OnConstruction()
  22. {
  23. m_sFlexControllerName.Init( this, "flexControllerName" );
  24. m_nBoneComponent.Init( this, "boneComponent" );
  25. m_flMin.InitAndSet( this, "min", 0.0f );
  26. m_flMax.InitAndSet( this, "max", 1.0f );
  27. }
  28. //-----------------------------------------------------------------------------
  29. //
  30. //-----------------------------------------------------------------------------
  31. void CDmeBoneFlexDriverControl::OnDestruction()
  32. {
  33. }
  34. //-----------------------------------------------------------------------------
  35. //
  36. //-----------------------------------------------------------------------------
  37. int CDmeBoneFlexDriverControl::SetBoneComponent( int nBoneComponent )
  38. {
  39. // Range [STUDIO_BONE_FLEX_TX, STUDIO_BONE_FLEX_RZ]
  40. m_nBoneComponent = clamp( nBoneComponent, 0, 5 );
  41. return m_nBoneComponent.Get();
  42. }
  43. //===========================================================================//
  44. // CDmeBoneFlexDriver
  45. //===========================================================================//
  46. //-----------------------------------------------------------------------------
  47. // Expose this class to the scene database
  48. //-----------------------------------------------------------------------------
  49. IMPLEMENT_ELEMENT_FACTORY( DmeBoneFlexDriver, CDmeBoneFlexDriver );
  50. //-----------------------------------------------------------------------------
  51. //
  52. //-----------------------------------------------------------------------------
  53. void CDmeBoneFlexDriver::OnConstruction()
  54. {
  55. m_sBoneName.Init( this, "boneName" );
  56. m_eControlList.Init( this, "controlList" );
  57. }
  58. //-----------------------------------------------------------------------------
  59. //
  60. //-----------------------------------------------------------------------------
  61. void CDmeBoneFlexDriver::OnDestruction()
  62. {
  63. }
  64. //-----------------------------------------------------------------------------
  65. //
  66. //-----------------------------------------------------------------------------
  67. CDmeBoneFlexDriverControl *CDmeBoneFlexDriver::FindOrCreateControl( const char *pszControlName )
  68. {
  69. CDmeBoneFlexDriverControl *pDmeBoneFlexDriverControl = NULL;
  70. for ( int i = 0; i < m_eControlList.Count(); ++i )
  71. {
  72. pDmeBoneFlexDriverControl = m_eControlList[i];
  73. if ( !pDmeBoneFlexDriverControl )
  74. continue;
  75. if ( !Q_stricmp( pszControlName, pDmeBoneFlexDriverControl->m_sFlexControllerName.Get() ) )
  76. return pDmeBoneFlexDriverControl;
  77. }
  78. pDmeBoneFlexDriverControl = CreateElement< CDmeBoneFlexDriverControl >( "", GetFileId() ); // Nameless
  79. if ( !pDmeBoneFlexDriverControl )
  80. return NULL;
  81. pDmeBoneFlexDriverControl->m_sFlexControllerName = pszControlName;
  82. m_eControlList.AddToTail( pDmeBoneFlexDriverControl );
  83. return pDmeBoneFlexDriverControl;
  84. }
  85. //===========================================================================//
  86. // CDmeBoneFlexDriverList
  87. //===========================================================================//
  88. //-----------------------------------------------------------------------------
  89. // Expose this class to the scene database
  90. //-----------------------------------------------------------------------------
  91. IMPLEMENT_ELEMENT_FACTORY( DmeBoneFlexDriverList, CDmeBoneFlexDriverList );
  92. //-----------------------------------------------------------------------------
  93. //
  94. //-----------------------------------------------------------------------------
  95. void CDmeBoneFlexDriverList::OnConstruction()
  96. {
  97. m_eBoneFlexDriverList.Init( this, "boneFlexDriverList" );
  98. }
  99. //-----------------------------------------------------------------------------
  100. //
  101. //-----------------------------------------------------------------------------
  102. void CDmeBoneFlexDriverList::OnDestruction()
  103. {
  104. }
  105. //-----------------------------------------------------------------------------
  106. //
  107. //-----------------------------------------------------------------------------
  108. CDmeBoneFlexDriver *CDmeBoneFlexDriverList::FindOrCreateBoneFlexDriver( const char *pszBoneName )
  109. {
  110. CDmeBoneFlexDriver *pDmeBoneFlexDriver = NULL;
  111. for ( int i = 0; i < m_eBoneFlexDriverList.Count(); ++i )
  112. {
  113. pDmeBoneFlexDriver = m_eBoneFlexDriverList[i];
  114. if ( !pDmeBoneFlexDriver )
  115. continue;
  116. if ( !Q_stricmp( pszBoneName, pDmeBoneFlexDriver->m_sBoneName.Get() ) )
  117. return pDmeBoneFlexDriver;
  118. }
  119. pDmeBoneFlexDriver = CreateElement< CDmeBoneFlexDriver >( "", GetFileId() ); // Nameless
  120. if ( !pDmeBoneFlexDriver )
  121. return NULL;
  122. pDmeBoneFlexDriver->m_sBoneName = pszBoneName;
  123. m_eBoneFlexDriverList.AddToTail( pDmeBoneFlexDriver );
  124. return pDmeBoneFlexDriver;
  125. }