mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Removed TalentRowData, and reworked CharacterSpec so it's not needed.
This commit is contained in:
parent
55fafecc9d
commit
fdf0163f47
3
SCsub
3
SCsub
@ -55,8 +55,7 @@ sources = [
|
||||
"entities/skills/entity_skill_data.cpp",
|
||||
|
||||
"entities/data/character_spec.cpp",
|
||||
"entities/data/talent_row_data.cpp",
|
||||
|
||||
|
||||
"skeleton/character_bones.cpp",
|
||||
|
||||
"entities/stats/stat_data.cpp",
|
||||
|
@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="TalentRowData" inherits="Resource" version="3.2">
|
||||
<brief_description>
|
||||
Contains one row of for a talent specialization.
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_talent" qualifiers="const">
|
||||
<return type="Aura">
|
||||
</return>
|
||||
<argument index="0" name="culomn" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="rank" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_talent_index" qualifiers="const">
|
||||
<return type="Aura">
|
||||
</return>
|
||||
<argument index="0" name="index" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_talent_with_id">
|
||||
<return type="Aura">
|
||||
</return>
|
||||
<argument index="0" name="id" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_talent_with_id">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<argument index="0" name="id" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_talent">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="culomn" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="rank" type="int">
|
||||
</argument>
|
||||
<argument index="2" name="talent" type="Aura">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_talent_index">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="index" type="int">
|
||||
</argument>
|
||||
<argument index="1" name="value" type="Aura">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
<constant name="MAX_TALENTS_IN_ROW" value="5">
|
||||
</constant>
|
||||
<constant name="MAX_TALENTS_PER_ENTRY" value="5">
|
||||
</constant>
|
||||
<constant name="TOTAL_ENTRIES" value="25">
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -26,46 +26,111 @@ SOFTWARE.
|
||||
|
||||
#include "../../defines.h"
|
||||
|
||||
int CharacterSpec::get_id() {
|
||||
int CharacterSpec::get_id() const {
|
||||
return _id;
|
||||
}
|
||||
void CharacterSpec::set_id(int value) {
|
||||
void CharacterSpec::set_id(const int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
int CharacterSpec::get_num_talent_rows() {
|
||||
int CharacterSpec::get_num_rows() const {
|
||||
return _rows.size();
|
||||
}
|
||||
void CharacterSpec::set_num_talent_rows(int value) {
|
||||
void CharacterSpec::set_num_rows(const int value) {
|
||||
_rows.resize(value);
|
||||
}
|
||||
|
||||
Ref<TalentRowData> CharacterSpec::get_talent_row(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, _rows.size(), Ref<TalentRowData>(NULL));
|
||||
int CharacterSpec::get_num_columns(const int row) const {
|
||||
ERR_FAIL_INDEX_V(row, _rows.size(), 0);
|
||||
|
||||
return _rows[index];
|
||||
return _rows[row].size();
|
||||
}
|
||||
void CharacterSpec::set_talent_row(const int index, const Ref<TalentRowData> row) {
|
||||
ERR_FAIL_INDEX(index, _rows.size());
|
||||
void CharacterSpec::set_num_columns(const int row, int value) {
|
||||
ERR_FAIL_INDEX(row, _rows.size());
|
||||
|
||||
_rows.set(index, row);
|
||||
_rows.write[row].resize(value);
|
||||
}
|
||||
|
||||
Vector<Variant> CharacterSpec::get_talent_rows() {
|
||||
VARIANT_ARRAY_GET(_rows);
|
||||
int CharacterSpec::get_num_ranks(const int row, const int column) const {
|
||||
ERR_FAIL_INDEX_V(row, _rows.size(), 0);
|
||||
ERR_FAIL_INDEX_V(column, _rows[row].size(), 0);
|
||||
|
||||
return _rows[row][column].size();
|
||||
}
|
||||
void CharacterSpec::set_talent_rows(const Vector<Variant> &talent_rows) {
|
||||
VARIANT_ARRAY_SET(talent_rows, _rows, TalentRowData);
|
||||
void CharacterSpec::set_num_ranks(const int row, const int column, int value) {
|
||||
ERR_FAIL_INDEX(row, _rows.size());
|
||||
|
||||
_rows.write[row].write[column].resize(value);
|
||||
}
|
||||
|
||||
Ref<Aura> CharacterSpec::get_talent(const int row_index, const int culomn, const int rank) const {
|
||||
ERR_FAIL_INDEX_V(row_index, _rows.size(), Ref<Aura>(NULL));
|
||||
Vector<Variant> CharacterSpec::get_talents() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _rows.size(); i++) {
|
||||
Vector<Variant> col;
|
||||
|
||||
if (_rows[row_index].is_valid()) {
|
||||
return _rows[row_index]->get_talent(culomn, rank);
|
||||
for (int j = 0; j < _rows[i].size(); j++) {
|
||||
Vector<Variant> entries;
|
||||
|
||||
for (int k = 0; k < _rows[j].size(); k++) {
|
||||
#if GODOT4
|
||||
entries.push_back(_rows[i][j][k]);
|
||||
#else
|
||||
entries.push_back(_rows[i][j][k].get_ref_ptr());
|
||||
#endif
|
||||
}
|
||||
|
||||
col.push_back(entries);
|
||||
}
|
||||
|
||||
r.push_back(col);
|
||||
}
|
||||
|
||||
return Ref<Aura>(NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
Ref<Aura> CharacterSpec::get_talent(const int row, const int column, const int rank) {
|
||||
ERR_FAIL_INDEX_V(row, _rows.size(), Ref<Aura>());
|
||||
ERR_FAIL_INDEX_V(column, _rows[row].size(), Ref<Aura>());
|
||||
ERR_FAIL_INDEX_V(rank, _rows[row][column].size(), Ref<Aura>());
|
||||
|
||||
return _rows[row][column][rank];
|
||||
}
|
||||
void CharacterSpec::set_talent(const int row, const int column, const int rank, const Ref<Aura> &talent) {
|
||||
ERR_FAIL_INDEX(row, _rows.size());
|
||||
ERR_FAIL_INDEX(column, _rows[row].size());
|
||||
ERR_FAIL_INDEX(rank, _rows[row][column].size());
|
||||
|
||||
_rows.write[row].write[column].write[rank] = talent;
|
||||
}
|
||||
|
||||
bool CharacterSpec::has_talent_with_id(const int id) {
|
||||
for (int i = 0; i < _rows.size(); ++i) {
|
||||
for (int j = 0; j < _rows[i].size(); ++j) {
|
||||
for (int k = 0; k < _rows[i][j].size(); ++k) {
|
||||
const Ref<Aura> a = _rows[i][j][k];
|
||||
|
||||
if (a.is_valid() && a->get_id() == id)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Ref<Aura> CharacterSpec::get_talent_with_id(const int id) {
|
||||
for (int i = 0; i < _rows.size(); ++i) {
|
||||
for (int j = 0; j < _rows[i].size(); ++j) {
|
||||
for (int k = 0; k < _rows[i][j].size(); ++k) {
|
||||
const Ref<Aura> a = _rows[i][j][k];
|
||||
|
||||
if (a.is_valid() && a->get_id() == id)
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Ref<Aura>();
|
||||
}
|
||||
|
||||
CharacterSpec::CharacterSpec() {
|
||||
@ -73,9 +138,128 @@ CharacterSpec::CharacterSpec() {
|
||||
}
|
||||
|
||||
CharacterSpec::~CharacterSpec() {
|
||||
for (int i = 0; i < _rows.size(); ++i) {
|
||||
for (int j = 0; j < _rows[i].size(); ++j) {
|
||||
for (int k = 0; k < _rows[i][j].size(); ++k) {
|
||||
_rows.write[i].write[j].write[k].unref();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_rows.clear();
|
||||
}
|
||||
|
||||
bool CharacterSpec::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String name = p_name;
|
||||
|
||||
if (name.begins_with("row_")) {
|
||||
String nprop = name.get_slicec('/', 0); //row_[]
|
||||
int row_id = nprop.get_slicec('_', 1).to_int();
|
||||
|
||||
if (row_id >= _rows.size()) {
|
||||
_rows.resize(row_id + 1);
|
||||
}
|
||||
|
||||
String cprop = name.get_slicec('/', 1); //column_[] or size
|
||||
|
||||
if (cprop == "size") {
|
||||
_rows.write[row_id].resize(p_value);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
int col_id = cprop.get_slicec('_', 1).to_int();
|
||||
|
||||
if (col_id >= _rows[row_id].size()) {
|
||||
_rows.write[row_id].resize(col_id + 1);
|
||||
}
|
||||
|
||||
String eprop = name.get_slicec('/', 2); //entry_[] or size
|
||||
|
||||
if (eprop == "size") {
|
||||
_rows.write[row_id].write[col_id].resize(p_value);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
int entry_id = eprop.get_slicec('_', 1).to_int();
|
||||
|
||||
if (entry_id >= _rows[row_id][col_id].size()) {
|
||||
_rows.write[row_id].write[col_id].resize(col_id + 1);
|
||||
}
|
||||
|
||||
_rows.write[row_id].write[col_id].write[entry_id] = p_value;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CharacterSpec::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
String name = p_name;
|
||||
|
||||
if (name.begins_with("row_")) {
|
||||
String nprop = name.get_slicec('/', 0); //row_[]
|
||||
int row_id = nprop.get_slicec('_', 1).to_int();
|
||||
|
||||
if (row_id >= _rows.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String cprop = name.get_slicec('/', 1); //column_[] or size
|
||||
|
||||
if (cprop == "size") {
|
||||
r_ret = _rows[row_id].size();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
int col_id = cprop.get_slicec('_', 1).to_int();
|
||||
|
||||
if (col_id >= _rows[row_id].size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String eprop = name.get_slicec('/', 2); //entry_[] or size
|
||||
|
||||
if (eprop == "size") {
|
||||
r_ret = _rows[row_id][col_id].size();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
int entry_id = eprop.get_slicec('_', 1).to_int();
|
||||
|
||||
if (entry_id >= _rows[row_id][col_id].size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
r_ret = _rows[row_id][col_id][entry_id];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CharacterSpec::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
for (int i = 0; i < _rows.size(); ++i) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "row_" + itos(i) + "/size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED));
|
||||
|
||||
for (int j = 0; j < _rows[i].size(); ++j) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "row_" + itos(i) + "/column_" + itos(j) + "/size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED));
|
||||
|
||||
for (int k = 0; k < _rows[i][j].size(); ++k) {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "row_" + itos(i) + "/column_" + itos(j) + "/entry_" + itos(k), PROPERTY_HINT_RESOURCE_TYPE, "Aura", PROPERTY_USAGE_DEFAULT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CharacterSpec::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_id"), &CharacterSpec::get_id);
|
||||
ClassDB::bind_method(D_METHOD("set_id", "value"), &CharacterSpec::set_id);
|
||||
@ -83,15 +267,21 @@ void CharacterSpec::_bind_methods() {
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_name", "get_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_num_rows"), &CharacterSpec::get_num_rows);
|
||||
ClassDB::bind_method(D_METHOD("set_num_rows", "value"), &CharacterSpec::set_num_rows);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "num_rows", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_num_rows", "get_num_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);
|
||||
ClassDB::bind_method(D_METHOD("get_num_columns", "row"), &CharacterSpec::get_num_columns);
|
||||
ClassDB::bind_method(D_METHOD("set_num_columns", "row", "value"), &CharacterSpec::set_num_columns);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_talent", "row_index", "culomn", "rank"), &CharacterSpec::get_talent);
|
||||
ClassDB::bind_method(D_METHOD("get_num_ranks", "row", "culomn"), &CharacterSpec::get_num_ranks);
|
||||
ClassDB::bind_method(D_METHOD("set_num_ranks", "row", "culomn", "value"), &CharacterSpec::set_num_ranks);
|
||||
|
||||
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_talents"), &CharacterSpec::get_talents);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_talent", "row", "culomn", "rank"), &CharacterSpec::get_talent);
|
||||
ClassDB::bind_method(D_METHOD("set_talent", "row", "culomn", "rank"), &CharacterSpec::set_talent);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_talent_with_id", "id"), &CharacterSpec::has_talent_with_id);
|
||||
ClassDB::bind_method(D_METHOD("get_talent_with_id", "id"), &CharacterSpec::get_talent_with_id);
|
||||
}
|
||||
|
@ -27,38 +27,44 @@ SOFTWARE.
|
||||
#include "core/ustring.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "talent_row_data.h"
|
||||
|
||||
class TalentRowData;
|
||||
class Aura;
|
||||
|
||||
class CharacterSpec : public Resource {
|
||||
GDCLASS(CharacterSpec, Resource);
|
||||
|
||||
public:
|
||||
int get_id();
|
||||
void set_id(int value);
|
||||
int get_id() const;
|
||||
void set_id(const int value);
|
||||
|
||||
int get_num_talent_rows();
|
||||
void set_num_talent_rows(int value);
|
||||
int get_num_rows() const;
|
||||
void set_num_rows(const int value);
|
||||
|
||||
Ref<TalentRowData> get_talent_row(int index) const;
|
||||
void set_talent_row(const int index, const Ref<TalentRowData> row);
|
||||
int get_num_columns(const int row) const;
|
||||
void set_num_columns(const int row, int value);
|
||||
|
||||
Vector<Variant> get_talent_rows();
|
||||
void set_talent_rows(const Vector<Variant> &auras);
|
||||
int get_num_ranks(const int row, const int column) const;
|
||||
void set_num_ranks(const int row, const int column, int value);
|
||||
|
||||
Ref<Aura> get_talent(const int row_index, const int culomn, const int rank) const;
|
||||
Vector<Variant> get_talents();
|
||||
|
||||
Ref<Aura> get_talent(const int row, const int column, const int rank);
|
||||
void set_talent(const int row, const int column, const int rank, const Ref<Aura> &talent);
|
||||
|
||||
bool has_talent_with_id(const int id);
|
||||
Ref<Aura> get_talent_with_id(const int id);
|
||||
|
||||
CharacterSpec();
|
||||
~CharacterSpec();
|
||||
|
||||
protected:
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _id;
|
||||
Vector<Ref<TalentRowData> > _rows;
|
||||
Vector<Vector<Vector<Ref<Aura> > > > _rows;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "talent_row_data.h"
|
||||
|
||||
Ref<Aura> TalentRowData::get_talent_index(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, TOTAL_ENTRIES, Ref<Aura>());
|
||||
|
||||
return _talents[index];
|
||||
}
|
||||
|
||||
void TalentRowData::set_talent_index(int index, Ref<Aura> talent) {
|
||||
ERR_FAIL_INDEX(index, TOTAL_ENTRIES);
|
||||
|
||||
_talents[index] = Ref<Aura>(talent);
|
||||
}
|
||||
|
||||
Ref<Aura> TalentRowData::get_talent(int culomn, int rank) const {
|
||||
ERR_FAIL_INDEX_V(culomn, MAX_TALENTS_IN_ROW, Ref<Aura>());
|
||||
ERR_FAIL_INDEX_V(rank, MAX_TALENTS_PER_ENTRY, Ref<Aura>());
|
||||
|
||||
return _talents[culomn * MAX_TALENTS_IN_ROW + rank];
|
||||
}
|
||||
void TalentRowData::set_talent(int culomn, int rank, Ref<Aura> talent) {
|
||||
ERR_FAIL_INDEX(culomn, MAX_TALENTS_IN_ROW);
|
||||
ERR_FAIL_INDEX(rank, MAX_TALENTS_PER_ENTRY);
|
||||
|
||||
_talents[culomn * MAX_TALENTS_IN_ROW + rank] = talent;
|
||||
}
|
||||
|
||||
bool TalentRowData::has_talent_with_id(int id) {
|
||||
for (int i = 0; i < TOTAL_ENTRIES; ++i) {
|
||||
if (_talents[i].is_valid() && _talents[i]->get_id() == id)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Ref<Aura> TalentRowData::get_talent_with_id(int id) {
|
||||
for (int i = 0; i < TOTAL_ENTRIES; ++i) {
|
||||
if (_talents[i].is_valid() && _talents[i]->get_id() == id)
|
||||
return _talents[i];
|
||||
}
|
||||
|
||||
return Ref<Aura>();
|
||||
}
|
||||
|
||||
TalentRowData::TalentRowData() {
|
||||
}
|
||||
TalentRowData::~TalentRowData() {
|
||||
for (int i = 0; i < TOTAL_ENTRIES; ++i) {
|
||||
_talents[i].unref();
|
||||
}
|
||||
}
|
||||
|
||||
void TalentRowData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_talent_index", "index"), &TalentRowData::get_talent_index);
|
||||
ClassDB::bind_method(D_METHOD("set_talent_index", "index", "value"), &TalentRowData::set_talent_index);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_talent", "culomn", "rank"), &TalentRowData::get_talent);
|
||||
ClassDB::bind_method(D_METHOD("set_talent", "culomn", "rank", "talent"), &TalentRowData::set_talent);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_talent_with_id", "id"), &TalentRowData::has_talent_with_id);
|
||||
ClassDB::bind_method(D_METHOD("get_talent_with_id", "id"), &TalentRowData::get_talent_with_id);
|
||||
|
||||
for (int i = 0; i < MAX_TALENTS_IN_ROW; ++i) {
|
||||
for (int j = 0; j < MAX_TALENTS_PER_ENTRY; ++j) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "Talent_" + itos(i) + "_" + itos(j), PROPERTY_HINT_RESOURCE_TYPE, "Aura", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_talent_index", "get_talent_index", i * MAX_TALENTS_IN_ROW + j);
|
||||
}
|
||||
}
|
||||
|
||||
BIND_CONSTANT(MAX_TALENTS_IN_ROW);
|
||||
BIND_CONSTANT(MAX_TALENTS_PER_ENTRY);
|
||||
BIND_CONSTANT(TOTAL_ENTRIES);
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef TALENT_ROW_DATA_H
|
||||
#define TALENT_ROW_DATA_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "../../data/auras/aura.h"
|
||||
|
||||
class Aura;
|
||||
|
||||
class TalentRowData : public Resource {
|
||||
GDCLASS(TalentRowData, Resource);
|
||||
|
||||
public:
|
||||
Ref<Aura> get_talent_index(int index) const;
|
||||
void set_talent_index(int index, Ref<Aura> talent);
|
||||
|
||||
Ref<Aura> get_talent(int culomn, int rank) const;
|
||||
void set_talent(int culomn, int rank, Ref<Aura> talent);
|
||||
|
||||
bool has_talent_with_id(int id);
|
||||
Ref<Aura> get_talent_with_id(int id);
|
||||
|
||||
TalentRowData();
|
||||
~TalentRowData();
|
||||
|
||||
public:
|
||||
enum {
|
||||
MAX_TALENTS_IN_ROW = 5,
|
||||
MAX_TALENTS_PER_ENTRY = 5,
|
||||
TOTAL_ENTRIES = MAX_TALENTS_IN_ROW * MAX_TALENTS_PER_ENTRY,
|
||||
};
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<Aura> _talents[TOTAL_ENTRIES];
|
||||
};
|
||||
|
||||
#endif
|
@ -35,7 +35,6 @@ SOFTWARE.
|
||||
#include "../pipelines/spell_heal_info.h"
|
||||
#include "../profiles/class_profile.h"
|
||||
#include "./data/character_spec.h"
|
||||
#include "./data/talent_row_data.h"
|
||||
#include "./resources/entity_resource_health.h"
|
||||
#include "./resources/entity_resource_speed.h"
|
||||
#include "./skills/entity_skill.h"
|
||||
@ -4775,12 +4774,8 @@ void Entity::_class_talent_sreceive_learn_request(int spec_index, int class_tale
|
||||
|
||||
ERR_FAIL_COND(!spec.is_valid());
|
||||
|
||||
Ref<TalentRowData> tr = spec->get_talent_row(class_talent_row);
|
||||
|
||||
ERR_FAIL_COND(!tr.is_valid());
|
||||
|
||||
for (int i = 0; i < TalentRowData::MAX_TALENTS_PER_ENTRY; ++i) {
|
||||
Ref<Aura> class_talent = tr->get_talent(class_talent_culomn, i);
|
||||
for (int i = 0; i < spec->get_num_ranks(class_talent_row, class_talent_culomn); ++i) {
|
||||
Ref<Aura> class_talent = spec->get_talent(class_talent_row, class_talent_culomn, i);
|
||||
|
||||
if (!class_talent.is_valid())
|
||||
return;
|
||||
@ -4803,7 +4798,7 @@ void Entity::_class_talent_sreceive_learn_request(int spec_index, int class_tale
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
Ref<Aura> pt = tr->get_talent(class_talent_culomn, i - 1);
|
||||
Ref<Aura> pt = spec->get_talent(class_talent_row, class_talent_culomn, i - 1);
|
||||
|
||||
for (int j = 0; j < aura_gets_count(); ++j) {
|
||||
Ref<AuraData> ad = aura_gets(j);
|
||||
@ -4998,12 +4993,10 @@ void Entity::_character_talent_sreceive_learn_request(int spec_index, int charac
|
||||
|
||||
ERR_FAIL_COND(!spec.is_valid());
|
||||
|
||||
Ref<TalentRowData> tr = spec->get_talent_row(character_talent_row);
|
||||
ERR_FAIL_COND(!spec.is_valid());
|
||||
|
||||
ERR_FAIL_COND(!tr.is_valid());
|
||||
|
||||
for (int i = 0; i < TalentRowData::MAX_TALENTS_PER_ENTRY; ++i) {
|
||||
Ref<Aura> character_talent = tr->get_talent(character_talent_culomn, i);
|
||||
for (int i = 0; i < spec->get_num_ranks(character_talent_row, character_talent_culomn); ++i) {
|
||||
Ref<Aura> character_talent = spec->get_talent(character_talent_row, character_talent_culomn, i);
|
||||
|
||||
if (!character_talent.is_valid())
|
||||
return;
|
||||
@ -5026,7 +5019,7 @@ void Entity::_character_talent_sreceive_learn_request(int spec_index, int charac
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
Ref<Aura> pt = tr->get_talent(character_talent_culomn, i - 1);
|
||||
Ref<Aura> pt = spec->get_talent(character_talent_row, character_talent_culomn, i - 1);
|
||||
|
||||
for (int j = 0; j < aura_gets_count(); ++j) {
|
||||
Ref<AuraData> ad = aura_gets(j);
|
||||
@ -6467,7 +6460,7 @@ bool Entity::_set(const StringName &p_name, const Variant &p_value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
|
||||
/*
|
||||
sets_entity_type((int)((int)dict.get("type", 0)));
|
||||
@ -6756,7 +6749,7 @@ bool Entity::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
/*
|
||||
Dictionary dict;
|
||||
|
||||
|
@ -49,7 +49,6 @@ SOFTWARE.
|
||||
#include "entities/skills/entity_skill_data.h"
|
||||
|
||||
#include "entities/data/character_spec.h"
|
||||
#include "entities/data/talent_row_data.h"
|
||||
|
||||
#include "data/items/model_visual.h"
|
||||
#include "data/items/model_visual_entry.h"
|
||||
@ -174,7 +173,6 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<ItemTemplate>();
|
||||
ClassDB::register_class<ItemInstance>();
|
||||
ClassDB::register_class<SpellCooldownManipulationData>();
|
||||
ClassDB::register_class<TalentRowData>();
|
||||
|
||||
ClassDB::register_class<EquipmentData>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user