9 #ifndef TurtleBrains_ParticleManager_hpp
10 #define TurtleBrains_ParticleManager_hpp
12 #include <turtle_brains/core/tb_string.hpp>
13 #include <turtle_brains/core/tb_noncopyable.hpp>
14 #include <turtle_brains/core/tb_types.hpp>
15 #include <turtle_brains/math/tb_vector.hpp>
16 #include <turtle_brains/graphics/tb_sprite.hpp>
38 float mDragCoefficient;
42 bool mGlobalAcceleration;
48 bool Update(
const float deltaTime);
62 template <
typename Type>
class RangedType
65 explicit RangedType(
const Type& value) :
71 explicit RangedType(
const Type& minimumValue,
const Type& maximumValue) :
72 mMinimumValue(minimumValue),
73 mMaximumValue(maximumValue)
75 tb_error_if(maximumValue < minimumValue,
"tbExternalError: Expected minimumValue to be less-than-or-equal-to maximumValue.");
82 void SetRange(
const Type& minimumValue,
const Type& maximumValue)
85 mMinimumValue = minimumValue;
86 mMaximumValue = maximumValue;
89 const Type&
Minimum(
void)
const {
return mMinimumValue; }
90 const Type&
Maximum(
void)
const {
return mMaximumValue; }
97 struct ParticleDefinition
100 RangedType<float> mSpawnDistanceRange;
101 RangedType<float> mDragCoefficientRange;
102 RangedType<float> mScaleRange;
103 RangedType<float> mSpeedRange;
104 RangedType<float> mLaunchAngleRange;
105 RangedType<tbMath::Vector2> mAccelerationRange;
107 RangedType<tbCore::uint32> mParticleLifeTimeRange;
108 RangedType<tbCore::uint32> mParticleFadeInTimeRange;
109 RangedType<tbCore::uint32> mParticleFadeOutTimeRange;
111 bool mGlobalAcceleration;
117 struct EmitterDefinition
120 std::vector<ParticleDefinition> mParticleDefinitions;
125 explicit EmitterDefinition(
const TextureHandle& textureHandle);
135 ParticleManager(
void);
136 ~ParticleManager(
void);
144 void ReloadModifiedSheets(
void);
149 void ClearAllParticles(
void);
150 void ManageParticle(
const tbImplementation::Particle& particle);
151 void UpdateParticles(
const float deltaTime);
152 void RenderParticles(
void)
const;
156 size_t GetParticleCount(
void);
159 typedef std::list<tbImplementation::Particle> ParticleList;
160 typedef std::map<tbGraphics::TextureHandle, ParticleList> ParticleTable;
162 ParticleTable mParticleTable;
166 typedef std::map<tbCore::tbString, ParticleDefinition> ParticleDefinitionTable;
167 typedef std::map<tbCore::tbString, EmitterDefinition> EmitterDefinitionTable;
169 ParticleDefinitionTable mParticles;
170 EmitterDefinitionTable mEmitters;
173 typedef std::map<tbCore::tbString, ParticleSheet> ParticleSheetTable;
174 ParticleSheetTable mParticleSheets;
177 typedef std::map<tbCore::tbString, tbCore::tbString> FileToSheetTable;
178 FileToSheetTable mFileToSheets;
181 extern ParticleManager theParticleManager;
Definition: tb_vector.hpp:48
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
Definition: tb_sprite.hpp:29
TurtleBrains::Core::ResourceHandle< tbImplementation::TextureHandleSaver > TextureHandle
Definition: tb_texture_manager.hpp:42
Definition: tb_noncopyable.hpp:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
Definition: tb_color.hpp:24
uint8_t uint8
Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
Definition: tb_types.hpp:23
constexpr const T & Maximum(const T &leftValue, const T &rightValue) noexcept
Definition: tb_math.hpp:76
uint32_t uint32
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1)...
Definition: tb_types.hpp:28
#define tb_error_if(errorTest, message,...)
Definition: tb_error.hpp:42
std::string tbString
Definition: tb_string.hpp:335
Definition: tb_application_dialog.hpp:19
constexpr const T & Minimum(const T &leftValue, const T &rightValue) noexcept
Definition: tb_math.hpp:89