Created AnimViewMap
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "world.hpp"
|
||||
#include "idalloc.hpp"
|
||||
#include "animqueue.hpp"
|
||||
#include <iostream>
|
||||
|
||||
LuaDefineType(World);
|
||||
@@ -60,10 +61,6 @@ void World::init_standalone() {
|
||||
player->be_a_player();
|
||||
}
|
||||
|
||||
std::vector<int64_t> World::scan_radius(const std::string &plane, float x, float y, float radius) {
|
||||
return plane_map_.scan_radius(plane, x, y, radius);
|
||||
}
|
||||
|
||||
Tangible *World::tangible_get(int64_t id) {
|
||||
auto iter = tangibles_.find(id);
|
||||
if (iter == tangibles_.end()) {
|
||||
@@ -73,6 +70,25 @@ Tangible *World::tangible_get(int64_t id) {
|
||||
}
|
||||
}
|
||||
|
||||
void World::update_view_map(AnimViewMap *vm, int64_t player_id, float radius) {
|
||||
vm->clear_updated_bits();
|
||||
|
||||
// Update the player's AnimView first.
|
||||
vm->update_one(tangible_get(player_id)->anim_queue_);
|
||||
const AnimView *player_view = vm->get_one(player_id);
|
||||
|
||||
// Find out where's the center of the world.
|
||||
std::string plane = player_view->get_plane();
|
||||
util::XYZ xyz = player_view->get_xyz();
|
||||
|
||||
// Update AnimViews for every tangible near the player.
|
||||
for (int64_t id : plane_map_.scan_radius(plane, xyz.x, xyz.y, 100.0)) {
|
||||
vm->update_one(tangible_get(id)->anim_queue_);
|
||||
}
|
||||
|
||||
vm->delete_non_updated();
|
||||
}
|
||||
|
||||
Tangible *World::tangible_make(lua_State *L, int64_t id, bool pushdb) {
|
||||
LuaVar tangibles, metatab;
|
||||
LuaRet database;
|
||||
@@ -86,6 +102,7 @@ Tangible *World::tangible_make(lua_State *L, int64_t id, bool pushdb) {
|
||||
assert(t->world_ == nullptr);
|
||||
t->world_ = this;
|
||||
t->plane_item_.set_id(id);
|
||||
t->anim_queue_.set_id(id);
|
||||
plane_map_.track(&t->plane_item_);
|
||||
|
||||
// Create the tangible's database and metatable.
|
||||
|
||||
Reference in New Issue
Block a user