Pixelpart 1.8.4
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/PixelpartParticleRenderer2D.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 <memory>
16#include <unordered_map>
17
18namespace godot {
24class PixelpartEffect2D : public Node2D {
25 GDCLASS(PixelpartEffect2D, Node2D)
26
27public:
28 PixelpartEffect2D();
29 virtual ~PixelpartEffect2D();
30
31#ifdef DOXYGEN
36
40 bool playing;
41
45 bool loop;
46
52 float loop_time;
53
60
64 float speed;
65
70
76 int seed;
77
82
88 Dictionary inputs;
89
96
100 bool flip_h;
101
105 bool flip_v;
106#endif
107
108 virtual void _enter_tree() override;
109
110 virtual void _process(double dt) override;
111
112 virtual void _draw() override;
113
119 void set_effect(Ref<PixelpartEffectResource> resource);
120
126 Ref<PixelpartEffectResource> get_effect() const;
127
135 void play(bool state);
136
142 void pause();
143
148 void restart();
149
154 void reset();
155
161 bool is_playing() const;
162
168 float get_time() const;
169
175 void set_loop(bool mode);
176
182 bool get_loop() const;
183
191 void set_loop_time(float time);
192
198 float get_loop_time() const;
199
207 void set_warmup_time(float time);
208
214 float get_warmup_time() const;
215
221 void set_speed(float sp);
222
228 float get_speed() const;
229
235 void set_frame_rate(float rate);
236
242 float get_frame_rate() const;
243
251 void set_seed(int sd);
252
258 int get_seed() const;
259
265 void enable_random_seed(bool mode);
266
272 bool is_random_seed_enabled() const;
273
281 void set_effect_scale(float scale);
282
288 float get_effect_scale() const;
289
295 void set_flip_h(bool flip);
296
302 void set_flip_v(bool flip);
303
309 bool get_flip_h() const;
310
316 bool get_flip_v() const;
317
325 void set_inputs(Dictionary inputs);
326
334 Dictionary get_inputs() const;
335
342 void set_input_bool(String name, bool value);
343
350 void set_input_int(String name, int value);
351
358 void set_input_float(String name, float value);
359
366 void set_input_float2(String name, Vector2 value);
367
374 void set_input_float3(String name, Vector3 value);
375
382 void set_input_float4(String name, Vector4 value);
383
390 bool get_input_bool(String name) const;
391
398 int get_input_int(String name) const;
399
406 float get_input_float(String name) const;
407
414 Vector2 get_input_float2(String name) const;
415
422 Vector3 get_input_float3(String name) const;
423
430 Vector4 get_input_float4(String name) const;
431
438 int get_input_type(String name) const;
439
445 TypedArray<String> get_input_names() const;
446
452 void activate_trigger(String name);
453
460 bool is_trigger_activated(String name) const;
461
469 void spawn_particles(String particleEmitterName, String particleTypeName, int count);
470
477 Ref<PixelpartNode> find_node(String name) const;
478
485 Ref<PixelpartNode> get_node(int id) const;
486
493 Ref<PixelpartNode> get_node_at_index(int index) const;
494
501 Ref<PixelpartParticleType> find_particle_type(String name) const;
502
509 Ref<PixelpartParticleType> get_particle_type(int id) const;
510
517 Ref<PixelpartParticleType> get_particle_type_at_index(int index) const;
518
527 Ref<PixelpartParticleEmitter> find_particle_emitter(String name) const;
528
537 Ref<PixelpartForceField> find_force_field(String name) const;
538
547 Ref<PixelpartCollider> find_collider(String name) const;
548
557 Ref<PixelpartParticleEmitter> get_particle_emitter(int id) const;
558
567 Ref<PixelpartForceField> get_force_field(int id) const;
568
577 Ref<PixelpartCollider> get_collider(int id) const;
578
587 Ref<PixelpartParticleEmitter> get_particle_emitter_at_index(int index) const;
588
597 Ref<PixelpartForceField> get_force_field_at_index(int index) const;
598
607 Ref<PixelpartCollider> get_collider_at_index(int index) const;
608
609protected:
610 static void _bind_methods();
611
612private:
613 void update_transform();
614
615 Ref<PixelpartEffectResource> effectResource;
616 PixelpartEffectRuntime effectRuntime;
617
618 float effectScale = 100.0f;
619 bool flipH = false;
620 bool flipV = true;
621
622 bool finishedSignalEmitted = false;
623
624 PixelpartGraphicsResourceProvider graphicsResourceProvider;
625 std::unordered_map<pixelpart::ParticleEmissionPair, std::unique_ptr<PixelpartParticleRenderer2D>> particleRenderers;
626};
627}
628
629#endif
Ref< PixelpartNode > find_node(String name) const
Return the node with the given name.
Definition PixelpartEffect2D.cpp:289
Vector3 get_input_float3(String name) const
Return value of an effect input. The effect input must be of type Vector3.
Definition PixelpartEffect2D.cpp:265
float get_speed() const
Return how fast the effect is being played.
Definition PixelpartEffect2D.cpp:183
int get_input_int(String name) const
Return value of an effect input. The effect input must be of type int.
Definition PixelpartEffect2D.cpp:256
void set_input_float3(String name, Vector3 value)
Definition PixelpartEffect2D.cpp:247
int seed
Seed used to initialize the effect simulation.
Definition PixelpartEffect2D.h:76
Vector4 get_input_float4(String name) const
Return value of an effect input. The effect input must be of type Vector4.
Definition PixelpartEffect2D.cpp:268
void set_input_bool(String name, bool value)
Definition PixelpartEffect2D.cpp:235
bool loop
Whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.h:45
bool get_flip_v() const
Return whether the effect is flipped vertically.
Definition PixelpartEffect2D.cpp:224
Ref< PixelpartEffectResource > get_effect() const
Return the effect resource that is being shown.
Definition PixelpartEffect2D.cpp:136
Ref< PixelpartNode > get_node(int id) const
Return the node with the given ID.
Definition PixelpartEffect2D.cpp:292
float frame_rate
At which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.h:69
void set_effect_scale(float scale)
Set multiplier for the size of the effect.
Definition PixelpartEffect2D.cpp:208
bool playing
Whether the effect is currently playing or not.
Definition PixelpartEffect2D.h:40
void set_input_float(String name, float value)
Definition PixelpartEffect2D.cpp:241
bool get_flip_h() const
Return whether the effect is flipped horizontally.
Definition PixelpartEffect2D.cpp:221
Ref< PixelpartForceField > get_force_field_at_index(int index) const
Return the force field at the given index.
Definition PixelpartEffect2D.cpp:330
Ref< PixelpartParticleType > get_particle_type_at_index(int index) const
Return the particle type at the given index.
Definition PixelpartEffect2D.cpp:305
Ref< PixelpartCollider > get_collider(int id) const
Return the collider with the given ID.
Definition PixelpartEffect2D.cpp:324
void pause()
Pause simulation of the effect.
Definition PixelpartEffect2D.cpp:143
float effect_scale
Multiplier for the size of the effect.
Definition PixelpartEffect2D.h:95
void activate_trigger(String name)
Activate trigger name.
Definition PixelpartEffect2D.cpp:278
void play(bool state)
Start playing or pause simulation of the effect.
Definition PixelpartEffect2D.cpp:140
Ref< PixelpartParticleEmitter > find_particle_emitter(String name) const
Return the particle emitter with the given name.
Definition PixelpartEffect2D.cpp:309
void set_inputs(Dictionary inputs)
Set dictionary of effect input values.
Definition PixelpartEffect2D.cpp:228
float warmup_time
Time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.h:59
float get_loop_time() const
Return time in seconds after which the effect loops.
Definition PixelpartEffect2D.cpp:169
void reset()
Restart the effect, but do not remove existing particles.
Definition PixelpartEffect2D.cpp:149
void set_loop(bool mode)
Set whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.cpp:159
void set_input_float2(String name, Vector2 value)
Definition PixelpartEffect2D.cpp:244
Dictionary inputs
Dictionary of effect input values.
Definition PixelpartEffect2D.h:88
bool is_trigger_activated(String name) const
Return whether trigger name was activated.
Definition PixelpartEffect2D.cpp:281
Ref< PixelpartForceField > find_force_field(String name) const
Return the force field with the given name.
Definition PixelpartEffect2D.cpp:312
Ref< PixelpartParticleEmitter > get_particle_emitter_at_index(int index) const
Return the particle emitter at the given index.
Definition PixelpartEffect2D.cpp:327
void spawn_particles(String particleEmitterName, String particleTypeName, int count)
Generate count particles of the given type from the given emitter.
Definition PixelpartEffect2D.cpp:285
void set_flip_h(bool flip)
Set whether the effect is flipped horizontally.
Definition PixelpartEffect2D.cpp:215
float get_effect_scale() const
Return multiplier for the size of the effect.
Definition PixelpartEffect2D.cpp:211
float get_input_float(String name) const
Return value of an effect input. The effect input must be of type float.
Definition PixelpartEffect2D.cpp:259
float get_warmup_time() const
Return time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.cpp:176
Ref< PixelpartCollider > get_collider_at_index(int index) const
Return the collider at the given index.
Definition PixelpartEffect2D.cpp:333
void set_flip_v(bool flip)
Set whether the effect is flipped vertically.
Definition PixelpartEffect2D.cpp:218
void set_speed(float sp)
Set how fast the effect is being played.
Definition PixelpartEffect2D.cpp:180
float get_frame_rate() const
Return at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.cpp:190
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:271
float loop_time
Time in seconds after which the effect loops.
Definition PixelpartEffect2D.h:52
bool get_input_bool(String name) const
Return value of an effect input. The effect input must be of type bool.
Definition PixelpartEffect2D.cpp:253
Ref< PixelpartParticleEmitter > get_particle_emitter(int id) const
Return the particle emitter with the given ID.
Definition PixelpartEffect2D.cpp:318
Ref< PixelpartParticleType > find_particle_type(String name) const
Return the particle type with the given name.
Definition PixelpartEffect2D.cpp:299
float speed
How fast the effect is being played.
Definition PixelpartEffect2D.h:64
Ref< PixelpartForceField > get_force_field(int id) const
Return the force field with the given ID.
Definition PixelpartEffect2D.cpp:321
bool get_loop() const
Return whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.cpp:162
void set_frame_rate(float rate)
Set at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.cpp:187
int get_seed() const
Return the seed used to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:197
void enable_random_seed(bool mode)
Use a random seed to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:201
Ref< PixelpartParticleType > get_particle_type(int id) const
Return the particle type with the given ID.
Definition PixelpartEffect2D.cpp:302
PixelpartEffectResource effect
Effect resource that is shown.
Definition PixelpartEffect2D.h:35
TypedArray< String > get_input_names() const
Return names of available effect inputs.
Definition PixelpartEffect2D.cpp:274
bool flip_h
Whether the effect is flipped horizontally.
Definition PixelpartEffect2D.h:100
void set_warmup_time(float time)
Set time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.cpp:173
void set_input_float4(String name, Vector4 value)
Definition PixelpartEffect2D.cpp:250
Ref< PixelpartCollider > find_collider(String name) const
Return the collider with the given name.
Definition PixelpartEffect2D.cpp:315
bool is_playing() const
Return whether the effect is currently playing or is paused.
Definition PixelpartEffect2D.cpp:152
bool flip_v
Whether the effect is flipped vertically.
Definition PixelpartEffect2D.h:105
Ref< PixelpartNode > get_node_at_index(int index) const
Return the node at the given index.
Definition PixelpartEffect2D.cpp:295
bool is_random_seed_enabled() const
Return whether a random seed is used to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:204
Dictionary get_inputs() const
Return dictionary of effect input values.
Definition PixelpartEffect2D.cpp:231
void set_input_int(String name, int value)
Definition PixelpartEffect2D.cpp:238
bool random_seed
Whether to use a random seed to initialize the effect simulation.
Definition PixelpartEffect2D.h:81
Vector2 get_input_float2(String name) const
Return value of an effect input. The effect input must be of type Vector2.
Definition PixelpartEffect2D.cpp:262
void set_loop_time(float time)
Set time in seconds after which the effect loops.
Definition PixelpartEffect2D.cpp:166
void set_seed(int sd)
Set the seed used to initialize the effect simulation.
Definition PixelpartEffect2D.cpp:194
float get_time() const
Return the time in seconds since the effect has started playing.
Definition PixelpartEffect2D.cpp:155
void set_effect(Ref< PixelpartEffectResource > resource)
Change the effect resource that is shown.
Definition PixelpartEffect2D.cpp:98
void restart()
Restart the effect and remove all existing particles.
Definition PixelpartEffect2D.cpp:146
Resource for a Pixelpart effect that is contained in a ppfx file.
Definition PixelpartEffectResource.h:15