Added more variables to AISpellACtion, and added an AiSpellActionContainer.

This commit is contained in:
Relintai 2019-09-25 11:29:25 +02:00
parent 1d317c56b7
commit bdc90b4b47
6 changed files with 152 additions and 0 deletions

1
SCsub
View File

@ -111,4 +111,5 @@ module_env.add_source_files(env.modules_sources,"loot/loot_data_item.cpp")
module_env.add_source_files(env.modules_sources,"ai/ai_action.cpp")
module_env.add_source_files(env.modules_sources,"ai/ai_spell_action.cpp")
module_env.add_source_files(env.modules_sources,"ai/ai_action_container.cpp")
module_env.add_source_files(env.modules_sources,"ai/ai_spell_action_container.cpp")

View File

@ -18,8 +18,42 @@ void AISpellAction::set_spell(Ref<Spell> spell) {
_spell = spell;
}
int AISpellAction::get_keep_aura_on_target() const {
return _keep_aura_on_target;
}
void AISpellAction::set_keep_aura_on_target(const int value) {
_keep_aura_on_target = value;
}
int AISpellAction::get_keep_aura_on_target_index() const {
return _keep_aura_on_target_index;
}
void AISpellAction::set_keep_aura_on_target_index(const int value) {
_keep_aura_on_target_index = value;
}
int AISpellAction::get_keep_aura_on_self() const {
return _keep_aura_on_self;
}
void AISpellAction::set_keep_aura_on_self(const int value) {
_keep_aura_on_self = value;
}
int AISpellAction::get_keep_aura_on_self_index() const {
return _keep_aura_on_self_index;
}
void AISpellAction::set_keep_aura_on_self_index(const int value) {
_keep_aura_on_self_index = value;
}
AISpellAction::AISpellAction() {
_type = AI_SPELL_ACTION_TYPE_NONE;
_keep_aura_on_target = false;
_keep_aura_on_target_index = 0;
_keep_aura_on_self = false;
_keep_aura_on_self_index = 0;
}
void AISpellAction::_bind_methods() {
@ -31,6 +65,24 @@ void AISpellAction::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_spell", "value"), &AISpellAction::set_spell);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_spell", "get_spell");
ADD_GROUP("keep_aura", "Keep Auras");
ClassDB::bind_method(D_METHOD("get_keep_aura_on_target"), &AISpellAction::get_keep_aura_on_target);
ClassDB::bind_method(D_METHOD("set_keep_aura_on_target", "value"), &AISpellAction::set_keep_aura_on_target);
ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aura_on_target"), "set_keep_aura_on_target", "get_keep_aura_on_target");
ClassDB::bind_method(D_METHOD("get_keep_aura_on_target_index"), &AISpellAction::get_keep_aura_on_target_index);
ClassDB::bind_method(D_METHOD("set_keep_aura_on_target_index", "value"), &AISpellAction::set_keep_aura_on_target_index);
ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aura_on_target_index"), "set_keep_aura_on_target_index", "get_keep_aura_on_target_index");
ClassDB::bind_method(D_METHOD("get_keep_aura_on_self"), &AISpellAction::get_keep_aura_on_self);
ClassDB::bind_method(D_METHOD("set_keep_aura_on_self", "value"), &AISpellAction::set_keep_aura_on_self);
ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aura_on_self"), "set_keep_aura_on_self", "get_keep_aura_on_self");
ClassDB::bind_method(D_METHOD("get_keep_aura_on_self_index"), &AISpellAction::get_keep_aura_on_self_index);
ClassDB::bind_method(D_METHOD("set_keep_aura_on_self_index", "value"), &AISpellAction::set_keep_aura_on_self_index);
ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aura_on_self_index"), "set_keep_aura_on_self_index", "get_keep_aura_on_self_index");
BIND_ENUM_CONSTANT(AI_SPELL_ACTION_TYPE_NONE);
BIND_ENUM_CONSTANT(AI_SPELL_ACTION_TYPE_ATTACK);
BIND_ENUM_CONSTANT(AI_SPELL_ACTION_TYPE_CHARGE);

View File

