Created AnimViewMap

This commit is contained in:
2021-01-22 19:10:47 -05:00
parent b0440a4e12
commit 827a114752
10 changed files with 302 additions and 266 deletions

View File

@@ -13,61 +13,6 @@ int64_t Viewer::get_player_id() {
return 1;
}
void Viewer::update_view() {
// Get ready to delete views that aren't in use.
//
for (auto pair : anim_view_) {
pair.second.set_updated(false);
}
// Update the player's AnimView first.
//
Tangible *player = world_->tangible_get(1);
AnimView *player_view = &anim_view_[1];
player_view->update_from(player->anim_queue_);
// Find out where's the center of the world.
//
std::string plane = player_view->get_plane();
util::XYZ xyz = player_view->get_xyz();
// Get a list of everything near the player.
//
tangibles_ = world_->scan_radius(plane, xyz.x, xyz.y, 100.0);
// Update AnimViews for every tangible near the player.
//
for (int64_t id : tangibles_) {
Tangible *tan = world_->tangible_get(id);
assert (tan != nullptr);
anim_view_[id].update_from(tan->anim_queue_);
}
// Delete any AnimView that was not updated.
//
for (auto iter = anim_view_.begin(); iter != anim_view_.end(); ) {
if (iter->second.updated()) {
iter++;
} else {
iter = anim_view_.erase(iter);
}
}
}
const std::vector<int64_t> &Viewer::get_tangibles_near_player() {
return tangibles_;
}
AnimView *Viewer::get_animation_view(int64_t id) {
auto iter = anim_view_.find(id);
if (iter == anim_view_.end()) {
return nullptr;
} else {
return &iter->second;
}
}
// Get the menu of the specified tangible.
//
std::vector<std::string> Viewer::get_menu(int64_t id) {