mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Now CharacterSpec also uses variant vectors for the inspector.
This commit is contained in:
parent
3201488ac4
commit
627ec8613f
@ -88,7 +88,7 @@ public:
|
||||
void set_ai_action(int index, Ref<AIAction> aura);
|
||||
|
||||
Vector<Variant> get_ai_actions();
|
||||
void set_ai_actions(const Vector<Variant> &auras);
|
||||
void set_ai_actions(const Vector<Variant> &ai_actions);
|
||||
|
||||
//Setup
|
||||
void setup_resources(Entity *entity);
|
||||
|
@ -5,7 +5,6 @@
|
||||
int CharacterSpec::get_spec_id() {
|
||||
return _spec_id;
|
||||
}
|
||||
|
||||
void CharacterSpec::set_spec_id(int value) {
|
||||
_spec_id = value;
|
||||
}
|
||||
@ -13,25 +12,46 @@ void CharacterSpec::set_spec_id(int value) {
|
||||
String CharacterSpec::get_spec_name() {
|
||||
return _spec_name;
|
||||
}
|
||||
|
||||
void CharacterSpec::set_spec_name(String value) {
|
||||
_spec_name = value;
|
||||
}
|
||||
|
||||
int CharacterSpec::get_num_talent_rows() {
|
||||
return _rows.size();
|
||||
}
|
||||
void CharacterSpec::set_num_talent_rows(int value) {
|
||||
_rows.resize(value);
|
||||
}
|
||||
|
||||
Ref<TalentRowData> CharacterSpec::get_talent_row(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_TALENT_ROWS, Ref<TalentRowData>(NULL));
|
||||
ERR_FAIL_INDEX_V(index, _rows.size(), Ref<TalentRowData>(NULL));
|
||||
|
||||
return _rows[index];
|
||||
}
|
||||
|
||||
void CharacterSpec::set_talent_row(const int index, const Ref<TalentRowData> row) {
|
||||
ERR_FAIL_INDEX(index, MAX_TALENT_ROWS);
|
||||
ERR_FAIL_INDEX(index, _rows.size());
|
||||
|
||||
_rows[index] = row;
|
||||
_rows.set(index, row);
|
||||
}
|
||||
|
||||
Vector<Variant> CharacterSpec::get_talent_rows() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _rows.size(); i++) {
|
||||
r.push_back(_rows[i].get_ref_ptr());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
void CharacterSpec::set_talent_rows(const Vector<Variant> &talent_rows) {
|
||||
_rows.clear();
|
||||
for (int i = 0; i < talent_rows.size(); i++) {
|
||||
Ref<TalentRowData> talent_row = Ref<TalentRowData>(talent_rows[i]);
|
||||
|
||||
_rows.push_back(talent_row);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Talent> CharacterSpec::get_talent(const int row_index, const int index) const {
|
||||
ERR_FAIL_INDEX_V(row_index, MAX_TALENT_ROWS, Ref<Talent>(NULL));
|
||||
ERR_FAIL_INDEX_V(row_index, _rows.size(), Ref<Talent>(NULL));
|
||||
|
||||
if (_rows[row_index].is_valid()) {
|
||||
return _rows[row_index]->get_talent(index);
|
||||
@ -46,9 +66,7 @@ CharacterSpec::CharacterSpec() {
|
||||
}
|
||||
|
||||
CharacterSpec::~CharacterSpec() {
|
||||
for (int i = 0; i < MAX_TALENT_ROWS; ++i) {
|
||||
_rows[i].unref();
|
||||
}
|
||||
_rows.clear();
|
||||
}
|
||||
|
||||
void CharacterSpec::_bind_methods() {
|
||||
@ -60,14 +78,15 @@ void CharacterSpec::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_spec_name", "value"), &CharacterSpec::set_spec_name);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "spec_name"), "set_spec_name", "get_spec_name");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_num_talent_rows"), &CharacterSpec::get_num_talent_rows);
|
||||
ClassDB::bind_method(D_METHOD("set_num_talent_rows", "value"), &CharacterSpec::set_num_talent_rows);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_talent_row", "index"), &CharacterSpec::get_talent_row);
|
||||
ClassDB::bind_method(D_METHOD("set_talent_row", "index", "row"), &CharacterSpec::set_talent_row);
|
||||
|
||||
for (int i = 0; i < MAX_TALENT_ROWS; i++) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Row_" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "TalentRowData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_row", "get_talent_row", i);
|
||||
}
|
||||
ClassDB::bind_method(D_METHOD("get_talent_rows"), &CharacterSpec::get_talent_rows);
|
||||
ClassDB::bind_method(D_METHOD("set_talent_rows", "auras"), &CharacterSpec::set_talent_rows);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "talent_rows", PROPERTY_HINT_NONE, "17/17:TalentRowData", PROPERTY_USAGE_DEFAULT, "TalentRowData"), "set_talent_rows", "get_talent_rows");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_talent", "row_index", "index"), &CharacterSpec::get_talent);
|
||||
|
||||
BIND_CONSTANT(MAX_TALENT_ROWS);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "core/resource.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "talent_row_data.h"
|
||||
|
||||
@ -18,26 +19,27 @@ public:
|
||||
String get_spec_name();
|
||||
void set_spec_name(String value);
|
||||
|
||||
int get_num_talent_rows();
|
||||
void set_num_talent_rows(int value);
|
||||
|
||||
Ref<TalentRowData> get_talent_row(int index) const;
|
||||
void set_talent_row(const int index, const Ref<TalentRowData> row);
|
||||
|
||||
Vector<Variant> get_talent_rows();
|
||||
void set_talent_rows(const Vector<Variant> &auras);
|
||||
|
||||
Ref<Talent> get_talent(const int row_index, const int index) const;
|
||||
|
||||
CharacterSpec();
|
||||
~CharacterSpec();
|
||||
|
||||
public:
|
||||
enum {
|
||||
MAX_TALENT_ROWS = 10,
|
||||
};
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _spec_id;
|
||||
String _spec_name;
|
||||
Ref<TalentRowData> _rows[MAX_TALENT_ROWS];
|
||||
Vector<Ref<TalentRowData> > _rows;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user