feat: projectile can now return itself
This commit is contained in:
parent
f93bb5c045
commit
9c2e78ceca
|
@ -1,4 +1,16 @@
|
||||||
#include "projectile.hpp"
|
#include "projectile.hpp"
|
||||||
|
#include "projectile_pool.hpp"
|
||||||
#include <godot_cpp/classes/node3d.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ class IProjectile {
|
||||||
public:
|
public:
|
||||||
virtual void set_weapon_data(Ref<WeaponData> data) = 0;
|
virtual void set_weapon_data(Ref<WeaponData> data) = 0;
|
||||||
void return_to_pool();
|
void return_to_pool();
|
||||||
|
void set_projectile_pool(ProjectilePool *pool);
|
||||||
private:
|
private:
|
||||||
ProjectilePool *pool{nullptr};
|
ProjectilePool *pool{nullptr};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue