mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-22 17:18:12 +01:00
Started reworking CharacterClass to use variant vector properties.
This commit is contained in:
parent
1f83d7ac6c
commit
e070031073
@ -47,66 +47,83 @@ void CharacterClass::set_stat_data(Ref<StatData> value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CharacterClass::get_num_spells() {
|
int CharacterClass::get_num_spells() {
|
||||||
return _num_spells;
|
return _spells.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterClass::set_num_spells(int value) {
|
void CharacterClass::set_num_spells(int value) {
|
||||||
_num_spells = value;
|
_spells.resize(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharacterClass::get_current_spell_page() {
|
Ref<Spell> CharacterClass::get_spell(int index) {
|
||||||
return _current_spell_page;
|
ERR_FAIL_INDEX_V(index, _spells.size(), Ref<Spell>());
|
||||||
|
|
||||||
|
return _spells[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterClass::set_current_spell_page(int value) {
|
|
||||||
if (value < 0 || value > (int)(_num_spells / ITEMS_PER_PAGE)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_current_spell_page = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<Spell> CharacterClass::get_spell(int id) {
|
|
||||||
ERR_FAIL_INDEX_V(id, MAX_SPELLS, Ref<Spell>());
|
|
||||||
|
|
||||||
return _spells[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CharacterClass::set_spell(int index, Ref<Spell> spell) {
|
void CharacterClass::set_spell(int index, Ref<Spell> spell) {
|
||||||
ERR_FAIL_INDEX(index, MAX_SPELLS);
|
ERR_FAIL_INDEX(index, _spells.size());
|
||||||
|
|
||||||
_spells[index] = Ref<Spell>(spell);
|
_spells.set(index, Ref<Spell>(spell));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Variant> CharacterClass::get_spells() {
|
||||||
|
Vector<Variant> r;
|
||||||
|
for (int i = 0; i < _spells.size(); i++) {
|
||||||
|
r.push_back(_spells[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
void CharacterClass::set_spells(const Vector<Variant> &spells) {
|
||||||
|
_spells.clear();
|
||||||
|
for (int i = 0; i < spells.size(); i++) {
|
||||||
|
Ref<Spell> spell = Ref<Spell>(spells[i]);
|
||||||
|
|
||||||
|
_spells.push_back(spell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharacterClass::get_num_specs() {
|
int CharacterClass::get_num_specs() {
|
||||||
return _num_specs;
|
return _specs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterClass::set_num_specs(int value) {
|
void CharacterClass::set_num_specs(int value) {
|
||||||
_num_specs = value;
|
_specs.resize(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<CharacterSpec> CharacterClass::get_spec(int index) const {
|
Ref<CharacterSpec> CharacterClass::get_spec(int index) const {
|
||||||
ERR_FAIL_INDEX_V(index, MAX_SPECS, Ref<CharacterSpec>());
|
ERR_FAIL_INDEX_V(index, _specs.size(), Ref<CharacterSpec>());
|
||||||
|
|
||||||
return _specs[index];
|
return _specs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterClass::set_spec(int index, Ref<CharacterSpec> spec) {
|
void CharacterClass::set_spec(int index, Ref<CharacterSpec> spec) {
|
||||||
ERR_FAIL_INDEX(index, MAX_SPECS);
|
ERR_FAIL_INDEX(index, _specs.size());
|
||||||
|
|
||||||
_specs[index] = Ref<CharacterSpec>(spec);
|
_specs.set(index, Ref<CharacterSpec>(spec));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Variant> CharacterClass::get_specs() {
|
||||||
|
Vector<Variant> r;
|
||||||
|
for (int i = 0; i < _specs.size(); i++) {
|
||||||
|
r.push_back(_specs[i].get_ref_ptr());
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
void CharacterClass::set_specs(const Vector<Variant> &specs) {
|
||||||
|
_specs.clear();
|
||||||
|
for (int i = 0; i < specs.size(); i++) {
|
||||||
|
Ref<Spell> spec = Ref<Spell>(specs[i]);
|
||||||
|
|
||||||
|
_specs.push_back(spec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Aura> CharacterClass::get_aura(int index) {
|
Ref<Aura> CharacterClass::get_aura(int index) {
|
||||||
ERR_FAIL_INDEX_V(index, MAX_AURAS, Ref<Aura>());
|
ERR_FAIL_INDEX_V(index, _auras.size(), Ref<Aura>());
|
||||||
|
|
||||||
return _auras[index];
|
return _auras[index];
|
||||||
}
|
}
|
||||||
void CharacterClass::set_aura(int index, Ref<Aura> aura) {
|
void CharacterClass::set_aura(int index, Ref<Aura> aura) {
|
||||||
ERR_FAIL_INDEX(index, MAX_AURAS);
|
ERR_FAIL_INDEX(index, _auras.size());
|
||||||
|
|
||||||
_auras[index] = aura;
|
_auras.set(index, aura);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterClass::setup_resources(Entity *entity) {
|
void CharacterClass::setup_resources(Entity *entity) {
|
||||||
@ -555,26 +572,6 @@ void CharacterClass::sai_attack_bind(Node *entity) {
|
|||||||
sai_attack(e);
|
sai_attack(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterClass::_validate_property(PropertyInfo &property) const {
|
|
||||||
|
|
||||||
String prop = property.name;
|
|
||||||
if (prop.begins_with("Spell_")) {
|
|
||||||
int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int();
|
|
||||||
if (frame >= _num_spells || frame < ITEMS_PER_PAGE * _current_spell_page || frame > ITEMS_PER_PAGE * (_current_spell_page + 1)) {
|
|
||||||
property.usage = 0;
|
|
||||||
}
|
|
||||||
} else if (prop.begins_with("Spec_")) {
|
|
||||||
int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int();
|
|
||||||
if (frame >= _num_specs) {
|
|
||||||
property.usage = 0;
|
|
||||||
}
|
|
||||||
} else if (prop.begins_with("current_spell_page")) {
|
|
||||||
if (_num_spells <= ITEMS_PER_PAGE) {
|
|
||||||
property.usage = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CharacterClass::_bind_methods() {
|
void CharacterClass::_bind_methods() {
|
||||||
//EventHandlers
|
//EventHandlers
|
||||||
ClassDB::bind_method(D_METHOD("son_before_cast", "info"), &CharacterClass::son_before_cast);
|
ClassDB::bind_method(D_METHOD("son_before_cast", "info"), &CharacterClass::son_before_cast);
|
||||||
|
@ -52,21 +52,32 @@ public:
|
|||||||
int get_num_spells();
|
int get_num_spells();
|
||||||
void set_num_spells(int value);
|
void set_num_spells(int value);
|
||||||
|
|
||||||
int get_current_spell_page();
|
|
||||||
void set_current_spell_page(int value);
|
|
||||||
|
|
||||||
Ref<Spell> get_spell(int index);
|
Ref<Spell> get_spell(int index);
|
||||||
void set_spell(int index, Ref<Spell> spell);
|
void set_spell(int index, Ref<Spell> spell);
|
||||||
|
|
||||||
|
Vector<Variant> get_spells();
|
||||||
|
void set_spells(const Vector<Variant> &spells);
|
||||||
|
|
||||||
|
|
||||||
int get_num_specs();
|
int get_num_specs();
|
||||||
void set_num_specs(int value);
|
void set_num_specs(int value);
|
||||||
|
|
||||||
Ref<CharacterSpec> get_spec(int index) const;
|
Ref<CharacterSpec> get_spec(int index) const;
|
||||||
void set_spec(int index, Ref<CharacterSpec> spec);
|
void set_spec(int index, Ref<CharacterSpec> spec);
|
||||||
|
|
||||||
|
Vector<Variant> get_specs();
|
||||||
|
void set_specs(const Vector<Variant> &specs);
|
||||||
|
|
||||||
|
|
||||||
|
int get_num_auras();
|
||||||
|
void set_num_auras(int value);
|
||||||
|
|
||||||
Ref<Aura> get_aura(int index);
|
Ref<Aura> get_aura(int index);
|
||||||
void set_aura(int index, Ref<Aura> aura);
|
void set_aura(int index, Ref<Aura> aura);
|
||||||
|
|
||||||
|
Vector<Variant> get_auras();
|
||||||
|
void set_auras(const Vector<Variant> &auras);
|
||||||
|
|
||||||
void setup_resources(Entity *entity);
|
void setup_resources(Entity *entity);
|
||||||
//void _setup_resources(Entity *entity);
|
//void _setup_resources(Entity *entity);
|
||||||
|
|
||||||
@ -167,15 +178,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _validate_property(PropertyInfo &property) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
MAX_SPELLS = 100,
|
|
||||||
MAX_SPECS = 5,
|
|
||||||
MAX_AURAS = 5,
|
|
||||||
ITEMS_PER_PAGE = 100,
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _id;
|
int _id;
|
||||||
@ -186,14 +188,9 @@ private:
|
|||||||
|
|
||||||
Ref<StatData> _stat_data;
|
Ref<StatData> _stat_data;
|
||||||
|
|
||||||
int _num_spells;
|
Vector<Ref<Spell> > _spells;
|
||||||
int _current_spell_page;
|
Vector<Ref<CharacterSpec> > _specs;
|
||||||
Ref<Spell> _spells[MAX_SPELLS];
|
Vector<Ref<Aura> > _auras;
|
||||||
|
|
||||||
int _num_specs;
|
|
||||||
Ref<CharacterSpec> _specs[MAX_SPECS];
|
|
||||||
|
|
||||||
Ref<Aura> _auras[MAX_AURAS];
|
|
||||||
|
|
||||||
//Vector<int> _mob_party_ids;
|
//Vector<int> _mob_party_ids;
|
||||||
//Vector<int> _mob_dislike_ids;
|
//Vector<int> _mob_dislike_ids;
|
||||||
|
Loading…
Reference in New Issue
Block a user