12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include <Textur.h>
- #include "Block.h"
- #include "Globals.h"
- Block::Block(const BlockType* zType, Framework::Vec3<int> 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<float>)pos + Framework::Vec3<float>{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<int> 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;
- }
|