feat: projectile is no longer an interface

This commit is contained in:
Sara 2024-03-20 09:48:53 +01:00
parent 71de14003d
commit cd9260871e
2 changed files with 19 additions and 9 deletions

View file

@ -3,14 +3,20 @@
#include <godot_cpp/classes/node3d.hpp>
namespace godot {
void IProjectile::return_to_pool() {
void Projectile::_bind_methods() {
#define CLASSNAME Projectile
}
void Projectile::return_to_pool() {
if(!this->pool)
return;
Node3D *node = dynamic_cast<Node3D*>(this);
if(node)
this->pool->return_projectile(node);
this->pool->return_projectile(this);
}
void IProjectile::set_projectile_pool(ProjectilePool *pool) {
void Projectile::set_weapon_data(Ref<WeaponData> data) {
this->data = data;
}
void Projectile::set_projectile_pool(ProjectilePool *pool) {
this->pool = pool;
}
}

View file

@ -2,17 +2,21 @@
#define PROJECTILE_HPP
#include "weapon_data.hpp"
#include <godot_cpp/classes/node3d.hpp>
namespace godot {
class Node3D;
class ProjectilePool;
class IProjectile {
class Projectile : public Node3D {
GDCLASS(Projectile, Node3D);
static void _bind_methods();
public:
virtual void set_weapon_data(Ref<WeaponData> data) = 0;
void return_to_pool();
void set_weapon_data(Ref<WeaponData> data);
void set_projectile_pool(ProjectilePool *pool);
private:
protected:
ProjectilePool *pool{nullptr};
Ref<WeaponData> data{nullptr};
};
}