Thrive
compound_emitter_system.h
1 #pragma once
2 
3 #include <boost/range/adaptor/map.hpp>
4 
5 #include "engine/component.h"
6 #include "engine/system.h"
7 #include "engine/touchable.h"
8 #include "scripting/luabind.h"
9 #include "engine/typedefs.h"
10 #include "microbe_stage/compound.h"
11 
12 #include <luabind/object.hpp>
13 #include <memory>
14 #include <OgreCommon.h>
15 #include <OgreMath.h>
16 #include <OgreVector3.h>
17 #include <unordered_set>
18 
19 
20 namespace thrive {
21 
22 using BoostCompoundMapIterator = boost::range_detail::select_second_mutable_range<std::unordered_map<std::string, CompoundId>>;
23 using BoostAbsorbedMapIterator = boost::range_detail::select_first_range<std::unordered_map<CompoundId, float>>;
24 
29  COMPONENT(CompoundEmitter)
30 
31 public:
32 
47  static luabind::scope
48  luaBindings();
49 
53  Ogre::Real m_emissionRadius = 0.0;
54 
58  Ogre::Real m_maxInitialSpeed = 0.0;
59 
63  Ogre::Real m_minInitialSpeed = 0.0;
64 
70  Ogre::Degree m_maxEmissionAngle = Ogre::Degree(360);
71 
77  Ogre::Degree m_minEmissionAngle = Ogre::Degree(0);
78 
82  Milliseconds m_particleLifetime = 1000;
83 
98  void
100  CompoundId compoundId,
101  double amount,
102  double angle,
103  double radius
104  );
105 
106  void
107  load(
109  ) override;
110 
112  storage() const override;
113 
114 private:
115 
116  friend class CompoundEmitterSystem;
117  std::vector<std::tuple<CompoundId, double, double, double>> m_compoundEmissions;
118 
119 };
120 
121 
127 
128 public:
129 
142  static luabind::scope
143  luaBindings();
144 
148  CompoundId m_compoundId;// = NULL_COMPOUND;
149 
154 
158  float m_potencyPerParticle = 1.0f;
159 
163  Milliseconds m_emitInterval = 1000;
164 
168  Milliseconds m_timeSinceLastEmission = 0;
169 
170  void
171  load(
173  ) override;
174 
176  storage() const override;
177 
178 };
179 
180 
185 
186 public:
187 
196  static luabind::scope
197  luaBindings();
198 
203 
208 
214  void init(GameState* gameState) override;
215 
219  void shutdown() override;
220 
224  void update(int, int) override;
225 
226 private:
227 
228  struct Implementation;
229  std::unique_ptr<Implementation> m_impl;
230 };
231 
232 }
static luabind::scope luaBindings()
Lua bindings.
Definition: compound_emitter_system.cpp:147
CompoundId m_compoundId
The compound id to emit.
Definition: compound_emitter_system.h:148
Component for automatic timed compound emissions.
Definition: compound_emitter_system.h:125
StorageContainer storage() const override
Serializes the component.
Definition: compound_emitter_system.cpp:129
StorageContainer storage() const override
Serializes the component.
Definition: compound_emitter_system.cpp:78
Ogre::Real m_maxInitialSpeed
The maximum initial speed of new particles.
Definition: compound_emitter_system.h:58
void load(const StorageContainer &storage) override
Loads the component.
Definition: compound_emitter_system.cpp:116
Ogre::Degree m_maxEmissionAngle
The maximum angle at which to emit particles.
Definition: compound_emitter_system.h:70
void init(GameState *gameState) override
Initializes the system.
Definition: compound_emitter_system.cpp:177
Ogre::Degree m_minEmissionAngle
The minimum angle at which to emit particles.
Definition: compound_emitter_system.h:77
Milliseconds m_timeSinceLastEmission
For use by TimedCompoundEmitterSystem.
Definition: compound_emitter_system.h:168
Base class for components.
Definition: component.h:31
void emitCompound(CompoundId compoundId, double amount, double angle, double radius)
Emits an compound according to the set properties.
Definition: compound_emitter_system.cpp:53
A system handles one specific part of the game.
Definition: system.h:23
static luabind::scope luaBindings()
Lua bindings.
Definition: compound_emitter_system.cpp:97
Emitter for compound particles.
Definition: compound_emitter_system.h:28
Milliseconds m_particleLifetime
How long new particles will stay alive.
Definition: compound_emitter_system.h:82
Milliseconds m_emitInterval
How often new particles are spawned.
Definition: compound_emitter_system.h:163
Definition: bullet_ogre_conversion.h:6
Spawns compound particles for CompoundEmitterComponent.
Definition: compound_emitter_system.h:184
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
CompoundEmitterSystem()
Constructor.
Definition: compound_emitter_system.cpp:167
Ogre::Real m_minInitialSpeed
The minimum initial speed of new particles.
Definition: compound_emitter_system.h:63
void load(const StorageContainer &storage) override
Loads the component.
Definition: compound_emitter_system.cpp:65
static luabind::scope luaBindings()
Lua bindings.
Definition: compound_emitter_system.cpp:31
Ogre::Real m_emissionRadius
How far away the particles are spawned.
Definition: compound_emitter_system.h:53
void shutdown() override
Shuts the system down.
Definition: compound_emitter_system.cpp:187
void update(int, int) override
Updates the system.
Definition: compound_emitter_system.cpp:268
uint16_t m_particlesPerEmission
The number of particles created per emission interval.
Definition: compound_emitter_system.h:153
A key-value storage for serialization.
Definition: serialization.h:36
~CompoundEmitterSystem()
Destructor.
Definition: compound_emitter_system.cpp:173
float m_potencyPerParticle
The potency new particles will receive.
Definition: compound_emitter_system.h:158