From bc797e4ffbc9827d379c50e9e8bf76690c5b7111 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 28 Dec 2019 00:44:21 +0100 Subject: [PATCH] Added the ability to manually update Entities. This will allow for turn based games. --- entities/entity.cpp | 16 +++++++++++++++- entities/entity.h | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/entities/entity.cpp b/entities/entity.cpp index 0660fa9..aa4252c 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -4768,6 +4768,13 @@ void Entity::loaded() { //// PlayerData //// +bool Entity::get_maunal_process() const { + return _maunal_process; +} +void Entity::set_maunal_process(const bool value) { + _maunal_process = value; +} + void Entity::update(float delta) { if (_s_gcd > 0.0000001) { _s_gcd -= delta; @@ -5058,6 +5065,7 @@ void Entity::register_for_physics_process(Ref info) { } Entity::Entity() { + _maunal_process = false; _deserialized = false; _s_guid = 0; @@ -5413,7 +5421,8 @@ void Entity::_notification(int p_what) { } } break; case NOTIFICATION_PROCESS: { - update(get_process_delta_time()); + if (!_maunal_process) + update(get_process_delta_time()); } break; case NOTIFICATION_PHYSICS_PROCESS: { son_physics_process(get_physics_process_delta_time()); @@ -6364,4 +6373,9 @@ void Entity::_bind_methods() { ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "vrpc", &Entity::_vrpc_bind, mi); ClassDB::bind_method(D_METHOD("register_for_physics_process", "info"), &Entity::register_for_physics_process); + + ClassDB::bind_method(D_METHOD("get_maunal_process"), &Entity::get_maunal_process); + ClassDB::bind_method(D_METHOD("set_maunal_process", "value"), &Entity::set_maunal_process); + + ClassDB::bind_method(D_METHOD("update", "delta"), &Entity::update); } diff --git a/entities/entity.h b/entities/entity.h index 41a442c..0bd22e8 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -888,15 +888,21 @@ public: void register_for_physics_process(Ref info); + bool get_maunal_process() const; + void set_maunal_process(bool value); + + void update(float delta); + Entity(); ~Entity(); protected: static void _bind_methods(); virtual void _notification(int p_what); - virtual void update(float delta); private: + bool _maunal_process; + const float SAVE_BASE_SECONDS = 10.0; bool _deserialized;