1 /** 2 2D particle emitter. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.particles2d; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.node2d; 24 import godot.material; 25 import godot.texture; 26 import godot.canvasitem; 27 import godot.node; 28 /** 29 2D particle emitter. 30 31 2D particle node used to create a variety of particle systems and effects. `Particles2D` features an emitter that generates some number of particles at a given rate. 32 Use the `process_material` property to add a $(D ParticlesMaterial) to configure particle appearance and behavior. Alternatively, you can add a $(D ShaderMaterial) which will be applied to all particles. 33 */ 34 @GodotBaseClass struct Particles2D 35 { 36 enum string _GODOT_internal_name = "Particles2D"; 37 public: 38 @nogc nothrow: 39 union { godot_object _godot_object; Node2D _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct _classBinding 44 { 45 __gshared: 46 @GodotName("set_emitting") GodotMethod!(void, bool) setEmitting; 47 @GodotName("set_amount") GodotMethod!(void, long) setAmount; 48 @GodotName("set_lifetime") GodotMethod!(void, double) setLifetime; 49 @GodotName("set_one_shot") GodotMethod!(void, bool) setOneShot; 50 @GodotName("set_pre_process_time") GodotMethod!(void, double) setPreProcessTime; 51 @GodotName("set_explosiveness_ratio") GodotMethod!(void, double) setExplosivenessRatio; 52 @GodotName("set_randomness_ratio") GodotMethod!(void, double) setRandomnessRatio; 53 @GodotName("set_visibility_rect") GodotMethod!(void, Rect2) setVisibilityRect; 54 @GodotName("set_use_local_coordinates") GodotMethod!(void, bool) setUseLocalCoordinates; 55 @GodotName("set_fixed_fps") GodotMethod!(void, long) setFixedFps; 56 @GodotName("set_fractional_delta") GodotMethod!(void, bool) setFractionalDelta; 57 @GodotName("set_process_material") GodotMethod!(void, Material) setProcessMaterial; 58 @GodotName("set_speed_scale") GodotMethod!(void, double) setSpeedScale; 59 @GodotName("is_emitting") GodotMethod!(bool) isEmitting; 60 @GodotName("get_amount") GodotMethod!(long) getAmount; 61 @GodotName("get_lifetime") GodotMethod!(double) getLifetime; 62 @GodotName("get_one_shot") GodotMethod!(bool) getOneShot; 63 @GodotName("get_pre_process_time") GodotMethod!(double) getPreProcessTime; 64 @GodotName("get_explosiveness_ratio") GodotMethod!(double) getExplosivenessRatio; 65 @GodotName("get_randomness_ratio") GodotMethod!(double) getRandomnessRatio; 66 @GodotName("get_visibility_rect") GodotMethod!(Rect2) getVisibilityRect; 67 @GodotName("get_use_local_coordinates") GodotMethod!(bool) getUseLocalCoordinates; 68 @GodotName("get_fixed_fps") GodotMethod!(long) getFixedFps; 69 @GodotName("get_fractional_delta") GodotMethod!(bool) getFractionalDelta; 70 @GodotName("get_process_material") GodotMethod!(Material) getProcessMaterial; 71 @GodotName("get_speed_scale") GodotMethod!(double) getSpeedScale; 72 @GodotName("set_draw_order") GodotMethod!(void, long) setDrawOrder; 73 @GodotName("get_draw_order") GodotMethod!(Particles2D.DrawOrder) getDrawOrder; 74 @GodotName("set_texture") GodotMethod!(void, Texture) setTexture; 75 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 76 @GodotName("set_normal_map") GodotMethod!(void, Texture) setNormalMap; 77 @GodotName("get_normal_map") GodotMethod!(Texture) getNormalMap; 78 @GodotName("capture_rect") GodotMethod!(Rect2) captureRect; 79 @GodotName("set_v_frames") GodotMethod!(void, long) setVFrames; 80 @GodotName("get_v_frames") GodotMethod!(long) getVFrames; 81 @GodotName("set_h_frames") GodotMethod!(void, long) setHFrames; 82 @GodotName("get_h_frames") GodotMethod!(long) getHFrames; 83 @GodotName("restart") GodotMethod!(void) restart; 84 } 85 bool opEquals(in Particles2D other) const { return _godot_object.ptr is other._godot_object.ptr; } 86 Particles2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 87 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 88 mixin baseCasts; 89 static Particles2D _new() 90 { 91 static godot_class_constructor constructor; 92 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Particles2D"); 93 if(constructor is null) return typeof(this).init; 94 return cast(Particles2D)(constructor()); 95 } 96 @disable new(size_t s); 97 /// 98 enum DrawOrder : int 99 { 100 /** 101 Particles are drawn in the order emitted. 102 */ 103 drawOrderIndex = 0, 104 /** 105 Particles are drawn in order of remaining lifetime. 106 */ 107 drawOrderLifetime = 1, 108 } 109 /// 110 enum Constants : int 111 { 112 drawOrderIndex = 0, 113 drawOrderLifetime = 1, 114 } 115 /** 116 117 */ 118 void setEmitting(in bool emitting) 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(_classBinding.setEmitting, _godot_object, emitting); 122 } 123 /** 124 125 */ 126 void setAmount(in long amount) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(_classBinding.setAmount, _godot_object, amount); 130 } 131 /** 132 133 */ 134 void setLifetime(in double secs) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(_classBinding.setLifetime, _godot_object, secs); 138 } 139 /** 140 141 */ 142 void setOneShot(in bool secs) 143 { 144 checkClassBinding!(typeof(this))(); 145 ptrcall!(void)(_classBinding.setOneShot, _godot_object, secs); 146 } 147 /** 148 149 */ 150 void setPreProcessTime(in double secs) 151 { 152 checkClassBinding!(typeof(this))(); 153 ptrcall!(void)(_classBinding.setPreProcessTime, _godot_object, secs); 154 } 155 /** 156 157 */ 158 void setExplosivenessRatio(in double ratio) 159 { 160 checkClassBinding!(typeof(this))(); 161 ptrcall!(void)(_classBinding.setExplosivenessRatio, _godot_object, ratio); 162 } 163 /** 164 165 */ 166 void setRandomnessRatio(in double ratio) 167 { 168 checkClassBinding!(typeof(this))(); 169 ptrcall!(void)(_classBinding.setRandomnessRatio, _godot_object, ratio); 170 } 171 /** 172 173 */ 174 void setVisibilityRect(in Rect2 visibility_rect) 175 { 176 checkClassBinding!(typeof(this))(); 177 ptrcall!(void)(_classBinding.setVisibilityRect, _godot_object, visibility_rect); 178 } 179 /** 180 181 */ 182 void setUseLocalCoordinates(in bool enable) 183 { 184 checkClassBinding!(typeof(this))(); 185 ptrcall!(void)(_classBinding.setUseLocalCoordinates, _godot_object, enable); 186 } 187 /** 188 189 */ 190 void setFixedFps(in long fps) 191 { 192 checkClassBinding!(typeof(this))(); 193 ptrcall!(void)(_classBinding.setFixedFps, _godot_object, fps); 194 } 195 /** 196 197 */ 198 void setFractionalDelta(in bool enable) 199 { 200 checkClassBinding!(typeof(this))(); 201 ptrcall!(void)(_classBinding.setFractionalDelta, _godot_object, enable); 202 } 203 /** 204 205 */ 206 void setProcessMaterial(Material material) 207 { 208 checkClassBinding!(typeof(this))(); 209 ptrcall!(void)(_classBinding.setProcessMaterial, _godot_object, material); 210 } 211 /** 212 213 */ 214 void setSpeedScale(in double scale) 215 { 216 checkClassBinding!(typeof(this))(); 217 ptrcall!(void)(_classBinding.setSpeedScale, _godot_object, scale); 218 } 219 /** 220 221 */ 222 bool isEmitting() const 223 { 224 checkClassBinding!(typeof(this))(); 225 return ptrcall!(bool)(_classBinding.isEmitting, _godot_object); 226 } 227 /** 228 229 */ 230 long getAmount() const 231 { 232 checkClassBinding!(typeof(this))(); 233 return ptrcall!(long)(_classBinding.getAmount, _godot_object); 234 } 235 /** 236 237 */ 238 double getLifetime() const 239 { 240 checkClassBinding!(typeof(this))(); 241 return ptrcall!(double)(_classBinding.getLifetime, _godot_object); 242 } 243 /** 244 245 */ 246 bool getOneShot() const 247 { 248 checkClassBinding!(typeof(this))(); 249 return ptrcall!(bool)(_classBinding.getOneShot, _godot_object); 250 } 251 /** 252 253 */ 254 double getPreProcessTime() const 255 { 256 checkClassBinding!(typeof(this))(); 257 return ptrcall!(double)(_classBinding.getPreProcessTime, _godot_object); 258 } 259 /** 260 261 */ 262 double getExplosivenessRatio() const 263 { 264 checkClassBinding!(typeof(this))(); 265 return ptrcall!(double)(_classBinding.getExplosivenessRatio, _godot_object); 266 } 267 /** 268 269 */ 270 double getRandomnessRatio() const 271 { 272 checkClassBinding!(typeof(this))(); 273 return ptrcall!(double)(_classBinding.getRandomnessRatio, _godot_object); 274 } 275 /** 276 277 */ 278 Rect2 getVisibilityRect() const 279 { 280 checkClassBinding!(typeof(this))(); 281 return ptrcall!(Rect2)(_classBinding.getVisibilityRect, _godot_object); 282 } 283 /** 284 285 */ 286 bool getUseLocalCoordinates() const 287 { 288 checkClassBinding!(typeof(this))(); 289 return ptrcall!(bool)(_classBinding.getUseLocalCoordinates, _godot_object); 290 } 291 /** 292 293 */ 294 long getFixedFps() const 295 { 296 checkClassBinding!(typeof(this))(); 297 return ptrcall!(long)(_classBinding.getFixedFps, _godot_object); 298 } 299 /** 300 301 */ 302 bool getFractionalDelta() const 303 { 304 checkClassBinding!(typeof(this))(); 305 return ptrcall!(bool)(_classBinding.getFractionalDelta, _godot_object); 306 } 307 /** 308 309 */ 310 Ref!Material getProcessMaterial() const 311 { 312 checkClassBinding!(typeof(this))(); 313 return ptrcall!(Material)(_classBinding.getProcessMaterial, _godot_object); 314 } 315 /** 316 317 */ 318 double getSpeedScale() const 319 { 320 checkClassBinding!(typeof(this))(); 321 return ptrcall!(double)(_classBinding.getSpeedScale, _godot_object); 322 } 323 /** 324 325 */ 326 void setDrawOrder(in long order) 327 { 328 checkClassBinding!(typeof(this))(); 329 ptrcall!(void)(_classBinding.setDrawOrder, _godot_object, order); 330 } 331 /** 332 333 */ 334 Particles2D.DrawOrder getDrawOrder() const 335 { 336 checkClassBinding!(typeof(this))(); 337 return ptrcall!(Particles2D.DrawOrder)(_classBinding.getDrawOrder, _godot_object); 338 } 339 /** 340 341 */ 342 void setTexture(Texture texture) 343 { 344 checkClassBinding!(typeof(this))(); 345 ptrcall!(void)(_classBinding.setTexture, _godot_object, texture); 346 } 347 /** 348 349 */ 350 Ref!Texture getTexture() const 351 { 352 checkClassBinding!(typeof(this))(); 353 return ptrcall!(Texture)(_classBinding.getTexture, _godot_object); 354 } 355 /** 356 357 */ 358 void setNormalMap(Texture texture) 359 { 360 checkClassBinding!(typeof(this))(); 361 ptrcall!(void)(_classBinding.setNormalMap, _godot_object, texture); 362 } 363 /** 364 365 */ 366 Ref!Texture getNormalMap() const 367 { 368 checkClassBinding!(typeof(this))(); 369 return ptrcall!(Texture)(_classBinding.getNormalMap, _godot_object); 370 } 371 /** 372 373 */ 374 Rect2 captureRect() const 375 { 376 checkClassBinding!(typeof(this))(); 377 return ptrcall!(Rect2)(_classBinding.captureRect, _godot_object); 378 } 379 /** 380 381 */ 382 void setVFrames(in long frames) 383 { 384 checkClassBinding!(typeof(this))(); 385 ptrcall!(void)(_classBinding.setVFrames, _godot_object, frames); 386 } 387 /** 388 389 */ 390 long getVFrames() const 391 { 392 checkClassBinding!(typeof(this))(); 393 return ptrcall!(long)(_classBinding.getVFrames, _godot_object); 394 } 395 /** 396 397 */ 398 void setHFrames(in long frames) 399 { 400 checkClassBinding!(typeof(this))(); 401 ptrcall!(void)(_classBinding.setHFrames, _godot_object, frames); 402 } 403 /** 404 405 */ 406 long getHFrames() const 407 { 408 checkClassBinding!(typeof(this))(); 409 return ptrcall!(long)(_classBinding.getHFrames, _godot_object); 410 } 411 /** 412 413 */ 414 void restart() 415 { 416 checkClassBinding!(typeof(this))(); 417 ptrcall!(void)(_classBinding.restart, _godot_object); 418 } 419 /** 420 If `true` particles are being emitted. Default value: `true`. 421 */ 422 @property bool emitting() 423 { 424 return isEmitting(); 425 } 426 /// ditto 427 @property void emitting(bool v) 428 { 429 setEmitting(v); 430 } 431 /** 432 Number of particles emitted in one emission cycle. 433 */ 434 @property long amount() 435 { 436 return getAmount(); 437 } 438 /// ditto 439 @property void amount(long v) 440 { 441 setAmount(v); 442 } 443 /** 444 Amount of time each particle will exist. Default value: `1`. 445 */ 446 @property double lifetime() 447 { 448 return getLifetime(); 449 } 450 /// ditto 451 @property void lifetime(double v) 452 { 453 setLifetime(v); 454 } 455 /** 456 If `true` only one emission cycle occurs. If set `true` during a cycle, emission will stop at the cycle's end. Default value: `false`. 457 */ 458 @property bool oneShot() 459 { 460 return getOneShot(); 461 } 462 /// ditto 463 @property void oneShot(bool v) 464 { 465 setOneShot(v); 466 } 467 /** 468 Particle system starts as if it had already run for this many seconds. 469 */ 470 @property double preprocess() 471 { 472 return getPreProcessTime(); 473 } 474 /// ditto 475 @property void preprocess(double v) 476 { 477 setPreProcessTime(v); 478 } 479 /** 480 Particle system's running speed scaling ratio. Default value: `1`. A value of `0` can be used to pause the particles. 481 */ 482 @property double speedScale() 483 { 484 return getSpeedScale(); 485 } 486 /// ditto 487 @property void speedScale(double v) 488 { 489 setSpeedScale(v); 490 } 491 /** 492 How rapidly particles in an emission cycle are emitted. If greater than `0`, there will be a gap in emissions before the next cycle begins. Default value: `0`. 493 */ 494 @property double explosiveness() 495 { 496 return getExplosivenessRatio(); 497 } 498 /// ditto 499 @property void explosiveness(double v) 500 { 501 setExplosivenessRatio(v); 502 } 503 /** 504 Emission lifetime randomness ratio. Default value: `0`. 505 */ 506 @property double randomness() 507 { 508 return getRandomnessRatio(); 509 } 510 /// ditto 511 @property void randomness(double v) 512 { 513 setRandomnessRatio(v); 514 } 515 /** 516 517 */ 518 @property long fixedFps() 519 { 520 return getFixedFps(); 521 } 522 /// ditto 523 @property void fixedFps(long v) 524 { 525 setFixedFps(v); 526 } 527 /** 528 529 */ 530 @property bool fractDelta() 531 { 532 return getFractionalDelta(); 533 } 534 /// ditto 535 @property void fractDelta(bool v) 536 { 537 setFractionalDelta(v); 538 } 539 /** 540 Editor visibility helper. 541 */ 542 @property Rect2 visibilityRect() 543 { 544 return getVisibilityRect(); 545 } 546 /// ditto 547 @property void visibilityRect(Rect2 v) 548 { 549 setVisibilityRect(v); 550 } 551 /** 552 If `true` particles use the parent node's coordinate space. If `false` they use global coordinates. Default value: `true`. 553 */ 554 @property bool localCoords() 555 { 556 return getUseLocalCoordinates(); 557 } 558 /// ditto 559 @property void localCoords(bool v) 560 { 561 setUseLocalCoordinates(v); 562 } 563 /** 564 Particle draw order. Uses `DRAW_ORDER_*` values. Default value: `DRAW_ORDER_INDEX`. 565 */ 566 @property Particles2D.DrawOrder drawOrder() 567 { 568 return getDrawOrder(); 569 } 570 /// ditto 571 @property void drawOrder(long v) 572 { 573 setDrawOrder(v); 574 } 575 /** 576 Particle texture. If `null` particles will be squares. 577 */ 578 @property Texture texture() 579 { 580 return getTexture(); 581 } 582 /// ditto 583 @property void texture(Texture v) 584 { 585 setTexture(v); 586 } 587 /** 588 589 */ 590 @property Texture normalMap() 591 { 592 return getNormalMap(); 593 } 594 /// ditto 595 @property void normalMap(Texture v) 596 { 597 setNormalMap(v); 598 } 599 /** 600 Number of horizontal frames in `texture`. 601 */ 602 @property long hFrames() 603 { 604 return getHFrames(); 605 } 606 /// ditto 607 @property void hFrames(long v) 608 { 609 setHFrames(v); 610 } 611 /** 612 Number of vertical frames in `texture`. 613 */ 614 @property long vFrames() 615 { 616 return getVFrames(); 617 } 618 /// ditto 619 @property void vFrames(long v) 620 { 621 setVFrames(v); 622 } 623 }