Brunot
Loading...
Searching...
No Matches
ParticleGenerator.h
Go to the documentation of this file.
1
10// ____ __ __ __
11// /\__ _\/\ \ /\ \/\ \
12// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
13// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
14// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
15// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
16// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
17
18#pragma once
19#include "Framework/Component.h"
21
22class ParticleEmitter;
23
59class ParticleGenerator final : public Component
60{
61public:
62#pragma region static_functions
63
64#pragma endregion
65
68 auto operator=(const ParticleGenerator&) -> ParticleGenerator& = default;
69 ~ParticleGenerator() override = default;
70 ParticleGenerator(ParticleGenerator&& other) noexcept = default;
71 auto operator=(ParticleGenerator&& other) noexcept -> ParticleGenerator& = default;
72
73#pragma region overriden_functions
74
75 auto clone() const -> std::unique_ptr<GameObject> override
76 {
77 return std::make_unique<ParticleGenerator>(*this);
78 }
79
80 auto componentShowMenu() -> void override;
81 // for debug ImGUI
82 auto onUpdate(float dt) -> void override;
83
84 auto endWindow() -> void override
85 {
86 } // for debug ImGUI
87 auto onRender() -> void override;
88 auto load(const Stream& stream) -> void override;
89 auto save(Stream& stream) const -> void override;
90 auto onEnterEngine() -> void override;
91
92 friend auto to_json(json& j, const ParticleGenerator& n) -> void;
93 friend auto from_json(const json& j, ParticleGenerator& n) -> void;
94
95
96#pragma endregion
97
98#pragma region ParticleGenerator_functions
99
101 auto addEmitter() -> void;
102
108 auto activate() -> void;
109
115 auto deactivate() -> void;
116
117#pragma endregion
118
119#pragma region messaging_functions
120 auto linkMessages() -> void;
121
122#pragma endregion
123
124private:
125#pragma region member_variables
126
127
129 std::vector<std::unique_ptr<ParticleEmitter>> emitters;
130
132 bool active = true;
134 bool repeats = true;
135
136#pragma endregion
137
138#pragma region helper_functions
139
140#pragma endregion
141
142#pragma region static_variables
143
144#pragma endregion
145
146};
sys::Json Stream
Definition AudioObject.h:20
The base class for components, holding all of their shared All components should inherit from this.
nlohmann::json json
Definition Json.cpp:19
An object that manages many of a single type of particle.
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
An object that manages many of a single type of particle.
Definition ParticleEmitter.h:32
A Component that generates several types of particles, by holding several ParticleEmitters.
Definition ParticleGenerator.h:60
std::vector< std::unique_ptr< ParticleEmitter > > emitters
All the particle emitters inside the generator.
Definition ParticleGenerator.h:129
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition ParticleGenerator.h:84
auto activate() -> void
Activates the particle generator, and all it's emitters If the particle generator is set to repeat,...
Definition ParticleGenerator.cpp:182
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition ParticleGenerator.cpp:131
auto onRender() -> void override
called every frame after update has been called for every object.
Definition ParticleGenerator.cpp:117
~ParticleGenerator() override=default
friend auto to_json(json &j, const ParticleGenerator &n) -> void
Definition ParticleGenerator.cpp:139
auto operator=(const ParticleGenerator &) -> ParticleGenerator &=default
auto operator=(ParticleGenerator &&other) noexcept -> ParticleGenerator &=default
ParticleGenerator()
Definition ParticleGenerator.cpp:27
bool active
whether the generator should currently emit particles
Definition ParticleGenerator.h:132
bool repeats
whether the generator continuously emits particles (true), or emits on a burst
Definition ParticleGenerator.h:134
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition ParticleGenerator.cpp:126
auto linkMessages() -> void
Definition ParticleGenerator.cpp:199
ParticleGenerator(ParticleGenerator &&other) noexcept=default
auto addEmitter() -> void
Creates a new, default constructed Particle Emitter.
Definition ParticleGenerator.cpp:176
friend auto from_json(const json &j, ParticleGenerator &n) -> void
Definition ParticleGenerator.cpp:152
auto onUpdate(float dt) -> void override
called once every frame.
Definition ParticleGenerator.cpp:86
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition ParticleGenerator.h:75
auto deactivate() -> void
deactivates the particle generator, and all of it's emitters If the particle generator is set to repe...
Definition ParticleGenerator.cpp:192
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition ParticleGenerator.cpp:121
auto componentShowMenu() -> void override
Definition ParticleGenerator.cpp:50