diff --git a/data/character_class.cpp b/data/character_class.cpp index 66408f1..516e696 100644 --- a/data/character_class.cpp +++ b/data/character_class.cpp @@ -149,41 +149,70 @@ void CharacterClass::start_casting(int spell_id, Entity *caster, float spellScal } } -void CharacterClass::casting_finished(Entity *caster, float spellScale) { +void CharacterClass::sai_follow(Entity *entity) { + ERR_FAIL_COND(entity == NULL); + + if (has_method("_sai_follow")) { + call("_sai_follow", entity); + } +} +void CharacterClass::sai_rest(Entity *entity) { + ERR_FAIL_COND(entity == NULL); + + if (has_method("_sai_rest")) { + call("_sai_rest", entity); + } +} +void CharacterClass::sai_regenerate(Entity *entity) { + ERR_FAIL_COND(entity == NULL); + + if (has_method("_sai_regenerate")) { + call("_sai_regenerate", entity); + } +} +void CharacterClass::sai_attack(Entity *entity) { + ERR_FAIL_COND(entity == NULL); + + if (has_method("_sai_attack")) { + call("_sai_attack", entity); + } } -void CharacterClass::casting_failed(Entity *caster) { +void CharacterClass::sai_follow_bind(Node *entity) { + ERR_FAIL_COND(entity == NULL); + + Entity *e = Object::cast_to(entity); + + ERR_FAIL_COND(e == NULL); + + sai_follow(e); } +void CharacterClass::sai_rest_bind(Node *entity) { + ERR_FAIL_COND(entity == NULL); -void CharacterClass::spell_hit(Entity *caster, Entity *target, Node *worldSpell, Spell *spell, float spellScale) { + Entity *e = Object::cast_to(entity); + + ERR_FAIL_COND(e == NULL); + + sai_rest(e); } +void CharacterClass::sai_regenerate_bind(Node *entity) { + ERR_FAIL_COND(entity == NULL); -void CharacterClass::on_player_move(Entity *caster) { + Entity *e = Object::cast_to(entity); + + ERR_FAIL_COND(e == NULL); + + sai_regenerate(e); } +void CharacterClass::sai_attack_bind(Node *entity) { + ERR_FAIL_COND(entity == NULL); -void CharacterClass::c_on_spell_cast_started(Entity *caster) { -} + Entity *e = Object::cast_to(entity); -void CharacterClass::c_on_spell_cast_success(Entity *caster) { -} + ERR_FAIL_COND(e == NULL); -void CharacterClass::c_on_spell_cast_failed(Entity *caster) { -} - -void CharacterClass::c_on_spell_cast_ended(Entity *caster) { -} - -void CharacterClass::on_cast_state_changed(Entity *caster) { -} - -String CharacterClass::get_name() { - - return "stubname"; -} - -String CharacterClass::get_description(int level) { - - return "stubdesc"; + sai_attack(e); } void CharacterClass::_validate_property(PropertyInfo &property) const { @@ -207,6 +236,16 @@ void CharacterClass::_validate_property(PropertyInfo &property) const { } void CharacterClass::_bind_methods() { + BIND_VMETHOD(MethodInfo("_sai_follow", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + BIND_VMETHOD(MethodInfo("_sai_rest", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + BIND_VMETHOD(MethodInfo("_sai_regenerate", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + BIND_VMETHOD(MethodInfo("_sai_attack", PropertyInfo(Variant::OBJECT, "entity", PROPERTY_HINT_RESOURCE_TYPE, "Entity"))); + + ClassDB::bind_method(D_METHOD("sai_follow", "entity"), &CharacterClass::sai_follow_bind); + ClassDB::bind_method(D_METHOD("sai_rest", "entity"), &CharacterClass::sai_rest_bind); + ClassDB::bind_method(D_METHOD("sai_regenerate", "entity"), &CharacterClass::sai_regenerate_bind); + ClassDB::bind_method(D_METHOD("sai_attack", "entity"), &CharacterClass::sai_attack_bind); + ClassDB::bind_method(D_METHOD("get_id"), &CharacterClass::get_id); ClassDB::bind_method(D_METHOD("set_id", "value"), &CharacterClass::set_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); diff --git a/data/character_class.h b/data/character_class.h index e0cf126..84269d8 100644 --- a/data/character_class.h +++ b/data/character_class.h @@ -13,6 +13,7 @@ class Aura; class Spell; class Entity; class CharacterSpec; +class Entity; enum CharacterWeaponDataTypes { CHARACTER_WEAPON_DATA_TYPES_NONE, @@ -81,17 +82,16 @@ public: //// Spell System //// void start_casting(int spell_id, Entity *caster, float spellScale); - void casting_finished(Entity *caster, float spellScale); - void casting_failed(Entity *caster); - void spell_hit(Entity *caster, Entity *target, Node *worldSpell, Spell *spell, float spellScale); - void on_player_move(Entity *caster); - void c_on_spell_cast_started(Entity *player); - void c_on_spell_cast_success(Entity *player); - void c_on_spell_cast_failed(Entity *player); - void c_on_spell_cast_ended(Entity *player); - void on_cast_state_changed(Entity *caster); - String get_name(); - String get_description(int level); + + void sai_follow(Entity *entity); + void sai_rest(Entity *entity); + void sai_regenerate(Entity *entity); + void sai_attack(Entity *entity); + + void sai_follow_bind(Node *entity); + void sai_rest_bind(Node *entity); + void sai_regenerate_bind(Node *entity); + void sai_attack_bind(Node *entity); CharacterClass(); ~CharacterClass(); diff --git a/entities/mob.cpp b/entities/mob.cpp index 7bf4509..70e62f2 100644 --- a/entities/mob.cpp +++ b/entities/mob.cpp @@ -1,5 +1,19 @@ #include "mob.h" -Mob::Mob() : Entity() { - +EntityEnums::AIStates Mob::gets_ai_state() const { + return _sai_state; +} +void Mob::sets_ai_state(EntityEnums::AIStates state) { + _sai_state = state; +} + +Mob::Mob() : Entity() { + _sai_state = EntityEnums::AI_STATE_OFF; +} + + +void Mob::_bind_methods() { + ClassDB::bind_method(D_METHOD("gets_ai_state"), &Mob::gets_ai_state); + ClassDB::bind_method(D_METHOD("sets_ai_state", "value"), &Mob::sets_ai_state); + ADD_PROPERTY(PropertyInfo(Variant::INT, "ai_state", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_AI_STATES), "sets_ai_state", "gets_ai_state"); } diff --git a/entities/mob.h b/entities/mob.h index 65a087a..a099bf2 100644 --- a/entities/mob.h +++ b/entities/mob.h @@ -2,12 +2,22 @@ #define MOB_H #include "entity.h" +#include "../entity_enums.h" class Mob : public Entity { GDCLASS(Mob, Entity); public: Mob(); + + EntityEnums::AIStates gets_ai_state() const; + void sets_ai_state(EntityEnums::AIStates state); + +protected: + static void _bind_methods(); + +private: + EntityEnums::AIStates _sai_state; }; #endif diff --git a/entity_enums.cpp b/entity_enums.cpp index 2478a3c..f322207 100644 --- a/entity_enums.cpp +++ b/entity_enums.cpp @@ -4,4 +4,5 @@ const String EntityEnums::BINDING_STRING_PLAYER_RESOURCE_TYPES = "None, Rage, Ma const String EntityEnums::BINDING_STRING_ENTITY_TYPES = "None, Player, AI, Mob"; const String EntityEnums::BINDING_STRING_ENTITY_STATE_TYPES = "None, Stun, Root, Frozen, Silenced, Disoriented, Feared, Burning, Cold, Cursed, Pacified"; const String EntityEnums::BINDING_STRING_CHARCATER_SKELETON_POINTS = "Root, Pelvis, Spine, Spine 1, Spine 2, Neck, Head, Left Clavicle, Left upper Arm, Left Forearm, Left Hand, Left Thumb Base, Left Thumb End, Left Fingers Base, Left Fingers End, Right Clavicle, Right upper Arm, Right Forearm, Right Hand, Right Thumb Base, Right Thumb End, Right Fingers Base, Right Fingers End, Left Thigh, Left Calf, Left Foot, Right Thigh, Right Calf, Right Foot"; +const String EntityEnums::BINDING_STRING_AI_STATES = "Off,Rest,Regenerate,Attack"; diff --git a/entity_enums.h b/entity_enums.h index 9451037..29867f8 100644 --- a/entity_enums.h +++ b/entity_enums.h @@ -12,6 +12,7 @@ public: static const String BINDING_STRING_ENTITY_TYPES; static const String BINDING_STRING_ENTITY_STATE_TYPES; static const String BINDING_STRING_CHARCATER_SKELETON_POINTS; + static const String BINDING_STRING_AI_STATES; enum PlayerResourceTypes { PLAYER_RESOURCE_TYPES_NONE, @@ -123,6 +124,13 @@ public: SKELETON_POINTS_MAX = 29, }; + enum AIStates { + AI_STATE_OFF, + AI_STATE_REST, + AI_STATE_REGENERATE, + AI_STATE_ATTACK, + }; + EntityEnums() {} protected: @@ -198,6 +206,12 @@ protected: BIND_ENUM_CONSTANT(SKELETON_POINT_RIGHT_FOOT); BIND_ENUM_CONSTANT(SKELETON_POINTS_MAX); + + + BIND_ENUM_CONSTANT(AI_STATE_OFF); + BIND_ENUM_CONSTANT(AI_STATE_REST); + BIND_ENUM_CONSTANT(AI_STATE_REGENERATE); + BIND_ENUM_CONSTANT(AI_STATE_ATTACK); } }; @@ -206,5 +220,6 @@ VARIANT_ENUM_CAST(EntityEnums::PlayerResourceTypes); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeFlags); VARIANT_ENUM_CAST(EntityEnums::EntityStateTypeIndexes); VARIANT_ENUM_CAST(EntityEnums::CharacterSkeletonPoints); +VARIANT_ENUM_CAST(EntityEnums::AIStates); #endif