#ifndef WORLD_HPP #define WORLD_HPP #include "luastack.hpp" #include "planemap.hpp" #include "idalloc.hpp" #include "animqueue.hpp" #include "source.hpp" #include #include class World; class Tangible { public: // Simple constructor initializes everything to null. // Tangible(); // Always points back to the world model. World *world_; // Animation queue. // AnimQueue anim_queue_; // Plane Item. // // The PlaneItem also contains this tangible's ID. // To move this Tangible, update the anim_queue first, then update // this plane_item_ from the anim_queue. PlaneItem plane_item_; // Player ID pool // // Note: this is only allocated if this Tangible is a player. std::unique_ptr id_player_pool_; void be_a_player(); }; class World { public: // A pointer to the lua State. // lua_State *lua_state_; // The Global ID Pool. // IdGlobalPool id_global_pool_; // Source Database. // SourceDB source_db_; PlaneMap plane_map_; std::unordered_map tangibles_; public: // Constructor. // // The constructor also calls 'lua_open' to create a new // lua interpreter for this world model. The lua interpreter // is stored in world::lua_state_. A significant amount of // initial setup is done by this constructor. // World(); // Destructor. // // Not currently functional. // ~World(); // Initialize for single-player mode. // void init_standalone(); // get_lua_state // // Get the lua interpreter associated with this world model. // lua_State *get_lua_state() { return lua_state_; } // update_view_map // // Update the view map with information about all the tangibles near // the specified player. // void update_view_map(AnimViewMap *vm, int64_t player_id, float radius); // Make a tangible. // // If the ID is zero, allocates an ID using the thread's ID allocator. If // pushdb is true, pushes the tangible's database onto the lua stack. // Otherwise, leaves the lua stack untouched. // Tangible *tangible_make(lua_State *L, int64_t id, bool pushdb); // Get a pointer to the specified tangible. // Tangible *tangible_get(int64_t id); // Delete a tangible with the specified ID. // // If the tangible doesn't exist, does nothing. // void tangible_del(int64_t id); // fetch // // Given a lua state, fetch the world model associated with // that lua state. // static World *fetch(lua_State *L); }; #endif // WORLD_HPP