BVB Source Codes

CRYENGINE Show PersonalInterestManager.h Source code

Return Download CRYENGINE: download PersonalInterestManager.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /********************************************************************
  4.    ---------------------------------------------------------------------
  5.    File name:   PersonalInterestManager.h
  6.    $Id$
  7.    $DateTime$
  8.    Description: Interest Manager (tracker) for interested individuals
  9.  
  10.    Note:        PIMs are owned by the CentralInterestManager - delete there
  11.    ---------------------------------------------------------------------
  12.    History:
  13.    - 07:03:2007 : Created by Matthew Jack
  14.    - 15:02:2010 : Heavily refactored by Ricardo Pillosu
  15.  
  16.  *********************************************************************/
  17.  
  18. #ifndef __PersonalInterestManager_H__
  19. #define __PersonalInterestManager_H__
  20.  
  21. #if _MSC_VER > 1000
  22.         #pragma once
  23. #endif
  24.  
  25. #include <CryAISystem/IInterestSystem.h>
  26. #include <CryAISystem/IAIAction.h>
  27.  
  28. class CCentralInterestManager;
  29. struct SEntityInterest;
  30.  
  31. // Settings for ai actors
  32. struct SActorInterestSettings
  33. {
  34.         SActorInterestSettings(bool bEnablePIM, float fInterestFilter, float fAngleInDegrees) :
  35.                 m_bEnablePIM(bEnablePIM), m_fInterestFilter(fInterestFilter)
  36.         {
  37.                 SetAngleInDegrees(fAngleInDegrees);
  38.         }
  39.  
  40.         SActorInterestSettings()
  41.         {
  42.                 Reset();
  43.         }
  44.  
  45.         // Set to defaults
  46.         void Reset()
  47.         {
  48.                 m_bEnablePIM = true;
  49.                 m_fInterestFilter = 0.f;
  50.                 SetAngleInDegrees(270.f);
  51.         }
  52.  
  53.         void SetAngleInDegrees(float fAngleInDegrees)
  54.         {
  55.                 clamp_tpl(fAngleInDegrees, 0.f, 360.f);
  56.                 m_fAngleCos = cos(DEG2RAD(.5f * fAngleInDegrees));
  57.         }
  58.  
  59.         void Serialize(TSerialize ser)
  60.         {
  61.                 ser.Value("fInterestFilter", m_fInterestFilter);
  62.                 ser.Value("fAngleCos", m_fAngleCos);
  63.                 ser.Value("bEnablePIM", m_bEnablePIM);
  64.         }
  65.  
  66.         void Set(bool bEnablePIM, float fInterestFilter, float fAngleCos)
  67.         {
  68.                 m_bEnablePIM = bEnablePIM;
  69.  
  70.                 if (fInterestFilter >= 0.f)
  71.                 {
  72.                         m_fInterestFilter = fInterestFilter;
  73.                 }
  74.  
  75.                 if (fAngleCos >= -1.f)
  76.                 {
  77.                         m_fAngleCos = fAngleCos;
  78.                 }
  79.         }
  80.  
  81.         float m_fInterestFilter;  // What minimum interest must something have for this actor?
  82.         float m_fAngleCos;        // If the angle between our movement direction and the interest Object is beyond this range, it will be ignored
  83.         bool  m_bEnablePIM;       // Can this actor use the interest system at all?
  84. };
  85.  
  86. class CPersonalInterestManager : public IAIAction::IAIActionListener
  87. {
  88. public:
  89.         CPersonalInterestManager(CAIActor* pAIActor = NULL);
  90.  
  91.         // Clear tracking cache, clear assignment
  92.         void Reset();
  93.  
  94.         bool ForgetInterestingEntity();
  95.  
  96.         // Is assignment cleared?
  97.         bool IsReset() const { return m_refAIActor.IsReset(); }
  98.  
  99.         // Required to implement external interface - might use adapter
  100.         void Assign(CAIActor* pAIActor);
  101.  
  102.         // (Re)assign to an actor (helps in object re-use)
  103.         // NILREF is acceptable, to leave unassigned
  104.         // You must also ensure the PIM pointer in the CAIActor is set to this object
  105.         void Assign(CWeakRef<CAIActor> refAIActor);
  106.  
  107.         // Get the currently assigned AIActor
  108.         CAIActor* GetAssigned() const { return m_refAIActor.GetAIObject(); }
  109.  
  110.         // Update
  111.         bool Update(bool bCloseToCamera);
  112.  
  113.         void Serialize(TSerialize ser);
  114.  
  115.         // Update interest settings
  116.         // Checks with the CIM for any new settings associated with this actor
  117.         void SetSettings(bool bEnablePIM, float fInterestFilter = -1.f, float fAngleCos = -1.f);
  118.  
  119.         // Do we have any interest target right now?
  120.         // Allows us to move on as quickly as possible for the common (uninterested) case
  121.         bool IsInterested() const { return m_IdInterestingEntity > 0; }
  122.  
  123.         // Which entity are we currently interested in?
  124.         // Returns NULL if not currently interested in anything, or that target is not an entity
  125.         IEntity* GetInterestEntity() const;
  126.  
  127.         // Returns the dummy interest object if currently interested or NILREF
  128.         // Works regardless of the type of the interesting object
  129.         CWeakRef<CAIObject> GetInterestDummyPoint();
  130.  
  131.         Vec3                GetInterestingPos() const;
  132.  
  133.         ELookStyle          GetLookingStyle() const;
  134.  
  135.         /// Implement Action Listener Interface
  136.         virtual void OnActionEvent(IAIAction::EActionEvent event);
  137.  
  138. protected:
  139.  
  140.         const SEntityInterest* PickMostInteresting() const;
  141.  
  142.         bool                   CheckVisibility(const SEntityInterest& interestingRef) const;
  143.  
  144.         CWeakRef<CAIActor>       m_refAIActor;                // The actor we are responsible for
  145.         EntityId                 m_IdInterestingEntity;
  146.         EntityId                 m_IdLastInterestingEntity;
  147.         CTimeValue               m_timeLastInterestingEntity;
  148.         Vec3                     m_vOffsetInterestingEntity;
  149.         CCountedRef<CAIObject>   m_refInterestDummy;          // Dummy that moves around with any interest target
  150.         CCentralInterestManager* m_pCIM;                      // Cached pointer to CIM
  151.         SActorInterestSettings   m_Settings;                  // Interest settings for this actor
  152.         bool                     m_bIsPlayingAction;
  153. };
  154.  
  155. #endif // __PersonalInterestManager_H__
  156.  
downloadPersonalInterestManager.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