Team Fortress 2 Source Code as on 22/4/2020
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.

63 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. // memdbgon must be the last include file in a .cpp file!!!
  8. #include "tier0/memdbgon.h"
  9. class CTextureToggle : public CPointEntity
  10. {
  11. public:
  12. DECLARE_CLASS( CTextureToggle, CPointEntity );
  13. void InputIncrementBrushTexIndex( inputdata_t &inputdata );
  14. void InputSetBrushTexIndex( inputdata_t &inputdata );
  15. private:
  16. DECLARE_DATADESC();
  17. };
  18. LINK_ENTITY_TO_CLASS( env_texturetoggle, CTextureToggle );
  19. BEGIN_DATADESC( CTextureToggle )
  20. DEFINE_INPUTFUNC( FIELD_VOID, "IncrementTextureIndex", InputIncrementBrushTexIndex ),
  21. DEFINE_INPUTFUNC( FIELD_INTEGER, "SetTextureIndex", InputSetBrushTexIndex ),
  22. END_DATADESC()
  23. //-----------------------------------------------------------------------------
  24. // Purpose:
  25. // Input : &inputdata -
  26. //-----------------------------------------------------------------------------
  27. void CTextureToggle::InputIncrementBrushTexIndex( inputdata_t& inputdata )
  28. {
  29. CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, m_target );
  30. while( pEntity )
  31. {
  32. int iCurrentIndex = pEntity->GetTextureFrameIndex() + 1;
  33. pEntity->SetTextureFrameIndex( iCurrentIndex );
  34. pEntity = gEntList.FindEntityByName( pEntity, m_target );
  35. }
  36. }
  37. void CTextureToggle::InputSetBrushTexIndex( inputdata_t& inputdata )
  38. {
  39. CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, m_target );
  40. while( pEntity )
  41. {
  42. int iData = inputdata.value.Int();
  43. pEntity->SetTextureFrameIndex( iData );
  44. pEntity = gEntList.FindEntityByName( pEntity, m_target );
  45. }
  46. }