generated from Persson-dev/Godot-Xmake
bullet: remove transparency
This commit is contained in:
@@ -18,9 +18,8 @@ class Bullet : public godot::Node3D {
|
||||
|
||||
private:
|
||||
bool m_Stuck;
|
||||
float m_LifeTime;
|
||||
|
||||
void SetTransparency(godot::Node* a_Root, float a_Transparency);
|
||||
void Destroy();
|
||||
};
|
||||
|
||||
} // namespace blitz
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <godot_cpp/classes/geometry_instance3d.hpp>
|
||||
#include <godot_cpp/classes/physics_direct_space_state3d.hpp>
|
||||
#include <godot_cpp/classes/physics_ray_query_parameters3d.hpp>
|
||||
#include <godot_cpp/classes/timer.hpp>
|
||||
#include <godot_cpp/classes/world3d.hpp>
|
||||
#include <godot_cpp/variant/utility_functions.hpp>
|
||||
|
||||
@@ -18,7 +19,13 @@ void Bullet::_bind_methods() {}
|
||||
|
||||
Bullet::Bullet() : m_Stuck(false) {}
|
||||
|
||||
void Bullet::_ready() {}
|
||||
void Bullet::_ready() {
|
||||
Timer* timer = memnew(Timer);
|
||||
add_child(timer);
|
||||
timer->connect("timeout", callable_mp(this, &Bullet::Destroy));
|
||||
timer->set_wait_time(MaxAlive);
|
||||
timer->start();
|
||||
}
|
||||
|
||||
Bullet::~Bullet() {}
|
||||
|
||||
@@ -27,14 +34,7 @@ void Bullet::_process(float a_Delta) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_LifeTime += a_Delta;
|
||||
if (m_LifeTime > MaxAlive) {
|
||||
queue_free();
|
||||
return;
|
||||
}
|
||||
|
||||
auto* head = get_node<Node3D>("Armature");
|
||||
SetTransparency(head, m_LifeTime / MaxAlive);
|
||||
|
||||
if (m_Stuck)
|
||||
return;
|
||||
@@ -56,15 +56,8 @@ void Bullet::_process(float a_Delta) {
|
||||
head->set_global_position(intersectPoint);
|
||||
}
|
||||
|
||||
void Bullet::SetTransparency(Node* a_Root, float a_Transparency) {
|
||||
for (int i = 0; i < a_Root->get_child_count(); i++) {
|
||||
SetTransparency(a_Root->get_child(i), a_Transparency);
|
||||
}
|
||||
|
||||
GeometryInstance3D* mesh = Object::cast_to<GeometryInstance3D>(a_Root);
|
||||
if (mesh) {
|
||||
mesh->set_transparency(a_Transparency);
|
||||
}
|
||||
void Bullet::Destroy() {
|
||||
queue_free();
|
||||
}
|
||||
|
||||
} // namespace blitz
|
||||
Reference in New Issue
Block a user