Thrive
powerup_system.h
1 #pragma once
2 
3 #include "engine/component.h"
4 #include "engine/system.h"
5 #include "engine/touchable.h"
6 #include "engine/typedefs.h"
7 #include "scripting/luabind.h"
8 
9 #include <luabind/object.hpp>
10 
11 namespace luabind {
12 class scope;
13 }
14 
15 
16 namespace thrive {
17 
18 
22 class PowerupComponent : public Component {
23  COMPONENT(PowerupComponent)
24 
25 public:
26 
36  static luabind::scope
37  luaBindings();
38 
39 
46  void
47  setEffect(
48  std::function<bool(EntityId)>* effect
49  );
50 
58  void
59  setEffect(
60  const luabind::object& effect
61  );
62 
63  void
64  load(
66  ) override;
67 
69  storage() const override;
70 
71 private:
72 
73  friend class PowerupSystem;
74 
78  std::function<bool(EntityId)>* m_effect;
79 
80 };
81 
82 
86 class PowerupSystem : public System {
87 
88 public:
89 
98  static luabind::scope
99  luaBindings();
100 
104  PowerupSystem();
105 
109  ~PowerupSystem();
110 
115  void init(GameState* gameState) override;
116 
120  void shutdown() override;
121 
125  void update(int, int) override;
126 
127 private:
128 
129  struct Implementation;
130  std::unique_ptr<Implementation> m_impl;
131 };
132 
133 }
134 
Component for entities that work as powerups.
Definition: powerup_system.h:22
void shutdown() override
Shuts the system down.
Definition: powerup_system.cpp:118
System for handling powerups.
Definition: powerup_system.h:86
Base class for components.
Definition: component.h:31
A system handles one specific part of the game.
Definition: system.h:23
void setEffect(std::function< bool(EntityId)> *effect)
Sets the effect to use upon activation of the powerup.
Definition: powerup_system.cpp:33
void update(int, int) override
Updates the system.
Definition: powerup_system.cpp:126
PowerupSystem()
Constructor.
Definition: powerup_system.cpp:97
void init(GameState *gameState) override
Initializes the system.
Definition: powerup_system.cpp:107
static luabind::scope luaBindings()
Lua bindings.
Definition: powerup_system.cpp:16
Definition: bullet_to_ogre_system.h:5
Definition: bullet_ogre_conversion.h:6
GameState * gameState() const
Returns the system's game state.
Definition: system.cpp:183
Represents a distinct set of active systems and entities.
Definition: game_state.h:41
static luabind::scope luaBindings()
Lua bindings.
Definition: powerup_system.cpp:72
void load(const StorageContainer &storage) override
Loads the component.
Definition: powerup_system.cpp:52
StorageContainer storage() const override
Serializes the component.
Definition: powerup_system.cpp:60
A key-value storage for serialization.
Definition: serialization.h:36
~PowerupSystem()
Destructor.
Definition: powerup_system.cpp:103