Pixelpart 1.10.0
Godot Plugin
Loading...
Searching...
No Matches
PixelpartEffect2D.h
1#ifndef PIXELPART_EFFECT_2D_H
2#define PIXELPART_EFFECT_2D_H
3
4#include "PixelpartEffectResource.h"
5#include "PixelpartEffectRuntime.h"
6#include "rendering/PixelpartGraphicsResourceProvider.h"
7#include "rendering/PixelpartParticleCanvasItem.h"
8#include "particletype/PixelpartParticleType.h"
9#include "node/PixelpartParticleEmitter.h"
10#include "node/PixelpartForceField.h"
11#include "node/PixelpartCollider.h"
12#include <pixelpart-runtime/effect/ParticleEmissionPair.h>
13#include <godot_cpp/core/binder_common.hpp>
14#include <godot_cpp/classes/node2d.hpp>
15#include <cstdint>
16#include <memory>
17#include <unordered_map>
18
19namespace godot {
30class PixelpartEffect2D : public Node2D {
31 GDCLASS(PixelpartEffect2D, Node2D)
32
33public:
34 PixelpartEffect2D();
35 virtual ~PixelpartEffect2D();
36
37#ifdef DOXYGEN
42
46 bool playing;
47
51 bool loop;
52
58 float loop_time;
59
66
70 float speed;
71
76
82 int seed;
83
88
94 Dictionary inputs;
95
102
106 bool flip_h;
107
111 bool flip_v;
112#endif
113
114 virtual void _enter_tree() override;
115
116 virtual void _process(double dt) override;
117
118 virtual void _draw() override;
119
120 void _notification(int p_what);
121
127 void set_effect(Ref<PixelpartEffectResource> resource);
128
134 Ref<PixelpartEffectResource> get_effect() const;
135
143 void play(bool state = true);
144
150 void pause();
151
157 void restart(bool clear = true);
158
164 void reset();
165
171 bool is_playing() const;
172
178 float get_time() const;
179
185 void set_loop(bool mode);
186
192 bool get_loop() const;
193
201 void set_loop_time(float time);
202
208 float get_loop_time() const;
209
217 void set_warmup_time(float time);
218
224 float get_warmup_time() const;
225
231 void set_speed(float sp);
232
238 float get_speed() const;
239
245 void set_frame_rate(float rate);
246
252 float get_frame_rate() const;
253
261 void set_seed(int sd);
262
268 int get_seed() const;
269
275 void enable_random_seed(bool mode);
276
282 bool is_random_seed_enabled() const;
283
291 void set_effect_scale(float scale);
292
298 float get_effect_scale() const;
299
305 void set_flip_h(bool flip);
306
312 void set_flip_v(bool flip);
313
319 bool get_flip_h() const;
320
326 bool get_flip_v() const;
327
335 void set_inputs(Dictionary inputs);
336
344 Dictionary get_inputs() const;
345
352 void set_input_bool(String name, bool value);
353
360 void set_input_int(String name, int value);
361
368 void set_input_float(String name, float value);
369
376 void set_input_float2(String name, Vector2 value);
377
384 void set_input_float3(String name, Vector3 value);
385
392 void set_input_float4(String name, Vector4 value);
393
400 bool get_input_bool(String name) const;
401
408 int get_input_int(String name) const;
409
416 float get_input_float(String name) const;
417
424 Vector2 get_input_float2(String name) const;
425
432 Vector3 get_input_float3(String name) const;
433
440 Vector4 get_input_float4(String name) const;
441
448 int get_input_type(String name) const;
449
455 TypedArray<String> get_input_names() const;
456
462 void activate_trigger(String name);
463
470 bool is_trigger_activated(String name) const;
471
479 void spawn_particles(String particleEmitterName, String particleTypeName, int count);
480
487 Ref<PixelpartNode> find_effect_node(String name) const;
488
495 Ref<PixelpartNode> get_effect_node(int id) const;
496
503 Ref<PixelpartNode> get_effect_node_at_index(int index) const;
504
511 Ref<PixelpartParticleType> find_particle_type(String name) const;
512
519 Ref<PixelpartParticleType> get_particle_type(int id) const;
520
527 Ref<PixelpartParticleType> get_particle_type_at_index(int index) const;
528
529#ifdef DOXYGEN
538 Ref<PixelpartNode> find_node(String name) const;
539
548 Ref<PixelpartNode> get_node_at_index(int index) const;
549#endif
550
551protected:
552 static void _bind_methods();
553
554private:
555 void apply_transform();
556 void apply_lod();
557
558 Ref<PixelpartEffectResource> effectResource;
559 PixelpartEffectRuntime effectRuntime;
560 bool editorPreviewEnabled = true;
561
562 float effectScale = 100.0f;
563 bool flipH = false;
564 bool flipV = true;
565
566 bool finishedSignalEmitted = false;
567
568 PixelpartGraphicsResourceProvider graphicsResourceProvider;
569 std::unordered_map<pixelpart::ParticleEmissionPair, std::unique_ptr<PixelpartParticleCanvasItem>> particleCanvasItems;
570};
571}
572
573#endif
Ref< PixelpartNode > find_node(String name) const
Return the effect node with the given name.
Vector3 get_input_float3(String name) const
Return value of an effect input. The effect input must be of type Vector3.
Definition PixelpartEffect2D.cpp:284
float get_speed() const
Return how fast the effect is being played.
Definition PixelpartEffect2D.cpp:199
int get_input_int(String name) const
Return value of an effect input. The effect input must be of type int.
Definition PixelpartEffect2D.cpp:275
void set_input_float3(String name, Vector3 value)
Definition PixelpartEffect2D.cpp:266
int seed
Seed used to initialize the effect simulation.
Definition PixelpartEffect2D.h:82
Ref< PixelpartNode > get_effect_node(int id) const
Return the effect node with the given ID.
Definition PixelpartEffect2D.cpp:311
Vector4 get_input_float4(String name) const
Return value of an effect input. The effect input must be of type Vector4.
Definition PixelpartEffect2D.cpp:287
void set_input_bool(String name, bool value)
Definition PixelpartEffect2D.cpp:254
bool loop
Whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.h:51
bool get_flip_v() const
Return whether the effect is flipped vertically.
Definition PixelpartEffect2D.cpp:243
Ref< PixelpartEffectResource > get_effect() const
Return the effect resource that is being shown.
Definition PixelpartEffect2D.cpp:152
float frame_rate
At which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.h:75
void set_effect_scale(float scale)
Set multiplier for the size of the effect.
Definition PixelpartEffect2D.cpp:224
bool playing
Whether the effect is currently playing or not.
Definition PixelpartEffect2D.h:46
void set_input_float(String name, float value)
Definition PixelpartEffect2D.cpp:260
bool get_flip_h() const
Return whether the effect is flipped horizontally.
Definition PixelpartEffect2D.cpp:240
void restart(bool clear=true)
Restart the effect.
Definition PixelpartEffect2D.cpp:162
Ref< PixelpartParticleType > get_particle_type_at_index(int index) const
Return the particle type at the given index.
Definition PixelpartEffect2D.cpp:324
void pause()
Pause simulation of the effect.
Definition PixelpartEffect2D.cpp:159
float effect_scale
Multiplier for the size of the effect.
Definition PixelpartEffect2D.h:101
void activate_trigger(String name)
Activate trigger name.
Definition PixelpartEffect2D.cpp:297
void set_inputs(Dictionary inputs)
Set dictionary of effect input values.
Definition PixelpartEffect2D.cpp:247
float warmup_time
Time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.h:65
float get_loop_time() const
Return time in seconds after which the effect loops.
Definition PixelpartEffect2D.cpp:185
void reset()
Restart the effect, but do not remove existing particles.
Definition PixelpartEffect2D.cpp:165
void set_loop(bool mode)
Set whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.cpp:175
void set_input_float2(String name, Vector2 value)
Definition PixelpartEffect2D.cpp:263
Dictionary inputs
Dictionary of effect input values.
Definition PixelpartEffect2D.h:94
bool is_trigger_activated(String name) const
Return whether trigger name was activated.
Definition PixelpartEffect2D.cpp:300
void spawn_particles(String particleEmitterName, String particleTypeName, int count)
Generate count particles of the given type from the given emitter.
Definition PixelpartEffect2D.cpp:304
void set_flip_h(bool flip)
Set whether the effect is flipped horizontally.
Definition PixelpartEffect2D.cpp:232
float get_effect_scale() const
Return multiplier for the size of the effect.
Definition PixelpartEffect2D.cpp:228
Ref< PixelpartNode > get_effect_node_at_index(int index) const
Return the effect node at the given index.
Definition PixelpartEffect2D.cpp:314
float get_input_float(String name) const
Return value of an effect input. The effect input must be of type float.
Definition PixelpartEffect2D.cpp:278
Ref< PixelpartNode > find_effect_node(String name) const
Return the effect node with the given name.
Definition PixelpartEffect2D.cpp:308
float get_warmup_time() const
Return time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.cpp:192
void set_flip_v(bool flip)
Set whether the effect is flipped vertically.
Definition PixelpartEffect2D.cpp:236
void set_speed(float sp)
Set how fast the effect is being played.
Definition PixelpartEffect2D.cpp:196
float get_frame_rate() const
Return at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.cpp:206
int get_input_type(String name) const
Return the type of an effect input or -1 if the effect input does not exist.
Definition PixelpartEffect2D.cpp:290
float loop_time
Time in seconds after which the effect loops.
Definition PixelpartEffect2D.h:58
bool get_input_bool(String name) const
Return value of an effect input. The effect input must be of type bool.
Definition PixelpartEffect2D.cpp:272
Ref< PixelpartParticleType > find_particle_type(String name) const
Return the particle type with the given name.
Definition PixelpartEffect2D.cpp:318
float speed
How fast the effect is being played.
Definition PixelpartEffect2D.h:70
bool get_loop() const
Return whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.cpp:178
void set_frame_rate(float rate)
Set at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.cpp:203
int get_seed() const
Return the seed used to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:213
void enable_random_seed(bool mode)
Use a random seed to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:217
Ref< PixelpartParticleType > get_particle_type(int id) const
Return the particle type with the given ID.
Definition PixelpartEffect2D.cpp:321
PixelpartEffectResource effect
Effect resource that is shown.
Definition PixelpartEffect2D.h:41
TypedArray< String > get_input_names() const
Return names of available effect inputs.
Definition PixelpartEffect2D.cpp:293
bool flip_h
Whether the effect is flipped horizontally.
Definition PixelpartEffect2D.h:106
void set_warmup_time(float time)
Set time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.cpp:189
void set_input_float4(String name, Vector4 value)
Definition PixelpartEffect2D.cpp:269
void play(bool state=true)
Start playing or pause simulation of the effect.
Definition PixelpartEffect2D.cpp:156
bool is_playing() const
Return whether the effect is currently playing or is paused.
Definition PixelpartEffect2D.cpp:168
bool flip_v
Whether the effect is flipped vertically.
Definition PixelpartEffect2D.h:111
Ref< PixelpartNode > get_node_at_index(int index) const
Return the effect node at the given index.
bool is_random_seed_enabled() const
Return whether a random seed is used to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:220
Dictionary get_inputs() const
Return dictionary of effect input values.
Definition PixelpartEffect2D.cpp:250
void set_input_int(String name, int value)
Definition PixelpartEffect2D.cpp:257
bool random_seed
Whether to use a random seed to initialize the effect simulation.
Definition PixelpartEffect2D.h:87
Vector2 get_input_float2(String name) const
Return value of an effect input. The effect input must be of type Vector2.
Definition PixelpartEffect2D.cpp:281
void set_loop_time(float time)
Set time in seconds after which the effect loops.
Definition PixelpartEffect2D.cpp:182
void set_seed(int sd)
Set the seed used to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:210
float get_time() const
Return the time in seconds since the effect has started playing.
Definition PixelpartEffect2D.cpp:171
void set_effect(Ref< PixelpartEffectResource > resource)
Change the effect resource that is shown.
Definition PixelpartEffect2D.cpp:107
Resource for a Pixelpart effect that is contained in a ppfx file.
Definition PixelpartEffectResource.h:15