BVB Source Codes

CRYENGINE Show AIBubblesSystemImpl.h Source code

Return Download CRYENGINE: download AIBubblesSystemImpl.h Source code - Download CRYENGINE Source code - Type:.h
  1. /********************************************************************
  2. Crytek Source File.
  3. Copyright (C), Crytek Studios, 2001-2008.
  4. -------------------------------------------------------------------------
  5. File name:   AIBubblesSystemImpl.h
  6. Description: Central class to create and display speech bubbles over the
  7. AI agents to notify messages to the designers
  8.  
  9. -------------------------------------------------------------------------
  10. History:
  11. - 09:11:2011 : Created by Francesco Roccucci
  12. *********************************************************************/
  13.  
  14. #ifndef __AIBubblesSystem_h__
  15. #define __AIBubblesSystem_h__
  16.  
  17. #include "AIBubblesSystem.h"
  18.  
  19. #ifdef CRYAISYSTEM_DEBUG
  20.  
  21. class CAIBubblesSystem : public IAIBubblesSystem
  22. {
  23. public:
  24.         // IAIBubblesSystem
  25.         virtual void Init() override;
  26.         virtual void Reset() override;
  27.         virtual SBubbleRequestId QueueMessage(const char* messageName, const SAIBubbleRequest& request) override;
  28.         virtual bool CancelMessageBubble(const EntityId entityId, const SBubbleRequestId& bubbleRequestId) override;
  29.         virtual void Update() override;
  30.         virtual void SetNameFilter(const char* szMessageNameFilter) override;
  31.         // ~IAIBubblesSystem
  32.  
  33. private:
  34.  
  35.         // SAIBubbleRequestContainer needs only to be known internally in the
  36.         // BubblesNotifier
  37.         struct SAIBubbleRequestContainer
  38.         {
  39.                 SAIBubbleRequestContainer(const SBubbleRequestId& _requestId, const uint32 _messageNameId, const SAIBubbleRequest& _request)
  40.                         :messageNameId(_messageNameId)
  41.                         ,requestId(_requestId)
  42.                         ,expiringTime(.0f)
  43.                         ,request(_request)
  44.                         ,startExpiringTime(true)
  45.                         ,neverExpireFromTime(false)
  46.                 {
  47.                 }
  48.  
  49.                 const SAIBubbleRequest& GetRequest()
  50.                 {
  51.                         if(startExpiringTime)
  52.                         {
  53.                                 neverExpireFromTime = request.IsDurationInfinite();
  54.                                 if (!neverExpireFromTime)
  55.                                 {
  56.                                         UpdateDuration(request.GetDuration());
  57.                                 }
  58.                                 startExpiringTime = false;
  59.                         }
  60.                         return request;
  61.                 }
  62.                 uint32 GetMessageNameId() const { return messageNameId; }
  63.                 const SBubbleRequestId& GetRequestId() const { return requestId; }
  64.  
  65.                 bool IsOld (const CTimeValue currentTimestamp) const
  66.                 {
  67.                         return !neverExpireFromTime && (currentTimestamp > expiringTime);
  68.                 }
  69.  
  70.         private:
  71.                 void UpdateDuration(const float duration)
  72.                 {
  73.                         expiringTime = gEnv->pTimer->GetFrameStartTime() + (duration ? CTimeValue(duration) : CTimeValue(gAIEnv.CVars.BubblesSystemDecayTime));
  74.                 }
  75.  
  76.                 uint32           messageNameId;
  77.                 SBubbleRequestId requestId;
  78.                 CTimeValue       expiringTime;
  79.                 bool             startExpiringTime;
  80.                 bool             neverExpireFromTime;
  81.                 SAIBubbleRequest request;
  82.         };
  83.  
  84.         struct SRequestByMessageNameFinder
  85.         {
  86.                 SRequestByMessageNameFinder(uint32 _messageNameId) : messageNameId(_messageNameId) {}
  87.                 bool operator()(const SAIBubbleRequestContainer& container) const {return container.GetMessageNameId() == messageNameId;}
  88.                 uint32 messageNameId;
  89.         };
  90.  
  91.         struct SRequestByRequestIdFinder
  92.         {
  93.                 SRequestByRequestIdFinder(const SBubbleRequestId& _requestId) : requestId(_requestId) {}
  94.                 bool operator()(const SAIBubbleRequestContainer& container) const {return container.GetRequestId() == requestId;}
  95.                 SBubbleRequestId requestId;
  96.         };
  97.  
  98.         class CBubbleRender;
  99.  
  100.         bool DisplaySpeechBubble(SAIBubbleRequestContainer& requestContainer, CBubbleRender& bubbleRender) const;
  101.  
  102.         // Information logging/popping up
  103.         void LogMessage(const char* const message, const TBubbleRequestOptionFlags flags) const;
  104.         void PopupBlockingAlert(const char* const message, const TBubbleRequestOptionFlags flags) const;
  105.  
  106.         bool ShouldSuppressMessageVisibility(const SAIBubbleRequest::ERequestType requestType = SAIBubbleRequest::eRT_ErrorMessage) const;
  107.         bool ShouldFilterOutMessage(const uint32 messsageNameUniqueId) const;
  108.  
  109.         typedef std::list<SAIBubbleRequestContainer> RequestsList;
  110.         typedef std::unordered_map<EntityId, RequestsList, stl::hash_uint32> EntityRequestsMap;
  111.         EntityRequestsMap       m_entityRequestsMap;
  112.  
  113.         typedef std::unordered_set<uint32> MessageNameFilterSet;
  114.         MessageNameFilterSet m_messageNameFilterSet;
  115.  
  116.         SBubbleRequestId m_requestIdCounter;
  117. };
  118. #endif // CRYAISYSTEM_DEBUG
  119.  
  120. #endif // __AIBubblesSystem_h__
  121.  
downloadAIBubblesSystemImpl.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