Add GetWorld to Actor. Integrate google test. Add Model manager class. Rename *.h to *.hpp files
This commit is contained in:
@@ -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)
|
||||
};
|
||||
*/
|
||||
Reference in New Issue
Block a user