BVB Source Codes

CRYENGINE Show AIPlayer.h Source code

Return Download CRYENGINE: download AIPlayer.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:   AIPlayer.h
  6.    $Id$
  7.    Description:
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - ?
  12.    - 2 Mar 2009                  : Evgeny Adamenkov: Removed IRenderer
  13.  
  14.  *********************************************************************/
  15. #ifndef _AI_PLAYER_
  16. #define _AI_PLAYER_
  17.  
  18. #if _MSC_VER > 1000
  19.         #pragma once
  20. #endif
  21.  
  22. #include "AIActor.h"
  23. #include <CrySystem/TimeValue.h>
  24. #include "AIDbgRecorder.h"
  25.  
  26. class CMissLocationSensor;
  27.  
  28. // ChrisR: Disable the MissLocationSensor to save multiple
  29. // GetEntitiesAround calls in physics that are quite heavy in very concentrated
  30. // combat scenes. Currently this can amount to large percentages of the main
  31. // thread time.
  32. #if !CRY_PLATFORM_MOBILE
  33.         #define ENABLE_MISSLOCATION_SENSOR 1
  34. #endif
  35. #ifndef ENABLE_MISSLOCATION_SENSOR
  36.         #define ENABLE_MISSLOCATION_SENSOR 1
  37. #endif
  38.  
  39. class CAIPlayer : public CAIActor
  40. {
  41.         typedef CAIActor MyBase;
  42.  
  43. public:
  44.         CAIPlayer();
  45.         ~CAIPlayer();
  46.  
  47.         void                       ParseParameters(const AIObjectParams& params, bool bParseMovementParams = true) override;
  48.         void                       Reset(EObjectResetType type) override;
  49.  
  50.         void                       UpdateAttentionTarget(CWeakRef<CAIObject> refTarget);
  51.         virtual EFieldOfViewResult IsPointInFOV(const Vec3& pos, float distanceScale = 1.0f) const override;
  52.         void                       Update(EObjectUpdate type) override;
  53.         virtual void               UpdateProxy(EObjectUpdate type) override {}
  54.         virtual void               Serialize(TSerialize ser) override;
  55.         virtual void               OnObjectRemoved(CAIObject* pObject) override;
  56.         virtual bool               IsLowHealthPauseActive() const override;
  57.         virtual IEntity*           GetGrabbedEntity() const override;// consider only player grabbing things, don't care about NPC
  58.         virtual bool               IsGrabbedEntityInView(const Vec3& pos) const override;
  59.  
  60.         virtual void               GetObservablePositions(ObservableParams& observableParams) const override;
  61.         virtual uint32             GetObservableTypeMask() const override;
  62.  
  63.         // Inherited
  64.         virtual DamagePartVector* GetDamageParts() override;
  65.  
  66.         virtual void              Event(unsigned short eType, SAIEVENT* pEvent) override;
  67.  
  68.         int                       GetDeathCount() { return m_deathCount; }
  69.         void                      IncDeathCount() { m_deathCount++; }
  70.  
  71.         virtual void              RecordEvent(IAIRecordable::e_AIDbgEvent event, const IAIRecordable::RecorderEventData* pEventData = NULL) override;
  72.         virtual void              RecordSnapshot() override;
  73.  
  74.         virtual float             AdjustTargetVisibleRange(const CAIActor& observer, float fVisibleRange) const override;
  75.         virtual bool              IsAffectedByLight() const override;
  76.  
  77.         bool                      IsThrownByPlayer(EntityId ent) const;
  78.         bool                      IsPlayerStuntAffectingTheDeathOf(CAIActor* pDeadActor) const;
  79.         EntityId                  GetNearestThrownEntity(const Vec3& pos);
  80.         bool                      IsDoingStuntActionRelatedTo(const Vec3& pos, float nearDistance);
  81.  
  82.         virtual void              GetPhysicalSkipEntities(PhysSkipList& skipList) const override;
  83.  
  84.         bool                      GetMissLocation(const Vec3& shootPos, const Vec3& shootDir, float maxAngle, Vec3& pos);
  85.         void                      NotifyMissLocationConsumed();
  86.         void                      NotifyPlayerActionToTheLookingAgents(const char* eventName);
  87.  
  88.         void                      DebugDraw();
  89.  
  90. private:
  91.         CAIPlayer(const CAIPlayer&); // disallow copies
  92.         CAIPlayer& operator=(const CAIPlayer&);
  93.  
  94.         EntityId         m_lastGrabbedEntityID;
  95.  
  96.         CTimeValue       m_fLastUpdateTargetTime;
  97.         float            m_FOV;
  98.         DamagePartVector m_damageParts;
  99.         bool             m_damagePartsUpdated;
  100.         int              m_deathCount;
  101.  
  102.         struct SThrownItem
  103.         {
  104.                 SThrownItem(EntityId id) : id(id), time(0.0f), pos(0, 0, 0), vel(0, 0, 0), r(0.1f) {}
  105.                 inline bool operator<(const SThrownItem& rhs) const { return time < rhs.time; }
  106.                 float    time;
  107.                 Vec3     pos, vel;
  108.                 float    r;
  109.                 EntityId id;
  110.         };
  111.         std::vector<SThrownItem> m_lastThrownItems;
  112.  
  113.         struct SStuntTargetAIActor
  114.         {
  115.                 SStuntTargetAIActor(CAIActor* pAIActor, const Vec3& pos) : pAIActor(pAIActor), t(0), exposed(0), signalled(false), threatPos(pos) {}
  116.                 CAIActor* pAIActor;
  117.                 Vec3      threatPos;
  118.                 float     t;
  119.                 float     exposed;
  120.                 bool      signalled;
  121.         };
  122.         std::vector<SStuntTargetAIActor> m_stuntTargets;
  123.  
  124.         void AddThrownEntity(EntityId id);
  125.  
  126.         void UpdatePlayerStuntActions();
  127.         void HandleCloaking(bool cloak);
  128.         void HandleArmoredHit();
  129.         void HandleStampMelee();
  130.  
  131.         Vec3  m_stuntDir;
  132.  
  133.         float m_playerStuntSprinting;
  134.         float m_playerStuntJumping;
  135.         float m_playerStuntCloaking;
  136.         float m_playerStuntUncloaking;
  137.  
  138.         float m_mercyTimer;
  139.  
  140.         void CollectExposedCover();
  141.         void ReleaseExposedCoverObjects();
  142.         void AddExposedCoverObject(IPhysicalEntity* pPhysEnt);
  143.         void CollectExposedCoverRayComplete(const QueuedRayID& rayID, const RayCastResult& result);
  144.  
  145.         float m_coverExposedTime;
  146.         float m_coolMissCooldown;
  147.  
  148.         struct SExposedCoverObject
  149.         {
  150.                 SExposedCoverObject(IPhysicalEntity* pPhysEnt, float t) : pPhysEnt(pPhysEnt), t(t) {}
  151.                 IPhysicalEntity* pPhysEnt;
  152.                 float            t;
  153.         };
  154.  
  155.         struct ExposedCoverState
  156.         {
  157.                 ExposedCoverState() : asyncState(AsyncReady), rayID(0) {}
  158.                 AsyncState  asyncState;
  159.                 QueuedRayID rayID;
  160.         };
  161.  
  162.         std::vector<SExposedCoverObject> m_exposedCoverObjects;
  163.         ExposedCoverState                m_exposedCoverState;
  164.  
  165. #if ENABLE_MISSLOCATION_SENSOR
  166.         std::unique_ptr<CMissLocationSensor> m_pMissLocationSensor;
  167. #endif
  168. };
  169.  
  170. inline const CAIPlayer* CastToCAIPlayerSafe(const IAIObject* pAI) { return pAI ? pAI->CastToCAIPlayer() : 0; }
  171. inline CAIPlayer*       CastToCAIPlayerSafe(IAIObject* pAI)       { return pAI ? pAI->CastToCAIPlayer() : 0; }
  172.  
  173. #endif
  174.  
downloadAIPlayer.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