mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
format: reformat project
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
parent
736cd175d5
commit
bbf33e8e4d
202 changed files with 7389 additions and 5609 deletions
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef WORLD_LEVEL_HPP_
|
||||
#define WORLD_LEVEL_HPP_
|
||||
|
||||
#include "../interfaces/Object.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "../interfaces/Object.hpp"
|
||||
|
||||
inline constexpr float DEF_PLAYER_Y = 100.0f;
|
||||
inline constexpr float DEF_PLAYER_SPEED = 4.0f;
|
||||
inline constexpr int DEF_PLAYER_INVENTORY_SIZE = 40;
|
||||
|
|
@ -36,42 +36,49 @@ public:
|
|||
std::unique_ptr<Lighting> lighting;
|
||||
std::unique_ptr<LevelEvents> events;
|
||||
std::unique_ptr<Entities> entities;
|
||||
std::vector<std::shared_ptr<Camera>> cameras; // move somewhere?
|
||||
std::vector<std::shared_ptr<Camera>> cameras; // move somewhere?
|
||||
|
||||
const EngineSettings& settings;
|
||||
|
||||
Level(
|
||||
std::unique_ptr<World> world,
|
||||
const Content* content,
|
||||
std::unique_ptr<World> world,
|
||||
const Content* content,
|
||||
EngineSettings& settings
|
||||
);
|
||||
~Level();
|
||||
|
||||
void loadMatrix(int32_t x, int32_t z, uint32_t radius);
|
||||
|
||||
|
||||
World* getWorld();
|
||||
|
||||
/// Spawns object of class T and returns pointer to it.
|
||||
/// @param T class that derives the Object class
|
||||
/// @param args pass arguments needed for T class constructor
|
||||
template<class T, typename... Args>
|
||||
template <class T, typename... Args>
|
||||
std::shared_ptr<T> spawnObject(Args&&... args) {
|
||||
static_assert(std::is_base_of<Object, T>::value, "T must be a derived of Object class");
|
||||
static_assert(
|
||||
std::is_base_of<Object, T>::value,
|
||||
"T must be a derived of Object class"
|
||||
);
|
||||
std::shared_ptr<T> tObj = std::make_shared<T>(args...);
|
||||
|
||||
std::shared_ptr<Object> obj = std::dynamic_pointer_cast<Object, T>(tObj);
|
||||
|
||||
std::shared_ptr<Object> obj =
|
||||
std::dynamic_pointer_cast<Object, T>(tObj);
|
||||
obj->objectUID = objects.size();
|
||||
objects.push_back(obj);
|
||||
obj->spawned();
|
||||
return tObj;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
std::shared_ptr<T> getObject(uint64_t id) {
|
||||
static_assert(std::is_base_of<Object, T>::value, "T must be a derived of Object class");
|
||||
static_assert(
|
||||
std::is_base_of<Object, T>::value,
|
||||
"T must be a derived of Object class"
|
||||
);
|
||||
if (id >= objects.size()) return nullptr;
|
||||
std::shared_ptr<T> object = std::dynamic_pointer_cast<T>(objects[id]);
|
||||
return object;
|
||||
return object;
|
||||
}
|
||||
|
||||
void onSave();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue