feat: game state is now loaded from user://savegame.res

main
Sara 2024-10-24 19:27:57 +02:00
parent 885d843cda
commit c3f104b630
4 changed files with 7 additions and 5 deletions

View File

@ -2,7 +2,7 @@
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/classes/packed_scene.hpp>
#include <godot_cpp/classes/scene_state.hpp>
#include "utils/godot_macros.hpp"
#include "godot_macros.hpp"
namespace utils {
void GameMode::_bind_methods() {

View File

@ -12,6 +12,7 @@
#include <godot_cpp/classes/input.hpp>
#include <godot_cpp/classes/packed_scene.hpp>
#include <godot_cpp/classes/scene_state.hpp>
#include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/templates/pair.hpp>
#include <godot_cpp/variant/string_name.hpp>
@ -44,8 +45,9 @@ void GameRoot3D::_enter_tree() {
}
void GameRoot3D::_ready() {
// TODO: try load save data from file.
this->game_state = this->game_state_prototype->duplicate(true);
this->game_state = gd::ResourceLoader::get_singleton()->load("user://savegame.res");
if(!this->game_state.is_valid())
this->game_state = this->game_state_prototype->duplicate(true);
this->load_level(this->first_boot_level);
}

View File

@ -1,6 +1,6 @@
#include "level.hpp"
#include "godot_macros.hpp"
#include <godot_cpp/core/class_db.hpp>
#include "utils/godot_macros.hpp"
#include <godot_cpp/classes/scene_state.hpp>
namespace utils {

View File

@ -1,5 +1,5 @@
#include "spawn_point.hpp"
#include "utils/game_root.hpp"
#include "game_root.hpp"
namespace utils {
void SpawnPoint3D::_bind_methods() {