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.

134 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef C_SCENEENTITY_H
  8. #define C_SCENEENTITY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "ichoreoeventcallback.h"
  13. #include "choreoscene.h"
  14. class C_SceneEntity : public C_BaseEntity, public IChoreoEventCallback
  15. {
  16. friend class CChoreoEventCallback;
  17. public:
  18. DECLARE_CLASS( C_SceneEntity, C_BaseEntity );
  19. DECLARE_CLIENTCLASS();
  20. C_SceneEntity( void );
  21. ~C_SceneEntity( void );
  22. // From IChoreoEventCallback
  23. virtual void StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  24. virtual void EndEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  25. virtual void ProcessEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  26. virtual bool CheckEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  27. virtual void PostDataUpdate( DataUpdateType_t updateType );
  28. virtual void PreDataUpdate( DataUpdateType_t updateType );
  29. virtual void StopClientOnlyScene();
  30. virtual void SetupClientOnlyScene( const char *pszFilename, C_BaseFlex *pOwner = NULL , bool bMultiplayer = false );
  31. virtual void ClientThink();
  32. void OnResetClientTime();
  33. CHandle< C_BaseFlex > GetActor( int i ){ return ( i < m_hActorList.Count() ) ? m_hActorList[i] : NULL; }
  34. virtual void DispatchStartSpeak( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event, soundlevel_t iSoundlevel );
  35. virtual void DispatchEndSpeak( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  36. bool IsClientOnly( void ){ return m_bClientOnly; }
  37. private:
  38. void ResetActorFlexesForScene();
  39. // Scene load/unload
  40. CChoreoScene *LoadScene( const char *filename );
  41. void LoadSceneFromFile( const char *filename );
  42. void UnloadScene( void );
  43. void PrefetchAnimBlocks( CChoreoScene *pScene );
  44. C_BaseFlex *FindNamedActor( CChoreoActor *pChoreoActor );
  45. virtual void DispatchStartFlexAnimation( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  46. virtual void DispatchEndFlexAnimation( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  47. virtual void DispatchStartExpression( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  48. virtual void DispatchEndExpression( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  49. virtual void DispatchStartGesture( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  50. virtual void DispatchProcessGesture( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  51. virtual void DispatchEndGesture( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  52. virtual void DispatchStartSequence( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  53. virtual void DispatchProcessSequence( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  54. virtual void DispatchEndSequence( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event );
  55. void DispatchProcessLoop( CChoreoScene *scene, CChoreoEvent *event );
  56. char const *GetSceneFileName();
  57. void DoThink( float frametime );
  58. void ClearSceneEvents( CChoreoScene *scene, bool canceled );
  59. void SetCurrentTime( float t, bool forceClientSync );
  60. bool GetHWMorphSceneFileName( const char *pFilename, char *pHWMFilename );
  61. private:
  62. void CheckQueuedEvents();
  63. void WipeQueuedEvents();
  64. void QueueStartEvent( float starttime, CChoreoScene *scene, CChoreoEvent *event );
  65. bool m_bIsPlayingBack;
  66. bool m_bPaused;
  67. bool m_bMultiplayer;
  68. float m_flCurrentTime;
  69. float m_flForceClientTime;
  70. int m_nSceneStringIndex;
  71. bool m_bClientOnly;
  72. CHandle< C_BaseFlex > m_hOwner; // if set, this overrides the m_hActorList in FindNamedActor()
  73. CUtlVector< CHandle< C_BaseFlex > > m_hActorList;
  74. private:
  75. bool m_bWasPlaying;
  76. CChoreoScene *m_pScene;
  77. struct QueuedEvents_t
  78. {
  79. float starttime;
  80. CChoreoScene *scene;
  81. CChoreoEvent *event;
  82. };
  83. CUtlVector< QueuedEvents_t > m_QueuedEvents;
  84. };
  85. //-----------------------------------------------------------------------------
  86. // Binary compiled VCDs get their strings from a pool
  87. //-----------------------------------------------------------------------------
  88. class CChoreoStringPool : public IChoreoStringPool
  89. {
  90. public:
  91. short FindOrAddString( const char *pString )
  92. {
  93. // huh?, no compilation at run time, only fetches
  94. Assert( 0 );
  95. return -1;
  96. }
  97. bool GetString( short stringId, char *buff, int buffSize );
  98. };
  99. #endif // C_SCENEENTITY_H