X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclientobject.cpp;h=bec9f46fdd0c8a6cb5942c92cbe2fb55fbf5e36b;hb=c01c487c6226cbe72e63a7cd5519a5c87aa10f71;hp=46db389cdc53e696200e18ca66a304adddac971a;hpb=c57637b4c39319e0c0d5d80d0ae2884aec66d691;p=minetest.git diff --git a/src/clientobject.cpp b/src/clientobject.cpp index 46db389cd..bec9f46fd 100644 --- a/src/clientobject.cpp +++ b/src/clientobject.cpp @@ -21,7 +21,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "debug.h" #include "porting.h" #include "constants.h" -#include "utility.h" + +/* + ClientActiveObject +*/ ClientActiveObject::ClientActiveObject(u16 id): ActiveObject(id) @@ -35,135 +38,29 @@ ClientActiveObject::~ClientActiveObject() ClientActiveObject* ClientActiveObject::create(u8 type) { - if(type == ACTIVEOBJECT_TYPE_INVALID) - { - dstream<<"ClientActiveObject::create(): passed " - <<"ACTIVEOBJECT_TYPE_INVALID"<::Node *n; + n = m_types.find(type); + if(n == NULL) { - dstream<<"ClientActiveObject::create(): passed " - <<"ACTIVEOBJECT_TYPE_TEST"<getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false); - buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true); - buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - // Add to mesh - mesh->addMeshBuffer(buf); - buf->drop(); - m_node = smgr->addMeshSceneNode(mesh, NULL); - mesh->drop(); - updateNodePos(); -} - -void TestCAO::removeFromScene() -{ - if(m_node == NULL) - return; - m_node->remove(); - m_node = NULL; -} - -void TestCAO::updateLight(u8 light_at_pos) -{ -} - -v3s16 TestCAO::getLightPosition() -{ - return floatToInt(m_position, BS); + Factory f = n->getValue(); + ClientActiveObject *object = (*f)(); + return object; } -void TestCAO::updateNodePos() +void ClientActiveObject::registerType(u16 type, Factory f) { - if(m_node == NULL) + core::map::Node *n; + n = m_types.find(type); + if(n) return; - - m_node->setPosition(m_position); - //m_node->setRotation(v3f(0, 45, 0)); -} - -void TestCAO::step(float dtime) -{ - if(m_node) - { - v3f rot = m_node->getRotation(); - //dstream<<"dtime="<>cmd; - if(cmd == 0) - { - v3f newpos; - is>>newpos.X; - is>>newpos.Y; - is>>newpos.Z; - m_position = newpos; - updateNodePos(); - } + m_types.insert(type, f); }