BVB Source Codes

CRYENGINE Show CommunicationHandler.h Source code

Return Download CRYENGINE: download CommunicationHandler.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __CommunicationHandler_h__
  4. #define __CommunicationHandler_h__
  5.  
  6. #pragma once
  7.  
  8. #include <CryAISystem/IAgent.h>
  9.  
  10. class CommunicationHandler
  11.         : public IAICommunicationHandler
  12.           , public IAnimationGraphStateListener
  13. {
  14.         friend class CommunicationVoiceTestManager;
  15. public:
  16.         CommunicationHandler(CAIProxy& proxy, IEntity* entity);
  17.         virtual ~CommunicationHandler();
  18.  
  19.         // IAICommunicationHandler
  20.         virtual SCommunicationSound PlaySound(CommPlayID playID, const char* name, IEventListener* listener = 0) override;
  21.         virtual void                StopSound(const SCommunicationSound& soundToStop) override;
  22.  
  23.         virtual SCommunicationSound PlayVoice(CommPlayID playID, const char* variationName, IEventListener* listener = 0) override;
  24.         virtual void                StopVoice(const SCommunicationSound& voiceToStop) override;
  25.  
  26.         virtual void                SendDialogueRequest(CommPlayID playID, const char* name, IEventListener* listener = 0) override {}
  27.  
  28.         virtual void                PlayAnimation(CommPlayID playID, const char* name, EAnimationMethod method, IEventListener* listener = 0) override;
  29.         virtual void                StopAnimation(CommPlayID playID, const char* name, EAnimationMethod method) override;
  30.  
  31.         virtual bool                IsInAGState(const char* name) override;
  32.         virtual void                ResetAnimationState() override;
  33.  
  34.         virtual bool                IsPlayingAnimation() const override;
  35.         virtual bool                IsPlayingSound() const override;
  36.  
  37.         virtual void                OnSoundTriggerFinishedToPlay(const AudioControlId nTriggerID) override;
  38.         //~IAICommunicationHandler
  39.  
  40.         // IAnimationgGraphStateListener
  41.         virtual void SetOutput(const char* output, const char* value) override {};
  42.         virtual void QueryComplete(TAnimationGraphQueryID queryID, bool succeeded) override;
  43.         virtual void DestroyedState(IAnimationGraphState*) override;
  44.         //~IAnimationgGraphStateListener
  45.  
  46.         void        Reset();
  47.         void        OnReused(IEntity* entity);
  48.  
  49.         static void TriggerFinishedCallback(SAudioRequestInfo const* const pAudioRequestInfo);
  50.  
  51. private:
  52.         enum ESoundType
  53.         {
  54.                 Sound = 0,
  55.                 Voice,
  56.         };
  57.  
  58.         SCommunicationSound   PlaySound(CommPlayID playID, const char* name, ESoundType type, IEventListener* listener = 0);
  59.         IAnimationGraphState* GetAGState();
  60.  
  61.         CAIProxy&             m_proxy;
  62.         EntityId              m_entityId;
  63.         IAnimationGraphState* m_agState;
  64.  
  65.         struct PlayingSound
  66.         {
  67.                 PlayingSound()
  68.                         : listener(0)
  69.                         , type(Sound)
  70.                         , playID(0)
  71.                         , correspondingStopControlId(INVALID_AUDIO_CONTROL_ID)
  72.                 {
  73.                 }
  74.  
  75.                 ESoundType type;
  76.                 IAICommunicationHandler::IEventListener* listener;
  77.                 //Index used to reference this event in listener. Set when sound event started
  78.                 CommPlayID                               playID;
  79.                 AudioControlId                           correspondingStopControlId;
  80.         };
  81.  
  82.         struct PlayingAnimation
  83.         {
  84.                 PlayingAnimation()
  85.                         : listener(0)
  86.                         , playing(false)
  87.                         , playID(0)
  88.                 {
  89.                 }
  90.  
  91.                 IAICommunicationHandler::IEventListener* listener;
  92.                 string           name;
  93.  
  94.                 EAnimationMethod method;
  95.                 bool             playing;
  96.                 //Index used to reference this event in listener. Set when animation event started
  97.                 CommPlayID       playID;
  98.         };
  99.  
  100.         typedef std::map<TAnimationGraphQueryID, PlayingAnimation> PlayingAnimations;
  101.         PlayingAnimations      m_playingAnimations;
  102.         TAnimationGraphQueryID m_currentQueryID;  // because animation graph can send query result during SetInput,
  103.         bool                   m_currentPlaying;  // before we had chance to insert in the map
  104.  
  105.         typedef std::map<AudioControlId, PlayingSound> PlayingSounds;
  106.         PlayingSounds         m_playingSounds;
  107.  
  108.         AnimationGraphInputID m_signalInputID;
  109.         AnimationGraphInputID m_actionInputID;
  110. };
  111.  
  112. #endif
  113.  
downloadCommunicationHandler.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top