2021-01-18 00:48:42 -05:00
|
|
|
#ifndef VIEWER_HPP
|
|
|
|
|
#define VIEWER_HPP
|
|
|
|
|
|
2021-01-22 17:35:23 -05:00
|
|
|
#include "world.hpp"
|
|
|
|
|
#include "animqueue.hpp"
|
2021-02-07 13:38:29 -05:00
|
|
|
#include "gui.hpp"
|
2021-01-22 17:35:23 -05:00
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2021-01-18 00:48:42 -05:00
|
|
|
class Viewer {
|
2021-01-22 17:35:23 -05:00
|
|
|
private:
|
|
|
|
|
std::unique_ptr<World> world_;
|
|
|
|
|
|
2021-01-18 00:48:42 -05:00
|
|
|
public:
|
2021-01-22 17:35:23 -05:00
|
|
|
Viewer();
|
|
|
|
|
~Viewer();
|
2021-01-18 00:48:42 -05:00
|
|
|
|
2021-02-09 17:15:54 -05:00
|
|
|
// Snapshot/rollback the lua state (temporary hack)
|
|
|
|
|
void snapshot() { world_->lua_snap_.snapshot(); }
|
|
|
|
|
void rollback() { world_->lua_snap_.rollback(); }
|
|
|
|
|
|
2021-01-22 17:35:23 -05:00
|
|
|
// Get the lua state for interaction.
|
|
|
|
|
//
|
2021-02-09 17:15:54 -05:00
|
|
|
lua_State *state() { return world_->state(); }
|
2021-01-22 19:10:47 -05:00
|
|
|
|
2021-01-18 00:48:42 -05:00
|
|
|
// Get the player ID of the current player.
|
|
|
|
|
//
|
|
|
|
|
int64_t get_player_id();
|
|
|
|
|
|
2021-02-07 13:38:29 -05:00
|
|
|
// Get the list of tangibles near the player.
|
2021-01-18 00:48:42 -05:00
|
|
|
//
|
2021-02-07 13:38:29 -05:00
|
|
|
std::vector<int64_t> get_near() { return world_->get_near(1, 100); }
|
|
|
|
|
|
|
|
|
|
// Get the specified tangible.
|
2021-01-18 00:48:42 -05:00
|
|
|
//
|
2021-02-07 13:38:29 -05:00
|
|
|
const Tangible *tangible_get(int64_t id) { return world_->tangible_get(id); }
|
2021-01-18 00:48:42 -05:00
|
|
|
|
2021-02-07 13:38:29 -05:00
|
|
|
// Update the GUI for the specified sprite.
|
|
|
|
|
//
|
2021-02-07 13:45:03 -05:00
|
|
|
// The gui passed in will be overwritten.
|
2021-01-18 00:48:42 -05:00
|
|
|
//
|
2021-02-07 13:38:29 -05:00
|
|
|
void update_gui(int64_t id, Gui *g);
|
2021-01-18 00:48:42 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // VIEWER_HPP
|