X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FWorld.hpp;h=9739e21f18415eff4df70010fe9b588d82ba332b;hb=99345b497912db65204d48348140fc774dcb6989;hp=3981b28e336f9dcf8e28ee84411486d1e23121d2;hpb=dbfcb12348b80e2582f710acb1e4ed0011889ba2;p=blank.git diff --git a/src/world/World.hpp b/src/world/World.hpp index 3981b28..9739e21 100644 --- a/src/world/World.hpp +++ b/src/world/World.hpp @@ -5,7 +5,9 @@ #include "Entity.hpp" #include "Generator.hpp" +#include #include +#include #include #include @@ -21,6 +23,7 @@ class World { public: struct Config { + std::string name = "default"; // initial player position glm::vec3 spawn = { 0.0f, 0.0f, 0.0f }; // direction facing towards(!) the light @@ -37,6 +40,8 @@ public: 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 @@ -66,7 +71,14 @@ public: /// 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 &Players() const noexcept { return players; } const std::list &Entities() const noexcept { return entities; } @@ -75,6 +87,10 @@ public: void Render(Viewport &); +private: + using EntityHandle = std::list::iterator; + EntityHandle RemoveEntity(EntityHandle &); + private: Config config;