Added the ability to manually update Entities. This will allow for turn based games.

This commit is contained in:
Relintai 2019-12-28 00:44:21 +01:00
parent d81b5eaf13
commit bc797e4ffb
2 changed files with 22 additions and 2 deletions

View File

@ -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<SpellCastInfo> 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);
}

View File

@ -888,15 +888,21 @@ public:
void register_for_physics_process(Ref<SpellCastInfo> 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;