#include "Entity.hpp"
#include "Generator.hpp"
+#include <cstdint>
#include <list>
+#include <string>
#include <vector>
#include <glm/glm.hpp>
public:
struct Config {
+ std::string name = "default";
// initial player position
glm::vec3 spawn = { 0.0f, 0.0f, 0.0f };
// direction facing towards(!) the light
World(const BlockTypeRegistry &, const Config &, const WorldSave &);
+ const std::string &Name() const noexcept { return config.name; }
+
/// check if this ray hits a block
/// depth in the collision is the distance between the ray's
/// origin and the intersection point
/// add player with given name
/// returns nullptr if the name is already taken
Entity *AddPlayer(const std::string &name);
- Entity &AddEntity() { entities.emplace_back(); return entities.back(); }
+ /// add player with given name and ID
+ /// returns nullptr if the name or ID is already taken
+ Entity *AddPlayer(const std::string &name, std::uint32_t id);
+ /// add an entity with an autogenerated ID
+ Entity &AddEntity();
+ /// add entity with given ID
+ /// returns nullptr if the ID is already taken
+ Entity *AddEntity(std::uint32_t id);
const std::vector<Entity *> &Players() const noexcept { return players; }
const std::list<Entity> &Entities() const noexcept { return entities; }
void Render(Viewport &);
+private:
+ using EntityHandle = std::list<Entity>::iterator;
+ EntityHandle RemoveEntity(EntityHandle &);
+
private:
Config config;