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.

144 lines
3.7 KiB

  1. //=========== Copyright (c) Valve Corporation, All rights reserved. ===========
  2. //
  3. //=============================================================================
  4. #ifndef DMEFLEXRULES_H
  5. #define DMEFLEXRULES_H
  6. #if defined( COMPILER_MSVC )
  7. #pragma once
  8. #endif
  9. // Valve includes
  10. #include "datamodel/dmattributevar.h"
  11. #include "mathlib/expressioncalculator.h"
  12. #include "movieobjects/dmeoperator.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class CDmeCombinationOperator;
  17. //-----------------------------------------------------------------------------
  18. //
  19. //-----------------------------------------------------------------------------
  20. class CDmeFlexRuleBase : public CDmeOperator
  21. {
  22. DEFINE_ELEMENT( CDmeFlexRuleBase, CDmeOperator );
  23. public:
  24. // CDmeOperator
  25. virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
  26. virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
  27. CDmAttribute *ResultAttr() { return m_flResult.GetAttribute(); }
  28. protected:
  29. friend class CDmeFlexRules;
  30. CDmeFlexRules *GetFlexRules() const;
  31. CDmaVar< float > m_flResult;
  32. };
  33. //-----------------------------------------------------------------------------
  34. //
  35. //-----------------------------------------------------------------------------
  36. class CDmeFlexRulePassThrough : public CDmeFlexRuleBase
  37. {
  38. DEFINE_ELEMENT( CDmeFlexRulePassThrough, CDmeFlexRuleBase );
  39. public:
  40. // CDmeOperator
  41. virtual void Operate();
  42. protected:
  43. friend class CDmeFlexRules;
  44. };
  45. //-----------------------------------------------------------------------------
  46. //
  47. //-----------------------------------------------------------------------------
  48. class CDmeFlexRuleExpression : public CDmeFlexRuleBase
  49. {
  50. DEFINE_ELEMENT( CDmeFlexRuleExpression, CDmeFlexRuleBase );
  51. public:
  52. // CDmeOperator
  53. virtual void Operate();
  54. virtual void Resolve();
  55. bool SetExpression( const char *pszExpression );
  56. const char *GetExpression() const { return m_expr.Get(); }
  57. protected:
  58. friend class CDmeFlexRules;
  59. CDmaString m_expr;
  60. CExpressionCalculator m_calc;
  61. };
  62. //-----------------------------------------------------------------------------
  63. //
  64. //-----------------------------------------------------------------------------
  65. class CDmeFlexRuleLocalVar : public CDmeFlexRuleBase
  66. {
  67. DEFINE_ELEMENT( CDmeFlexRuleLocalVar, CDmeFlexRuleBase );
  68. public:
  69. protected:
  70. friend class CDmeFlexRules;
  71. };
  72. //-----------------------------------------------------------------------------
  73. //
  74. //-----------------------------------------------------------------------------
  75. class CDmeFlexRules : public CDmeOperator
  76. {
  77. DEFINE_ELEMENT( CDmeFlexRules, CDmeOperator );
  78. public:
  79. // From DmeOperator
  80. virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
  81. virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
  82. virtual void Operate();
  83. virtual void Resolve();
  84. void AddFlexRule( CDmeFlexRuleBase *pDmeFlexRule );
  85. int GetRuleCount() const { return m_eDeltaStates.Count(); }
  86. CDmeFlexRuleBase *GetRule( int i ) const { return ( i < 0 || i >= GetRuleCount() ) ? NULL : m_eDeltaStates[i]; }
  87. void RemoveAllRules();
  88. void SetTarget( CDmElement *pDmElement );
  89. int GetDeltaStateIndex( const char *pszDeltaName ) const;
  90. float GetDeltaStateWeight( const char *pszDeltaName ) const;
  91. protected:
  92. friend class CDmeFlexRuleBase;
  93. friend class CDmeFlexRuleExpression;
  94. // Required to drive this node from a DmeCombinationOperator
  95. CDmaElementArray< CDmeFlexRuleBase > m_eDeltaStates;
  96. CDmaArray< Vector2D > m_vDeltaStateWeights;
  97. CDmaElement< CDmElement > m_eTarget;
  98. CDmeCombinationOperator *GetComboOp() const;
  99. CUtlVector< int > m_deltaToTargetMap;
  100. };
  101. #endif // DMEFLEXRULES_H