feat: implement freeze effect

This commit is contained in:
2021-10-08 19:04:26 +02:00
parent 48b5372533
commit 4fcf25b5bc
5 changed files with 79 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ typedef std::uint32_t MobID;
typedef std::uint8_t MobLevel;
typedef std::vector<TowerType> TowerImmunities;
typedef std::vector<EffectType> EffectImmunities;
typedef std::pair<EffectType, float> EffectDuration;
class MobStats {
private:
@@ -71,6 +72,7 @@ private:
PlayerID m_Sender;
MobLevel m_Level;
Direction m_Direction;
std::vector<EffectDuration> m_Effects;
float m_X = 0, m_Y = 0;
public:
@@ -80,7 +82,7 @@ public:
virtual MobType getType() const = 0;
virtual void tick(std::uint64_t delta) {}
virtual void tick(std::uint64_t delta);
const TowerImmunities& getTowerImmunities() const { return getMobTowerImmunities(getType(), m_Level); }
const EffectImmunities& getEffectImmunities() const { return getMobEffectImmunities(getType(), m_Level); }
@@ -99,10 +101,19 @@ public:
float getY() const { return m_Y; }
void setY(float y) { m_Y = y; }
bool isImmuneTo(TowerType type);
bool isImmuneTo(EffectType type);
void addEffect(EffectType type, float durationSec);
bool hasEffect(EffectType type);
Direction getDirection() const { return m_Direction; }
void setDirection(Direction dir) { m_Direction = dir; }
protected:
void initHealth() { m_Health = (float)getStats()->getMaxLife(); }
private:
void updateEffects(std::uint64_t delta);
};
typedef std::shared_ptr<Mob> MobPtr;