diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 10:44:20 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 10:44:20 +0200 |
commit | 5344dec760649e356d93a47a56a0c49871ad81de (patch) | |
tree | 4df18d91912833d3b3fb406e43c75cf8e897aecc /src/content_cao.cpp | |
parent | 89bc3066328cf7500a8ef978d5e5ed6c1c154576 (diff) | |
download | minetest-5344dec760649e356d93a47a56a0c49871ad81de.tar.gz minetest-5344dec760649e356d93a47a56a0c49871ad81de.tar.bz2 minetest-5344dec760649e356d93a47a56a0c49871ad81de.zip |
Move ServerRemotePlayer to a separate file
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r-- | src/content_cao.cpp | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 20eb3cf1b..8d1fcc24e 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -2090,6 +2090,8 @@ private: float m_yaw; SmoothTranslator pos_translator; bool m_is_local_player; + LocalPlayer *m_local_player; + float m_damage_visual_timer; public: PlayerCAO(IGameDef *gamedef, ClientEnvironment *env): @@ -2099,7 +2101,9 @@ public: m_text(NULL), m_position(v3f(0,10*BS,0)), m_yaw(0), - m_is_local_player(false) + m_is_local_player(false), + m_local_player(NULL), + m_damage_visual_timer(0) { if(gamedef == NULL) ClientActiveObject::registerType(getType(), create); @@ -2122,13 +2126,13 @@ public: // yaw m_yaw = readF1000(is); - Player *player = m_env->getPlayer(m_name.c_str()); - if(player && player->isLocal()) - m_is_local_player = true; - pos_translator.init(m_position); - updateNodePos(); + Player *player = m_env->getPlayer(m_name.c_str()); + if(player && player->isLocal()){ + m_is_local_player = true; + m_local_player = (LocalPlayer*)player; + } } ~PlayerCAO() @@ -2183,7 +2187,6 @@ public: buf->append(vertices, 4, indices, 6); // Set material buf->getMaterial().setFlag(video::EMF_LIGHTING, false); - buf->getMaterial().setTexture(0, tsrc->getTextureRaw("player.png")); buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false); buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true); buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; @@ -2205,7 +2208,6 @@ public: buf->append(vertices, 4, indices, 6); // Set material buf->getMaterial().setFlag(video::EMF_LIGHTING, false); - buf->getMaterial().setTexture(0, tsrc->getTextureRaw("player_back.png")); buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false); buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true); buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; @@ -2225,7 +2227,9 @@ public: m_text = smgr->addTextSceneNode(gui->getBuiltInFont(), wname.c_str(), video::SColor(255,255,255,255), m_node); m_text->setPosition(v3f(0, (f32)BS*2.1, 0)); - + + updateTextures(""); + updateNodePos(); } void removeFromScene() @@ -2296,6 +2300,36 @@ public: updateNodePos(); } } + + void updateTextures(const std::string &mod) + { + if(!m_node) + return; + ITextureSource *tsrc = m_gamedef->tsrc(); + scene::IMesh *mesh = m_node->getMesh(); + if(mesh){ + { + std::string tname = "player.png"; + tname += mod; + scene::IMeshBuffer *buf = mesh->getMeshBuffer(0); + buf->getMaterial().setTexture(0, + tsrc->getTextureRaw(tname)); + } + { + std::string tname = "player_back.png"; + tname += mod; + scene::IMeshBuffer *buf = mesh->getMeshBuffer(1); + buf->getMaterial().setTexture(0, + tsrc->getTextureRaw(tname)); + } + } + } + + bool directReportPunch(const std::string &toolname, v3f dir) + { + updateTextures("^[brighten"); + return false; + } }; // Prototype |