Change how animstate is accessed
This commit is contained in:
@@ -57,9 +57,8 @@ Tangible::Tangible(World *w, int64_t id) : world_(w), id_player_pool_(&w->id_glo
|
||||
}
|
||||
|
||||
void Tangible::update_plane_item() {
|
||||
util::XYZ xyz = anim_queue_.get_xyz();
|
||||
std::string plane = anim_queue_.get_plane();
|
||||
plane_item_.set_pos(plane, xyz.x, xyz.y, xyz.z);
|
||||
const AnimStep &aqback = anim_queue_.back();
|
||||
plane_item_.set_pos(aqback.plane(), aqback.xyz().x, aqback.xyz().y, aqback.xyz().z);
|
||||
}
|
||||
|
||||
void Tangible::serialize(StreamBuffer *sb) {
|
||||
@@ -164,13 +163,12 @@ std::vector<int64_t> World::get_near(int64_t player_id, float radius, bool exclu
|
||||
Tangible *player = tangible_get(player_id);
|
||||
|
||||
// Find out where's the center of the world.
|
||||
std::string plane = player->anim_queue_.get_plane();
|
||||
if (exclude_nowhere && (plane == "nowhere")) {
|
||||
const AnimStep &aqback = player->anim_queue_.back();
|
||||
if (exclude_nowhere && (aqback.plane() == "nowhere")) {
|
||||
return std::vector<int64_t>();
|
||||
}
|
||||
util::XYZ xyz = player->anim_queue_.get_xyz();
|
||||
|
||||
return plane_map_.scan_radius(plane, xyz.x, xyz.y, radius, player_id);
|
||||
return plane_map_.scan_radius(aqback.plane(), aqback.xyz().x, aqback.xyz().y, radius, player_id);
|
||||
}
|
||||
|
||||
Tangible *World::tangible_make(lua_State *L, int64_t id, bool pushdb) {
|
||||
@@ -446,36 +444,19 @@ void World::rollback() {
|
||||
deserialize(&snapshot_);
|
||||
}
|
||||
|
||||
LuaDefine(tangible_xyz, "c") {
|
||||
LuaDefine(tangible_animstate, "c") {
|
||||
LuaArg tanobj;
|
||||
LuaRet X, Y, Z;
|
||||
LuaStack LS(L, tanobj, X, Y, Z);
|
||||
LuaRet graphic, plane, x, y, z, facing;
|
||||
LuaStack LS(L, tanobj, graphic, plane, x, y, z, facing);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
Tangible *tan = w->tangible_get(L, tanobj.index());
|
||||
util::XYZ xyz = tan->anim_queue_.get_xyz();
|
||||
LS.set(X, xyz.x);
|
||||
LS.set(Y, xyz.y);
|
||||
LS.set(Z, xyz.z);
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_plane, "c") {
|
||||
LuaArg tanobj;
|
||||
LuaRet plane;
|
||||
LuaStack LS(L, tanobj, plane);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
Tangible *tan = w->tangible_get(L, tanobj.index());
|
||||
LS.set(plane, tan->anim_queue_.get_plane());
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_graphic, "c") {
|
||||
LuaArg tanobj;
|
||||
LuaRet graphic;
|
||||
LuaStack LS(L, tanobj, graphic);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
Tangible *tan = w->tangible_get(L, tanobj.index());
|
||||
LS.set(graphic, tan->anim_queue_.get_graphic());
|
||||
const AnimStep &aqback = tan->anim_queue_.back();
|
||||
LS.set(graphic, aqback.graphic());
|
||||
LS.set(plane, aqback.plane());
|
||||
LS.set(x, aqback.xyz().x);
|
||||
LS.set(y, aqback.xyz().y);
|
||||
LS.set(z, aqback.xyz().z);
|
||||
LS.set(facing, aqback.facing());
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
@@ -516,6 +497,20 @@ LuaDefine(tangible_make, "c") {
|
||||
return 1;
|
||||
}
|
||||
|
||||
LuaDefine(tangible_get, "c") {
|
||||
LuaArg id;
|
||||
LuaVar tangibles;
|
||||
LuaRet database;
|
||||
LuaStack LS(L, id, tangibles, database);
|
||||
int64_t nid = LS.ckinteger(id);
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
LS.rawget(database, tangibles, id);
|
||||
if (!LS.istable(database)) {
|
||||
luaL_error(L, "Not a tangible ID: %d", nid);
|
||||
}
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(world_wait, "f") {
|
||||
if ((lua_gettop(L) != 1) || (lua_type(L, -1) != LUA_TNUMBER)) {
|
||||
luaL_error(L, "Argument to wait must be a number.");
|
||||
|
||||
Reference in New Issue
Block a user