mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Cleaned up Talent a bit.
This commit is contained in:
parent
5afc9d4e08
commit
0d294e89cd
@ -1,10 +1,31 @@
|
||||
#include "talent.h"
|
||||
|
||||
Ref<Talent> Talent::get_next_rank() const {
|
||||
return _next_rank;
|
||||
Ref<Talent> Talent::get_required_talent() const {
|
||||
return _required_talent;
|
||||
}
|
||||
void Talent::set_next_rank(const Ref<Talent> rank) {
|
||||
_next_rank = rank;
|
||||
void Talent::set_required_talent(const Ref<Talent> rank) {
|
||||
_required_talent = rank;
|
||||
}
|
||||
|
||||
Ref<Spell> Talent::get_required_spell() const {
|
||||
return _required_talent;
|
||||
}
|
||||
void Talent::set_required_spell(const Ref<Spell> spell) {
|
||||
_required_spell = spell;
|
||||
}
|
||||
|
||||
Ref<Spell> Talent::get_teaches_spell() const {
|
||||
return _teaches_spell;
|
||||
}
|
||||
void Talent::set_teaches_spell(const Ref<Spell> spell) {
|
||||
_teaches_spell = spell;
|
||||
}
|
||||
|
||||
Ref<Aura> Talent::get_apply_aura() const {
|
||||
return _aura;
|
||||
}
|
||||
void Talent::set_apply_aura(Ref<Aura> aura) {
|
||||
_aura = Ref<Aura>(aura);
|
||||
}
|
||||
|
||||
Talent::Talent() {
|
||||
@ -13,14 +34,24 @@ Talent::Talent() {
|
||||
}
|
||||
|
||||
Talent::~Talent() {
|
||||
_next_rank.unref();
|
||||
_required_talent.unref();
|
||||
_required_spell.unref();
|
||||
_teaches_spell.unref();
|
||||
_aura.unref();
|
||||
}
|
||||
|
||||
void Talent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_next_rank"), &Talent::get_next_rank);
|
||||
ClassDB::bind_method(D_METHOD("set_next_rank", "next_rank"), &Talent::set_next_rank);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_rank", PROPERTY_HINT_RESOURCE_TYPE, "Talent"), "set_next_rank", "get_next_rank");
|
||||
ClassDB::bind_method(D_METHOD("get_required_talent"), &Talent::get_required_talent);
|
||||
ClassDB::bind_method(D_METHOD("set_required_talent", "next_rank"), &Talent::set_required_talent);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "required_talent", PROPERTY_HINT_RESOURCE_TYPE, "Talent"), "set_required_talent", "get_required_talent");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_required_spell"), &Talent::get_required_spell);
|
||||
ClassDB::bind_method(D_METHOD("set_required_spell", "next_rank"), &Talent::set_required_spell);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "required_spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_required_spell", "get_required_spell");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_teaches_spell"), &Talent::get_teaches_spell);
|
||||
ClassDB::bind_method(D_METHOD("set_teaches_spell", "next_rank"), &Talent::set_teaches_spell);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "teaches_spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_teaches_spell", "get_teaches_spell");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_apply_aura"), &Talent::get_apply_aura);
|
||||
ClassDB::bind_method(D_METHOD("set_apply_aura", "value"), &Talent::set_apply_aura);
|
||||
|
@ -6,15 +6,23 @@
|
||||
|
||||
#include "aura.h"
|
||||
|
||||
class Spell;
|
||||
|
||||
class Talent : public Aura {
|
||||
GDCLASS(Talent, Aura);
|
||||
|
||||
public:
|
||||
Ref<Talent> get_next_rank() const;
|
||||
void set_next_rank(const Ref<Talent> rank);
|
||||
Ref<Talent> get_required_talent() const;
|
||||
void set_required_talent(const Ref<Talent> rank);
|
||||
|
||||
Ref<Aura> get_apply_aura() const { return _aura; }
|
||||
void set_apply_aura(Ref<Aura> aura) { _aura = Ref<Aura>(aura); }
|
||||
Ref<Spell> get_required_spell() const;
|
||||
void set_required_spell(const Ref<Spell> spell);
|
||||
|
||||
Ref<Spell> get_teaches_spell() const;
|
||||
void set_teaches_spell(const Ref<Spell> spell);
|
||||
|
||||
Ref<Aura> get_apply_aura() const;
|
||||
void set_apply_aura(Ref<Aura> aura);
|
||||
|
||||
Talent();
|
||||
~Talent();
|
||||
@ -23,7 +31,9 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<Talent> _next_rank;
|
||||
Ref<Talent> _required_talent;
|
||||
Ref<Spell> _required_spell;
|
||||
Ref<Spell> _teaches_spell;
|
||||
|
||||
Ref<Aura> _aura;
|
||||
};
|
||||
|
@ -3383,7 +3383,17 @@ void Entity::_sreceive_talent_learn_request(int spec_index, int talent_row, int
|
||||
if (hass_talent(talent_id))
|
||||
continue;
|
||||
|
||||
//check requirement
|
||||
if (talent->get_required_talent().is_valid()) {
|
||||
if (!hass_talent(talent->get_required_talent()->get_id())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (talent->get_required_spell().is_valid()) {
|
||||
if (!hass_spell(talent->get_required_spell())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<AuraApplyInfo> info;
|
||||
info.instance();
|
||||
|
Loading…
Reference in New Issue
Block a user