GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Trigger.hpp
Go to the documentation of this file.
1 #ifndef RADIX_COMPONENT_TRIGGER_HPP
2 #define RADIX_COMPONENT_TRIGGER_HPP
3 
4 #include <radix/BaseGame.hpp>
7 #include <radix/Entity.hpp>
8 
9 #include <memory>
10 #include <functional>
11 #include <BulletCollision/CollisionShapes/btCapsuleShape.h>
12 #include <bullet/BulletCollision/CollisionDispatch/btGhostObject.h>
13 
14 namespace radix {
15 
16 class Trigger : public Component {
17 private:
18  btGhostObject *ghostObject;
19 public:
20  btGhostObject *getBulletGhostObject();
21  using Action = std::function<void(BaseGame*)>;
22 
27 
29 
30  std::shared_ptr<btConvexShape> shape;
31 
32  Trigger(Entity &ent);
33  ~Trigger();
34 
35  const char* getName() const {
36  return "Trigger";
37  }
38 
39  void setActionOnExit(Action action);
40  void setActionOnEnter(Action action);
41  void setActionOnMove(Action action);
42  void setActionOnUpdate(Action action);
43 
44  TypeId getTypeId() const {
45  return Component::getTypeId<std::remove_reference<decltype(*this)>::type>();
46  }
47 
48  void serialize(serine::Archiver &ar) {
49  }
50 
51  void onEnter(BaseGame* game) { actionOnEnter(game); };
52  void onExit(BaseGame* game) { actionOnExit(game); };
53  void onMove(BaseGame* game) { actionOnMove(game); };
54  void onUpdate(BaseGame* game) { actionOnUpdate(game); };
55 };
56 
57 } /* namespace radix */
58 
59 #endif /* RADIX_COMPONENT_TRIGGER_HPP */
void setActionOnMove(Action action)
Definition: Trigger.cpp:50
Definition: GameController.hpp:7
std::shared_ptr< btConvexShape > shape
Definition: Trigger.hpp:30
Action actionOnUpdate
Definition: Trigger.hpp:26
void setActionOnEnter(Action action)
Definition: Trigger.cpp:46
ECS entity, Component container It is created like this:
Definition: Entity.hpp:23
void onUpdate(BaseGame *game)
Definition: Trigger.hpp:54
std::function< void(BaseGame *)> Action
Definition: Trigger.hpp:21
Trigger(Entity &ent)
Definition: Trigger.cpp:6
Action actionOnMove
Definition: Trigger.hpp:25
void serialize(serine::Archiver &ar)
Definition: Trigger.hpp:48
TypeId getTypeId() const
Definition: Trigger.hpp:44
const char * getName() const
Definition: Trigger.hpp:35
Base class to create entity components.
Definition: Component.hpp:25
void onEnter(BaseGame *game)
Definition: Trigger.hpp:51
EventDispatcher::CallbackHolder callbackOnEnter
Definition: Trigger.hpp:28
btGhostObject * getBulletGhostObject()
Definition: Trigger.cpp:42
ComponentTypeId TypeId
Definition: Component.hpp:35
Action actionOnExit
Definition: Trigger.hpp:24
~Trigger()
Definition: Trigger.cpp:62
void setActionOnUpdate(Action action)
Definition: Trigger.cpp:54
void onMove(BaseGame *game)
Definition: Trigger.hpp:53
void setActionOnExit(Action action)
Definition: Trigger.cpp:58
Definition: EventDispatcher.hpp:20
Action actionOnEnter
Definition: Trigger.hpp:23
Definition: BaseGame.hpp:22
btGhostObject * ghostObject
Definition: Trigger.hpp:18
EventDispatcher::CallbackHolder callbackOnExit
Definition: Trigger.hpp:28
void onExit(BaseGame *game)
Definition: Trigger.hpp:52
Definition: Trigger.hpp:16