39 lines
862 B
C++
39 lines
862 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
#include <memory>
|
|
#include "assets/sectordef.hpp"
|
|
#include "sector.hpp"
|
|
#include "entity.hpp"
|
|
|
|
namespace game
|
|
{
|
|
class World
|
|
{
|
|
std::vector<std::unique_ptr<Sector>> sectors_;
|
|
std::vector<std::unique_ptr<Entity>> entities_;
|
|
|
|
public:
|
|
World();
|
|
|
|
size_t AddSector(std::shared_ptr<assets::SectorDef> def);
|
|
|
|
void LinkPortals(size_t sector1, const std::string& portal_name1,
|
|
size_t sector2, const std::string& portal_name2);
|
|
|
|
template<class T, class... TArgs>
|
|
T* Spawn(TArgs&&... args)
|
|
{
|
|
auto entity = std::make_unique<T>(this, std::forward<TArgs>(args)...);
|
|
T* entity_ptr = entity.get();
|
|
entities_.push_back(std::move(entity));
|
|
return entity_ptr;
|
|
}
|
|
|
|
Sector& GetSector(size_t idx) { return *sectors_[idx]; }
|
|
const Sector& GetSector(size_t idx) const { return *sectors_[idx]; }
|
|
|
|
};
|
|
|
|
} |