Repository: godotengine/godot
File: scene/2d/gpu_particles_2d.cpp (C++)

Code before:
			Vector<int> indices;
			indices.resize(6);
			indices.write[0] = 0;
			indices.write[1] = 1;
			indices.write[2] = 2;
			indices.write[3] = 0;
			indices.write[4] = 2;
			indices.write[5] = 3;
			Array arr;
			arr.resize(RS::ARRAY_MAX);
			arr[RS::ARRAY_VERTEX] = points;
			arr[RS::ARRAY_TEX_UV] = uvs;
			arr[RS::ARRAY_INDEX] = indices;

			RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RS::PRIMITIVE_TRIANGLES, arr, Array(), Dictionary(), RS::ARRAY_FLAG_USE_2D_VERTICES);
			RS::get_singleton()->particles_set_trail_bind_poses(particles, Vector<Transform3D>());
		}
		RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid);

#ifdef TOOLS_ENABLED
		if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) {
			draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
		}
#endif
	}

	if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
		if (can_process()) {
			RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
		} else {
			RS::get_singleton()->particles_set_speed_scale(particles, 0);
		}
	}

	if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
		_update_particle_emission_transform();
	}

	if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
		if (one_shot && !is_emitting()) {
			notify_property_list_changed();
			set_process_internal(false);
		}
	}
}

void GPUParticles2D::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles2D::set_emitting);
	ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles2D::set_amount);
	ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles2D::set_lifetime);
	ClassDB::bind_method(D_METHOD("set_one_shot", "secs"), &GPUParticles2D::set_one_shot);

Review comment (suggestion):
The property is only set inside editor, so the `Engine::get_singleton()->is_editor_hint()` part is no longer necessary.

Code after:
			points.write[3] = Vector2(-size.x / 2.0, size.y / 2.0);
			Vector<Vector2> uvs;
			uvs.resize(4);
			uvs.write[0] = Vector2(0, 0);
			uvs.write[1] = Vector2(1, 0);
			uvs.write[2] = Vector2(1, 1);
			uvs.write[3] = Vector2(0, 1);
			Vector<int> indices;
			indices.resize(6);
			indices.write[0] = 0;
			indices.write[1] = 1;
			indices.write[2] = 2;
			indices.write[3] = 0;
			indices.write[4] = 2;
			indices.write[5] = 3;
			Array arr;
			arr.resize(RS::ARRAY_MAX);
			arr[RS::ARRAY_VERTEX] = points;
			arr[RS::ARRAY_TEX_UV] = uvs;
			arr[RS::ARRAY_INDEX] = indices;

			RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RS::PRIMITIVE_TRIANGLES, arr, Array(), Dictionary(), RS::ARRAY_FLAG_USE_2D_VERTICES);
			RS::get_singleton()->particles_set_trail_bind_poses(particles, Vector<Transform3D>());
		}
		RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid);

#ifdef TOOLS_ENABLED
		if (show_visibility_rect) {
			draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
		}
#endif
	}

	if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
		if (can_process()) {
			RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
		} else {
			RS::get_singleton()->particles_set_speed_scale(particles, 0);
		}
	}

	if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
		_update_particle_emission_transform();
	}

	if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
		if (one_shot && !is_emitting()) {
			notify_property_list_changed();
			set_process_internal(false);
		}
	}