BVB Source Codes

CRYENGINE Show MovementPlan.h Source code

Return Download CRYENGINE: download MovementPlan.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #pragma once
  4.  
  5. #ifndef MovementPlan_h
  6.         #define MovementPlan_h
  7.  
  8. struct IMovementActor;
  9. struct MovementUpdateContext;
  10.  
  11.         #include <CryAISystem/MovementBlock.h>
  12.         #include <CryAISystem/MovementRequestID.h>
  13.  
  14. namespace Movement
  15. {
  16. // This is a plan that will satisfy a movement request such as
  17. // "reach this destination" or "stop immediately".
  18. //
  19. // It's comprised of one or more movement blocks that each take care
  20. // of a certain part of plan. They are executed in order.
  21. //
  22. // As an example a plan to satisfy the request "move to this cover" could
  23. // be comprised of the following movement blocks:
  24. // [FollowPath] -> [UseSmartObject] -> [FollowPath] -> [InstallInCover]
  25. class Plan
  26. {
  27. public:
  28.         static const uint32 NoBlockIndex = ~0u;
  29.        
  30.         enum Status
  31.         {
  32.                 None,
  33.                 Running,
  34.                 Finished,
  35.                 CantBeFinished,
  36.         };
  37.  
  38.         Plan()
  39.                 : m_current(NoBlockIndex)
  40.                 , m_lastStatus(Status::Running)
  41.         {
  42.         }
  43.  
  44.         template<typename BlockType>
  45.         void AddBlock()
  46.         {
  47.                 m_blocks.push_back(std::shared_ptr<Block>(new BlockType()));
  48.         }
  49.  
  50.         void AddBlock(const std::shared_ptr<Block>& block)
  51.         {
  52.                 m_blocks.push_back(block);
  53.         }
  54.  
  55.         Status                   Execute(const MovementUpdateContext& context);
  56.         void                     ChangeToIndex(const uint newIndex, IMovementActor& actor);
  57.         bool                     HasBlocks() const { return !m_blocks.empty(); }
  58.         void                     Clear(IMovementActor& actor);
  59.         void                     CutOffAfterCurrentBlock();
  60.         bool                     InterruptibleNow() const;
  61.         uint32                   GetCurrentBlockIndex() const { return m_current; }
  62.         uint32                   GetBlockCount() const        { return m_blocks.size(); }
  63.         const Block*             GetBlock(uint32 index) const;
  64.  
  65.         const MovementRequestID& GetRequestId() const                             { return m_requestId; }
  66.         void                     SetRequestId(const MovementRequestID& requestId) { m_requestId = requestId; }
  67.  
  68.         Status                   GetLastStatus() const { return m_lastStatus; }
  69.  
  70. private:
  71.         typedef std::vector<std::shared_ptr<Block>> Blocks;
  72.         Blocks            m_blocks;
  73.         uint32            m_current;
  74.         MovementRequestID m_requestId;
  75.         Status            m_lastStatus;
  76. };
  77.  
  78. }
  79.  
  80. #endif // MovementPlan_h
  81.  
downloadMovementPlan.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