BVB Source Codes

CRYENGINE Show CustomAction.h Source code

Return Download CRYENGINE: download CustomAction.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef _CUSTOMACTION_H_
  4. #define _CUSTOMACTION_H_
  5.  
  6. #if _MSC_VER > 1000
  7.         #pragma once
  8. #endif
  9.  
  10. #include <CryFlowGraph/IFlowSystem.h>
  11. #include <CryAction/ICustomActions.h>
  12. #include <CryCore/Containers/CryListenerSet.h>
  13.  
  14. // Forward declaration
  15. class CCustomActionManager;
  16.  
  17. ///////////////////////////////////////////////////
  18. // CCustomAction references a Flow Graph - sequence of elementary actions
  19. ///////////////////////////////////////////////////
  20. class CCustomAction : public ICustomAction
  21. {
  22.         friend class CCustomActionManager;  // CCustomActionManager needs right to access and modify these private data members
  23.  
  24. public:
  25.         CCustomAction(const CCustomAction& src)
  26.                 : m_listeners(1)
  27.                 , m_pObjectEntity(NULL)
  28.                 , m_currentState(CAS_Ended)
  29.         {
  30.                 m_customActionGraphName = src.m_customActionGraphName;
  31.  
  32.                 // Doesn't make sense to copy state
  33.         }
  34.  
  35.         CCustomAction()
  36.                 : m_listeners(1)
  37.                 , m_pObjectEntity(NULL)
  38.                 , m_currentState(CAS_Ended)
  39.                 , m_customActionGraphName("")
  40.                 , m_pFlowGraph(NULL)
  41.         {}
  42.         virtual ~CCustomAction() {}
  43.  
  44.         CCustomAction& operator=(const CCustomAction& src)
  45.         {
  46.                 m_customActionGraphName = src.m_customActionGraphName;
  47.  
  48.                 // Doesn't make sense to copy state
  49.  
  50.                 return *this;
  51.         }
  52.  
  53.         // Overloaded comparison
  54.         bool operator==(const CCustomAction& src) const
  55.         {
  56.                 return (m_pObjectEntity == src.m_pObjectEntity &&
  57.                         m_customActionGraphName == src.m_customActionGraphName);   // Only needed for remove so ok to have duplicates after terminations
  58.         }
  59.  
  60.         // ICustomAction
  61.         virtual IEntity*           GetObjectEntity() const          { return m_pObjectEntity; }
  62.         virtual const char*        GetCustomActionGraphName() const { return m_customActionGraphName; }
  63.         virtual IFlowGraph*        GetFlowGraph() const             { return m_pFlowGraph; }
  64.         virtual bool               StartAction();
  65.         virtual bool               SucceedAction();
  66.         virtual bool               SucceedWaitAction();
  67.         virtual bool               SucceedWaitCompleteAction();
  68.         virtual bool               EndActionSuccess();
  69.         virtual bool               EndActionFailure();
  70.         virtual bool               AbortAction();
  71.         virtual void               TerminateAction();
  72.         virtual void               Invalidate()                                                              { m_pFlowGraph = NULL; }
  73.         virtual ECustomActionState GetCurrentState() const                                                   { return m_currentState; }
  74.         virtual void               RegisterListener(ICustomActionListener* pEventListener, const char* name) { m_listeners.Add(pEventListener, name); }
  75.         virtual void               UnregisterListener(ICustomActionListener* pEventListener)                 { m_listeners.Remove(pEventListener); }
  76.         // ~ICustomAction
  77.  
  78.         // Called on serialize
  79.         void Serialize(TSerialize ser);
  80.  
  81.         void GetMemoryUsage(ICrySizer* pSizer) const
  82.         {
  83.                 pSizer->AddObject(m_customActionGraphName);
  84.                 pSizer->AddObject(m_pFlowGraph);
  85.         }
  86.  
  87. protected:
  88.         bool SwitchState(const ECustomActionState newState,
  89.                          const ECustomActionEvent event,
  90.                          const char* szNodeToCall,
  91.                          const char* szLuaFuncToCall);
  92.  
  93.         void NotifyListeners(ECustomActionEvent event, ICustomAction& customAction)
  94.         {
  95.                 for (TCustomActionListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
  96.                         notifier->OnCustomActionEvent(event, customAction);
  97.         }
  98.  
  99.         IEntity*           m_pObjectEntity;         // Entities participants in this Action
  100.         string             m_customActionGraphName; // Name of the custom action graph
  101.         IFlowGraphPtr      m_pFlowGraph;            // Points to a flow graph which would be used to execute the Action
  102.         ECustomActionState m_currentState;          // Current state of the action
  103.  
  104.         typedef CListenerSet<ICustomActionListener*> TCustomActionListeners;
  105.         TCustomActionListeners m_listeners; // Actions listeners that listener to state change events
  106. };
  107.  
  108. #endif
  109.  
downloadCustomAction.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