From 677f138a462b248d45b679a66d0b4cd3ed886ef8 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 24 Apr 2020 00:43:18 +0200 Subject: [PATCH] Added a c_is_controller property to Entity. the server will set it to true for the owner if this is the entity they are supposed to control. --- entities/entity.cpp | 19 +++++++++++++++++++ entities/entity.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/entities/entity.cpp b/entities/entity.cpp index 5263038..c97209b 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -763,6 +763,17 @@ EntityEnums::EntityController Entity::gets_entity_controller() { } void Entity::sets_entity_controller(EntityEnums::EntityController value) { _s_entity_controller = value; + + ORPC(setc_is_controlled, value == EntityEnums::ENITIY_CONTROLLER_PLAYER); +} + +bool Entity::getc_is_controlled() { + return _c_is_controlled; +} +void Entity::setc_is_controlled(bool value) { + _c_is_controlled = value; + + emit_signal("isc_controlled_changed", value); } Ref Entity::gets_ai() { @@ -6047,6 +6058,7 @@ Entity::Entity() { _s_original_entity_controller = EntityEnums::ENITIY_CONTROLLER_NONE; _s_entity_controller = EntityEnums::ENITIY_CONTROLLER_NONE; + _c_is_controlled = false; _s_pet_owner = NULL; _c_pet_owner = NULL; @@ -6066,6 +6078,7 @@ Entity::Entity() { SET_RPC_REMOTE("setc_class_xp"); SET_RPC_REMOTE("setc_character_xp"); SET_RPC_REMOTE("setc_seed"); + SET_RPC_REMOTE("setc_is_controlled"); //EntityType @@ -7586,6 +7599,12 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("sets_entity_controller", "value"), &Entity::sets_entity_controller); ADD_PROPERTY(PropertyInfo(Variant::INT, "sentity_controller", PROPERTY_HINT_ENUM, EntityEnums::BINDING_STRING_ENTITY_CONTOLLER), "sets_entity_controller", "gets_entity_controller"); + ADD_SIGNAL(MethodInfo("isc_controlled_changed", PropertyInfo(Variant::BOOL, "value"))); + + ClassDB::bind_method(D_METHOD("getc_is_controlled"), &Entity::getc_is_controlled); + ClassDB::bind_method(D_METHOD("setc_is_controlled", "value"), &Entity::setc_is_controlled); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "c_is_controlled"), "setc_is_controlled", "getc_is_controlled"); + ClassDB::bind_method(D_METHOD("gets_ai"), &Entity::gets_ai); ClassDB::bind_method(D_METHOD("sets_ai", "value"), &Entity::sets_ai); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "sai", PROPERTY_HINT_RESOURCE_TYPE, "EntityAI"), "sets_ai", "gets_ai"); diff --git a/entities/entity.h b/entities/entity.h index 1a30756..10f0f2c 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -920,6 +920,9 @@ public: EntityEnums::EntityController gets_entity_controller(); void sets_entity_controller(EntityEnums::EntityController value); + bool getc_is_controlled(); + void setc_is_controlled(bool value); + Ref gets_ai(); void sets_ai(Ref value); @@ -1193,6 +1196,7 @@ private: EntityEnums::EntityController _s_original_entity_controller; EntityEnums::EntityController _s_entity_controller; + bool _c_is_controlled; Ref _s_ai; //Pets