@ -30,6 +30,19 @@ public:
Ref<Spell> get_spell();
void set_spell(Ref<Spell> spell);
int get_keep_aura_on_target() const;
void set_keep_aura_on_target(const int value);
int get_keep_aura_on_target_index() const;
void set_keep_aura_on_target_index(const int value);
int get_keep_aura_on_self() const;
void set_keep_aura_on_self(const int value);
int get_keep_aura_on_self_index() const;
void set_keep_aura_on_self_index(const int value);
AISpellAction();
protected:
@ -38,6 +51,12 @@ protected:
private:
AISpellActionType _type;
Ref<Spell> _spell;
bool _keep_aura_on_target;
int _keep_aura_on_target_index;
bool _keep_aura_on_self;
int _keep_aura_on_self_index;
};
VARIANT_ENUM_CAST(AISpellAction::AISpellActionType);

View File

@ -0,0 +1,50 @@
#include "ai_spell_action_container.h"
int AISpellActionContainer::get_num_ai_spell_actions() {
return _ai_spell_actions.size();
}
void AISpellActionContainer::set_num_ai_spell_actions(int value) {
_ai_spell_actions.resize(value);
}
Ref<AISpellAction> AISpellActionContainer::get_ai_spell_action(int index) {
ERR_FAIL_INDEX_V(index, _ai_spell_actions.size(), Ref<AISpellAction>());
return _ai_spell_actions[index];
}
void AISpellActionContainer::set_ai_spell_action(int index, Ref<AISpellAction> ai_spell_action) {
ERR_FAIL_INDEX(index, _ai_spell_actions.size());
_ai_spell_actions.set(index, ai_spell_action);
}
Vector<Variant> AISpellActionContainer::get_ai_spell_actions() {
Vector<Variant> r;
for (int i = 0; i < _ai_spell_actions.size(); i++) {
r.push_back(_ai_spell_actions[i].get_ref_ptr());
}
return r;
}
void AISpellActionContainer::set_ai_spell_actions(const Vector<Variant> &ai_spell_actions) {
_ai_spell_actions.clear();
for (int i = 0; i < ai_spell_actions.size(); i++) {
Ref<AISpellAction> ai_spell_action = Ref<AISpellAction>(ai_spell_actions[i]);
_ai_spell_actions.push_back(ai_spell_action);
}
}
AISpellActionContainer::AISpellActionContainer() {
}
void AISpellActionContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_num_ai_spell_actions"), &AISpellActionContainer::get_num_ai_spell_actions);
ClassDB::bind_method(D_METHOD("set_num_ai_spell_actions", "value"), &AISpellActionContainer::set_num_ai_spell_actions);
ClassDB::bind_method(D_METHOD("get_ai_spell_action", "index"), &AISpellActionContainer::get_ai_spell_action);
ClassDB::bind_method(D_METHOD("set_ai_spell_action", "index", "action"), &AISpellActionContainer::set_ai_spell_action);
ClassDB::bind_method(D_METHOD("get_ai_spell_actions"), &AISpellActionContainer::get_ai_spell_actions);
ClassDB::bind_method(D_METHOD("set_ai_spell_actions", "action"), &AISpellActionContainer::set_ai_spell_actions);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "ai_spell_actions", PROPERTY_HINT_NONE, "17/17:AISpellAction", PROPERTY_USAGE_DEFAULT, "AISpellAction"), "set_ai_spell_actions", "get_ai_spell_actions");
}

View File

@ -0,0 +1,28 @@
#ifndef AI_SPELL_ACTION_CONTAINER_H
#define AI_SPELL_ACTION_CONTAINER_H
#include "ai_spell_action.h"
class AISpellActionContainer : public AIAction {
GDCLASS(AISpellActionContainer, AIAction);
public:
int get_num_ai_spell_actions();
void set_num_ai_spell_actions(int value);
Ref<AISpellAction> get_ai_spell_action(int index);
void set_ai_spell_action(int index, Ref<AISpellAction> action);
Vector<Variant> get_ai_spell_actions();
void set_ai_spell_actions(const Vector<Variant> &auras);
AISpellActionContainer();
protected:
static void _bind_methods();
private:
Vector<Ref<AISpellAction> > _ai_spell_actions;
};
#endif

View File

@ -101,6 +101,7 @@
#include "ai/ai_action.h"
#include "ai/ai_spell_action.h"
#include "ai/ai_action_container.h"
#include "ai/ai_spell_action_container.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_plugin.h"
@ -222,6 +223,7 @@ void register_entity_spell_system_types() {
ClassDB::register_class<AIAction>();
ClassDB::register_class<AISpellAction>();
ClassDB::register_class<AIActionContainer>();
ClassDB::register_class<AISpellActionContainer>();
//meshes
ClassDB::register_class<MeshDataResource>();