BVB Source Codes

CRYENGINE Show PipeUser.h Source code

Return Download CRYENGINE: download PipeUser.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:   PipeUser.h
  6.    $Id$
  7.    Description:
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    -
  12.  
  13.  *********************************************************************/
  14. #ifndef _PIPE_USER_
  15. #define _PIPE_USER_
  16.  
  17. #if _MSC_VER > 1000
  18.         #pragma once
  19. #endif
  20.  
  21. // created by Petar
  22.  
  23. #include "GoalPipe.h"
  24. #include "AIActor.h"
  25. #include <CryAISystem/IAISystem.h>
  26. #include "AIHideObject.h"
  27. #include "ObjectContainer.h"
  28. #include "Cover/CoverUser.h"
  29. #include "MNMPathfinder.h"
  30. #include <CryAISystem/IMovementSystem.h>
  31. #include "PipeUserMovementActorAdapter.h"
  32.  
  33. struct PathFollowerParams;
  34.  
  35. struct CoverUsageInfo
  36. {
  37.         CoverUsageInfo()
  38.                 : lowLeft(false)
  39.                 , lowCenter(false)
  40.                 , lowRight(false)
  41.                 , highLeft(false)
  42.                 , highCenter(false)
  43.                 , highRight(false)
  44.                 , lowCompromised(false)
  45.                 , highCompromised(false)
  46.         {
  47.         };
  48.  
  49.         CoverUsageInfo(bool state)
  50.                 : lowLeft(state)
  51.                 , lowCenter(state)
  52.                 , lowRight(state)
  53.                 , highLeft(state)
  54.                 , highCenter(state)
  55.                 , highRight(state)
  56.                 , lowCompromised(state)
  57.                 , highCompromised(state)
  58.         {
  59.         };
  60.  
  61.         bool lowLeft         : 1;
  62.         bool lowCenter       : 1;
  63.         bool lowRight        : 1;
  64.         bool lowCompromised  : 1;
  65.         bool highLeft        : 1;
  66.         bool highCenter      : 1;
  67.         bool highRight       : 1;
  68.         bool highCompromised : 1;
  69. };
  70.  
  71. enum EAimState
  72. {
  73.         AI_AIM_NONE,        // No aiming requested
  74.         AI_AIM_WAITING,     // Aiming requested, but not yet ready.
  75.         AI_AIM_OBSTRUCTED,  // Aiming obstructed.
  76.         AI_AIM_READY,
  77.         AI_AIM_FORCED,
  78. };
  79.  
  80. class CGoalPipe;
  81. class MovementStyle;
  82.  
  83. class CPipeUser
  84.         : public CAIActor
  85.           , public CPipeUserAdapter
  86. {
  87.         friend class CAISystem;
  88.  
  89. public:
  90.         CPipeUser();
  91.         virtual ~CPipeUser();
  92.  
  93.         virtual const IPipeUser* CastToIPipeUser() const override { return this; }
  94.         virtual IPipeUser*       CastToIPipeUser() override       { return this; }
  95.  
  96.         virtual void             Event(unsigned short int eType, SAIEVENT* pAIEvent) override;
  97.         virtual void             ParseParameters(const AIObjectParams& params, bool bParseMovementParams = true) override;
  98.  
  99.         virtual void             RecordEvent(IAIRecordable::e_AIDbgEvent event, const IAIRecordable::RecorderEventData* pEventData = NULL) override;
  100.         virtual void             RecordSnapshot() override;
  101.  
  102.         virtual void             Reset(EObjectResetType type) override;
  103.         virtual void             SetName(const char* pName) override;
  104.         void                     GetStateFromActiveGoals(SOBJECTSTATE& state);
  105.         CGoalPipe*               GetGoalPipe(const char* name);
  106.         void                     RemoveActiveGoal(int nOrder);
  107.  
  108.         virtual void             SetAttentionTarget(CWeakRef<CAIObject> refTarget) override;
  109.  
  110.         virtual void             ClearPotentialTargets() {};
  111.         void                     SetLastOpResult(CWeakRef<CAIObject> refObject);
  112.  
  113.         /// fUrgency would normally be a value from AISPEED_WALK and similar. This returns the "normal" movement
  114.         /// speed associated with each for the current stance - as a guideline for the AI system to use in its requests.
  115.         /// For vehicles the urgency is irrelevant.
  116.         /// if slowForStrafe is set then the returned speed depends on last the body/move direction
  117.         //  virtual float GetNormalMovementSpeed(float fUrgency, bool slowForStrafe) const {return 0.0f;}
  118.         /// Returns the speed (as GetNormalMovementSpeeds) used to do accurate maneuvering/tight turning.
  119.         //  virtual float GetManeuverMovementSpeed() {return 0.0f;}
  120.  
  121.         /// Steers the puppet outdoors and makes it avoid the immediate obstacles (or slow down). This finds all the potential
  122.         /// AI objects that must be navigated around, and calls NavigateAroundAIObject on each.
  123.         /// targetPos is a reasonably stable position ahead on the path that should be steered towards.
  124.         /// fullUpdate indicates if this is called from a full or "dry" update
  125.         /// Returns true if some steering needed to be done
  126.         virtual bool NavigateAroundObjects(const Vec3& targetPos, bool fullUpdate) { return false; }
  127.  
  128.         virtual void CancelRequestedPath(bool actorRemoved) override;
  129.  
  130.         virtual void HandlePathDecision(MNMPathRequestResult& result) override;
  131.         void         AdjustPath();
  132.  
  133.         //////////////////////////////////////////////////////////////////////////
  134.         /// MNM Path handling
  135.         void OnMNMPathResult(const MNM::QueuedPathID& requestId, MNMPathRequestResult& result);
  136.  
  137.         /// Adjust the path to plan "local" steering. Returns true if the resulting path can be used, false otherwise
  138.         bool AdjustPathAroundObstacles();
  139.  
  140.         /// returns the path follower if it exists (it may be created if appropriate). May return 0
  141.         class IPathFollower* GetPathFollower();
  142.  
  143.         /// returns the current path follower. Will never create one. May return 0.
  144.         virtual class IPathFollower* GetPathFollower() const override;
  145.  
  146.         virtual void                 GetPathFollowerParams(struct PathFollowerParams& outParams) const;
  147.         EntityId                     GetPendingSmartObjectID() const;
  148.  
  149.         virtual void                 RequestPathTo(const Vec3& pos, const Vec3& dir, bool allowDangerousDestination, int forceTargetBuildingId = -1, float endTol = std::numeric_limits<float>::max(),
  150.                                                    float endDistance = 0.0f, CAIObject* pTargetObject = 0, const bool cutPathAtSmartObject = true, const MNMDangersFlags dangersFlags = eMNMDangers_None, const bool considerActorsAsPathObstacles = false);
  151.         void                         RequestPathTo(MNMPathRequest& request);
  152.         virtual void                 RequestPathInDirection(const Vec3& pos, float distance, CWeakRef<CAIObject> refTargetObject, float endDistance = 0.0f);
  153.         /// inherited
  154.         virtual void                 SetPathToFollow(const char* pathName) override;
  155.         virtual void                 SetPathAttributeToFollow(bool bSpline) override;
  156.  
  157.         const char*                  GetPathToFollow() const { return m_pathToFollowName.c_str(); }
  158.         /// returns the entry point on the designer created path.
  159.         virtual bool                 GetPathEntryPoint(Vec3& entryPos, bool reverse, bool startNearest) const;
  160.         /// use a predefined path - returns true if successful
  161.         virtual bool                 UsePathToFollow(bool reverse, bool startNearest, bool loop);
  162.         virtual void                 SetPointListToFollow(const std::vector<Vec3>& pointList, IAISystem::ENavigationType navType, bool bSpline);
  163.         virtual bool                 UsePointListToFollow(void);
  164.         virtual void                 ClearDevalued() override              {};
  165.         virtual void                 Forget(CAIObject* pDummyObject)       {}
  166.         virtual void                 Navigate3d(CAIObject* pTarget)        {}
  167.         virtual void                 MakeIgnorant(bool bIgnorant) override {}
  168.         CGoalPipe*                   GetCurrentGoalPipe() override         { return m_pCurrentGoalPipe; }
  169.         const CGoalPipe*             GetCurrentGoalPipe() const            { return m_pCurrentGoalPipe; }
  170.         const CGoalPipe*             GetActiveGoalPipe() const             { return m_pCurrentGoalPipe ? m_pCurrentGoalPipe->GetLastSubpipe() : 0; }
  171.         const char*                  GetActiveGoalPipeName() const         { const CGoalPipe* pipe = GetActiveGoalPipe(); return pipe ? pipe->GetName() : "No Active GoalPipe"; }
  172.         void                         ResetCurrentPipe(bool resetAlways) override;
  173.         int                          GetGoalPipeId() const override;
  174.         void                         ResetLookAt() override;
  175.         bool                         SetLookAtPointPos(const Vec3& point, bool priority = false) override;
  176.         bool                         SetLookAtDir(const Vec3& dir, bool priority = false) override;
  177.         void                         CreateLookAtTarget();
  178.         void                         ResetBodyTargetDir() override;
  179.         void                         SetBodyTargetDir(const Vec3& dir) override;
  180.         const Vec3&        GetBodyTargetDir() const override { return m_vBodyTargetDir; }
  181.         void               ResetDesiredBodyDirectionAtTarget();
  182.         void               SetDesiredBodyDirectionAtTarget(const Vec3& dir);
  183.         const Vec3&        GetDesiredBodyDirectionAtTarget() const { return m_vDesiredBodyDirectionAtTarget; }
  184.         void               ResetMovementContext();
  185.         void               ClearMovementContext(unsigned int movementContext);
  186.         void               SetMovementContext(unsigned int movementContext);
  187.         const unsigned int GetMovementContext() const                                                   { return m_movementContext; }
  188.         // Sets the allowed start and end of the path strafing distance.
  189.         void               SetAllowedStrafeDistances(float start, float end, bool whileMoving) override {}
  190.  
  191.         void               SetExtraPriority(float priority) override                                    { m_AttTargetPersistenceTimeout = priority; };
  192.         float              GetExtraPriority() override                                                  { return m_AttTargetPersistenceTimeout; };
  193.  
  194.         // Set/reset the looseAttention target to some existing object
  195.         //id is used when clearing the loose attention target
  196.         // m_looseAttentionId is the id of the "owner" of the last SetLooseAttentionTarget(target) operation
  197.         // if the given id is not the same, it means that a more recent SetLooseAttentionTarget() has been set
  198.         // by someone else so the requester can't clear the loose att target    int SetLooseAttentionTarget(CAIObject* pObject=NULL,int id=0);
  199.         int          SetLooseAttentionTarget(CWeakRef<CAIObject> refObject, int id = -1);
  200.  
  201.         void         SetLookStyle(ELookStyle eLookStyle);
  202.         virtual void AllowLowerBodyToTurn(bool bAllowLowerBodyToTurn) override;
  203.         virtual bool IsAllowingBodyTurn() override;
  204.  
  205.         ELookStyle   GetLookStyle();
  206.  
  207.         // Set/reset the looseAttention target to the lookAtPoint and its position
  208.         inline int SetLooseAttentionTarget(const Vec3& pos)
  209.         {
  210.                 SetLookAtPointPos(pos);
  211.                 return ++m_looseAttentionId;
  212.         }
  213.  
  214.         Vec3       GetLooseAttentionPos();
  215.  
  216.         inline int GetLooseAttentionId()
  217.         {
  218.                 return m_looseAttentionId;
  219.         }
  220.  
  221.         typedef std::weak_ptr<Vec3> LookTargetWeakPtr;
  222.         virtual LookTargetPtr CreateLookTarget() override;
  223.  
  224.         void                  RegisterAttack(const char* name);
  225.         void                  RegisterRetreat(const char* name);
  226.         void                  RegisterWander(const char* name);
  227.         void                  RegisterIdle(const char* name);
  228.         bool                  SelectPipe(int id, const char* name, CWeakRef<CAIObject> refArgument, int goalPipeId = 0, bool resetAlways = false, const GoalParams* node = 0) override; //const XmlNodeRef *node = 0);
  229.         IGoalPipe*            InsertSubPipe(int id, const char* name, CWeakRef<CAIObject> refArgument, int goalPipeId = 0, const GoalParams* node = 0) override;                        //const XmlNodeRef *node = 0);
  230.         bool                  CancelSubPipe(int goalPipeId) override;
  231.         bool                  RemoveSubPipe(int goalPipeId, bool keepInserted = false) override;
  232.         bool                  IsUsingPipe(const char* name) const override;
  233.         bool                  IsUsingPipe(int goalPipeId) const override;
  234.         bool                  AbortActionPipe(int goalPipeId);
  235. #ifdef USE_DEPRECATED_AI_CHARACTER_SYSTEM
  236.         bool                  SetCharacter(const char* character, const char* behaviour = NULL);
  237. #endif
  238.         bool                  IsUsing3DNavigation(); // returns true if it's currently using a 3D navigation
  239.  
  240.         virtual void          Pause(bool pause) override;
  241.         virtual bool          IsPaused() const override;
  242.  
  243.         // Returns true if the puppet wants to fire.
  244.         bool              AllowedToFire() const { return (m_fireMode != FIREMODE_OFF) && (m_fireMode != FIREMODE_AIM) && (m_fireMode != FIREMODE_AIM_SWEEP); }
  245.         // Sets the fire mode and shoot target selection (attention target or lastopresult).
  246.         virtual void      SetFireMode(EFireMode mode) override;
  247.         virtual void      SetFireTarget(CWeakRef<CAIObject> refTargetObject);
  248.         virtual EFireMode GetFireMode() const override { return m_fireMode; }
  249.  
  250.         // Inherited from IPipeUser
  251.         virtual CAIObject*  GetRefPoint() override { CreateRefPoint(); return m_refRefPoint.GetAIObject(); }
  252.  
  253.         virtual void        SetRefPointPos(const Vec3& pos) override;
  254.         virtual void        SetRefPointPos(const Vec3& pos, const Vec3& dir) override;
  255.         virtual void        SetRefShapeName(const char* shapeName) override;
  256.         virtual const char* GetRefShapeName() const override;
  257.         virtual Vec3        GetProbableTargetPosition() override;
  258.         SShape*             GetRefShape();
  259.  
  260.         void                SetCoverRegister(const CoverID& coverID);
  261.         const CoverID& GetCoverRegister() const;
  262.  
  263.         void           CreateRefPoint();
  264.  
  265.         // Sets an actor target request.
  266.         virtual void                 SetActorTargetRequest(const SAIActorTargetRequest& req) override;
  267.         //
  268.         virtual void                 ClearActorTargetRequest() override;
  269.         //
  270.         const SAIActorTargetRequest* GetActiveActorTargetRequest() const;
  271.  
  272.         virtual void                 IgnoreCurrentHideObject(float timeOut) override;
  273.  
  274.         virtual EntityId             GetLastUsedSmartObjectId() const override { return m_idLastUsedSmartObject; }
  275.         virtual bool                 IsUsingNavSO() const override             { return m_eNavSOMethod != nSOmNone; }
  276.         virtual void                 ClearPath(const char* dbgString) override;
  277.  
  278.         virtual ETriState            CanTargetPointBeReached(CTargetPointRequest& request) override;
  279.         virtual bool                 UseTargetPointRequest(const CTargetPointRequest& request) override;
  280.  
  281.         virtual void                 UpdateLookTarget(CAIObject* pTarget);
  282.         void                         EnableUpdateLookTarget(bool bEnable = true);
  283.  
  284.         /// Called when it is detected that our current path is invalid - if we want
  285.         /// to continue (assuming we're using it) we should request a new one
  286.         void PathIsInvalid();
  287.  
  288.         // Check if specified hideobject was recently unreachable.
  289.         bool WasHideObjectRecentlyUnreachable(const Vec3& pos) const;
  290.  
  291.         /// Returns the last live target position.
  292.         const Vec3&        GetLastLiveTargetPosition() const  { return m_lastLiveTargetPos; }
  293.         float              GetTimeSinceLastLiveTarget() const { return m_timeSinceLastLiveTarget; }
  294.  
  295.         virtual IAIObject* GetAttentionTargetAssociation() const override
  296.         {
  297.                 CAIObject* pAttentionTarget = m_refAttentionTarget.GetAIObject();
  298.                 return (pAttentionTarget ? pAttentionTarget->GetAssociation().GetAIObject() : NULL);
  299.         }
  300.  
  301.         virtual CAIObject*             GetLastOpResult() override { return m_refLastOpResult.GetAIObject(); }
  302.         virtual CAIObject*             GetSpecialAIObject(const char* objName, float range = 0.0f) override;
  303.  
  304.         inline virtual EAITargetThreat GetAttentionTargetThreat() const override { return m_AttTargetThreat; }
  305.         inline virtual EAITargetType   GetAttentionTargetType() const override   { return m_AttTargetType; }
  306.  
  307.         //Last finished AIAction sets status as succeed or failed
  308.         virtual void SetLastActionStatus(bool bSucceed) override;
  309.  
  310.         void         ClearInvalidatedSOLinks();
  311.         void         InvalidateSOLink(CSmartObject* pObject, SmartObjectHelper* pFromHelper, SmartObjectHelper* pToHelper) const;
  312.         bool         IsSOLinkInvalidated(CSmartObject* pObject, SmartObjectHelper* pFromHelper, SmartObjectHelper* pToHelper) const;
  313.         bool         ConvertPathToSpline(IAISystem::ENavigationType navType);
  314.  
  315.         void         Update(EObjectUpdate type) override;
  316.  
  317.         // Cover
  318.         void           SetCoverID(const CoverID& coverID);
  319.         const CoverID& GetCoverID() const;
  320.         Vec3           GetCoverLocation() const;
  321.         uint32         GetCoverEyes(CAIObject* targetEnemy, const Vec3& enemyTargetLocation, Vec3* eyes, uint32 maxCount) const;
  322.  
  323.         bool           IsAdjustingAim() const;
  324.         void           SetAdjustingAim(bool adjustingAim);
  325.  
  326.         virtual bool   IsInCover() const override;
  327.         virtual void   SetInCover(bool inCover) override;
  328.  
  329.         virtual void   SetCoverCompromised() override;
  330.         virtual bool   IsCoverCompromised() const override;
  331.  
  332.         void           SetMovingToCover(bool movingToCover);
  333.         bool           IsMovingToCover() const override;
  334.  
  335.         void           SetMovingInCover(bool movingInCover);
  336.         bool           IsMovingInCover() const;
  337.  
  338.         virtual bool   IsTakingCover(float distanceThreshold) const override;
  339.  
  340.         void           UpdateCoverBlacklist(float updateTime);
  341.         void           ResetCoverBlacklist();
  342.         void           SetCoverBlacklisted(const CoverID& coverID, bool blacklist, float time = 0.0f);
  343.         bool           IsCoverBlacklisted(const CoverID& coverID) const;
  344.         ILINE float    GetCoverLocationEffectiveHeight() const
  345.         {
  346.                 return m_coverUser.GetLocationEffectiveHeight();
  347.         }
  348.  
  349.         CoverHeight CalculateEffectiveCoverHeight() const override;
  350.  
  351.         ILINE float GetLastUpdateInterval() const
  352.         {
  353.                 return m_fTimePassed;
  354.         }
  355.  
  356.         AsyncState                GetCoverUsageInfo(CoverUsageInfo& usageInfo);
  357.  
  358.         virtual void              OnAIHandlerSentSignal(const char* szText, uint32 crcCode) override;
  359.  
  360.         Movement::PathfinderState GetPathfinderState();
  361.         INavPath*                 GetINavPath() { return &m_Path; };
  362.  
  363.         typedef std::vector<COPWaitSignal*> ListWaitGoalOps;
  364.         ListWaitGoalOps m_listWaitGoalOps;
  365.  
  366.         bool            m_bLastNearForbiddenEdge;
  367.         bool            m_bLastActionSucceed;
  368.  
  369.         typedef std::set<std::pair<CSmartObject*, std::pair<SmartObjectHelper*, SmartObjectHelper*>>> TSetInvalidatedSOLinks;
  370.         mutable TSetInvalidatedSOLinks m_invalidatedSOLinks;
  371.  
  372.         // DEBUG MEMBERS
  373.         EGoalOperations m_lastExecutedGoalop;
  374.         //-----------------------------------
  375.  
  376.         CWeakRef<CAIObject> m_refLastOpResult;
  377.  
  378.         // position of potentially usable smart object
  379.         Vec3                m_posLookAtSmartObject;
  380.  
  381.         CNavPath            m_Path;
  382.         CNavPath            m_OrigPath;
  383.         Vec3                m_PathDestinationPos;                      //! The last point on path before
  384.         bool                m_bPathfinderConsidersPathTargetDirection; //! Defines the way the movement to the target, true = strict, false = fastest, forget end direction.
  385.         float               m_fTimePassed;                             //! how much time passed since last full update
  386.  
  387.         CWeakRef<CAIObject> m_refPathFindTarget;    //! The target object of the current path find request, if applicable.
  388.  
  389.         bool                m_bLooseAttention; // true when we have don't have to look exactly at our target all the time
  390.  
  391.         CWeakRef<CAIObject> m_refLooseAttentionTarget;
  392.  
  393.         bool                m_bPriorityLookAtRequested;
  394.  
  395.         CAIHideObject       m_CurrentHideObject;
  396.  
  397.         Vec3                m_vLastMoveDir; // were was moving last - to be used while next path is generated
  398.         bool                m_bKeepMoving;
  399.         int                 m_nPathDecision;
  400.         uint32              m_queuedPathId;
  401.  
  402.         bool                m_IsSteering;            // if stering around local obstacle now
  403.         float               m_flightSteeringZOffset; // flight navigation only
  404.  
  405.         ENavSOMethod        m_eNavSOMethod; // defines which method to use for navigating through a navigational smart object
  406.         bool                m_navSOEarlyPathRegen;
  407.         EntityId            m_idLastUsedSmartObject;
  408.  
  409. #ifdef _DEBUG
  410.         ListPositions m_DEBUGCanTargetPointBeReached;
  411.         Vec3          m_DEBUGUseTargetPointRequest;
  412. #endif
  413.  
  414.         SNavSOStates m_currentNavSOStates;
  415.         SNavSOStates m_pendingNavSOStates;
  416.  
  417.         int          m_actorTargetReqId;
  418.  
  419.         // The movement reason is for debug purposes only.
  420.         enum EMovementReason
  421.         {
  422.                 AIMORE_UNKNOWN,
  423.                 AIMORE_TRACE,
  424.                 AIMORE_MOVE,
  425.                 AIMORE_MANEUVER,
  426.                 AIMORE_SMARTOBJECT,
  427.         };
  428.  
  429. #ifdef _DEBUG
  430.         int m_DEBUGmovementReason;
  431. #endif
  432.  
  433.         virtual void DebugDrawGoals();
  434.  
  435.         void         DebugDrawCoverUser();
  436.  
  437.         // goal pipe notifications - used by action graph nodes
  438.         typedef std::multimap<int, std::pair<IGoalPipeListener*, const char*>> TMapGoalPipeListeners;
  439.         TMapGoalPipeListeners m_mapGoalPipeListeners;
  440.         void         NotifyListeners(int goalPipeId, EGoalPipeEvent event);
  441.         void         NotifyListeners(CGoalPipe* pPipe, EGoalPipeEvent event, bool includeSubPipes = false);
  442.         virtual void RegisterGoalPipeListener(IGoalPipeListener* pListener, int goalPipeId, const char* debugClassName) override;
  443.         virtual void UnRegisterGoalPipeListener(IGoalPipeListener* pListener, int goalPipeId) override;
  444.  
  445.         int          CountGroupedActiveGoals(); //
  446.         void         ClearGroupedActiveGoals(); //
  447.  
  448.         EAimState    GetAimState() const;
  449.  
  450.         void         SetNavSOFailureStates();
  451.  
  452.         enum ESpecialAIObjects
  453.         {
  454.                 AISPECIAL_LAST_HIDEOBJECT,
  455.                 AISPECIAL_PROBTARGET,
  456.                 AISPECIAL_PROBTARGET_IN_TERRITORY,
  457.                 AISPECIAL_PROBTARGET_IN_REFSHAPE,
  458.                 AISPECIAL_PROBTARGET_IN_TERRITORY_AND_REFSHAPE,
  459.                 AISPECIAL_ATTTARGET_IN_TERRITORY,
  460.                 AISPECIAL_ATTTARGET_IN_REFSHAPE,
  461.                 AISPECIAL_ATTTARGET_IN_TERRITORY_AND_REFSHAPE,
  462.                 AISPECIAL_ANIM_TARGET,
  463.                 AISPECIAL_GROUP_TAC_POS,
  464.                 AISPECIAL_GROUP_TAC_LOOK,
  465.                 AISPECIAL_VEHICLE_AVOID_POS,
  466.                 COUNT_AISPECIAL // Must be last
  467.         };
  468.  
  469.         CAIObject* GetOrCreateSpecialAIObject(ESpecialAIObjects type);
  470.         bool       ShouldConsiderActorsAsPathObstacles() const { return m_considerActorsAsPathObstacles; }
  471.  
  472. protected:
  473.         virtual void           HandleVisualStimulus(SAIEVENT* pAIEvent) override;
  474.         virtual void           HandleSoundEvent(SAIEVENT* pAIEvent) override;
  475.  
  476.         void                   Serialize(TSerialize ser) override;
  477.         void                   PostSerialize() override;
  478.         void                   ClearActiveGoals();
  479.         bool                   ProcessBranchGoal(QGoal& Goal, bool& blocking);
  480.         bool                   ProcessRandomGoal(QGoal& Goal, bool& blocking);
  481.         bool                   ProcessClearGoal(QGoal& Goal, bool& blocking);
  482.         bool                   GetBranchCondition(QGoal& Goal);
  483.  
  484.         virtual IPathFollower* CreatePathFollower(const PathFollowerParams& params);
  485.  
  486.         void                   HandleNavSOFailure();
  487.         void                   SyncActorTargetPhaseWithAIProxy();
  488.  
  489.         float                      m_AttTargetPersistenceTimeout; // to make sure not to jitter between targets; once target is selected, make it stay for some time
  490.         EAITargetThreat            m_AttTargetThreat;
  491.         EAITargetThreat            m_AttTargetExposureThreat;
  492.         EAITargetType              m_AttTargetType;
  493.  
  494.         EFireMode                  m_fireMode; // Currently set firemode.
  495.         CWeakRef<CAIObject>        m_refFireTarget;
  496.         bool                       m_fireModeUpdated; // Flag indicating if the fire mode has been just updated.
  497.         bool                       m_outOfAmmoSent;   // Flag indicating if OnOutOfAmmo signal was sent for current fireMode session.
  498.         bool                       m_lowAmmoSent;
  499.         bool                       m_wasReloading;
  500.         VectorOGoals               m_vActiveGoals;
  501.         VectorOGoals               m_DeferredActiveGoals;
  502.         bool                       m_bBlocked;
  503.         bool                       m_bStartTiming;
  504.         float                      m_fEngageTime;
  505.         CGoalPipe*                 m_pCurrentGoalPipe;
  506.         VectorSet<int>             m_notAllowedSubpipes; // sub-pipes that we tried to remove or cancel even before inserting them
  507.         bool                       m_bFirstUpdate;
  508.         int                        m_looseAttentionId;
  509.         IAISystem::ENavigationType m_CurrentNodeNavType;
  510.         EAimState                  m_aimState;
  511.         float                      m_spreadFireTime;
  512.         Vec3                       m_vBodyTargetDir;
  513.         Vec3                       m_vDesiredBodyDirectionAtTarget;
  514.         unsigned int               m_movementContext;
  515.  
  516.         /// Name of the predefined path that we may subsequently be asked to follow
  517.         string                m_pathToFollowName;
  518.         bool                  m_bPathToFollowIsSpline;
  519.  
  520.         string                m_refShapeName;
  521.         SShape*               m_refShape;
  522.         Vec3                  m_vLastSOExitHelper;
  523.  
  524.         CStrongRef<CAIObject> m_refSpecialObjects[COUNT_AISPECIAL];
  525.  
  526.         typedef std::pair<float, Vec3>   FloatVecPair;
  527.         typedef std::deque<FloatVecPair> TimeOutVec3List;
  528.         TimeOutVec3List m_recentUnreachableHideObjects;
  529.  
  530.         Vec3            m_lastLiveTargetPos;
  531.         float           m_timeSinceLastLiveTarget;
  532.  
  533.         /// path follower is only set if we're using that class to follow a path
  534.         class IPathFollower* m_pPathFollower;
  535.  
  536.         /// Private helper - calculates the path obstacles - in practice a previous result may
  537.         /// be used if it's not out of date
  538.         void CalculatePathObstacles();
  539.         CPathObstacles         m_pathAdjustmentObstacles;
  540.         int                    m_adjustpath;
  541.  
  542.         SAIActorTargetRequest* m_pActorTargetRequest;
  543.  
  544.         bool                   m_inCover;
  545.         bool                   m_movingToCover;
  546.         bool                   m_movingInCover;
  547.         CoverUser              m_coverUser;
  548.         CoverID                m_regCoverID;
  549.  
  550.         //Pauses aspects of the AI's response
  551.         uint8 m_paused;
  552.         bool  m_bEnableUpdateLookTarget;
  553.  
  554.         typedef std::vector<LookTargetWeakPtr> LookTargets;
  555.         LookTargets m_lookTargets;
  556.  
  557. private:
  558.         Vec3 SetPointListToFollowSub(Vec3 a, Vec3 b, Vec3 c, std::vector<Vec3>& newPointList, float step);
  559.  
  560.         // Just here to avoid a warning and to make sure the correct version is used
  561.         void SetAttentionTarget(IAIObject* pObject) { assert(false); }
  562.  
  563.         EntityId              m_pendingSmartObjectId;
  564.         CStrongRef<CAIObject> m_refRefPoint;          // a tag point the puppet uses to remember a position
  565.         CStrongRef<CAIObject> m_refLookAtTarget;      // a look point - which the loose attention target may be set to!
  566.  
  567.         bool                  m_adjustingAim;
  568.  
  569.         typedef std::unordered_map<CoverID, float, stl::hash_uint32> CoverBlacklist;
  570.         CoverBlacklist m_coverBlacklist;
  571.  
  572.         void CoverUsageInfoRayComplete(const QueuedRayID& rayID, const RayCastResult& result);
  573.  
  574.         struct CoverUsageInfoState
  575.         {
  576.                 CoverUsageInfoState()
  577.                         : state(AsyncReady)
  578.                         , rayCount()
  579.                         , result(false)
  580.                 {
  581.                         for (uint32 i = 0; i < 6; ++i)
  582.                                 rayID[i] = 0;
  583.                 }
  584.  
  585.                 void Reset()
  586.                 {
  587.                         for (uint32 i = 0; i < 6; ++i)
  588.                         {
  589.                                 if (rayID[i])
  590.                                 {
  591.                                         gAIEnv.pRayCaster->Cancel(rayID[i]);
  592.                                         rayID[i] = 0;
  593.                                 }
  594.                         }
  595.  
  596.                         state = AsyncReady;
  597.                         rayCount = 0;
  598.                         result = CoverUsageInfo(false);
  599.                 }
  600.  
  601.                 QueuedRayID    rayID[6];
  602.                 AsyncState     state;
  603.                 uint8          rayCount;
  604.  
  605.                 CoverUsageInfo result;
  606.         };
  607.  
  608.         CoverUsageInfoState m_coverUsageInfoState;
  609.  
  610.         struct DelayedPipeSelection
  611.         {
  612.                 DelayedPipeSelection()
  613.                         : mode(0)
  614.                         , refArgument(NILREF)
  615.                         , goalPipeId(-1)
  616.                         , resetAlways(false)
  617.                 {
  618.                 }
  619.  
  620.                 DelayedPipeSelection(int _mode, const char* _name, CWeakRef<CAIObject> _refArgument,
  621.                                      int _goalPipeId, bool _resetAlways /*, const GoalParams* _params*/)
  622.                         : mode(_mode)
  623.                         , name(_name)
  624.                         , refArgument(_refArgument)
  625.                         , goalPipeId(_goalPipeId)
  626.                         , resetAlways(_resetAlways)
  627.                 {
  628.                         //if (_params)
  629.                         //      params = *_params;
  630.                 }
  631.  
  632.                 int                 mode;
  633.                 string              name;
  634.                 CWeakRef<CAIObject> refArgument;
  635.                 int                 goalPipeId;
  636.                 bool                resetAlways;
  637.                 //GoalParams params;
  638.         };
  639.  
  640.         DelayedPipeSelection         m_delayedPipeSelection;
  641.         bool                         m_pipeExecuting;
  642.  
  643.         bool                         m_cutPathAtSmartObject;
  644.         bool                         m_considerActorsAsPathObstacles;
  645.  
  646.         PipeUserMovementActorAdapter m_movementActorAdapter;
  647.         MovementActorCallbacks       m_callbacksForPipeuser;
  648. };
  649.  
  650. ILINE const CPipeUser* CastToCPipeUserSafe(const IAIObject* pAI) { return pAI ? pAI->CastToCPipeUser() : 0; }
  651. ILINE CPipeUser*       CastToCPipeUserSafe(IAIObject* pAI)       { return pAI ? pAI->CastToCPipeUser() : 0; }
  652.  
  653. #endif
  654.  
downloadPipeUser.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