Add GetWorld to Actor. Integrate google test. Add Model manager class. Rename *.h to *.hpp files

This commit is contained in:
Jiga228
2025-10-13 19:31:27 +07:00
parent fedffa7634
commit 8819114b63
44 changed files with 424 additions and 59 deletions
+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include <vector>
#include <fstream>
#include <string>
#include "Game/SaveMap/SaveMap.hpp"
class GameInstance;
class World;
struct WorldFactory
{
const char* world_name;
World*(*factory)(GameInstance&);
};
// Создаёт ассоцеативный список
// В нём соспоставляются имина уровней и фабрики их классов
#define WORLDS_LIST std::vector<WorldFactory> world_factories =
// Генерирует элемент списка
#define GENERATE_WORLD_FACTORY(Class, WorldName) WorldFactory{#WorldName,\
[](GameInstance& game_insance)->World* {\
Class* world = new Class(game_insance);\
std::ifstream config_file("./Worlds/" #WorldName ".world");\
if (config_file.fail())\
throw std::runtime_error("Can't open world file");\
std::string data;\
std::getline(config_file, data);\
world->load(std::make_shared<SaveMap>(data));\
return world;\
}},
/*
* Пример использования:
WORLDS_LIST {
GENERATE_WORLD_FACTORY(Sometime_class_world_One, WorldName_One)
GENERATE_WORLD_FACTORY(Sometime_class_world_Two, WorldName_Two)
};
*/