// // Created by koncord on 12.08.17. // #pragma once #include #include #include #include #include #include #include #include #include "Player.hpp" class LuaState; class Players { friend class Player; public: static void Init(LuaState &lua); public: Players() = delete; // static class protected: struct ByID {}; struct ByGUID {}; public: typedef boost::multi_index_container, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique, BOOST_MULTI_INDEX_CONST_MEM_FUN(Player, uint64_t, getGUID)>, boost::multi_index::ordered_unique, boost::multi_index::member > > > Store; static std::shared_ptr getPlayerByPID(int pid); static std::shared_ptr getPlayerByGUID(RakNet::RakNetGUID guid); static std::shared_ptr addPlayer(RakNet::RakNetGUID guid); static void deletePlayerByPID(int pid); static void deletePlayerByGUID(RakNet::RakNetGUID guid); static Store::const_iterator begin(); static Store::const_iterator end(); static size_t size(); static void for_each(std::function func); static void processUpdated(); private: static void addToQueue(Player *player); static Store store; static std::queue updateQueue; };