#include #include "Block.h" #include "Globals.h" Block::Block(const BlockType* zType, Framework::Vec3 pos, Model3DData* model, Model3DTextur* texture, int maxHP) : Model3D(), zType(zType), location(pos), maxHP((float)maxHP) { transparent = 0; hp = (float)maxHP; memset(sideVisible, 1, 6); Model3D::setPosition((Framework::Vec3)pos + Framework::Vec3{0.5f, 0.5f, 0.5f}); setModelDaten(model); setModelTextur(texture); breakTextur = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur("blocks.ltdb/crack.png", 0); } Block::~Block() { breakTextur->release(); } void Block::api(char* message) { // TODO: implement api switch (message[0]) { case 0: // hp change hp = *(float*)(message + 1); break; } } bool Block::isTransparent() const { return transparent; } void Block::setSideVisible(Direction dir, bool visible) { sideVisible[getDirectionIndex(dir)] = visible; } void setLightData(Direction dir, char* data) { } Vec3 Block::getLocation() const { return location; } const BlockType* Block::zBlockType() const { return zType; } Textur* Block::zEffectTextur() { if (hp < maxHP) return breakTextur; return 0; } float Block::getEffectPercentage() { return 1 - hp / maxHP; }