BVB Source Codes

CRYENGINE Show EnterLeaveUpdateGoalOp.h Source code

Return Download CRYENGINE: download EnterLeaveUpdateGoalOp.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 EnterLeaveUpdateGoalOp_h
  6.         #define EnterLeaveUpdateGoalOp_h
  7.  
  8.         #include "GoalOp.h"
  9.  
  10. // Helper class which you can derive from when you want to get clear
  11. // entry/exit/update points for your goal op.
  12. //
  13. // Preferably, this should be provided by the goal pipe system itself.
  14. //
  15. // Methods you may override:
  16. // - Enter is called when the execution starts.
  17. // - Leave is called when the execution stops.
  18. // - Update is continuously called on non-dry updates until:
  19. //   a) You explicitly say you've succeeded or failed with your operation.
  20. //   b) A new goal pipe is selected and your goal op is pulled out.
  21.  
  22. class EnterLeaveUpdateGoalOp : public CGoalOp
  23. {
  24. public:
  25.         EnterLeaveUpdateGoalOp()
  26.                 : m_initialized(false)
  27.                 , m_status(eGOR_IN_PROGRESS)
  28.         {
  29.         }
  30.  
  31.         // Called when the pipe user starts running this instance of the goal op.
  32.         virtual void Enter(CPipeUser& pipeUser)
  33.         {
  34.         }
  35.  
  36.         // Called when the pipe user stops running this instance of the goal op.
  37.         virtual void Leave(CPipeUser& pipeUser)
  38.         {
  39.         }
  40.  
  41.         // Don't override. Do your work in Update.
  42.         virtual EGoalOpResult Execute(CPipeUser* pPipeUser)
  43.         {
  44.                 assert(pPipeUser);
  45.  
  46.                 if (!m_initialized)
  47.                 {
  48.                         Enter(*pPipeUser);
  49.                         m_initialized = true;
  50.                 }
  51.  
  52.                 Update(*pPipeUser);
  53.  
  54.                 return m_status;
  55.         }
  56.  
  57.         // Don't override. Do your work in Update.
  58.         virtual void ExecuteDry(CPipeUser* pPipeUser)
  59.         {
  60.         }
  61.  
  62.         // Don't override. Do your work in OnLeave.
  63.         virtual void Reset(CPipeUser* pPipeUser)
  64.         {
  65.                 if (m_initialized)
  66.                 {
  67.                         Leave(*pPipeUser);
  68.  
  69.                         m_status = eGOR_IN_PROGRESS;
  70.                         m_initialized = false;
  71.                 }
  72.         }
  73.  
  74. protected:
  75.         // Override with your own Update code.
  76.         virtual void Update(CPipeUser& pipeUser)
  77.         {
  78.         }
  79.  
  80.         void          GoalOpSucceeded() { m_status = eGOR_SUCCEEDED; }
  81.         void          GoalOpFailed()    { m_status = eGOR_FAILED; }
  82.         EGoalOpResult GetStatus()       { return m_status; }
  83.  
  84. private:
  85.         EGoalOpResult m_status;
  86.         bool          m_initialized;
  87. };
  88.  
  89. #endif // EnterLeaveUpdateGoalOp_h
  90.  
downloadEnterLeaveUpdateGoalOp.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