Better/Different AuraGroup implementation.

This commit is contained in:
Relintai 2019-11-01 22:07:56 +01:00
parent 7e8212144c
commit 0bdf6652a6
8 changed files with 74 additions and 21 deletions

1
SCsub
View File

@ -12,6 +12,7 @@ module_env.add_source_files(env.modules_sources,"spell_enums.cpp")
module_env.add_source_files(env.modules_sources,"item_enums.cpp")
module_env.add_source_files(env.modules_sources,"data/aura.cpp")
module_env.add_source_files(env.modules_sources,"data/aura_group.cpp")
module_env.add_source_files(env.modules_sources,"data/talent_rank_data.cpp")
module_env.add_source_files(env.modules_sources,"data/xp_data.cpp")
module_env.add_source_files(env.modules_sources,"data/item_stat_modifier.cpp")

View File

@ -28,11 +28,11 @@ void Aura::set_tick(float value) {
_tick = value;
}
int Aura::get_aura_group() {
return aura_group;
Ref<AuraGroup> Aura::get_aura_group() {
return _aura_group;
}
void Aura::set_aura_group(int value) {
aura_group = value;
void Aura::set_aura_group(Ref<AuraGroup> value) {
_aura_group = value;
}
bool Aura::get_is_debuff() {
@ -135,12 +135,6 @@ void Aura::set_teaches_spell(const Ref<Spell> spell) {
_teaches_spell = spell;
}
void Aura::set(int id, float time, int auraGroup) {
this->set_id(id);
this->set_time(time);
this->set_aura_group(auraGroup);
}
/*
void Aura::SetScalingData(AbilityScalingData *scalingData) {
scalingData->getDamageCurve();
@ -270,7 +264,6 @@ Aura::Aura() {
_tick = 0;
_aura_type = SpellEnums::AURA_TYPE_NONE;
_is_debuff = false;
aura_group = 0;
_hide = false;
_rank = 0;
@ -1385,7 +1378,7 @@ void Aura::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_aura_group"), &Aura::get_aura_group);
ClassDB::bind_method(D_METHOD("set_aura_group", "value"), &Aura::set_aura_group);
ADD_PROPERTY(PropertyInfo(Variant::INT, "aura_group"), "set_aura_group", "get_aura_group");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "aura_group", PROPERTY_HINT_RESOURCE_TYPE, "AuraGroup"), "set_aura_group", "get_aura_group");
ClassDB::bind_method(D_METHOD("get_hide"), &Aura::get_hide);
ClassDB::bind_method(D_METHOD("set_hide", "value"), &Aura::set_hide);

View File

@ -5,6 +5,8 @@
#include "scene/resources/curve.h"
#include "scene/resources/texture.h"
#include "aura_group.h"
#include "../entity_enums.h"
#include "../spell_enums.h"
@ -45,8 +47,8 @@ public:
float get_time();
void set_time(float value);
int get_aura_group();
void set_aura_group(int value);
Ref<AuraGroup> get_aura_group();
void set_aura_group(Ref<AuraGroup> value);
bool get_is_debuff();
void set_is_debuff(bool value);
@ -84,8 +86,7 @@ public:
float get_damage_scale_for_level(int level);
float get_heal_scale_for_level(int level);
float get_absorb_scale_for_level(int level);
void set(int id, float time, int auraGroup);
Ref<Spell> get_teaches_spell() const;
void set_teaches_spell(const Ref<Spell> spell);
@ -405,7 +406,7 @@ private:
int id;
float time;
float _tick;
int aura_group;
Ref<AuraGroup> _aura_group;
Ref<Texture> _icon;
SpellEnums::AuraType _aura_type;
bool _is_debuff;

8
data/aura_group.cpp Normal file
View File

@ -0,0 +1,8 @@
#include "aura_group.h"
AuraGroup::AuraGroup() {
}
void AuraGroup::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_description"), "set_text_description", "get_text_description");
}

16
data/aura_group.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef AURA_GROUP_H
#define AURA_GROUP_H
#include "core/resource.h"
class AuraGroup : public Resource {
GDCLASS(AuraGroup, Resource);
public:
AuraGroup();
protected:
static void _bind_methods();
};
#endif

View File

@ -2458,18 +2458,45 @@ Ref<AuraData> Entity::sget_aura_by(Entity *caster, int aura_id) {
}
Ref<AuraData> Entity::sget_aura_by_bind(Node *caster, int aura_id) {
if (!caster) {
return Ref<AuraData>(NULL);
return Ref<AuraData>();
}
Entity *e = cast_to<Entity>(caster);
if (!e) {
return Ref<AuraData>(NULL);
return Ref<AuraData>();
}
return sget_aura_by(e, aura_id);
}
Ref<AuraData> Entity::sget_aura_with_group_by(Entity *caster, Ref<AuraGroup> aura_group) {
for (int i = 0; i < _s_auras.size(); ++i) {
Ref<AuraData> ad = _s_auras.get(i);
if (ad->get_aura()->get_aura_group() == aura_group && ad->get_caster() == caster) {
return ad;
}
}
return Ref<AuraData>(NULL);
}
Ref<AuraData> Entity::sget_aura_with_group_by_bind(Node *caster, Ref<AuraGroup> aura_group) {
if (!caster) {
return Ref<AuraData>();
}
Entity *e = cast_to<Entity>(caster);
if (!e) {
return Ref<AuraData>();
}
return sget_aura_with_group_by(e, aura_group);
}
int Entity::cget_aura_count() {
return _s_auras.size();
}
@ -3568,7 +3595,7 @@ void Entity::setc_spell_cast_info(Ref<SpellCastInfo> info) {
_c_spell_cast_info = Ref<SpellCastInfo>(info);
}
void Entity::sremove_auras_with_group(int aura_group) {
void Entity::sremove_auras_with_group(Ref<AuraGroup> aura_group) {
for (int i = 0; i < _s_auras.size(); ++i) {
Ref<AuraData> ad = _s_auras.get(i);

View File

@ -38,6 +38,8 @@
#include "../ai/ai_fsm_action.h"
#include "../data/aura_group.h"
class EntityData;
class AuraData;
class Spell;
@ -500,7 +502,7 @@ public:
void cremove_aura_dispelled(Ref<AuraData> aura);
void caura_refreshed(Ref<AuraData> aura);
void sremove_auras_with_group(int aura_group);
void sremove_auras_with_group(Ref<AuraGroup> aura_group);
//NOTE: No reason for shas_aura_by, just query it, and check for null.
int sget_aura_count();
@ -508,6 +510,9 @@ public:
Ref<AuraData> sget_aura_by(Entity *caster, int aura_id);
Ref<AuraData> sget_aura_by_bind(Node *caster, int aura_id);
Ref<AuraData> sget_aura_with_group_by(Entity *caster, Ref<AuraGroup> aura_group);
Ref<AuraData> sget_aura_with_group_by_bind(Node *caster, Ref<AuraGroup> aura_group);
int cget_aura_count();
Ref<AuraData> cget_aura(int index);

View File

@ -4,6 +4,7 @@
#include "item_enums.h"
#include "data/aura.h"
#include "data/aura_group.h"
#include "data/aura_stat_attribute.h"
#include "entity_data_manager.h"
#include "data/xp_data.h"
@ -134,6 +135,7 @@ void register_entity_spell_system_types() {
ClassDB::register_class<Spell>();
ClassDB::register_class<Aura>();
ClassDB::register_class<AuraGroup>();
ClassDB::register_class<AuraStatAttribute>();
ClassDB::register_class<EntityData>();