make switches show their power state

This commit is contained in:
darkrose 2014-08-18 19:55:06 +10:00
parent 86bbf33337
commit e8fc2b8ecf
7 changed files with 23 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 B

After

Width:  |  Height:  |  Size: 602 B

View File

@ -1835,7 +1835,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
NodeMetadata *meta = data->m_env->getMap().getNodeMetadata(p+blockpos_nodes);
if (meta && meta->getEnergy()) {
u8 e = meta->getEnergy();
e *= 16;
e = (e*16)-1;
if (e < 80)
e = 80;
c = video::SColor(255,e,e,e);

View File

@ -172,8 +172,10 @@ void content_mapnode_circuit(bool repeat)
f->description = std::string("Switch");
f->setAllTextures("stone.png");
f->setTexture(5,"circuit_switch_front.png");
f->setAllMetaTextures("stone.png");
f->setMetaTexture(5,"circuit_switch_active_front.png");
f->param_type = CPT_FACEDIR_WALLMOUNT;
f->draw_type = CDT_NODEBOX;
f->draw_type = CDT_NODEBOX_META;
f->rotate_tile_with_nodebox = true;
f->is_ground_content = true;
f->energy_type = CET_SWITCH;

View File

@ -1228,9 +1228,6 @@ void content_nodebox_switch(ContentFeatures *f)
f->setNodeBox(core::aabbox3d<f32>(
-0.1875*BS,-0.0625*BS,0.4375*BS,0.1875*BS,0.125*BS,0.5*BS
));
f->addNodeBox(core::aabbox3d<f32>(
0.0625*BS,0.*BS,0.375*BS,0.125*BS,0.0625*BS,0.4375*BS
));
}
void content_nodebox_button(ContentFeatures *f)

View File

@ -2229,6 +2229,24 @@ bool SwitchNodeMetadata::energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s
m_energy = level;
return true;
}
std::vector<aabb3f> SwitchNodeMetadata::getNodeBoxes(MapNode &n)
{
std::vector<aabb3f> boxes;
boxes.clear();
if (m_energy) {
boxes.push_back(core::aabbox3d<f32>(
-0.125*BS,0.*BS,0.375*BS,-0.0625*BS,0.0625*BS,0.4375*BS
));
}else{
boxes.push_back(core::aabbox3d<f32>(
0.0625*BS,0.*BS,0.375*BS,0.125*BS,0.0625*BS,0.4375*BS
));
}
return transformNodeBox(n,boxes);
}
/*
ButtonNodeMetadata

View File

@ -487,6 +487,7 @@ public:
virtual NodeMetadata* clone();
virtual bool step(float dtime, v3s16 pos, ServerEnvironment *env);
virtual bool energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s16 pos);
virtual std::vector<aabb3f> getNodeBoxes(MapNode &n);
};
class SourceNodeMetadata : public SwitchNodeMetadata