BVB Source Codes

CRYENGINE Show GoalOpStick.h Source code

Return Download CRYENGINE: download GoalOpStick.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __GOALOP_STICK_H_
  4. #define __GOALOP_STICK_H_
  5.  
  6. #if _MSC_VER > 1000
  7.         #pragma once
  8. #endif
  9.  
  10. #include "GoalOp.h"
  11.  
  12. ////////////////////////////////////////////////////////////
  13. //
  14. //                      STICK - the agent keeps at a constant distance to his target
  15. //
  16. // regenerate path if target moved for more than m_fTrhDistance
  17. ////////////////////////////////////////////////////////
  18.  
  19. class COPStick : public CGoalOp
  20. {
  21. public:
  22.         COPStick(float fStickDistance, float fAccuracy, float fDuration, int fFlags, int nFlagsAux, ETraceEndMode eTraceEndMode = eTEM_FixedDistance);
  23.         COPStick(const XmlNodeRef& node);
  24.         virtual ~COPStick();
  25.  
  26.         virtual EGoalOpResult Execute(CPipeUser* pPipeUser);
  27.  
  28.         virtual void          ExecuteDry(CPipeUser* pPipeUser);
  29.         virtual void          Reset(CPipeUser* pPipeUser);
  30.         virtual void          Serialize(TSerialize ser);
  31.  
  32. private:
  33.         virtual void DebugDraw(CPipeUser* pPipeUser) const;
  34.         /// Keep a list of "safe" points of the stick target. This will be likely to have a valid
  35.         /// path between the point and the stick target - so when teleporting is necessary one
  36.         /// of these points (probably the one furthest back and invisible) can be chosen
  37.         void                 UpdateStickTargetSafePoints(CPipeUser* pPipeUser);
  38.         /// Attempts to teleport, and if it's necessary/practical does it, and returns true.
  39.         bool                 TryToTeleport(CPipeUser* pPipeUser);
  40.         /// sets teleporting info to the default don't-need-to-teleport state
  41.         void                 ClearTeleportData();
  42.         void                 RegeneratePath(CPipeUser* pPipeUser, const Vec3& destination);
  43.  
  44.         float                GetEndDistance(CPipeUser* pPipeUser) const;
  45.  
  46.         inline bool          GetStickAndSightTargets_CreatePathfindAndTraceGoalOps(CPipeUser* pPipeUser, EGoalOpResult* peGoalOpResult);
  47.         inline bool          Trace(CPipeUser* pPipeUser, CAIObject* pStickTarget, EGoalOpResult* peTraceResult);
  48.         inline bool          HandleHijack(CPipeUser* pPipeUser, const Vec3& vStickTargetPos, float fPathDistanceLeft, EGoalOpResult eTraceResult);
  49.         inline void          HandleTargetPrediction(CPipeUser* pPipeUser, const Vec3& vStickTargetPos);
  50.         inline bool          IsTargetDirty(CPipeUser* pPipeUser, const Vec3& vPipeUserPos, bool b2D, const Vec3& vStickTargetPos, IAISystem::ENavigationType ePipeUserLastNavNodeType);
  51.         inline EGoalOpResult HandlePathDecision(CPipeUser* pPipeUser, int nPathDecision, bool b2D);
  52.  
  53.         /// Stores when/where the stick target was
  54.         struct SSafePoint
  55.         {
  56.                 SSafePoint() : pos(ZERO), nodeIndex(0), safe(false), passRadius(0.0f) {}
  57.  
  58.                 SSafePoint(const Vec3& pos_, CPipeUser& pipeUser, unsigned lastNavNodeIndex);
  59.  
  60.                 void Reset(unsigned lastNavNodeIndex);
  61.                 void Serialize(TSerialize ser);
  62.  
  63.                 Vec3       pos;
  64.                 unsigned   nodeIndex;
  65.                 bool       safe; // used to store _unsafe_ locations too
  66.                 CTimeValue time;
  67.  
  68.         private:
  69.                 string                 requesterName;
  70.                 // only used for navgraph and serialization
  71.                 IAISystem::tNavCapMask navCapMask;
  72.                 float                  passRadius;
  73.         };
  74.         /// Point closest to the stick target is at the front
  75.         typedef MiniQueue<SSafePoint, 32> TStickTargetSafePoints;
  76.         TStickTargetSafePoints m_stickTargetSafePoints;
  77.         /// distance between safe points
  78.         float                  m_safePointInterval;
  79.         /// teleport current/destination locations
  80.         Vec3                   m_teleportCurrent, m_teleportEnd;
  81.         /// time at which the old teleport position was checked
  82.         CTimeValue             m_lastTeleportTime;
  83.         /// time at which the operand was last visible
  84.         CTimeValue             m_lastVisibleTime;
  85.  
  86.         // teleport params
  87.         /// Only teleport if the resulting apparent speed would not exceed this.
  88.         /// If 0 it disables teleporting
  89.         float               m_maxTeleportSpeed;
  90.         // Only teleport if the operand's path (if it exists) is longer than this
  91.         float               m_pathLengthForTeleport;
  92.         // Don't teleport closer than this to player
  93.         float               m_playerDistForTeleport;
  94.  
  95.         Vec3                m_vLastUsedTargetPos;
  96.         float               m_fTrhDistance;
  97.         CWeakRef<CAIObject> m_refStickTarget;
  98.         CWeakRef<CAIObject> m_refSightTarget;
  99.  
  100.         ETraceEndMode       m_eTraceEndMode;
  101.         float               m_fApproachTime;
  102.         float               m_fHijackDistance;
  103.  
  104.         /// Aim to stay/stop this far from the target
  105.         float m_fStickDistance;
  106.         /// we aim to stop within m_fAccuracy of the target minus m_fStickDistance
  107.         float m_fEndAccuracy;
  108.         /// Stop after this time (0 means disabled)
  109.         float m_fDuration;
  110.         float m_fCorrectBodyDirTime;
  111.         float m_fTimeSpentAligning;
  112.         bool  m_bContinuous;            // stick OR just approach moving target
  113.         bool  m_bTryShortcutNavigation; //
  114.         bool  m_bUseLastOpResult;
  115.         bool  m_bLookAtLastOp;  // where to look at
  116.         bool  m_bInitialized;
  117.         bool  m_bBodyIsAligned;
  118.         bool  m_bAlignBodyBeforeMove;
  119.         bool  m_bForceReturnPartialPath;
  120.         bool  m_bStopOnAnimationStart;
  121.         float m_targetPredictionTime;
  122.         bool  m_bConstantSpeed;
  123.  
  124.         // used for estimating the target position movement
  125.         CTimeValue m_lastTargetPosTime;
  126.         Vec3       m_lastTargetPos;
  127.         Vec3       m_smoothedTargetVel;
  128.  
  129.         int        m_looseAttentionId;
  130.  
  131.         // set to true when the path is first found
  132.         bool         m_bPathFound;
  133.         COPTrace*    m_pTraceDirective;
  134.         COPPathFind* m_pPathfindDirective;
  135.  
  136.         string       m_sLocateName;
  137. };
  138.  
  139. #endif  // #ifndef __GOALOP_STICK_H_
  140.  
downloadGoalOpStick.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