From 4aad057925df6e4cadd1e587d7892c972b28c6ae Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 17 Sep 2019 02:14:24 +0200 Subject: [PATCH] Added a few remaining things required for entity interactions. --- entities/entity.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++ entities/entity.h | 10 +++++++++ 2 files changed, 59 insertions(+) diff --git a/entities/entity.cpp b/entities/entity.cpp index e776a63..0cbf135 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -1219,10 +1219,44 @@ void Entity::sinteract() { _s_entity_data->sinteract(this); } +bool Entity::canc_interact() { + if (!ObjectDB::instance_validate(_c_target)) { + return false; + } + + EntityEnums::EntityInteractionType it = _c_target->getc_entity_interaction_type(); + + if (it == EntityEnums::ENITIY_INTERACTION_TYPE_NONE || it == EntityEnums::ENITIY_INTERACTION_TYPE_NORMAL) { + return false; + } + + return true; +} + void Entity::crequest_interact() { sinteract(); } +void Entity::ssend_open_loot_window() { + copen_loot_window(); +} +void Entity::ssend_open_container_window() { + copen_container_window(); +} +void Entity::ssend_open_vendor_window() { + copen_vendor_window(); +} + +void Entity::copen_loot_window() { + emit_signal("onc_open_loot_winow_request"); +} +void Entity::copen_container_window() { + emit_signal("onc_open_container_winow_request"); +} +void Entity::copen_vendor_window() { + emit_signal("onc_open_vendor_winow_request"); +} + //XP Operations void Entity::adds_xp(int value) { _s_xp += value; @@ -3609,6 +3643,11 @@ void Entity::_bind_methods() { //setup BIND_VMETHOD(MethodInfo("_setup")); + //Windows + ADD_SIGNAL(MethodInfo("onc_open_loot_winow_request")); + ADD_SIGNAL(MethodInfo("onc_open_container_winow_request")); + ADD_SIGNAL(MethodInfo("onc_open_vendor_winow_request")); + ClassDB::bind_method(D_METHOD("setup"), &Entity::setup); //ClassDB::bind_method(D_METHOD("_setup"), &Entity::_setup); @@ -3759,8 +3798,18 @@ void Entity::_bind_methods() { //Interactions ClassDB::bind_method(D_METHOD("cans_interact"), &Entity::cans_interact); ClassDB::bind_method(D_METHOD("sinteract"), &Entity::sinteract); + + ClassDB::bind_method(D_METHOD("canc_interact"), &Entity::canc_interact); ClassDB::bind_method(D_METHOD("crequest_interact"), &Entity::crequest_interact); + ClassDB::bind_method(D_METHOD("ssend_open_loot_window"), &Entity::ssend_open_loot_window); + ClassDB::bind_method(D_METHOD("ssend_open_container_window"), &Entity::ssend_open_container_window); + ClassDB::bind_method(D_METHOD("ssend_open_vendor_window"), &Entity::ssend_open_vendor_window); + + ClassDB::bind_method(D_METHOD("copen_loot_window"), &Entity::copen_loot_window); + ClassDB::bind_method(D_METHOD("copen_container_window"), &Entity::copen_container_window); + ClassDB::bind_method(D_METHOD("copen_vendor_window"), &Entity::copen_vendor_window); + //XP Operations ClassDB::bind_method(D_METHOD("adds_xp", "value"), &Entity::adds_xp); ClassDB::bind_method(D_METHOD("addc_xp", "value"), &Entity::addc_xp); diff --git a/entities/entity.h b/entities/entity.h index 9791484..7ca8888 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -369,8 +369,18 @@ public: //Interactions bool cans_interact(); void sinteract(); + + bool canc_interact(); void crequest_interact(); + void ssend_open_loot_window(); + void ssend_open_container_window(); + void ssend_open_vendor_window(); + + void copen_loot_window(); + void copen_container_window(); + void copen_vendor_window(); + //XP Operations void adds_xp(int value); void addc_xp(int value);