feat: projectile can now return itself

This commit is contained in:
Sara 2024-03-19 14:14:29 +01:00
parent f93bb5c045
commit 9c2e78ceca
2 changed files with 14 additions and 1 deletions

View file

@ -1,4 +1,16 @@
#include "projectile.hpp"
#include "projectile_pool.hpp"
#include <godot_cpp/classes/node3d.hpp>
namespace godot {}
namespace godot {
void IProjectile::return_to_pool() {
if(!this->pool)
return;
Node3D *node = dynamic_cast<Node3D*>(this);
if(node)
this->pool->return_projectile(node);
}
void IProjectile::set_projectile_pool(ProjectilePool *pool) {
this->pool = pool;
}
}

View file

@ -10,6 +10,7 @@ class IProjectile {
public:
virtual void set_weapon_data(Ref<WeaponData> data) = 0;
void return_to_pool();
void set_projectile_pool(ProjectilePool *pool);
private:
ProjectilePool *pool{nullptr};
};