RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
cactionmanager.h
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // cocos2d for iPhone: http://www.cocos2d-iphone.org
3 // -> This file was ported to C++ by Leopoldo Lomas Flores just for fun.
4 // I suggest you get the official C++ version of this file from:
5 // http://www.cocos2d-x.org/
6 //
7 // Copyright (c) 2008-2011 Ricardo Quesada
8 // Copyright (c) 2011 Zynga Inc.
9 // Copyright (c) 2013-2014 Cocos2D Authors
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a copy
12 // of this software and associated documentation files (the "Software"), to deal
13 // in the Software without restriction, including without limitation the rights
14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 // copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included in
19 // all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 // THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #ifndef RIOENGINE_CENGINE_CACTIONMANAGER_H_
31 #define RIOENGINE_CENGINE_CACTIONMANAGER_H_
32 
33 #include <vector>
34 #include "misc/uthash.h"
35 
36 class CGameObject;
37 class CAction;
38 
39 typedef struct _hashElement {
40  std::vector<CAction*> actions;
41  unsigned int actionIndex;
43  bool paused;
47 } tHashElement;
48 
49 class CActionManager : public CObject {
50 public:
51  CActionManager(void);
52 
53  // actions
62  void addAction(CAction* action, CGameObject* target, bool paused);
63 
67  void removeAllActions();
68 
74 
78  void removeAction(CAction* action);
79 
83  void removeActionByTag(unsigned int tag, CGameObject* target);
84 
89  CAction* getActionByTag(unsigned int tag, CGameObject* game_object);
90 
97  unsigned int numberOfRunningActionsInTarget(CGameObject* target);
98 
102  void pauseTarget(CGameObject* target);
103 
107  void resumeTarget(CGameObject* target);
108 
112  // CPointerArray<CGameObject>* pauseAllRunningActions();
113 
114  void update(double dt);
115 
119  //-(void) resumeTargets:(NSSet *)targetsToResume;
120 
121  ~CActionManager(void);
122 
123 private:
124  void removeActionAtIndex(unsigned int index, tHashElement* element);
125  void deleteHashElement(tHashElement* element);
126 
127  tHashElement* m_targets;
128  tHashElement* m_currentTarget;
129  bool m_currentTargetSalvaged;
130 };
131 
132 #endif RIOENGINE_CENGINE_CACTIONMANAGER_H_
void removeAction(CAction *action)
void removeActionByTag(unsigned int tag, CGameObject *target)
bool currentActionSalvaged
CAction * currentAction
void resumeTarget(CGameObject *target)
unsigned int numberOfRunningActionsInTarget(CGameObject *target)
std::vector< CAction * > actions
UT_hash_handle hh
CAction * getActionByTag(unsigned int tag, CGameObject *game_object)
void update(double dt)
void addAction(CAction *action, CGameObject *target, bool paused)
void removeAllActionsFromTarget(CGameObject *target)
struct _hashElement tHashElement
void pauseTarget(CGameObject *target)
unsigned int actionIndex
CGameObject * target