Files
PlanetFleet/destructable.h
devZoGok 1d0bf8d349 using GameObject class as an order target
Destructable made a member of GameObject
cruise missiles can be shot down
2025-12-04 15:03:35 +02:00

44 lines
1.3 KiB
C++

#ifndef DESTRUCTABLE_H
#define DESTRUCTABLE_H
#include <vector.h>
#include <vector>
#include <algorithm>
namespace vb01{
class Node;
}
namespace battleship{
enum class Armor {CAST, COMBINED, MECHANIC, SHELL, STEEL};
class GameObject;
class Destructable{
public:
Destructable(GameObject*);
void update();
void removeBar(vb01::Node*);
vb01::Node* createBar(vb01::Vector2, vb01::Vector2, vb01::Vector4);
void displayStats(vb01::Node*, vb01::Node*, int, int, bool, vb01::Vector2 offset = vb01::Vector2::VEC_ZERO);
inline int getHealth(){return health;}
inline int getMaxHealth(){return maxHealth;}
inline int getDeathHp(){return DEATH_HP;}
inline void takeDamage(int damage) {health -= damage * (1 + (freezeDmgFactor - 1) * freezeStatus * .01f);}
inline GameObject* getGameObject(){return gameObject;}
inline std::vector<Armor> getArmorTypes(){return armorTypes;}
inline void setFreezeStatus(int fs){this->freezeStatus = std::clamp(fs, 0, 100);}
inline int getFreezeStatus(){return freezeStatus;}
private:
std::vector<Armor> armorTypes;
const int DEATH_HP = 0;
int health = 0, maxHealth, freezeStatus = 0, freezeDmgFactor = 10;
GameObject *gameObject = nullptr;
void initProperties();
};
}
#endif