Overhaul of animstep, implement tangible.build
This commit is contained in:
@@ -76,8 +76,11 @@ void Tangible::be_a_player() {
|
||||
if (!id_player_pool_.fifo_enabled()) {
|
||||
id_player_pool_.enable_fifo();
|
||||
|
||||
anim_queue_.add(world_->id_global_pool_.get_one(), "");
|
||||
anim_queue_.set_graphic("player");
|
||||
AnimStep asinit;
|
||||
asinit.set_graphic("player");
|
||||
anim_queue_.add(world_->id_global_pool_.get_one(), asinit);
|
||||
anim_queue_.keep_only(1);
|
||||
update_plane_item();
|
||||
|
||||
LuaVar classtab, mt, place, tangibles;
|
||||
LuaStack LS(world_->state(), classtab, mt, place, tangibles);
|
||||
@@ -466,7 +469,9 @@ LuaDefine(tangible_animate, "c") {
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
Tangible *tan = w->tangible_get(L, tanobj.index());
|
||||
int64_t id = w->id_global_pool_.alloc_id_for_thread(L);
|
||||
tan->anim_queue_.add(id, L, config.index());
|
||||
AnimStep step;
|
||||
step.from_lua(L, config.index());
|
||||
tan->anim_queue_.add(id, step);
|
||||
tan->update_plane_item();
|
||||
return LS.result();
|
||||
}
|
||||
@@ -484,6 +489,8 @@ LuaDefine(tangible_setclass, "c") {
|
||||
}
|
||||
|
||||
LuaDefine(tangible_delete, "c") {
|
||||
// TODO: we need some sanity checks to make sure you're not deleting
|
||||
// the current player, or anything like that.
|
||||
LuaArg tanobj;
|
||||
LuaStack LS(L, tanobj);
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
@@ -492,9 +499,49 @@ LuaDefine(tangible_delete, "c") {
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_make, "c") {
|
||||
World::fetch_global_pointer(L)->tangible_make(L, 0, true);
|
||||
return 1;
|
||||
LuaDefine(tangible_build, "c") {
|
||||
LuaArg config;
|
||||
LuaVar classname, classtab, mt;
|
||||
LuaRet database;
|
||||
LuaStack LS(L, config, classname, classtab, database, mt);
|
||||
|
||||
LS.checktable(config);
|
||||
// Get the class of the new tangible.
|
||||
LS.rawget(classname, config, "class");
|
||||
if (LS.isnil(classname)) {
|
||||
luaL_error(L, "must specify a class name");
|
||||
}
|
||||
LS.getclass(classtab, classname);
|
||||
|
||||
// Parse the initial animation step.
|
||||
AnimStep initstep;
|
||||
initstep.from_lua(L, config.index());
|
||||
if (!initstep.has_xyz()) {
|
||||
luaL_error(L, "You must specify (X,Y,Z) for new tangible");
|
||||
}
|
||||
if (!initstep.has_plane()) {
|
||||
luaL_error(L, "You must specify plane for new tangible");
|
||||
}
|
||||
if (!initstep.has_graphic()) {
|
||||
luaL_error(L, "You must specify graphic for new tangible");
|
||||
}
|
||||
|
||||
// TODO: generate error if there's extra crap in the config table.
|
||||
|
||||
World *w = World::fetch_global_pointer(L);
|
||||
Tangible *tan = w->tangible_make(L, 0, true);
|
||||
lua_replace(L, database.index());
|
||||
|
||||
// Update the class of the new tangible.
|
||||
LS.getmetatable(mt, database);
|
||||
LS.rawset(mt, "__index", classtab);
|
||||
|
||||
// Update the animation queue and planemap of the new tangible.
|
||||
int64_t stepid = w->id_global_pool_.alloc_id_for_thread(L);
|
||||
tan->anim_queue_.add(stepid, initstep);
|
||||
tan->update_plane_item();
|
||||
|
||||
return LS.result();
|
||||
}
|
||||
|
||||
LuaDefine(tangible_get, "c") {
|
||||
|
||||
Reference in New Issue
Block a user