BVB Source Codes

CRYENGINE Show MovementPlan.cpp Source code

Return Download CRYENGINE: download MovementPlan.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "MovementPlan.h"
  5. #include <CryAISystem/MovementUpdateContext.h>
  6.  
  7. namespace Movement
  8. {
  9. Plan::Status Plan::Execute(const MovementUpdateContext& context)
  10. {
  11.         if (m_current == NoBlockIndex)
  12.                 ChangeToIndex(0, context.actor);
  13.  
  14.         m_lastStatus = Plan::Status::Running;
  15.  
  16.         while (true)
  17.         {
  18.                 assert(m_current != NoBlockIndex);
  19.                 assert(m_current < m_blocks.size());
  20.  
  21.                 const Block::Status blockStatus = m_blocks[m_current]->Update(context);
  22.                 switch (blockStatus)
  23.                 {
  24.                 case Block::Finished:
  25.                 {
  26.                         if (m_current + 1 < m_blocks.size())
  27.                         {
  28.                                 ChangeToIndex(m_current + 1, context.actor);
  29.                                 continue;
  30.                         }                      
  31.                         ChangeToIndex(NoBlockIndex, context.actor);
  32.                         m_lastStatus = Plan::Status::Finished;
  33.                         break;
  34.                 }
  35.                 case Block::CantBeFinished:
  36.                         m_lastStatus = Plan::Status::CantBeFinished;
  37.                         break;
  38.                 case Block::Running:
  39.                         m_lastStatus = Plan::Status::Running;
  40.                         break;
  41.                 default:
  42.                         assert(0);
  43.                         break;
  44.                 }
  45.                 break;
  46.         }
  47.         return m_lastStatus;
  48. }
  49.  
  50. void Plan::ChangeToIndex(const uint newIndex, IMovementActor& actor)
  51. {
  52.         const uint oldIndex = m_current;
  53.  
  54.         if (oldIndex != NoBlockIndex)
  55.                 m_blocks[oldIndex]->End(actor);
  56.  
  57.         if (newIndex != NoBlockIndex)
  58.                 m_blocks[newIndex]->Begin(actor);
  59.  
  60.         m_current = newIndex;
  61. }
  62.  
  63. void Plan::Clear(IMovementActor& actor)
  64. {
  65.         ChangeToIndex(NoBlockIndex, actor);
  66.         m_blocks.clear();
  67.         m_requestId = MovementRequestID();
  68.         m_lastStatus = Plan::Status::None;
  69. }
  70.  
  71. void Plan::CutOffAfterCurrentBlock()
  72. {
  73.         if (m_current < m_blocks.size())
  74.                 m_blocks.resize(m_current + 1);
  75. }
  76.  
  77. bool Plan::InterruptibleNow() const
  78. {
  79.         if (m_current == NoBlockIndex)
  80.                 return true;
  81.  
  82.         return m_blocks[m_current]->InterruptibleNow();
  83. }
  84.  
  85. const Block* Plan::GetBlock(uint32 index) const
  86. {
  87.         return m_blocks[index].get();
  88. }
  89. }
  90.  
downloadMovementPlan.cpp 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