From bdc90b4b47215dcbd8ca19de1f2c4f551b38d934 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 25 Sep 2019 11:29:25 +0200 Subject: [PATCH] Added more variables to AISpellACtion, and added an AiSpellActionContainer. --- SCsub | 1 + ai/ai_spell_action.cpp | 52 ++++++++++++++++++++++++++++++++ ai/ai_spell_action.h | 19 ++++++++++++ ai/ai_spell_action_container.cpp | 50 ++++++++++++++++++++++++++++++ ai/ai_spell_action_container.h | 28 +++++++++++++++++ register_types.cpp | 2 ++ 6 files changed, 152 insertions(+) create mode 100644 ai/ai_spell_action_container.cpp create mode 100644 ai/ai_spell_action_container.h diff --git a/SCsub b/SCsub index cdee6b2..505a2d2 100644 --- a/SCsub +++ b/SCsub @@ -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") diff --git a/ai/ai_spell_action.cpp b/ai/ai_spell_action.cpp index 73342d5..e5c8d74 100644 --- a/ai/ai_spell_action.cpp +++ b/ai/ai_spell_action.cpp @@ -18,8 +18,42 @@ void AISpellAction::set_spell(Ref 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); diff --git a/ai/ai_spell_action.h b/ai/ai_spell_action.h index 504460c..264b2c6 100644 --- a/ai/ai_spell_action.h +++ b/ai/ai_spell_action.h @@ -30,6 +30,19 @@ public: Ref get_spell(); void set_spell(Ref 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; + + 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); diff --git a/ai/ai_spell_action_container.cpp b/ai/ai_spell_action_container.cpp new file mode 100644 index 0000000..f47f634 --- /dev/null +++ b/ai/ai_spell_action_container.cpp @@ -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 AISpellActionContainer::get_ai_spell_action(int index) { + ERR_FAIL_INDEX_V(index, _ai_spell_actions.size(), Ref()); + + return _ai_spell_actions[index]; +} +void AISpellActionContainer::set_ai_spell_action(int index, Ref ai_spell_action) { + ERR_FAIL_INDEX(index, _ai_spell_actions.size()); + + _ai_spell_actions.set(index, ai_spell_action); +} + +Vector AISpellActionContainer::get_ai_spell_actions() { + Vector 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 &ai_spell_actions) { + _ai_spell_actions.clear(); + for (int i = 0; i < ai_spell_actions.size(); i++) { + Ref ai_spell_action = Ref(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"); +} diff --git a/ai/ai_spell_action_container.h b/ai/ai_spell_action_container.h new file mode 100644 index 0000000..1cfcecf --- /dev/null +++ b/ai/ai_spell_action_container.h @@ -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 get_ai_spell_action(int index); + void set_ai_spell_action(int index, Ref action); + + Vector get_ai_spell_actions(); + void set_ai_spell_actions(const Vector &auras); + + AISpellActionContainer(); + +protected: + static void _bind_methods(); + +private: + Vector > _ai_spell_actions; +}; + +#endif diff --git a/register_types.cpp b/register_types.cpp index 227c0b1..36184a7 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -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(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); //meshes ClassDB::register_class();