From fbc3a59652fd828de4842ff61a59f3e548c99cb1 Mon Sep 17 00:00:00 2001 From: Marinho Brandao Date: Thu, 14 Dec 2023 08:33:49 +0100 Subject: [PATCH] Hexagon mosaic, implosion, shockwave --- camera-effects.tscn | 6 +- camera-effects/hexagon-mosaic.gdshader | 25 +++++ camera-effects/hexagon_mosaic.tscn | 15 +++ environments/black-environment.tres | 3 +- godot-visual-effects.csproj | 9 ++ godot-visual-effects.sln | 19 ++++ particle-effects.tscn | 19 ++-- particles/implosion.tscn | 128 +++++++++++++++++++++++++ particles/shockwave.tscn | 87 +++++++++++++++++ particles/sparks.tscn | 15 +-- scripts/MultiParticles.cs | 95 +++++++++--------- 11 files changed, 353 insertions(+), 68 deletions(-) create mode 100644 camera-effects/hexagon-mosaic.gdshader create mode 100644 camera-effects/hexagon_mosaic.tscn create mode 100644 godot-visual-effects.csproj create mode 100644 godot-visual-effects.sln create mode 100644 particles/implosion.tscn create mode 100644 particles/shockwave.tscn diff --git a/camera-effects.tscn b/camera-effects.tscn index f8bdb42..da33fc4 100644 --- a/camera-effects.tscn +++ b/camera-effects.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://c051w6upl0t16"] +[gd_scene load_steps=16 format=3 uid="uid://c051w6upl0t16"] [ext_resource type="PackedScene" uid="uid://bydyult2k5rcb" path="res://addons/kenney_prototype_tools/scenes/green/green_01.tscn" id="1_61jfr"] [ext_resource type="PackedScene" uid="uid://bjupt5nu14hth" path="res://addons/kenney_prototype_tools/scenes/dark/dark_05.tscn" id="2_xlmfj"] @@ -11,6 +11,7 @@ [ext_resource type="PackedScene" uid="uid://ds5xw2us1br3q" path="res://camera-effects/vignette.tscn" id="9_q1phu"] [ext_resource type="PackedScene" uid="uid://dv3o1u4hc11vn" path="res://camera-effects/sepia.tscn" id="10_rqewe"] [ext_resource type="PackedScene" uid="uid://cf1adbox8xy7e" path="res://camera-effects/grain_noise.tscn" id="11_3qobw"] +[ext_resource type="PackedScene" uid="uid://dwppksddt4t0x" path="res://camera-effects/hexagon_mosaic.tscn" id="12_uvrob"] [sub_resource type="Environment" id="Environment_tln01"] glow_blend_mode = 4 @@ -165,3 +166,6 @@ visible = false visible = false [node name="Grain Noise" parent="CanvasLayer" instance=ExtResource("11_3qobw")] +visible = false + +[node name="Hexagon Mosaic" parent="CanvasLayer" instance=ExtResource("12_uvrob")] diff --git a/camera-effects/hexagon-mosaic.gdshader b/camera-effects/hexagon-mosaic.gdshader new file mode 100644 index 0000000..a1d4d30 --- /dev/null +++ b/camera-effects/hexagon-mosaic.gdshader @@ -0,0 +1,25 @@ +shader_type canvas_item; + +// source: https://docs.godotengine.org/en/4.0/tutorials/shaders/custom_postprocessing.html + +uniform vec2 size = vec2(32.0, 28.0); +uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; + +void fragment() { + vec2 norm_size = size * SCREEN_PIXEL_SIZE; + bool half = mod(SCREEN_UV.y / 2.0, norm_size.y) / norm_size.y < 0.5; + vec2 uv = SCREEN_UV + vec2(norm_size.x * 0.5 * float(half), 0.0); + vec2 center_uv = floor(uv / norm_size) * norm_size; + vec2 norm_uv = mod(uv, norm_size) / norm_size; + center_uv += mix(vec2(0.0, 0.0), + mix(mix(vec2(norm_size.x, -norm_size.y), + vec2(0.0, -norm_size.y), + float(norm_uv.x < 0.5)), + mix(vec2(0.0, -norm_size.y), + vec2(-norm_size.x, -norm_size.y), + float(norm_uv.x < 0.5)), + float(half)), + float(norm_uv.y < 0.3333333) * float(norm_uv.y / 0.3333333 < (abs(norm_uv.x - 0.5) * 2.0))); + + COLOR = textureLod(screen_texture, center_uv, 0.0); +} \ No newline at end of file diff --git a/camera-effects/hexagon_mosaic.tscn b/camera-effects/hexagon_mosaic.tscn new file mode 100644 index 0000000..a1c88bf --- /dev/null +++ b/camera-effects/hexagon_mosaic.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://dwppksddt4t0x"] + +[ext_resource type="Shader" path="res://camera-effects/hexagon-mosaic.gdshader" id="1_mlp7a"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_wpu0h"] +shader = ExtResource("1_mlp7a") +shader_parameter/size = Vector2(16, 14) + +[node name="Hexagon Mosaic" type="ColorRect"] +material = SubResource("ShaderMaterial_wpu0h") +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/environments/black-environment.tres b/environments/black-environment.tres index c1eb86a..aecfe32 100644 --- a/environments/black-environment.tres +++ b/environments/black-environment.tres @@ -3,6 +3,7 @@ [resource] background_mode = 1 glow_enabled = true -glow_blend_mode = 4 +glow_strength = 1.1 +glow_blend_mode = 0 fog_light_energy = 0.82 fog_sun_scatter = 0.15 diff --git a/godot-visual-effects.csproj b/godot-visual-effects.csproj new file mode 100644 index 0000000..892c0e3 --- /dev/null +++ b/godot-visual-effects.csproj @@ -0,0 +1,9 @@ + + + net6.0 + net7.0 + net8.0 + true + godotvisualeffects + + \ No newline at end of file diff --git a/godot-visual-effects.sln b/godot-visual-effects.sln new file mode 100644 index 0000000..885dc78 --- /dev/null +++ b/godot-visual-effects.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "godot-visual-effects", "godot-visual-effects.csproj", "{480A32A8-1426-4EFE-9E53-145C2A6D2882}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {480A32A8-1426-4EFE-9E53-145C2A6D2882}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {480A32A8-1426-4EFE-9E53-145C2A6D2882}.Debug|Any CPU.Build.0 = Debug|Any CPU + {480A32A8-1426-4EFE-9E53-145C2A6D2882}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {480A32A8-1426-4EFE-9E53-145C2A6D2882}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {480A32A8-1426-4EFE-9E53-145C2A6D2882}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {480A32A8-1426-4EFE-9E53-145C2A6D2882}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/particle-effects.tscn b/particle-effects.tscn index 30f428c..90ec27c 100644 --- a/particle-effects.tscn +++ b/particle-effects.tscn @@ -1,14 +1,16 @@ -[gd_scene load_steps=12 format=3 uid="uid://chomobsn1vdo4"] +[gd_scene load_steps=14 format=3 uid="uid://chomobsn1vdo4"] [ext_resource type="Environment" uid="uid://dxrk0u62aekxt" path="res://environments/black-environment.tres" id="1_k1rat"] [ext_resource type="PackedScene" uid="uid://cxj4cf67il71y" path="res://particles/smoke.tscn" id="1_vs4eb"] [ext_resource type="PackedScene" uid="uid://c4g1wgyk5ynef" path="res://particles/fire.tscn" id="2_ua5o7"] [ext_resource type="PackedScene" uid="uid://bdwxckix3vslo" path="res://particles/hurricane.tscn" id="3_1jf4n"] -[ext_resource type="PackedScene" uid="uid://ce6advdj56x0c" path="res://particles/hyperdrive.tscn" id="4_waeec"] +[ext_resource type="PackedScene" path="res://particles/hyperdrive.tscn" id="4_waeec"] [ext_resource type="PackedScene" uid="uid://b2dthk7xytysh" path="res://particles/shield.tscn" id="5_iqqai"] -[ext_resource type="PackedScene" uid="uid://ck5vuhi3tffgl" path="res://particles/sparks.tscn" id="6_n8y86"] +[ext_resource type="PackedScene" uid="uid://1p0djdxytw42" path="res://particles/sparks.tscn" id="6_n8y86"] [ext_resource type="PackedScene" uid="uid://1nbihtdf4hnv" path="res://particles/rain.tscn" id="8_pqidy"] [ext_resource type="PackedScene" uid="uid://jyk4uwcupa50" path="res://particles/impact.tscn" id="9_x76w5"] +[ext_resource type="PackedScene" uid="uid://brf0ftux0hwy8" path="res://particles/shockwave.tscn" id="10_e5e8r"] +[ext_resource type="PackedScene" uid="uid://10u16dtnpupt" path="res://particles/implosion.tscn" id="11_df01b"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_njwlo"] shading_mode = 0 @@ -23,7 +25,6 @@ size = Vector2(10, 10) [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(0.707107, -0.40558, 0.579228, 0, 0.819152, 0.573576, -0.707107, -0.40558, 0.579228, 30, 30, 30) environment = ExtResource("1_k1rat") -projection = 1 current = true fov = 3.8 size = 3.0 @@ -57,18 +58,18 @@ visible = false visible = false [node name="Sparks" parent="." instance=ExtResource("6_n8y86")] -visible = false [node name="Rain" parent="." instance=ExtResource("8_pqidy")] visible = false [node name="Impact" parent="." instance=ExtResource("9_x76w5")] +visible = false -[node name="Shockwave" type="Node3D" parent="."] +[node name="Shockwave" parent="." instance=ExtResource("10_e5e8r")] +visible = false + +[node name="Implosion" parent="." instance=ExtResource("11_df01b")] visible = false [node name="Electricity" type="Node3D" parent="."] visible = false - -[node name="Implosion" type="Node3D" parent="."] -visible = false diff --git a/particles/implosion.tscn b/particles/implosion.tscn new file mode 100644 index 0000000..99e22ed --- /dev/null +++ b/particles/implosion.tscn @@ -0,0 +1,128 @@ +[gd_scene load_steps=23 format=3 uid="uid://10u16dtnpupt"] + +[ext_resource type="Script" path="res://scripts/MultiParticles.cs" id="1_weson"] +[ext_resource type="Texture2D" uid="uid://b8yqiftn6q2ij" path="res://addons/kenney_particle_pack/circle_05.png" id="2_qtlvw"] + +[sub_resource type="Curve" id="Curve_tpndr"] +_data = [Vector2(0.782074, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_wtgks"] +curve = SubResource("Curve_tpndr") + +[sub_resource type="Curve" id="Curve_7t07v"] +min_value = -5.0 +max_value = 5.0 +_data = [Vector2(0, -5), 0.0, 0.0, 0, 0, Vector2(0.495606, -5), 0.0, 0.0, 0, 0, Vector2(1, 0.00593328), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_8froe"] +curve = SubResource("Curve_7t07v") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_50j2f"] +emission_shape = 2 +emission_sphere_radius = 3.0 +gravity = Vector3(2.08165e-12, 2.08165e-12, 2.08165e-12) +radial_accel_min = 0.2 +radial_accel_max = 0.2 +radial_accel_curve = SubResource("CurveTexture_8froe") +color = Color(0, 0.564706, 1, 1) +alpha_curve = SubResource("CurveTexture_wtgks") + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_blklt"] +transparency = 1 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("2_qtlvw") +emission_enabled = true +emission = Color(0, 0.741176, 1, 1) +emission_energy_multiplier = 5.0 +rim_enabled = true +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 1 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="QuadMesh" id="QuadMesh_lxuhl"] +material = SubResource("StandardMaterial3D_blklt") +size = Vector2(0.1, 0.1) + +[sub_resource type="Curve" id="Curve_0jmg7"] +_data = [Vector2(0.251318, 1), 0.0, 0.0, 0, 0, Vector2(0.991213, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_gf3su"] +curve = SubResource("Curve_0jmg7") + +[sub_resource type="Gradient" id="Gradient_vj4no"] +offsets = PackedFloat32Array(0.448141, 0.636008) +colors = PackedColorArray(0, 0.894118, 1, 1, 0, 0.564706, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_8k4ey"] +gradient = SubResource("Gradient_vj4no") + +[sub_resource type="Curve" id="Curve_iutvr"] +_data = [Vector2(0.490334, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_ga1td"] +curve = SubResource("Curve_iutvr") + +[sub_resource type="Curve" id="Curve_yuhne"] +max_value = 5.0 +_data = [Vector2(0, 0.169831), 0.0, 0.0, 0, 0, Vector2(0.625659, 0.729012), 0.0, 0.0, 0, 0, Vector2(1, 4.63364), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_nfm8j"] +curve = SubResource("Curve_yuhne") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_t7lly"] +gravity = Vector3(2.08165e-12, 2.08165e-12, 2.08165e-12) +scale_curve = SubResource("CurveTexture_nfm8j") +color_ramp = SubResource("GradientTexture1D_8k4ey") +alpha_curve = SubResource("CurveTexture_gf3su") +emission_curve = SubResource("CurveTexture_ga1td") + +[sub_resource type="Gradient" id="Gradient_30bhn"] +offsets = PackedFloat32Array(0.506744, 0.689788) +colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_1pmsb"] +gradient = SubResource("Gradient_30bhn") +width = 256 +height = 256 +fill = 1 +fill_from = Vector2(0.5, 0.5) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_k5esa"] +transparency = 1 +blend_mode = 1 +vertex_color_use_as_albedo = true +albedo_texture = SubResource("GradientTexture2D_1pmsb") +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 1 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="QuadMesh" id="QuadMesh_gvf03"] +material = SubResource("StandardMaterial3D_k5esa") + +[node name="Implosion" type="Node3D" node_paths=PackedStringArray("Particles")] +script = ExtResource("1_weson") +Particles = [NodePath("Bits"), NodePath("Sphere")] + +[node name="Bits" type="GPUParticles3D" parent="."] +amount = 64 +lifetime = 4.0 +explosiveness = 1.0 +fixed_fps = 60 +process_material = SubResource("ParticleProcessMaterial_50j2f") +draw_pass_1 = SubResource("QuadMesh_lxuhl") + +[node name="Sphere" type="GPUParticles3D" parent="."] +amount = 1 +lifetime = 4.0 +fixed_fps = 60 +process_material = SubResource("ParticleProcessMaterial_t7lly") +draw_pass_1 = SubResource("QuadMesh_gvf03") diff --git a/particles/shockwave.tscn b/particles/shockwave.tscn new file mode 100644 index 0000000..f81479d --- /dev/null +++ b/particles/shockwave.tscn @@ -0,0 +1,87 @@ +[gd_scene load_steps=17 format=3 uid="uid://brf0ftux0hwy8"] + +[ext_resource type="Script" path="res://scripts/MultiParticles.cs" id="1_yvu1a"] +[ext_resource type="Texture2D" uid="uid://bd2arrqo7xw7c" path="res://addons/kenney_particle_pack/circle_01.png" id="2_s6tl6"] + +[sub_resource type="Curve" id="Curve_jaxyf"] +_data = [Vector2(0.381371, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.0937408), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_qx1ma"] +curve = SubResource("Curve_jaxyf") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_dbh2b"] +gravity = Vector3(2.08165e-12, 2.08165e-12, 2.08165e-12) +scale_curve = SubResource("CurveTexture_qx1ma") + +[sub_resource type="Gradient" id="Gradient_2mquu"] +offsets = PackedFloat32Array(0.506744, 0.689788) +colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_fmsbu"] +gradient = SubResource("Gradient_2mquu") +width = 256 +height = 256 +fill = 1 +fill_from = Vector2(0.5, 0.5) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_82lug"] +transparency = 1 +blend_mode = 1 +vertex_color_use_as_albedo = true +albedo_texture = SubResource("GradientTexture2D_fmsbu") +billboard_mode = 3 +billboard_keep_scale = true +particles_anim_h_frames = 1 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="QuadMesh" id="QuadMesh_vwe5g"] +material = SubResource("StandardMaterial3D_82lug") + +[sub_resource type="Curve" id="Curve_q71c2"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_5xkdf"] +curve = SubResource("Curve_q71c2") + +[sub_resource type="Curve" id="Curve_0s8ld"] +max_value = 3.0 +_data = [Vector2(0, 0.0927029), 0.0, 0.0, 0, 0, Vector2(1, 3), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_406ad"] +curve = SubResource("Curve_0s8ld") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_aak2r"] +gravity = Vector3(2.08165e-12, 2.08165e-12, 2.08165e-12) +scale_curve = SubResource("CurveTexture_406ad") +alpha_curve = SubResource("CurveTexture_5xkdf") + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_y7i1b"] +transparency = 1 +vertex_color_use_as_albedo = true +albedo_texture = ExtResource("2_s6tl6") +rim_enabled = true + +[sub_resource type="PlaneMesh" id="PlaneMesh_iktve"] +material = SubResource("StandardMaterial3D_y7i1b") + +[node name="Shockwave" type="Node3D" node_paths=PackedStringArray("Particles")] +script = ExtResource("1_yvu1a") +Particles = [NodePath("Sphere"), NodePath("Ripple")] + +[node name="Sphere" type="GPUParticles3D" parent="."] +amount = 1 +lifetime = 3.0 +fixed_fps = 60 +process_material = SubResource("ParticleProcessMaterial_dbh2b") +draw_pass_1 = SubResource("QuadMesh_vwe5g") + +[node name="Ripple" type="GPUParticles3D" parent="."] +amount = 3 +lifetime = 3.0 +explosiveness = 0.8 +process_material = SubResource("ParticleProcessMaterial_aak2r") +draw_pass_1 = SubResource("PlaneMesh_iktve") diff --git a/particles/sparks.tscn b/particles/sparks.tscn index c0dbd44..6fb0acb 100644 --- a/particles/sparks.tscn +++ b/particles/sparks.tscn @@ -1,10 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://ck5vuhi3tffgl"] +[gd_scene load_steps=7 format=3 uid="uid://1p0djdxytw42"] [ext_resource type="Texture2D" uid="uid://iupf6jfowd7a" path="res://addons/kenney_particle_pack/trace_01.png" id="1_au4er"] [sub_resource type="Gradient" id="Gradient_206ev"] -offsets = PackedFloat32Array(0, 0.209386) -colors = PackedColorArray(1, 0.8, 0, 1, 1, 0, 0, 1) +offsets = PackedFloat32Array(0, 0.385519, 0.866928) +colors = PackedColorArray(1, 0.8, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1) [sub_resource type="GradientTexture1D" id="GradientTexture1D_lfvhw"] gradient = SubResource("Gradient_206ev") @@ -23,15 +23,16 @@ scale_min = 0.8 color_ramp = SubResource("GradientTexture1D_lfvhw") collision_mode = 1 collision_friction = 0.2 -collision_bounce = 0.5 +collision_bounce = 0.8 [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vihpm"] transparency = 1 blend_mode = 1 vertex_color_use_as_albedo = true albedo_texture = ExtResource("1_au4er") -emission = Color(1, 1, 0, 1) -emission_energy_multiplier = 8.05 +emission_enabled = true +emission = Color(1, 0.0705882, 0, 1) +emission_energy_multiplier = 2.0 rim_enabled = true [sub_resource type="QuadMesh" id="QuadMesh_wyolc"] @@ -41,7 +42,7 @@ size = Vector2(0.5, 0.5) [node name="Sparks" type="GPUParticles3D"] transform = Transform3D(0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, 0, 1, 0, 0, 0) amount = 48 -lifetime = 3.0 +lifetime = 5.0 speed_scale = 1.5 randomness = 0.3 fixed_fps = 60 diff --git a/scripts/MultiParticles.cs b/scripts/MultiParticles.cs index 81e4e39..9811a0f 100644 --- a/scripts/MultiParticles.cs +++ b/scripts/MultiParticles.cs @@ -1,65 +1,60 @@ -using System; using Godot; +using System; -/** - * MultiParticles : Node3D - * - * This class turns possible to control multiple particles in sync. - * Inspired by https://www.reddit.com/r/godot/comments/181ui9c/comment/kaewcca/?context=3 - */ public partial class MultiParticles : Node3D { - [Export] - public bool Emitting = true; + [Export] + public bool Emitting = true; - [Export] - public bool OneShot = false; + [Export] + public bool OneShot = false; - [Export] - public Godot.Collections.Array Particles; + [Export] + public Godot.Collections.Array Particles; - double Lifetime = 0.0f; + double Lifetime = 0.0f; - public override void _Ready() - { - if (Emitting) - { - StartEmitters(); - } - } + public override void _Ready() + { + if (Emitting) + { + StartEmitters(); + } + } - void GetLifetime() - { - foreach (var particle in Particles) - { - if (particle.Lifetime > Lifetime) - { - Lifetime = particle.Lifetime; - } - } - } + void GetLifetime() + { + foreach (var particle in Particles) + { + if (particle.Lifetime > Lifetime) + { + Lifetime = particle.Lifetime; + } + } + } - public async void StartEmitters() - { - GetLifetime(); + public async void StartEmitters() + { + GetLifetime(); - foreach (var particle in Particles) - particle.Emitting = true; + foreach (var particle in Particles) + particle.Emitting = true; - await ToSignal(GetTree().CreateTimer(Lifetime), SceneTreeTimer.SignalName.Timeout); - DisposeOfEmitters(); + await ToSignal(GetTree().CreateTimer(Lifetime), SceneTreeTimer.SignalName.Timeout); + DisposeOfEmitters(); - if (!OneShot) - { - StartEmitters(); - } - } + if (!OneShot) + { + StartEmitters(); + } + } + + void DisposeOfEmitters() + { + foreach (var particle in Particles) + { + particle.Emitting = false; + } + } - void DisposeOfEmitters() - { - foreach (var particle in Particles) - { - particle.Emitting = false; - } - } }