Pixelpart 1.8.2
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/ParticleRuntimeId.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 Dictionary inputs;
77
84
88 bool flip_h;
89
93 bool flip_v;
94#endif
95
96 virtual void _enter_tree() override;
97
98 virtual void _process(double dt) override;
99
100 virtual void _draw() override;
101
107 void set_effect(Ref<PixelpartEffectResource> resource);
108
114 Ref<PixelpartEffectResource> get_effect() const;
115
123 void play(bool state);
124
130 void pause();
131
136 void restart();
137
142 void reset();
143
149 bool is_playing() const;
150
156 float get_time() const;
157
163 void set_loop(bool mode);
164
170 bool get_loop() const;
171
179 void set_loop_time(float time);
180
186 float get_loop_time() const;
187
195 void set_warmup_time(float time);
196
202 float get_warmup_time() const;
203
209 void set_speed(float sp);
210
216 float get_speed() const;
217
223 void set_frame_rate(float rate);
224
230 float get_frame_rate() const;
231
239 void set_effect_scale(float scale);
240
246 float get_effect_scale() const;
247
253 void set_flip_h(bool flip);
254
260 void set_flip_v(bool flip);
261
267 bool get_flip_h() const;
268
274 bool get_flip_v() const;
275
283 void set_inputs(Dictionary inputs);
284
292 Dictionary get_inputs() const;
293
300 void set_input_bool(String name, bool value);
301
308 void set_input_int(String name, int value);
309
316 void set_input_float(String name, float value);
317
324 void set_input_float2(String name, Vector2 value);
325
332 void set_input_float3(String name, Vector3 value);
333
340 void set_input_float4(String name, Vector4 value);
341
348 bool get_input_bool(String name) const;
349
356 int get_input_int(String name) const;
357
364 float get_input_float(String name) const;
365
372 Vector2 get_input_float2(String name) const;
373
380 Vector3 get_input_float3(String name) const;
381
388 Vector4 get_input_float4(String name) const;
389
396 int get_input_type(String name) const;
397
403 TypedArray<String> get_input_names() const;
404
410 void activate_trigger(String name);
411
418 bool is_trigger_activated(String name) const;
419
427 void spawn_particles(String particleEmitterName, String particleTypeName, int count);
428
435 Ref<PixelpartNode> find_node(String name) const;
436
443 Ref<PixelpartNode> get_node(int id) const;
444
451 Ref<PixelpartNode> get_node_at_index(int index) const;
452
459 Ref<PixelpartParticleType> find_particle_type(String name) const;
460
467 Ref<PixelpartParticleType> get_particle_type(int id) const;
468
475 Ref<PixelpartParticleType> get_particle_type_at_index(int index) const;
476
485 Ref<PixelpartParticleEmitter> find_particle_emitter(String name) const;
486
495 Ref<PixelpartForceField> find_force_field(String name) const;
496
505 Ref<PixelpartCollider> find_collider(String name) const;
506
515 Ref<PixelpartParticleEmitter> get_particle_emitter(int id) const;
516
525 Ref<PixelpartForceField> get_force_field(int id) const;
526
535 Ref<PixelpartCollider> get_collider(int id) const;
536
545 Ref<PixelpartParticleEmitter> get_particle_emitter_at_index(int index) const;
546
555 Ref<PixelpartForceField> get_force_field_at_index(int index) const;
556
565 Ref<PixelpartCollider> get_collider_at_index(int index) const;
566
567protected:
568 static void _bind_methods();
569
570private:
571 void update_transform();
572
573 Ref<PixelpartEffectResource> effectResource;
574 PixelpartEffectRuntime effectRuntime;
575
576 float effectScale = 100.0f;
577 bool flipH = false;
578 bool flipV = true;
579
580 PixelpartGraphicsResourceProvider graphicsResourceProvider;
581 std::unordered_map<pixelpart::ParticleRuntimeId, std::unique_ptr<PixelpartParticleRenderer2D>> particleRenderers;
582};
583}
584
585#endif
Ref< PixelpartNode > find_node(String name) const
Return the node with the given name.
Definition PixelpartEffect2D.cpp:258
Vector3 get_input_float3(String name) const
Return value of an effect input. The effect input must be of type Vector3.
Definition PixelpartEffect2D.cpp:234
float get_speed() const
Return how fast the effect is being played.
Definition PixelpartEffect2D.cpp:166
int get_input_int(String name) const
Return value of an effect input. The effect input must be of type int.
Definition PixelpartEffect2D.cpp:225
void set_input_float3(String name, Vector3 value)
Definition PixelpartEffect2D.cpp:216
Vector4 get_input_float4(String name) const
Return value of an effect input. The effect input must be of type Vector4.
Definition PixelpartEffect2D.cpp:237
void set_input_bool(String name, bool value)
Definition PixelpartEffect2D.cpp:204
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:193
Ref< PixelpartEffectResource > get_effect() const
Return the effect resource that is being shown.
Definition PixelpartEffect2D.cpp:119
Ref< PixelpartNode > get_node(int id) const
Return the node with the given ID.
Definition PixelpartEffect2D.cpp:261
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:177
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:210
bool get_flip_h() const
Return whether the effect is flipped horizontally.
Definition PixelpartEffect2D.cpp:190
Ref< PixelpartForceField > get_force_field_at_index(int index) const
Return the force field at the given index.
Definition PixelpartEffect2D.cpp:299
Ref< PixelpartParticleType > get_particle_type_at_index(int index) const
Return the particle type at the given index.
Definition PixelpartEffect2D.cpp:274
Ref< PixelpartCollider > get_collider(int id) const
Return the collider with the given ID.
Definition PixelpartEffect2D.cpp:293
void pause()
Pause simulation of the effect.
Definition PixelpartEffect2D.cpp:126
float effect_scale
Multiplier for the size of the effect.
Definition PixelpartEffect2D.h:83
void activate_trigger(String name)
Activate trigger name.
Definition PixelpartEffect2D.cpp:247
void play(bool state)
Start playing or pause simulation of the effect.
Definition PixelpartEffect2D.cpp:123
Ref< PixelpartParticleEmitter > find_particle_emitter(String name) const
Return the particle emitter with the given name.
Definition PixelpartEffect2D.cpp:278
void set_inputs(Dictionary inputs)
Set dictionary of effect input values.
Definition PixelpartEffect2D.cpp:197
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:152
void reset()
Restart the effect, but do not remove existing particles.
Definition PixelpartEffect2D.cpp:132
void set_loop(bool mode)
Set whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.cpp:142
void set_input_float2(String name, Vector2 value)
Definition PixelpartEffect2D.cpp:213
Dictionary inputs
Dictionary of effect input values.
Definition PixelpartEffect2D.h:76
bool is_trigger_activated(String name) const
Return whether trigger name was activated.
Definition PixelpartEffect2D.cpp:250
Ref< PixelpartForceField > find_force_field(String name) const
Return the force field with the given name.
Definition PixelpartEffect2D.cpp:281
Ref< PixelpartParticleEmitter > get_particle_emitter_at_index(int index) const
Return the particle emitter at the given index.
Definition PixelpartEffect2D.cpp:296
void spawn_particles(String particleEmitterName, String particleTypeName, int count)
Generate count particles of the given type from the given emitter.
Definition PixelpartEffect2D.cpp:254
void set_flip_h(bool flip)
Set whether the effect is flipped horizontally.
Definition PixelpartEffect2D.cpp:184
float get_effect_scale() const
Return multiplier for the size of the effect.
Definition PixelpartEffect2D.cpp:180
float get_input_float(String name) const
Return value of an effect input. The effect input must be of type float.
Definition PixelpartEffect2D.cpp:228
float get_warmup_time() const
Return time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.cpp:159
Ref< PixelpartCollider > get_collider_at_index(int index) const
Return the collider at the given index.
Definition PixelpartEffect2D.cpp:302
void set_flip_v(bool flip)
Set whether the effect is flipped vertically.
Definition PixelpartEffect2D.cpp:187
void set_speed(float sp)
Set how fast the effect is being played.
Definition PixelpartEffect2D.cpp:163
float get_frame_rate() const
Return at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.cpp:173
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:240
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:222
Ref< PixelpartParticleEmitter > get_particle_emitter(int id) const
Return the particle emitter with the given ID.
Definition PixelpartEffect2D.cpp:287
Ref< PixelpartParticleType > find_particle_type(String name) const
Return the particle type with the given name.
Definition PixelpartEffect2D.cpp:268
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:290
bool get_loop() const
Return whether the effect restarts automatically after time loop_time.
Definition PixelpartEffect2D.cpp:145
void set_frame_rate(float rate)
Set at which rate the effect is simulated, in frames per second.
Definition PixelpartEffect2D.cpp:170
Ref< PixelpartParticleType > get_particle_type(int id) const
Return the particle type with the given ID.
Definition PixelpartEffect2D.cpp:271
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:243
bool flip_h
Whether the effect is flipped horizontally.
Definition PixelpartEffect2D.h:88
void set_warmup_time(float time)
Set time in seconds the effect is pre-simulated before being rendered.
Definition PixelpartEffect2D.cpp:156
void set_input_float4(String name, Vector4 value)
Definition PixelpartEffect2D.cpp:219
Ref< PixelpartCollider > find_collider(String name) const
Return the collider with the given name.
Definition PixelpartEffect2D.cpp:284
bool is_playing() const
Return whether the effect is currently playing or is paused.
Definition PixelpartEffect2D.cpp:135
bool flip_v
Whether the effect is flipped vertically.
Definition PixelpartEffect2D.h:93
Ref< PixelpartNode > get_node_at_index(int index) const
Return the node at the given index.
Definition PixelpartEffect2D.cpp:264
Dictionary get_inputs() const
Return dictionary of effect input values.
Definition PixelpartEffect2D.cpp:200
void set_input_int(String name, int value)
Definition PixelpartEffect2D.cpp:207
Vector2 get_input_float2(String name) const
Return value of an effect input. The effect input must be of type Vector2.
Definition PixelpartEffect2D.cpp:231
void set_loop_time(float time)
Set time in seconds after which the effect loops.
Definition PixelpartEffect2D.cpp:149
float get_time() const
Return the time in seconds since the effect has started playing.
Definition PixelpartEffect2D.cpp:138
void set_effect(Ref< PixelpartEffectResource > resource)
Change the effect resource that is shown.
Definition PixelpartEffect2D.cpp:82
void restart()
Restart the effect and remove all existing particles.
Definition PixelpartEffect2D.cpp:129
Resource for a Pixelpart effect that is contained in a ppfx file.
Definition PixelpartEffectResource.h:15