Add a WorldSpell property to SpellCastInfo.

This commit is contained in:
Relintai 2020-02-07 23:25:15 +01:00
parent d33a499847
commit dc23652f70
2 changed files with 36 additions and 13 deletions

View File

@ -23,7 +23,8 @@ SOFTWARE.
#include "spell_cast_info.h" #include "spell_cast_info.h"
#include "../data/spells/spell.h" #include "../data/spells/spell.h"
#include "../entities/entity.h"
#include "../world_spells/world_spell.h"
#include "../singletons/entity_data_manager.h" #include "../singletons/entity_data_manager.h"
//// SpellCastInfo //// //// SpellCastInfo ////
@ -35,11 +36,9 @@ Entity *SpellCastInfo::get_caster() {
return _caster; return _caster;
} }
void SpellCastInfo::set_caster(Entity *value) { void SpellCastInfo::set_caster(Entity *value) {
_caster = value; _caster = value;
} }
void SpellCastInfo::set_caster_bind(Node *caster) { void SpellCastInfo::set_caster_bind(Node *caster) {
if (!caster) { if (!caster) {
return; return;
@ -61,11 +60,9 @@ Entity *SpellCastInfo::get_target() {
return _target; return _target;
} }
void SpellCastInfo::set_target(Entity *value) { void SpellCastInfo::set_target(Entity *value) {
_target = value; _target = value;
} }
void SpellCastInfo::set_target_bind(Node *target) { void SpellCastInfo::set_target_bind(Node *target) {
if (!target) { if (!target) {
return; return;
@ -80,10 +77,33 @@ void SpellCastInfo::set_target_bind(Node *target) {
_target = e; _target = e;
} }
WorldSpell *SpellCastInfo::get_world_spell() {
if (_world_spell && !ObjectDB::instance_validate(_world_spell)) {
_world_spell = NULL;
}
return _world_spell;
}
void SpellCastInfo::set_world_spell(WorldSpell *world_spell) {
_world_spell = world_spell;
}
void SpellCastInfo::set_world_spell_bind(Node *world_spell) {
if (!world_spell) {
return;
}
WorldSpell *w = cast_to<WorldSpell>(world_spell);
if (!ObjectDB::instance_validate(w)) {
return;
}
_world_spell = w;
}
bool SpellCastInfo::get_has_cast_time() const { bool SpellCastInfo::get_has_cast_time() const {
return _has_cast_time; return _has_cast_time;
} }
void SpellCastInfo::set_has_cast_time(bool value) { void SpellCastInfo::set_has_cast_time(bool value) {
_has_cast_time = value; _has_cast_time = value;
} }
@ -91,7 +111,6 @@ void SpellCastInfo::set_has_cast_time(bool value) {
float SpellCastInfo::get_cast_time() const { float SpellCastInfo::get_cast_time() const {
return _cast_time; return _cast_time;
} }
void SpellCastInfo::set_cast_time(float value) { void SpellCastInfo::set_cast_time(float value) {
_cast_time = value; _cast_time = value;
} }
@ -99,7 +118,6 @@ void SpellCastInfo::set_cast_time(float value) {
float SpellCastInfo::get_current_cast_time() const { float SpellCastInfo::get_current_cast_time() const {
return _current_cast_time; return _current_cast_time;
} }
void SpellCastInfo::set_current_cast_time(float value) { void SpellCastInfo::set_current_cast_time(float value) {
_current_cast_time = value; _current_cast_time = value;
} }
@ -107,7 +125,6 @@ void SpellCastInfo::set_current_cast_time(float value) {
bool SpellCastInfo::get_is_casting() const { bool SpellCastInfo::get_is_casting() const {
return _is_casting; return _is_casting;
} }
void SpellCastInfo::set_is_casting(bool value) { void SpellCastInfo::set_is_casting(bool value) {
_is_casting = value; _is_casting = value;
} }
@ -115,7 +132,6 @@ void SpellCastInfo::set_is_casting(bool value) {
int SpellCastInfo::get_num_pushbacks() const { int SpellCastInfo::get_num_pushbacks() const {
return _num_pushbacks; return _num_pushbacks;
} }
void SpellCastInfo::set_num_pushbacks(int value) { void SpellCastInfo::set_num_pushbacks(int value) {
_num_pushbacks = value; _num_pushbacks = value;
} }
@ -123,7 +139,6 @@ void SpellCastInfo::set_num_pushbacks(int value) {
float SpellCastInfo::get_spell_scale() const { float SpellCastInfo::get_spell_scale() const {
return _spell_scale; return _spell_scale;
} }
void SpellCastInfo::set_spell_scale(float value) { void SpellCastInfo::set_spell_scale(float value) {
_spell_scale = value; _spell_scale = value;
} }
@ -131,7 +146,6 @@ void SpellCastInfo::set_spell_scale(float value) {
Ref<Spell> SpellCastInfo::get_spell() const { Ref<Spell> SpellCastInfo::get_spell() const {
return _spell; return _spell;
} }
void SpellCastInfo::set_spell(Ref<Spell> spell) { void SpellCastInfo::set_spell(Ref<Spell> spell) {
_spell = spell; _spell = spell;
} }
@ -235,6 +249,10 @@ void SpellCastInfo::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_target", "caster"), &SpellCastInfo::set_target_bind); ClassDB::bind_method(D_METHOD("set_target", "caster"), &SpellCastInfo::set_target_bind);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), "set_target", "get_target"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target", PROPERTY_HINT_RESOURCE_TYPE, "Entity"), "set_target", "get_target");
ClassDB::bind_method(D_METHOD("get_world_spell"), &SpellCastInfo::get_world_spell);
ClassDB::bind_method(D_METHOD("set_world_spell", "world_spell"), &SpellCastInfo::set_world_spell_bind);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_spell", PROPERTY_HINT_RESOURCE_TYPE, "WorldSpell"), "set_world_spell", "get_world_spell");
ClassDB::bind_method(D_METHOD("get_has_cast_time"), &SpellCastInfo::get_has_cast_time); ClassDB::bind_method(D_METHOD("get_has_cast_time"), &SpellCastInfo::get_has_cast_time);
ClassDB::bind_method(D_METHOD("set_has_cast_time", "value"), &SpellCastInfo::set_has_cast_time); ClassDB::bind_method(D_METHOD("set_has_cast_time", "value"), &SpellCastInfo::set_has_cast_time);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "has_cast_time"), "set_has_cast_time", "get_has_cast_time"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "has_cast_time"), "set_has_cast_time", "get_has_cast_time");

View File

@ -23,11 +23,11 @@ SOFTWARE.
#ifndef SPELL_INFOS_H #ifndef SPELL_INFOS_H
#define SPELL_INFOS_H #define SPELL_INFOS_H
#include "../entities/entity.h"
#include "core/reference.h" #include "core/reference.h"
class Spell; class Spell;
class Entity; class Entity;
class WorldSpell;
class SpellCastInfo : public Reference { class SpellCastInfo : public Reference {
GDCLASS(SpellCastInfo, Reference); GDCLASS(SpellCastInfo, Reference);
@ -41,6 +41,10 @@ public:
void set_target(Entity *caster); void set_target(Entity *caster);
void set_target_bind(Node *caster); void set_target_bind(Node *caster);
WorldSpell *get_world_spell();
void set_world_spell(WorldSpell *world_spell);
void set_world_spell_bind(Node *world_spell);
bool get_has_cast_time() const; bool get_has_cast_time() const;
void set_has_cast_time(bool value); void set_has_cast_time(bool value);
@ -79,6 +83,7 @@ protected:
private: private:
Entity *_caster; Entity *_caster;
Entity *_target; Entity *_target;
WorldSpell *_world_spell;
bool _has_cast_time; bool _has_cast_time;
float _cast_time; float _cast_time;
float _spell_scale; float _spell_scale;