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.

55 lines
1.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "graphicscriptinterface.h"
  8. #include "gamegraphic.h"
  9. #include "gameuisystemmgr.h"
  10. BEGIN_SCRIPTDESC_ROOT_NAMED( CGraphicScriptInterface, "CGraphicScriptInterface", SCRIPT_SINGLETON "" )
  11. DEFINE_SCRIPTFUNC( PlayAnim, "Play an animation by name" )
  12. END_SCRIPTDESC()
  13. //-----------------------------------------------------------------------------
  14. // Constructor
  15. //-----------------------------------------------------------------------------
  16. CGraphicScriptInterface::CGraphicScriptInterface( IScriptVM *pScriptVM )
  17. {
  18. m_pScriptVM = pScriptVM;
  19. m_pGraphic = NULL;
  20. HSCRIPT Scope = m_pScriptVM->RegisterInstance( this, "Graphic" );
  21. SetScope( Scope );
  22. }
  23. //-----------------------------------------------------------------------------
  24. // Tell this script what graphic it belongs to.
  25. //-----------------------------------------------------------------------------
  26. void CGraphicScriptInterface::InstallGraphic( CGameGraphic *pGraphic )
  27. {
  28. m_pGraphic = pGraphic;
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Play an animation on the graphic.
  32. //-----------------------------------------------------------------------------
  33. void CGraphicScriptInterface::PlayAnim( const char *pAnimName )
  34. {
  35. Assert( m_pGraphic );
  36. if ( !m_pGraphic->HasState( pAnimName ) )
  37. {
  38. Warning( "Unable to find state %s for graphic %s\n", pAnimName, m_pGraphic->GetName() );
  39. return;
  40. }
  41. m_pGraphic->SetState( pAnimName );
  42. }