GIGA REFACTOR
This commit is contained in:
@@ -40,30 +40,30 @@ public:
|
||||
Game(World* world);
|
||||
virtual ~Game();
|
||||
|
||||
virtual void tick(std::uint64_t delta);
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
|
||||
Team& getRedTeam() { return m_Teams[(std::uint8_t)TeamColor::Red]; }
|
||||
const Team& getRedTeam() const { return m_Teams[(std::uint8_t)TeamColor::Red]; }
|
||||
Team& GetRedTeam() { return m_Teams[(std::uint8_t)TeamColor::Red]; }
|
||||
const Team& GetRedTeam() const { return m_Teams[(std::uint8_t)TeamColor::Red]; }
|
||||
|
||||
Team& getBlueTeam() { return m_Teams[(std::uint8_t)TeamColor::Blue]; }
|
||||
const Team& getBlueTeam() const { return m_Teams[(std::uint8_t)TeamColor::Blue]; }
|
||||
Team& GetBlueTeam() { return m_Teams[(std::uint8_t)TeamColor::Blue]; }
|
||||
const Team& GetBlueTeam() const { return m_Teams[(std::uint8_t)TeamColor::Blue]; }
|
||||
|
||||
Team& getTeam(TeamColor team) { return m_Teams[(std::uint8_t)team]; }
|
||||
const Team& getTeam(TeamColor team) const { return m_Teams[(std::uint8_t)team]; }
|
||||
Team& GetTeam(TeamColor team) { return m_Teams[(std::uint8_t)team]; }
|
||||
const Team& GetTeam(TeamColor team) const { return m_Teams[(std::uint8_t)team]; }
|
||||
|
||||
GameState getGameState() const { return m_GameState; }
|
||||
void setGameState(GameState gameState) { m_GameState = gameState; };
|
||||
GameState GetGameState() const { return m_GameState; }
|
||||
void SetGameState(GameState gameState) { m_GameState = gameState; };
|
||||
|
||||
const World* getWorld() const { return m_World; }
|
||||
World* getWorld() { return m_World; }
|
||||
const World* GetWorld() const { return m_World; }
|
||||
World* GetWorld() { return m_World; }
|
||||
|
||||
const PlayerList& getPlayers() const { return m_Players; }
|
||||
PlayerList& getPlayers() { return m_Players; }
|
||||
const PlayerList& GetPlayers() const { return m_Players; }
|
||||
PlayerList& GetPlayers() { return m_Players; }
|
||||
|
||||
const Player* getPlayerById(PlayerID id) const;
|
||||
Player* getPlayerById(PlayerID id);
|
||||
const Player* GetPlayerById(PlayerID id) const;
|
||||
Player* GetPlayerById(PlayerID id);
|
||||
|
||||
const TeamList& getTeams() const { return m_Teams; }
|
||||
const TeamList& GetTeams() const { return m_Teams; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ public:
|
||||
Connexion(protocol::PacketDispatcher* dispatcher, network::TCPSocket& socket);
|
||||
virtual ~Connexion();
|
||||
|
||||
virtual bool updateSocket();
|
||||
void closeConnection();
|
||||
virtual bool UpdateSocket();
|
||||
void CloseConnection();
|
||||
|
||||
bool connect(const std::string& address, std::uint16_t port);
|
||||
bool Connect(const std::string& address, std::uint16_t port);
|
||||
|
||||
network::Socket::Status getSocketStatus() const { return m_Socket.GetStatus(); }
|
||||
network::Socket::Status GetSocketStatus() const { return m_Socket.GetStatus(); }
|
||||
|
||||
void sendPacket(const protocol::Packet* packet);
|
||||
void SendPacket(const protocol::Packet* packet);
|
||||
|
||||
REMOVE_COPY(Connexion);
|
||||
};
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
namespace GameManager {
|
||||
|
||||
void render();
|
||||
void init();
|
||||
void destroy();
|
||||
void tick();
|
||||
void Render();
|
||||
void Init();
|
||||
void Destroy();
|
||||
void Tick();
|
||||
|
||||
void startServer();
|
||||
void StartServer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +61,13 @@ public:
|
||||
m_MaxLife(maxLife), m_ExpReward(expReward) {
|
||||
}
|
||||
|
||||
float getDamage() const { return m_Damage; }
|
||||
float getMovementSpeed() const { return m_Speed; }
|
||||
const glm::vec2& getSize() const { return m_Size; }
|
||||
std::uint16_t getMoneyCost() const { return m_MoneyCost; }
|
||||
std::uint16_t getExpCost() const { return m_ExpCost; }
|
||||
std::uint16_t getExpReward() const { return m_ExpReward; }
|
||||
std::uint16_t getMaxLife() const { return m_MaxLife; }
|
||||
float GetDamage() const { return m_Damage; }
|
||||
float GetMovementSpeed() const { return m_Speed; }
|
||||
const glm::vec2& GetSize() const { return m_Size; }
|
||||
std::uint16_t GetMoneyCost() const { return m_MoneyCost; }
|
||||
std::uint16_t GetExpCost() const { return m_ExpCost; }
|
||||
std::uint16_t GetExpReward() const { return m_ExpReward; }
|
||||
std::uint16_t GetMaxLife() const { return m_MaxLife; }
|
||||
};
|
||||
|
||||
struct EffectDuration {
|
||||
@@ -76,9 +76,9 @@ struct EffectDuration {
|
||||
Tower* tower; // the tower that gived the effect
|
||||
};
|
||||
|
||||
const MobStats* getMobStats(MobType type, std::uint8_t level);
|
||||
const TowerImmunities& getMobTowerImmunities(MobType type, std::uint8_t level);
|
||||
const EffectImmunities& getMobEffectImmunities(MobType type, std::uint8_t level);
|
||||
const MobStats* GetMobStats(MobType type, std::uint8_t level);
|
||||
const TowerImmunities& GetMobTowerImmunities(MobType type, std::uint8_t level);
|
||||
const EffectImmunities& GetMobEffectImmunities(MobType type, std::uint8_t level);
|
||||
|
||||
class Mob : public utils::shape::Rectangle {
|
||||
protected:
|
||||
@@ -105,131 +105,133 @@ public:
|
||||
|
||||
}
|
||||
|
||||
virtual MobType getType() const = 0;
|
||||
virtual MobType GetType() const = 0;
|
||||
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
|
||||
virtual bool OnDeath(World* world) { return true; }
|
||||
|
||||
MobID getMobID() const { return m_ID; }
|
||||
const TowerImmunities& getTowerImmunities() const { return getMobTowerImmunities(getType(), m_Level); }
|
||||
const EffectImmunities& getEffectImmunities() const { return getMobEffectImmunities(getType(), m_Level); }
|
||||
PlayerID getSender() const { return m_Sender; }
|
||||
MobLevel getLevel() const { return m_Level; }
|
||||
const MobStats* getStats() const { return getMobStats(getType(), m_Level); }
|
||||
void setHealth(float newHealth) { m_Health = newHealth; }
|
||||
float getHealth() const { return m_Health; }
|
||||
bool isDead() const { return m_Health <= 0; }
|
||||
bool isAlive() const { return m_Health > 0; }
|
||||
const Tower* getLastDamageTower() { return m_LastDamage; }
|
||||
bool hasReachedEnemyCastle() { return m_CastleTarget != nullptr; }
|
||||
MobID GetMobID() const { return m_ID; }
|
||||
const TowerImmunities& GetTowerImmunities() const { return GetMobTowerImmunities(GetType(), m_Level); }
|
||||
const EffectImmunities& GetEffectImmunities() const { return GetMobEffectImmunities(GetType(), m_Level); }
|
||||
PlayerID GetSender() const { return m_Sender; }
|
||||
MobLevel GetLevel() const { return m_Level; }
|
||||
const MobStats* GetStats() const { return GetMobStats(GetType(), m_Level); }
|
||||
void SetHealth(float newHealth) { m_Health = newHealth; }
|
||||
float GetHealth() const { return m_Health; }
|
||||
bool IsDead() const { return m_Health <= 0; }
|
||||
bool IsAlive() const { return m_Health > 0; }
|
||||
const Tower* GetLastDamageTower() { return m_LastDamage; }
|
||||
bool HasReachedEnemyCastle() { return m_CastleTarget != nullptr; }
|
||||
|
||||
void damage(float dmg, const Tower* damager) { m_Health = std::max(0.0f, m_Health - dmg); m_LastDamage = damager; }
|
||||
void heal(float heal) { m_Health = std::min(static_cast<float>(getStats()->getMaxLife()), m_Health + heal); }
|
||||
void setMobReachedCastle(TeamCastle* castle) { m_CastleTarget = castle; } // used when mob is in front of the castle
|
||||
void Damage(float dmg, const Tower* damager) { m_Health = std::max(0.0f, m_Health - dmg); m_LastDamage = damager; }
|
||||
void Heal(float heal) { m_Health = std::min(static_cast<float>(GetStats()->GetMaxLife()), m_Health + heal); }
|
||||
void SetMobReachedCastle(TeamCastle* castle) { m_CastleTarget = castle; } // used when mob is in front of the castle
|
||||
|
||||
bool isImmuneTo(TowerType type);
|
||||
bool IsImmuneTo(TowerType type);
|
||||
|
||||
bool isImmuneTo(EffectType type);
|
||||
void addEffect(EffectType type, float durationSec, Tower* tower);
|
||||
bool hasEffect(EffectType type);
|
||||
bool IsImmuneTo(EffectType type);
|
||||
void AddEffect(EffectType type, float durationSec, Tower* tower);
|
||||
bool HasEffect(EffectType type);
|
||||
|
||||
float getTileX() { return getCenterX() - static_cast<float>(static_cast<std::int32_t>(getCenterX())); } // returns a float between 0 and 1 excluded
|
||||
float getTileY() { return getCenterY() - static_cast<float>(static_cast<std::int32_t>(getCenterY())); } // returns a float between 0 and 1 excluded
|
||||
float GetTileX() { return GetCenterX() - static_cast<float>(static_cast<std::int32_t>(GetCenterX())); } // returns a float between 0 and 1 excluded
|
||||
float GetTileY() { return GetCenterY() - static_cast<float>(static_cast<std::int32_t>(GetCenterY())); } // returns a float between 0 and 1 excluded
|
||||
|
||||
Direction getDirection() const { return m_Direction; }
|
||||
void setDirection(Direction dir) { m_Direction = dir; }
|
||||
Direction GetDirection() const { return m_Direction; }
|
||||
void SetDirection(Direction dir) { m_Direction = dir; }
|
||||
protected:
|
||||
void initMob() {
|
||||
m_Health = static_cast<float>(getStats()->getMaxLife());
|
||||
setSize(getStats()->getSize().x, getStats()->getSize().y);
|
||||
void InitMob() {
|
||||
m_Health = static_cast<float>(GetStats()->GetMaxLife());
|
||||
SetSize(GetStats()->GetSize().x, GetStats()->GetSize().y);
|
||||
}
|
||||
private:
|
||||
void updateEffects(std::uint64_t delta, World* world);
|
||||
void attackCastle(std::uint64_t delta, World* world);
|
||||
void move(std::uint64_t delta, World* world);
|
||||
void walk(std::uint64_t delta, World* world);
|
||||
void moveBack(const TeamCastle& castle, World* world);
|
||||
void changeDirection(const WalkableTile& tile, World* world);
|
||||
bool isTouchingCastle(const TeamCastle& castle) const;
|
||||
EffectDuration& getEffect(EffectType type);
|
||||
void UpdateEffects(std::uint64_t delta, World* world);
|
||||
void AttackCastle(std::uint64_t delta, World* world);
|
||||
void Move(std::uint64_t delta, World* world);
|
||||
void Walk(std::uint64_t delta, World* world);
|
||||
void MoveBack(const TeamCastle& castle, World* world);
|
||||
void ChangeDirection(const WalkableTile& tile, World* world);
|
||||
bool IsTouchingCastle(const TeamCastle& castle) const;
|
||||
EffectDuration& GetEffect(EffectType type);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Mob> MobPtr;
|
||||
|
||||
class Zombie : public Mob {
|
||||
public:
|
||||
Zombie(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Zombie(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Zombie; }
|
||||
virtual MobType GetType() const { return MobType::Zombie; }
|
||||
};
|
||||
|
||||
class Spider : public Mob {
|
||||
public:
|
||||
Spider(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Spider(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Spider; }
|
||||
virtual MobType GetType() const { return MobType::Spider; }
|
||||
};
|
||||
|
||||
class Skeleton : public Mob {
|
||||
public:
|
||||
Skeleton(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Skeleton(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Skeleton; }
|
||||
virtual MobType GetType() const { return MobType::Skeleton; }
|
||||
};
|
||||
|
||||
class PigMan : public Mob {
|
||||
public:
|
||||
PigMan(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
PigMan(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Pigman; }
|
||||
virtual MobType GetType() const { return MobType::Pigman; }
|
||||
};
|
||||
|
||||
class Creeper : public Mob {
|
||||
public:
|
||||
Creeper(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Creeper(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Creeper; }
|
||||
virtual MobType GetType() const { return MobType::Creeper; }
|
||||
};
|
||||
|
||||
class Silverfish : public Mob {
|
||||
public:
|
||||
Silverfish(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Silverfish(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Silverfish; }
|
||||
virtual MobType GetType() const { return MobType::Silverfish; }
|
||||
};
|
||||
|
||||
class Blaze : public Mob {
|
||||
public:
|
||||
Blaze(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Blaze(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Blaze; }
|
||||
virtual MobType GetType() const { return MobType::Blaze; }
|
||||
};
|
||||
|
||||
class Witch : public Mob {
|
||||
public:
|
||||
Witch(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Witch(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Witch; }
|
||||
virtual MobType GetType() const { return MobType::Witch; }
|
||||
};
|
||||
|
||||
class Slime : public Mob {
|
||||
public:
|
||||
Slime(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Slime(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Slime; }
|
||||
virtual MobType GetType() const { return MobType::Slime; }
|
||||
};
|
||||
|
||||
class Giant : public Mob {
|
||||
public:
|
||||
Giant(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { initMob(); }
|
||||
Giant(MobID id, std::uint8_t level, PlayerID sender) : Mob(id, level, sender) { InitMob(); }
|
||||
|
||||
virtual MobType getType() const { return MobType::Giant; }
|
||||
virtual MobType GetType() const { return MobType::Giant; }
|
||||
};
|
||||
|
||||
namespace MobFactory {
|
||||
MobPtr createMob(MobID id, MobType type, std::uint8_t level, PlayerID sender);
|
||||
std::string getMobName(MobType type);
|
||||
|
||||
MobPtr CreateMob(MobID id, MobType type, std::uint8_t level, PlayerID sender);
|
||||
std::string GetMobName(MobType type);
|
||||
|
||||
}
|
||||
|
||||
class MobListener {
|
||||
|
||||
@@ -23,26 +23,26 @@ public:
|
||||
|
||||
Player(std::uint8_t id = 0) : m_TeamColor(game::TeamColor::None), m_Gold(0), m_Exp(0), m_ID(id), m_GoldPerSecond(5) {}
|
||||
|
||||
const std::string& getName() const { return m_Name; }
|
||||
void setName(const std::string& name) { m_Name = name; }
|
||||
const std::string& GetName() const { return m_Name; }
|
||||
void SetName(const std::string& name) { m_Name = name; }
|
||||
|
||||
game::TeamColor getTeamColor() const { return m_TeamColor; }
|
||||
void setTeamColor(game::TeamColor teamColor) { m_TeamColor = teamColor; }
|
||||
game::TeamColor GetTeamColor() const { return m_TeamColor; }
|
||||
void SetTeamColor(game::TeamColor teamColor) { m_TeamColor = teamColor; }
|
||||
|
||||
std::uint8_t getGoldPerSecond() const { return m_GoldPerSecond; }
|
||||
void setGoldPerSecond(std::uint8_t goldPerSecond) { m_GoldPerSecond = goldPerSecond; }
|
||||
std::uint8_t GetGoldPerSecond() const { return m_GoldPerSecond; }
|
||||
void SetGoldPerSecond(std::uint8_t goldPerSecond) { m_GoldPerSecond = goldPerSecond; }
|
||||
|
||||
std::uint32_t getGold() const { return m_Gold; }
|
||||
void setGold(std::uint32_t gold) { m_Gold = gold; }
|
||||
void addGold(std::uint32_t gold) { m_Gold += gold; }
|
||||
void removeGold(std::uint32_t gold) { m_Gold -= gold; }
|
||||
std::uint32_t GetGold() const { return m_Gold; }
|
||||
void SetGold(std::uint32_t gold) { m_Gold = gold; }
|
||||
void AddGold(std::uint32_t gold) { m_Gold += gold; }
|
||||
void RemoveGold(std::uint32_t gold) { m_Gold -= gold; }
|
||||
|
||||
std::uint32_t getExp() const { return m_Exp; }
|
||||
void setExp(std::uint32_t exp) { m_Exp = exp; }
|
||||
void addExp(std::uint32_t exp) { m_Exp += exp; }
|
||||
void removeExp(std::uint32_t exp) { m_Exp -= exp; }
|
||||
std::uint32_t GetExp() const { return m_Exp; }
|
||||
void SetExp(std::uint32_t exp) { m_Exp = exp; }
|
||||
void AddExp(std::uint32_t exp) { m_Exp += exp; }
|
||||
void RemoveExp(std::uint32_t exp) { m_Exp -= exp; }
|
||||
|
||||
PlayerID getID() const { return m_ID; }
|
||||
PlayerID GetID() const { return m_ID; }
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -24,13 +24,13 @@ private:
|
||||
Direction m_Direction;
|
||||
public:
|
||||
Spawn() {
|
||||
setWidth(5);
|
||||
setHeight(5);
|
||||
SetWidth(5);
|
||||
SetHeight(5);
|
||||
}
|
||||
|
||||
Direction getDirection() const { return m_Direction; }
|
||||
Direction GetDirection() const { return m_Direction; }
|
||||
|
||||
void setDirection(Direction direction) { m_Direction = direction; }
|
||||
void SetDirection(Direction direction) { m_Direction = direction; }
|
||||
};
|
||||
|
||||
class Team;
|
||||
@@ -43,23 +43,23 @@ public:
|
||||
static constexpr int CastleMaxLife = 1000;
|
||||
|
||||
TeamCastle(const Team* team) : m_Team(team), m_Life(CastleMaxLife) {
|
||||
setWidth(5);
|
||||
setHeight(5);
|
||||
SetWidth(5);
|
||||
SetHeight(5);
|
||||
}
|
||||
|
||||
TeamCastle() : TeamCastle(nullptr) {}
|
||||
|
||||
float getLife() const { return m_Life; }
|
||||
float GetLife() const { return m_Life; }
|
||||
|
||||
const Team* getTeam() const { return m_Team; }
|
||||
void setTeam(const Team* team) { m_Team = team; }
|
||||
const Team* GetTeam() const { return m_Team; }
|
||||
void SetTeam(const Team* team) { m_Team = team; }
|
||||
|
||||
void setLife(float life) { m_Life = life; }
|
||||
void damage(float damage) { m_Life = std::max(0.0f, m_Life - damage); }
|
||||
void SetLife(float life) { m_Life = life; }
|
||||
void Damage(float damage) { m_Life = std::max(0.0f, m_Life - damage); }
|
||||
|
||||
void setShape(utils::shape::Rectangle rect) {
|
||||
setCenter(rect.getCenter());
|
||||
setSize(rect.getSize());
|
||||
void SetShape(utils::shape::Rectangle rect) {
|
||||
SetCenter(rect.GetCenter());
|
||||
SetSize(rect.GetSize());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -72,18 +72,18 @@ private:
|
||||
public:
|
||||
Team(TeamColor color);
|
||||
|
||||
void addPlayer(Player* newPlayer);
|
||||
void removePlayer(const Player* player);
|
||||
void AddPlayer(Player* newPlayer);
|
||||
void RemovePlayer(const Player* player);
|
||||
|
||||
TeamColor getColor() const;
|
||||
TeamColor GetColor() const;
|
||||
|
||||
const Spawn& getSpawn() const { return m_Spawn; }
|
||||
Spawn& getSpawn() { return m_Spawn; }
|
||||
const Spawn& GetSpawn() const { return m_Spawn; }
|
||||
Spawn& GetSpawn() { return m_Spawn; }
|
||||
|
||||
const TeamCastle& getCastle() const { return m_TeamCastle; }
|
||||
TeamCastle& getCastle() { return m_TeamCastle; }
|
||||
const TeamCastle& GetCastle() const { return m_TeamCastle; }
|
||||
TeamCastle& GetCastle() { return m_TeamCastle; }
|
||||
|
||||
std::uint8_t getPlayerCount() const;
|
||||
std::uint8_t GetPlayerCount() const;
|
||||
};
|
||||
|
||||
typedef std::array<Team, 2> TeamList;
|
||||
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
m_Range(range) {
|
||||
}
|
||||
|
||||
float getDamageRate() const { return m_Rate; }
|
||||
float getDamage() const { return m_Damage; }
|
||||
std::uint8_t getRange() const { return m_Range; }
|
||||
float GetDamageRate() const { return m_Rate; }
|
||||
float GetDamage() const { return m_Damage; }
|
||||
std::uint8_t GetRange() const { return m_Range; }
|
||||
};
|
||||
|
||||
class TowerLevel {
|
||||
@@ -70,20 +70,20 @@ public:
|
||||
TowerLevel() : m_Level(1), m_Path(TowerPath::Base) {}
|
||||
TowerLevel(std::uint8_t level, TowerPath path) : m_Level(level), m_Path(path) {}
|
||||
|
||||
std::uint8_t getLevel() const { return m_Level; }
|
||||
TowerPath getPath() const { return m_Path; }
|
||||
std::uint8_t GetLevel() const { return m_Level; }
|
||||
TowerPath GetPath() const { return m_Path; }
|
||||
|
||||
void setLevel(std::uint8_t level) { m_Level = level; }
|
||||
void setPath(TowerPath path) { m_Path = path; }
|
||||
void SetLevel(std::uint8_t level) { m_Level = level; }
|
||||
void SetPath(TowerPath path) { m_Path = path; }
|
||||
|
||||
// operator to sort maps
|
||||
friend bool operator<(const TowerLevel& level, const TowerLevel& other) {
|
||||
return level.getLevel() + static_cast<std::uint8_t>(level.getPath()) * 4 <
|
||||
other.getLevel() + static_cast<std::uint8_t>(other.getPath()) * 4;
|
||||
return level.GetLevel() + static_cast<std::uint8_t>(level.GetPath()) * 4 <
|
||||
other.GetLevel() + static_cast<std::uint8_t>(other.GetPath()) * 4;
|
||||
}
|
||||
};
|
||||
|
||||
const TowerStats* getTowerStats(TowerType type, TowerLevel level);
|
||||
const TowerStats* GetTowerStats(TowerType type, TowerLevel level);
|
||||
|
||||
typedef std::uint16_t TowerID;
|
||||
|
||||
@@ -97,36 +97,36 @@ protected:
|
||||
utils::CooldownTimer m_Timer;
|
||||
public:
|
||||
Tower(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder) : utils::shape::Circle(x + 0.5f, y + 0.5f, 0), m_ID(id), m_Type(type), m_Builder(builder),
|
||||
m_Timer(getStats()->getDamageRate() * 1000) { // converting seconds to millis
|
||||
setRadius(getStats()->getRange());
|
||||
m_Timer(GetStats()->GetDamageRate() * 1000) { // converting seconds to millis
|
||||
SetRadius(GetStats()->GetRange());
|
||||
}
|
||||
|
||||
virtual TowerType getType() const = 0;
|
||||
virtual TowerSize getSize() const = 0;
|
||||
virtual void tick(std::uint64_t delta, World* world) = 0;
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual TowerSize GetSize() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
|
||||
void upgrade(std::uint8_t level, TowerPath path) {
|
||||
m_Level.setLevel(level);
|
||||
m_Level.setPath(path);
|
||||
m_Timer.setCooldown(getStats()->getDamageRate() * 1000); // converting seconds to millis
|
||||
m_Timer.reset();
|
||||
setRadius(getStats()->getRange());
|
||||
void Upgrade(std::uint8_t level, TowerPath path) {
|
||||
m_Level.SetLevel(level);
|
||||
m_Level.SetPath(path);
|
||||
m_Timer.SetCooldown(GetStats()->GetDamageRate() * 1000); // converting seconds to millis
|
||||
m_Timer.Reset();
|
||||
SetRadius(GetStats()->GetRange());
|
||||
}
|
||||
|
||||
std::uint16_t getID() const { return m_ID; }
|
||||
const TowerLevel& getLevel() const { return m_Level; }
|
||||
const TowerStats* getStats() const { return getTowerStats(m_Type, m_Level); }
|
||||
PlayerID getBuilder() const { return m_Builder; }
|
||||
std::uint16_t GetID() const { return m_ID; }
|
||||
const TowerLevel& GetLevel() const { return m_Level; }
|
||||
const TowerStats* GetStats() const { return GetTowerStats(m_Type, m_Level); }
|
||||
PlayerID GetBuilder() const { return m_Builder; }
|
||||
|
||||
bool isMobInRange(MobPtr mob);
|
||||
bool IsMobInRange(MobPtr mob);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Tower> TowerPtr;
|
||||
|
||||
namespace TowerFactory {
|
||||
|
||||
TowerPtr createTower(TowerType type, TowerID id, std::int32_t x, std::int32_t y, PlayerID builder);
|
||||
std::string getTowerName(TowerType type);
|
||||
TowerPtr CreateTower(TowerType type, TowerID id, std::int32_t x, std::int32_t y, PlayerID builder);
|
||||
std::string GetTowerName(TowerType type);
|
||||
|
||||
} // namespace TowerFactory
|
||||
|
||||
@@ -139,13 +139,13 @@ public:
|
||||
TowerInfo(std::string&& name, std::string&& description, bool big) : m_Name(std::move(name)),
|
||||
m_Description(std::move(description)), m_IsBigTower(big) {}
|
||||
|
||||
const std::string& getName() const { return m_Name; }
|
||||
const std::string& getDescription() const { return m_Description; }
|
||||
const std::string& GetName() const { return m_Name; }
|
||||
const std::string& GetDescription() const { return m_Description; }
|
||||
|
||||
bool isBigTower() const { return m_IsBigTower; }
|
||||
bool IsBigTower() const { return m_IsBigTower; }
|
||||
};
|
||||
|
||||
const TowerInfo& getTowerInfo(TowerType type);
|
||||
const TowerInfo& GetTowerInfo(TowerType type);
|
||||
|
||||
// ---------- Little Towers ----------
|
||||
|
||||
@@ -153,77 +153,77 @@ class LittleTower : public Tower {
|
||||
public:
|
||||
LittleTower(TowerID id, TowerType type, std::uint16_t x, std::uint16_t y, PlayerID builder) : Tower(id, type, x, y, builder) {}
|
||||
|
||||
virtual TowerSize getSize() const { return TowerSize::Little; }
|
||||
virtual TowerSize GetSize() const { return TowerSize::Little; }
|
||||
|
||||
virtual TowerType getType() const = 0;
|
||||
virtual void tick(std::uint64_t delta, World* world) = 0;
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
};
|
||||
|
||||
class ArcherTower : public LittleTower {
|
||||
public:
|
||||
ArcherTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
ArcherTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
constexpr static float ExplosionRadius = 1.5f;
|
||||
constexpr static float FireDurationSec = 10.0f;
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Archer; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Archer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class IceTower : public LittleTower {
|
||||
public:
|
||||
IceTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
IceTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Ice; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Ice; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class MageTower : public LittleTower {
|
||||
public:
|
||||
MageTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
MageTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Mage; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Mage; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class PoisonTower : public LittleTower {
|
||||
public:
|
||||
PoisonTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
PoisonTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Poison; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Poison; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class QuakeTower : public LittleTower {
|
||||
public:
|
||||
QuakeTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
QuakeTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Quake; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Quake; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class ArtilleryTower : public LittleTower {
|
||||
public:
|
||||
ArtilleryTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
ArtilleryTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Artillery; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Artillery; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class SorcererTower : public LittleTower {
|
||||
public:
|
||||
SorcererTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
SorcererTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Sorcerer; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Sorcerer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class ZeusTower : public LittleTower {
|
||||
public:
|
||||
ZeusTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, getType(), x, y, builder) {}
|
||||
ZeusTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : LittleTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Zeus; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Zeus; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
// ---------- Big Towers ----------
|
||||
@@ -232,34 +232,34 @@ class BigTower : public Tower {
|
||||
public:
|
||||
BigTower(TowerID id, TowerType type, std::uint16_t x, std::uint16_t y, PlayerID builder) : Tower(id, type, x, y, builder) {}
|
||||
|
||||
virtual TowerSize getSize() const { return TowerSize::Big; }
|
||||
virtual TowerSize GetSize() const { return TowerSize::Big; }
|
||||
|
||||
virtual TowerType getType() const = 0;
|
||||
virtual void tick(std::uint64_t delta, World* world) = 0;
|
||||
virtual TowerType GetType() const = 0;
|
||||
virtual void Tick(std::uint64_t delta, World* world) = 0;
|
||||
};
|
||||
|
||||
class TurretTower : public BigTower {
|
||||
public:
|
||||
TurretTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, getType(), x, y, builder) {}
|
||||
TurretTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Turret; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Turret; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class NecromancerTower : public BigTower {
|
||||
public:
|
||||
NecromancerTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, getType(), x, y, builder) {}
|
||||
NecromancerTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Necromancer; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Necromancer; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
class LeachTower : public BigTower {
|
||||
public:
|
||||
LeachTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, getType(), x, y, builder) {}
|
||||
LeachTower(TowerID id, std::uint16_t x, std::uint16_t y, PlayerID builder) : BigTower(id, GetType(), x, y, builder) {}
|
||||
|
||||
virtual TowerType getType() const { return TowerType::Leach; }
|
||||
virtual void tick(std::uint64_t delta, World* world);
|
||||
virtual TowerType GetType() const { return TowerType::Leach; }
|
||||
virtual void Tick(std::uint64_t delta, World* world);
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -71,26 +71,26 @@ static constexpr Color GREEN{ 0, 255, 0 };
|
||||
static constexpr Color BLUE{ 0, 0, 255 };
|
||||
|
||||
struct Tile {
|
||||
virtual TileType getType() const = 0;
|
||||
virtual TileType GetType() const = 0;
|
||||
};
|
||||
|
||||
struct TowerTile : Tile {
|
||||
std::uint8_t color_palette_ref;
|
||||
TeamColor team_owner;
|
||||
|
||||
virtual TileType getType() const { return TileType::Tower; }
|
||||
virtual TileType GetType() const { return TileType::Tower; }
|
||||
};
|
||||
|
||||
struct WalkableTile : Tile {
|
||||
Direction direction;
|
||||
|
||||
virtual TileType getType() const { return TileType::Walk; }
|
||||
virtual TileType GetType() const { return TileType::Walk; }
|
||||
};
|
||||
|
||||
struct DecorationTile : Tile {
|
||||
std::uint16_t color_palette_ref;
|
||||
|
||||
virtual TileType getType() const { return TileType::Decoration; }
|
||||
virtual TileType GetType() const { return TileType::Decoration; }
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Tile> TilePtr;
|
||||
@@ -109,7 +109,7 @@ struct Chunk {
|
||||
ChunkData tiles{ 0 };
|
||||
ChunkPalette palette;
|
||||
|
||||
TileIndex getTileIndex(std::uint16_t tileNumber) const {
|
||||
TileIndex GetTileIndex(std::uint16_t tileNumber) const {
|
||||
TileIndex chunkPaletteIndex = tiles.at(tileNumber);
|
||||
if (chunkPaletteIndex == 0) // index 0 means empty tile index 1 = first tile
|
||||
return 0;
|
||||
@@ -168,29 +168,29 @@ protected:
|
||||
public:
|
||||
World(Game* game);
|
||||
|
||||
bool loadMap(const protocol::WorldBeginDataPacket* worldHeader);
|
||||
bool loadMap(const protocol::WorldDataPacket* worldData);
|
||||
bool LoadMap(const protocol::WorldBeginDataPacket* worldHeader);
|
||||
bool LoadMap(const protocol::WorldDataPacket* worldData);
|
||||
|
||||
bool loadMapFromFile(const std::string& fileName);
|
||||
bool saveMap(const std::string& fileName) const;
|
||||
bool LoadMapFromFile(const std::string& fileName);
|
||||
bool SaveMap(const std::string& fileName) const;
|
||||
|
||||
void tick(std::uint64_t delta);
|
||||
void Tick(std::uint64_t delta);
|
||||
|
||||
void spawnMobAt(MobID id, MobType type, std::uint8_t level, PlayerID sender, float x, float y, Direction dir);
|
||||
void SpawnMobAt(MobID id, MobType type, std::uint8_t level, PlayerID sender, float x, float y, Direction dir);
|
||||
|
||||
TowerPtr placeTowerAt(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder);
|
||||
TowerPtr removeTower(TowerID id);
|
||||
TowerPtr PlaceTowerAt(TowerID id, TowerType type, std::int32_t x, std::int32_t y, PlayerID builder);
|
||||
TowerPtr RemoveTower(TowerID id);
|
||||
|
||||
TilePtr getTile(std::int32_t x, std::int32_t y) const;
|
||||
TilePtr GetTile(std::int32_t x, std::int32_t y) const;
|
||||
|
||||
const TowerTileColorPalette& getTowerTileColorPalette() const { return m_TowerPlacePalette; }
|
||||
const Color& getWalkableTileColor() const { return m_WalkablePalette; }
|
||||
const std::vector<Color>& getDecorationPalette() const { return m_DecorationPalette; }
|
||||
const Color& getBackgroundColor() const { return m_Background; }
|
||||
const TowerTileColorPalette& GetTowerTileColorPalette() const { return m_TowerPlacePalette; }
|
||||
const Color& GetWalkableTileColor() const { return m_WalkablePalette; }
|
||||
const std::vector<Color>& GetDecorationPalette() const { return m_DecorationPalette; }
|
||||
const Color& GetBackgroundColor() const { return m_Background; }
|
||||
|
||||
const TilePalette& getTilePalette() const { return m_TilePalette; }
|
||||
const TilePalette& GetTilePalette() const { return m_TilePalette; }
|
||||
|
||||
TilePtr getTilePtr(TileIndex index) const {
|
||||
TilePtr GetTilePtr(TileIndex index) const {
|
||||
if (index == 0)
|
||||
return nullptr;
|
||||
return m_TilePalette.at(index - 1);
|
||||
@@ -199,36 +199,36 @@ public:
|
||||
bool CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID player) const;
|
||||
bool CanPlaceBigTower(const glm::vec2& worldPos, PlayerID player) const;
|
||||
|
||||
TowerPtr getTower(const glm::vec2& position) const; // returns null if no tower is here
|
||||
TowerPtr GetTower(const glm::vec2& position) const; // returns null if no tower is here
|
||||
|
||||
const std::unordered_map<ChunkCoord, ChunkPtr>& getChunks() const { return m_Chunks; }
|
||||
const std::unordered_map<ChunkCoord, ChunkPtr>& GetChunks() const { return m_Chunks; }
|
||||
|
||||
const Color& getSpawnColor(TeamColor color) const { return m_SpawnColorPalette[(std::size_t)color]; }
|
||||
const SpawnColorPalette& getSpawnColors() const { return m_SpawnColorPalette; }
|
||||
const Color& GetSpawnColor(TeamColor color) const { return m_SpawnColorPalette[(std::size_t)color]; }
|
||||
const SpawnColorPalette& GetSpawnColors() const { return m_SpawnColorPalette; }
|
||||
|
||||
const MobList& getMobList() const { return m_Mobs; }
|
||||
MobList& getMobList() { return m_Mobs; }
|
||||
const MobList& GetMobList() const { return m_Mobs; }
|
||||
MobList& GetMobList() { return m_Mobs; }
|
||||
|
||||
const Color* getTileColor(TilePtr tile) const;
|
||||
const Color* GetTileColor(TilePtr tile) const;
|
||||
|
||||
Team& getRedTeam();
|
||||
const Team& getRedTeam() const;
|
||||
Team& GetRedTeam();
|
||||
const Team& GetRedTeam() const;
|
||||
|
||||
Team& getBlueTeam();
|
||||
const Team& getBlueTeam() const;
|
||||
Team& GetBlueTeam();
|
||||
const Team& GetBlueTeam() const;
|
||||
|
||||
Team& getTeam(TeamColor team);
|
||||
const Team& getTeam(TeamColor team) const;
|
||||
Team& GetTeam(TeamColor team);
|
||||
const Team& GetTeam(TeamColor team) const;
|
||||
|
||||
const TeamList& getTeams() const;
|
||||
const TeamList& GetTeams() const;
|
||||
|
||||
const TowerList& getTowers() const { return m_Towers; };
|
||||
TowerPtr getTowerById(TowerID tower);
|
||||
const TowerList& GetTowers() const { return m_Towers; };
|
||||
TowerPtr GetTowerById(TowerID tower);
|
||||
|
||||
const Player* getPlayerById(PlayerID id) const;
|
||||
const Player* GetPlayerById(PlayerID id) const;
|
||||
|
||||
WorldNotifier& getWorldNotifier() { return m_WorldNotifier; }
|
||||
MobNotifier& getMobNotifier() { return m_MobNotifier; }
|
||||
WorldNotifier& GetWorldNotifier() { return m_WorldNotifier; }
|
||||
MobNotifier& GetMobNotifier() { return m_MobNotifier; }
|
||||
|
||||
// WorldListener
|
||||
|
||||
@@ -243,8 +243,8 @@ public:
|
||||
virtual void OnMobCastleDamage(Mob* damager, TeamCastle* enemyCastle, float damage);
|
||||
|
||||
private:
|
||||
void tickMobs(std::uint64_t delta);
|
||||
void cleanDeadMobs();
|
||||
void TickMobs(std::uint64_t delta);
|
||||
void CleanDeadMobs();
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -24,29 +24,29 @@ private:
|
||||
public:
|
||||
Client(render::Renderer* renderer) : m_Renderer(renderer), m_Game(std::make_unique<ClientGame>(this)), m_Connected(false) {}
|
||||
|
||||
const ClientGame& getGame() const { return *m_Game; }
|
||||
const ClientConnexion& getConnexion() const { return m_Connexion; }
|
||||
render::Renderer* getRenderer() const { return m_Renderer; }
|
||||
const ClientGame& GetGame() const { return *m_Game; }
|
||||
const ClientConnexion& GetConnexion() const { return m_Connexion; }
|
||||
render::Renderer* GetRenderer() const { return m_Renderer; }
|
||||
|
||||
ClientGame& getGame() { return *m_Game; }
|
||||
ClientConnexion& getConnexion() { return m_Connexion; }
|
||||
ClientGame& GetGame() { return *m_Game; }
|
||||
ClientConnexion& GetConnexion() { return m_Connexion; }
|
||||
|
||||
void tick(std::uint64_t delta);
|
||||
void Tick(std::uint64_t delta);
|
||||
|
||||
void render();
|
||||
void Render();
|
||||
|
||||
bool connect(const network::IPAddresses& addresses, std::uint16_t port);
|
||||
void closeConnection();
|
||||
bool Connect(const network::IPAddresses& addresses, std::uint16_t port);
|
||||
void CloseConnection();
|
||||
|
||||
bool isConnected() const { return m_Connexion.getSocketStatus() == network::Socket::Connected; }
|
||||
bool IsConnected() const { return m_Connexion.GetSocketStatus() == network::Socket::Connected; }
|
||||
|
||||
void selectTeam(game::TeamColor team);
|
||||
void sendMobs(const std::vector<protocol::MobSend>& mobSends);
|
||||
void placeTower(game::TowerType type, const glm::vec2& position);
|
||||
void upgradeTower(game::TowerID tower, game::TowerLevel level);
|
||||
void removeTower(game::TowerID tower);
|
||||
void SelectTeam(game::TeamColor team);
|
||||
void SendMobs(const std::vector<protocol::MobSend>& mobSends);
|
||||
void PlaceTower(game::TowerType type, const glm::vec2& position);
|
||||
void UpgradeTower(game::TowerID tower, game::TowerLevel level);
|
||||
void RemoveTower(game::TowerID tower);
|
||||
private:
|
||||
void reset();
|
||||
void Reset();
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -16,21 +16,21 @@ private:
|
||||
public:
|
||||
ClientConnexion();
|
||||
|
||||
virtual bool updateSocket();
|
||||
virtual bool UpdateSocket();
|
||||
|
||||
virtual void HandlePacket(const protocol::KeepAlivePacket* packet);
|
||||
virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet);
|
||||
virtual void HandlePacket(const protocol::DisconnectPacket* packet);
|
||||
virtual void HandlePacket(const protocol::ServerTpsPacket* packet);
|
||||
|
||||
const std::string& getDisconnectReason() const { return m_DisconnectReason; }
|
||||
float getServerTPS() const { return m_ServerTPS; }
|
||||
int getServerPing() const { return m_Ping; }
|
||||
const std::string& GetDisconnectReason() const { return m_DisconnectReason; }
|
||||
float GetServerTPS() const { return m_ServerTPS; }
|
||||
int GetServerPing() const { return m_Ping; }
|
||||
|
||||
REMOVE_COPY(ClientConnexion);
|
||||
private:
|
||||
void registerHandlers();
|
||||
void login();
|
||||
void RegisterHandlers();
|
||||
void Login();
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -27,17 +27,17 @@ public:
|
||||
ClientGame(Client* client);
|
||||
virtual ~ClientGame();
|
||||
|
||||
virtual void tick(std::uint64_t delta);
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
|
||||
void renderWorld();
|
||||
void RenderWorld();
|
||||
|
||||
std::uint32_t getLobbyTime() const { return m_LobbyTime; }
|
||||
const game::Player* getPlayer() const { return m_Player; }
|
||||
const WorldClient& getWorld() const { return m_WorldClient; }
|
||||
Client* getClient() const { return m_Client; }
|
||||
std::uint32_t GetLobbyTime() const { return m_LobbyTime; }
|
||||
const game::Player* GetPlayer() const { return m_Player; }
|
||||
const WorldClient& GetWorld() const { return m_WorldClient; }
|
||||
Client* GetClient() const { return m_Client; }
|
||||
|
||||
render::Renderer* getRenderer() const { return m_Renderer; }
|
||||
WorldClient& getWorldClient() { return m_WorldClient; }
|
||||
render::Renderer* GetRenderer() const { return m_Renderer; }
|
||||
WorldClient& GetWorldClient() { return m_WorldClient; }
|
||||
|
||||
virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet);
|
||||
virtual void HandlePacket(const protocol::PlayerJoinPacket* packet);
|
||||
|
||||
@@ -22,9 +22,9 @@ public:
|
||||
void OnPlayerJoin(std::uint8_t playerID);
|
||||
void OnPlayerLeave(std::uint8_t playerID);
|
||||
|
||||
void sendTimeRemaining();
|
||||
void SendTimeRemaining();
|
||||
|
||||
void tick();
|
||||
void Tick();
|
||||
|
||||
//static constexpr int LobbyWaitingTime = 2 * 60 * 1000; // in millis
|
||||
static constexpr int LobbyWaitingTime = 5 * 1000; // in millis
|
||||
|
||||
@@ -28,25 +28,25 @@ private:
|
||||
public:
|
||||
TickCounter() {}
|
||||
|
||||
void reset() {
|
||||
void Reset() {
|
||||
m_TPS = SERVER_TPS;
|
||||
m_LastTPSTime = utils::getTime();
|
||||
m_LastTPSTime = utils::GetTime();
|
||||
m_TickCount = 0;
|
||||
}
|
||||
|
||||
bool update() { // return true when tps is updated
|
||||
bool Update() { // return true when tps is updated
|
||||
m_TickCount++;
|
||||
if (m_TickCount >= SERVER_TPS) {
|
||||
std::uint64_t timeElapsedSinceLast20Ticks = td::utils::getTime() - m_LastTPSTime;
|
||||
std::uint64_t timeElapsedSinceLast20Ticks = td::utils::GetTime() - m_LastTPSTime;
|
||||
m_TPS = (float)SERVER_TPS / (float)(timeElapsedSinceLast20Ticks / 1000.0f);
|
||||
m_TickCount = 0;
|
||||
m_LastTPSTime = td::utils::getTime();
|
||||
m_LastTPSTime = td::utils::GetTime();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float getTPS() const { return m_TPS; }
|
||||
float GetTPS() const { return m_TPS; }
|
||||
};
|
||||
|
||||
class Server {
|
||||
@@ -63,36 +63,36 @@ public:
|
||||
Server(const std::string& worldFilePath);
|
||||
virtual ~Server();
|
||||
|
||||
bool start(std::uint16_t port);
|
||||
void stop(); // force the server to stop
|
||||
void close(); // at the end of a game
|
||||
bool Start(std::uint16_t port);
|
||||
void Stop(); // force the server to stop
|
||||
void Close(); // at the end of a game
|
||||
|
||||
void removeConnexion(std::uint8_t connexionID);
|
||||
void RemoveConnexion(std::uint8_t connexionID);
|
||||
|
||||
void broadcastPacket(const protocol::Packet* packet);
|
||||
void BroadcastPacket(const protocol::Packet* packet);
|
||||
|
||||
float getTPS() const { return m_TickCounter.getTPS(); }
|
||||
float GetTPS() const { return m_TickCounter.GetTPS(); }
|
||||
|
||||
bool isRunning() { return m_ServerRunning; }
|
||||
bool IsRunning() { return m_ServerRunning; }
|
||||
|
||||
const ServerGame& getGame() const { return m_Game; }
|
||||
ServerGame& getGame() { return m_Game; }
|
||||
const ServerGame& GetGame() const { return m_Game; }
|
||||
ServerGame& GetGame() { return m_Game; }
|
||||
|
||||
const Lobby& getLobby() const { return m_Lobby; }
|
||||
const ConnexionMap& getConnexions() const { return m_Connections; }
|
||||
ConnexionMap& getConnexions() { return m_Connections; }
|
||||
const Lobby& GetLobby() const { return m_Lobby; }
|
||||
const ConnexionMap& GetConnexions() const { return m_Connections; }
|
||||
ConnexionMap& GetConnexions() { return m_Connections; }
|
||||
|
||||
const game::PlayerList& getPlayers() const { return m_Game.getPlayers(); }
|
||||
game::PlayerList& getPlayers() { return m_Game.getPlayers(); }
|
||||
const game::PlayerList& GetPlayers() const { return m_Game.GetPlayers(); }
|
||||
game::PlayerList& GetPlayers() { return m_Game.GetPlayers(); }
|
||||
|
||||
private:
|
||||
void accept();
|
||||
void updateSockets();
|
||||
void Accept();
|
||||
void UpdateSockets();
|
||||
|
||||
void clean();
|
||||
void startThread();
|
||||
void stopThread();
|
||||
void tick(std::uint64_t delta);
|
||||
void Clean();
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
void Tick(std::uint64_t delta);
|
||||
|
||||
void OnPlayerJoin(std::uint8_t id);
|
||||
void OnPlayerLeave(std::uint8_t id);
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
ServerConnexion(ServerConnexion&& move);
|
||||
virtual ~ServerConnexion();
|
||||
|
||||
void setServer(Server* server);
|
||||
void SetServer(Server* server);
|
||||
|
||||
virtual void HandlePacket(const protocol::PlayerLoginPacket* packet);
|
||||
virtual void HandlePacket(const protocol::KeepAlivePacket* packet);
|
||||
@@ -42,18 +42,18 @@ public:
|
||||
virtual void HandlePacket(const protocol::UpgradeTowerPacket* packet);
|
||||
virtual void HandlePacket(const protocol::RemoveTowerPacket* packet);
|
||||
|
||||
std::uint8_t getID() const { return m_ID; }
|
||||
const game::Player* getPlayer() const { return m_Player; }
|
||||
game::Player* getPlayer() { return m_Player; }
|
||||
std::uint8_t GetID() const { return m_ID; }
|
||||
const game::Player* GetPlayer() const { return m_Player; }
|
||||
game::Player* GetPlayer() { return m_Player; }
|
||||
|
||||
virtual bool updateSocket();
|
||||
virtual bool UpdateSocket();
|
||||
|
||||
REMOVE_COPY(ServerConnexion);
|
||||
private:
|
||||
void registerHandlers();
|
||||
void checkKeepAlive();
|
||||
void sendKeepAlive();
|
||||
void initConnection();
|
||||
void RegisterHandlers();
|
||||
void CheckKeepAlive();
|
||||
void SendKeepAlive();
|
||||
void InitConnection();
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
@@ -20,10 +20,10 @@ public:
|
||||
ServerGame(Server* server);
|
||||
~ServerGame() {}
|
||||
|
||||
ServerWorld* getServerWorld() { return &m_ServerWorld; }
|
||||
ServerWorld* GetServerWorld() { return &m_ServerWorld; }
|
||||
|
||||
virtual void tick(std::uint64_t delta);
|
||||
void startGame();
|
||||
virtual void Tick(std::uint64_t delta);
|
||||
void StartGame();
|
||||
|
||||
// GameListener
|
||||
|
||||
@@ -32,10 +32,10 @@ public:
|
||||
virtual void OnGameEnd();
|
||||
virtual void OnGameClose();
|
||||
private:
|
||||
void balanceTeams();
|
||||
void updateMobStates();
|
||||
void updateGoldMines();
|
||||
void updatePlayerStats();
|
||||
void BalanceTeams();
|
||||
void UpdateMobStates();
|
||||
void UpdateGoldMines();
|
||||
void UpdatePlayerStats();
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
@@ -18,8 +18,8 @@ public:
|
||||
|
||||
ServerWorld(Server* server, ServerGame* game);
|
||||
|
||||
void spawnMobs(game::MobType type, std::uint8_t level, game::PlayerID sender, std::uint8_t count);
|
||||
game::TowerPtr placeTowerAt(game::TowerType type, std::int32_t x, std::int32_t y, game::PlayerID builder);
|
||||
void SpawnMobs(game::MobType type, std::uint8_t level, game::PlayerID sender, std::uint8_t count);
|
||||
game::TowerPtr PlaceTowerAt(game::TowerType type, std::int32_t x, std::int32_t y, game::PlayerID builder);
|
||||
|
||||
virtual void OnMobDie(game::Mob* mob);
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
namespace td {
|
||||
namespace utils {
|
||||
|
||||
std::uint64_t inflate(const std::string& source, std::string& dest);
|
||||
std::uint64_t deflate(const std::string& source, std::string& dest);
|
||||
std::uint64_t Inflate(const std::string& source, std::string& dest);
|
||||
std::uint64_t Deflate(const std::string& source, std::string& dest);
|
||||
|
||||
DataBuffer Compress(const DataBuffer& buffer);
|
||||
DataBuffer Decompress(DataBuffer& buffer);
|
||||
|
||||
@@ -7,63 +7,63 @@ constexpr float PI = 3.14159274101257324219;
|
||||
|
||||
/* Sine functions */
|
||||
|
||||
float easeInSine(float x);
|
||||
float easeOutSine(float x);
|
||||
float easeInOutSine(float x);
|
||||
float EaseInSine(float x);
|
||||
float EaseOutSine(float x);
|
||||
float EaseInOutSine(float x);
|
||||
|
||||
/* Cubic functions */
|
||||
|
||||
float easeInCubic(float x);
|
||||
float easeOutCubic(float x);
|
||||
float easeInOutCubic(float x);
|
||||
float EaseInCubic(float x);
|
||||
float EaseOutCubic(float x);
|
||||
float EaseInOutCubic(float x);
|
||||
|
||||
/* Quint functions */
|
||||
|
||||
float easeInQuint(float x);
|
||||
float easeOutQuint(float x);
|
||||
float easeInOutQuint(float x);
|
||||
float EaseInQuint(float x);
|
||||
float EaseOutQuint(float x);
|
||||
float EaseInOutQuint(float x);
|
||||
|
||||
/* Circ functions */
|
||||
|
||||
float easeInCirc(float x);
|
||||
float easeOutCirc(float x);
|
||||
float easeInOutCirc(float x);
|
||||
float EaseInCirc(float x);
|
||||
float EaseOutCirc(float x);
|
||||
float EaseInOutCirc(float x);
|
||||
|
||||
/* Elastic functions */
|
||||
|
||||
float easeInElastic(float x);
|
||||
float easeOutElastic(float x);
|
||||
float easeInOutElastic(float x);
|
||||
float EaseInElastic(float x);
|
||||
float EaseOutElastic(float x);
|
||||
float EaseInOutElastic(float x);
|
||||
|
||||
/* Quad functions */
|
||||
|
||||
float easeInQuad(float x);
|
||||
float easeOutQuad(float x);
|
||||
float easeInOutQuad(float x);
|
||||
float EaseInQuad(float x);
|
||||
float EaseOutQuad(float x);
|
||||
float EaseInOutQuad(float x);
|
||||
|
||||
/* Quart functions */
|
||||
|
||||
float easeInQuart(float x);
|
||||
float easeOutQuart(float x);
|
||||
float easeInOutQuart(float x);
|
||||
float EaseInQuart(float x);
|
||||
float EaseOutQuart(float x);
|
||||
float EaseInOutQuart(float x);
|
||||
|
||||
/* Expo functions */
|
||||
|
||||
float easeInExpo(float x);
|
||||
float easeOutExpo(float x);
|
||||
float easeInOutExpo(float x);
|
||||
float EaseInExpo(float x);
|
||||
float EaseOutExpo(float x);
|
||||
float EaseInOutExpo(float x);
|
||||
|
||||
/* Back functions */
|
||||
|
||||
float easeInBack(float x);
|
||||
float easeOutBack(float x);
|
||||
float easeInOutBack(float x);
|
||||
float EaseInBack(float x);
|
||||
float EaseOutBack(float x);
|
||||
float EaseInOutBack(float x);
|
||||
|
||||
/* Bounce functions */
|
||||
|
||||
float easeInBounce(float x);
|
||||
float easeOutBounce(float x);
|
||||
float easeInOutBounce(float x);
|
||||
float EaseInBounce(float x);
|
||||
float EaseOutBounce(float x);
|
||||
float EaseInOutBounce(float x);
|
||||
|
||||
} // namespace utils
|
||||
} // namespace td
|
||||
|
||||
@@ -13,20 +13,20 @@ protected:
|
||||
std::vector<Listener*> m_Listeners;
|
||||
|
||||
public:
|
||||
void bindListener(Listener* listener) {
|
||||
void BindListener(Listener* listener) {
|
||||
m_Listeners.push_back(listener);
|
||||
}
|
||||
|
||||
void unbindListener(Listener* listener) {
|
||||
void UnbindListener(Listener* listener) {
|
||||
auto iter = std::find(m_Listeners.begin(), m_Listeners.end(), listener);
|
||||
|
||||
if(iter == m_Listeners.end()) return;
|
||||
if (iter == m_Listeners.end()) return;
|
||||
|
||||
m_Listeners.erase(iter);
|
||||
}
|
||||
|
||||
template <typename Func, typename... Args>
|
||||
void notifyListeners(Func function, Args... args) {
|
||||
void NotifyListeners(Func function, Args... args) {
|
||||
for (Listener* listener : m_Listeners)
|
||||
std::bind(function, listener, args...)();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ enum class Architecture {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
inline Os getSystemOs() {
|
||||
inline Os GetSystemOs() {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return Os::Windows;
|
||||
#elif defined(__ANDROID__)
|
||||
@@ -31,7 +31,7 @@ inline Os getSystemOs() {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Architecture getSystemArchitecture() {
|
||||
inline Architecture GetSystemArchitecture() {
|
||||
#if defined(_WIN64)
|
||||
return Architecture::x86_64;
|
||||
#elif defined(_WIN32)
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace td {
|
||||
namespace utils {
|
||||
|
||||
template<typename NumberType>
|
||||
NumberType getRandomInt(NumberType min, NumberType max) {
|
||||
NumberType GetRandomInt(NumberType min, NumberType max) {
|
||||
std::random_device randomDevice;
|
||||
std::mt19937 generator(randomDevice());
|
||||
std::uniform_int_distribution<NumberType> distrib(min, max);
|
||||
@@ -14,7 +14,7 @@ NumberType getRandomInt(NumberType min, NumberType max) {
|
||||
}
|
||||
|
||||
template<typename NumberType>
|
||||
NumberType getRandomReal(NumberType min, NumberType max) {
|
||||
NumberType GetRandomReal(NumberType min, NumberType max) {
|
||||
std::random_device randomDevice;
|
||||
std::mt19937 generator(randomDevice());
|
||||
std::uniform_real_distribution<NumberType> distrib(min, max);
|
||||
|
||||
@@ -13,14 +13,14 @@ public:
|
||||
Point() : m_X(0), m_Y(0) {}
|
||||
Point(float x, float y) : m_X(x), m_Y(y) {}
|
||||
|
||||
float getX() const { return m_X; }
|
||||
float getY() const { return m_Y; }
|
||||
float GetX() const { return m_X; }
|
||||
float GetY() const { return m_Y; }
|
||||
|
||||
void setX(float x) { m_X = x; }
|
||||
void setY(float y) { m_Y = y; }
|
||||
void SetX(float x) { m_X = x; }
|
||||
void SetY(float y) { m_Y = y; }
|
||||
|
||||
float distance(const Point& point) const;
|
||||
float distanceSquared(const Point& point) const;
|
||||
float Distance(const Point& point) const;
|
||||
float DistanceSquared(const Point& point) const;
|
||||
};
|
||||
|
||||
class Circle;
|
||||
@@ -32,34 +32,34 @@ private:
|
||||
public:
|
||||
Rectangle() {}
|
||||
|
||||
const Point& getCenter() const { return m_Center; }
|
||||
float getCenterX() const { return m_Center.getX(); }
|
||||
float getCenterY() const { return m_Center.getY(); }
|
||||
const Point& GetCenter() const { return m_Center; }
|
||||
float GetCenterX() const { return m_Center.GetX(); }
|
||||
float GetCenterY() const { return m_Center.GetY(); }
|
||||
|
||||
float getWidth() const { return m_Width; }
|
||||
float getHeight() const { return m_Height; }
|
||||
float GetWidth() const { return m_Width; }
|
||||
float GetHeight() const { return m_Height; }
|
||||
|
||||
Point getTopLeft() const { return { m_Center.getX() - (m_Width / 2.0f), m_Center.getY() - (m_Height / 2.0f) }; }
|
||||
Point getBottomRight() const { return { m_Center.getX() + (m_Width / 2.0f), m_Center.getY() + (m_Height / 2.0f) }; }
|
||||
Point GetTopLeft() const { return { m_Center.GetX() - (m_Width / 2.0f), m_Center.GetY() - (m_Height / 2.0f) }; }
|
||||
Point GetBottomRight() const { return { m_Center.GetX() + (m_Width / 2.0f), m_Center.GetY() + (m_Height / 2.0f) }; }
|
||||
|
||||
void setCenter(const Point& center) { m_Center = center; }
|
||||
void setCenterX(float x) { m_Center.setX(x); }
|
||||
void setCenterY(float y) { m_Center.setY(y); }
|
||||
void SetCenter(const Point& center) { m_Center = center; }
|
||||
void SetCenterX(float x) { m_Center.SetX(x); }
|
||||
void SetCenterY(float y) { m_Center.SetY(y); }
|
||||
|
||||
void setSize(float width, float height) { setWidth(width); setHeight(height); }
|
||||
void setSize(Point size) { setSize(size.getX(), size.getY()); }
|
||||
Point getSize() { return { m_Width, m_Height }; }
|
||||
void SetSize(float width, float height) { SetWidth(width); SetHeight(height); }
|
||||
void SetSize(Point size) { SetSize(size.GetX(), size.GetY()); }
|
||||
Point GetSize() { return { m_Width, m_Height }; }
|
||||
|
||||
void setWidth(float width) { m_Width = width; }
|
||||
void setHeight(float height) { m_Height = height; }
|
||||
void SetWidth(float width) { m_Width = width; }
|
||||
void SetHeight(float height) { m_Height = height; }
|
||||
|
||||
bool collidesWith(const Point& point) const;
|
||||
bool collidesWith(const Rectangle& rect) const;
|
||||
bool collidesWith(const Circle& circle) const;
|
||||
bool CollidesWith(const Point& point) const;
|
||||
bool CollidesWith(const Rectangle& rect) const;
|
||||
bool CollidesWith(const Circle& circle) const;
|
||||
|
||||
// distance from the closest side of the rectangle
|
||||
float distance(const Circle& circle) const;
|
||||
float distanceSquared(const Circle& circle) const;
|
||||
float Distance(const Circle& circle) const;
|
||||
float DistanceSquared(const Circle& circle) const;
|
||||
};
|
||||
|
||||
class Circle {
|
||||
@@ -70,25 +70,25 @@ public:
|
||||
Circle(float x, float y, float radius) : m_Center(x, y), m_Radius(radius) {}
|
||||
Circle() : m_Radius(0) {}
|
||||
|
||||
const Point& getCenter() const { return m_Center; }
|
||||
float getCenterX() const { return m_Center.getX(); }
|
||||
float getCenterY() const { return m_Center.getY(); }
|
||||
const Point& GetCenter() const { return m_Center; }
|
||||
float GetCenterX() const { return m_Center.GetX(); }
|
||||
float GetCenterY() const { return m_Center.GetY(); }
|
||||
|
||||
float getRadius() const { return m_Radius; }
|
||||
float GetRadius() const { return m_Radius; }
|
||||
|
||||
void setCenter(const Point& center) { m_Center = center; }
|
||||
void setCenterX(float x) { m_Center.setX(x); }
|
||||
void setCenterY(float y) { m_Center.setY(y); }
|
||||
void SetCenter(const Point& center) { m_Center = center; }
|
||||
void SetCenterX(float x) { m_Center.SetX(x); }
|
||||
void SetCenterY(float y) { m_Center.SetY(y); }
|
||||
|
||||
void setRadius(float radius) { m_Radius = radius; }
|
||||
void SetRadius(float radius) { m_Radius = radius; }
|
||||
|
||||
bool collidesWith(const Point& point) const;
|
||||
bool collidesWith(const Rectangle& rect) const;
|
||||
bool collidesWith(const Circle& circle) const;
|
||||
bool CollidesWith(const Point& point) const;
|
||||
bool CollidesWith(const Rectangle& rect) const;
|
||||
bool CollidesWith(const Circle& circle) const;
|
||||
|
||||
// distance from the closest side of the rectangle
|
||||
float distance(const Rectangle& rect) const;
|
||||
float distanceSquared(const Rectangle& rect) const;
|
||||
float Distance(const Rectangle& rect) const;
|
||||
float DistanceSquared(const Rectangle& rect) const;
|
||||
};
|
||||
|
||||
} // namespace shape
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace td {
|
||||
namespace utils {
|
||||
|
||||
std::uint64_t getTime();
|
||||
std::uint64_t GetTime();
|
||||
|
||||
|
||||
typedef std::function<void()> TimerExecFunction;
|
||||
@@ -17,23 +17,23 @@ private:
|
||||
std::uint64_t m_Interval;
|
||||
TimerExecFunction m_Function;
|
||||
|
||||
std::uint64_t m_LastTime = getTime();
|
||||
std::uint64_t m_LastTime = GetTime();
|
||||
std::uint64_t m_InternalTime = 0;
|
||||
public:
|
||||
AutoTimer() : m_Interval(0), m_Function(nullptr) {}
|
||||
AutoTimer(std::uint64_t interval) : m_Interval(interval), m_Function(nullptr) {}
|
||||
AutoTimer(std::uint64_t interval, TimerExecFunction callback) : m_Interval(interval), m_Function(callback) {}
|
||||
|
||||
void update();
|
||||
void update(std::uint64_t delta);
|
||||
void Update();
|
||||
void Update(std::uint64_t delta);
|
||||
|
||||
void reset();
|
||||
void Reset();
|
||||
|
||||
void setInterval(std::uint64_t newInterval) { m_Interval = newInterval; }
|
||||
std::uint64_t getInterval() const { return m_Interval; }
|
||||
void SetInterval(std::uint64_t newInterval) { m_Interval = newInterval; }
|
||||
std::uint64_t GetInterval() const { return m_Interval; }
|
||||
|
||||
void setCallbackFunction(TimerExecFunction newCallback) { m_Function = newCallback; }
|
||||
TimerExecFunction getCallbackFunction() const { return m_Function; }
|
||||
void SetCallbackFunction(TimerExecFunction newCallback) { m_Function = newCallback; }
|
||||
TimerExecFunction GetCallbackFunction() const { return m_Function; }
|
||||
};
|
||||
|
||||
// utililty class to call function at regular period of time
|
||||
@@ -45,12 +45,12 @@ public:
|
||||
Timer() : m_Interval(0) {}
|
||||
Timer(std::uint64_t interval) : m_Interval(interval) {}
|
||||
|
||||
bool update(std::uint64_t delta);
|
||||
bool Update(std::uint64_t delta);
|
||||
|
||||
void reset();
|
||||
void Reset();
|
||||
|
||||
void setInterval(std::uint64_t newInterval) { m_Interval = newInterval; }
|
||||
std::uint64_t getInterval() const { return m_Interval; }
|
||||
void SetInterval(std::uint64_t newInterval) { m_Interval = newInterval; }
|
||||
std::uint64_t GetInterval() const { return m_Interval; }
|
||||
};
|
||||
|
||||
// utililty class to call function at regular period of time with a cooldown (used for towers and mobs )
|
||||
@@ -62,14 +62,14 @@ public:
|
||||
CooldownTimer() : m_Cooldown(0), m_CooldownTime(0) {}
|
||||
CooldownTimer(std::uint64_t cooldown) : m_Cooldown(0), m_CooldownTime(cooldown) {}
|
||||
|
||||
bool update(std::uint64_t delta);
|
||||
bool Update(std::uint64_t delta);
|
||||
|
||||
void applyCooldown();
|
||||
void ApplyCooldown();
|
||||
|
||||
void reset();
|
||||
void Reset();
|
||||
|
||||
void setCooldown(std::uint64_t newCooldown) { m_CooldownTime = newCooldown; }
|
||||
std::uint64_t getCooldown() const { return m_CooldownTime; }
|
||||
void SetCooldown(std::uint64_t newCooldown) { m_CooldownTime = newCooldown; }
|
||||
std::uint64_t GetCooldown() const { return m_CooldownTime; }
|
||||
};
|
||||
|
||||
} // namespace utils
|
||||
|
||||
@@ -13,17 +13,18 @@ public:
|
||||
TCPListener();
|
||||
~TCPListener();
|
||||
|
||||
bool listen(std::uint16_t port, int maxConnections);
|
||||
bool accept(TCPSocket& newSocket);
|
||||
bool Listen(std::uint16_t port, int maxConnections);
|
||||
bool Accept(TCPSocket& newSocket);
|
||||
|
||||
void destroy();
|
||||
bool close();
|
||||
bool setBlocking(bool blocking);
|
||||
void Destroy();
|
||||
bool Close();
|
||||
bool SetBlocking(bool blocking);
|
||||
|
||||
std::uint16_t getListeningPort() const {
|
||||
std::uint16_t GetListeningPort() const {
|
||||
return m_Port;
|
||||
}
|
||||
int getMaximumConnections() const {
|
||||
|
||||
int GetMaximumConnections() const {
|
||||
return m_MaxConnections;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace td {
|
||||
namespace protocol {
|
||||
namespace PacketFactory {
|
||||
|
||||
PacketPtr createPacket(PacketType type, DataBuffer& buffer);
|
||||
PacketPtr CreatePacket(PacketType type, DataBuffer& buffer);
|
||||
|
||||
}
|
||||
} // namespace protocol
|
||||
|
||||
@@ -74,8 +74,8 @@ public:
|
||||
|
||||
void WritePacketID(DataBuffer& data, bool packetID) const;
|
||||
|
||||
virtual PacketType getType() const = 0;
|
||||
std::uint8_t getID() const { return (std::uint8_t)getType(); }
|
||||
virtual PacketType GetType() const = 0;
|
||||
std::uint8_t GetID() const { return static_cast<std::uint8_t>(GetType()); }
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<Packet> PacketPtr;
|
||||
@@ -92,9 +92,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::uint64_t getAliveID() const { return m_AliveID; }
|
||||
std::uint64_t GetAliveID() const { return m_AliveID; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::KeepAlive; }
|
||||
virtual PacketType GetType() const { return PacketType::KeepAlive; }
|
||||
};
|
||||
|
||||
class PlayerLoginPacket : public Packet {
|
||||
@@ -109,9 +109,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
virtual PacketType getType() const { return PacketType::PlayerLogin; }
|
||||
virtual PacketType GetType() const { return PacketType::PlayerLogin; }
|
||||
|
||||
const std::string& getPlayerName() const { return m_PlayerName; }
|
||||
const std::string& GetPlayerName() const { return m_PlayerName; }
|
||||
};
|
||||
|
||||
class WorldBeginDataPacket : public Packet {
|
||||
@@ -128,22 +128,22 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
virtual PacketType getType() const { return PacketType::WorldBeginData; }
|
||||
virtual PacketType GetType() const { return PacketType::WorldBeginData; }
|
||||
|
||||
const game::TowerTileColorPalette& getTowerTilePalette() const { return m_Header.m_TowerPlacePalette; }
|
||||
const game::Color& getWalkableTileColor() const { return m_Header.m_WalkablePalette; }
|
||||
const std::vector<game::Color>& getDecorationPalette() const { return m_Header.m_DecorationPalette; }
|
||||
const game::Color& getBackgroundColor() const { return m_Header.m_Background; }
|
||||
const game::TowerTileColorPalette& GetTowerTilePalette() const { return m_Header.m_TowerPlacePalette; }
|
||||
const game::Color& GetWalkableTileColor() const { return m_Header.m_WalkablePalette; }
|
||||
const std::vector<game::Color>& GetDecorationPalette() const { return m_Header.m_DecorationPalette; }
|
||||
const game::Color& GetBackgroundColor() const { return m_Header.m_Background; }
|
||||
|
||||
const game::Spawn& getRedSpawn() const { return m_Header.m_RedSpawn; }
|
||||
const game::Spawn& getBlueSpawn() const { return m_Header.m_BlueSpawn; }
|
||||
const game::Spawn& GetRedSpawn() const { return m_Header.m_RedSpawn; }
|
||||
const game::Spawn& GetBlueSpawn() const { return m_Header.m_BlueSpawn; }
|
||||
|
||||
const game::SpawnColorPalette& getSpawnPalette() const { return m_Header.m_SpawnColorPalette; }
|
||||
const game::SpawnColorPalette& GetSpawnPalette() const { return m_Header.m_SpawnColorPalette; }
|
||||
|
||||
const game::TeamCastle& getRedCastle() const { return m_Header.m_RedCastle; }
|
||||
const game::TeamCastle& getBlueCastle() const { return m_Header.m_BlueCastle; }
|
||||
const game::TeamCastle& GetRedCastle() const { return m_Header.m_RedCastle; }
|
||||
const game::TeamCastle& GetBlueCastle() const { return m_Header.m_BlueCastle; }
|
||||
|
||||
const game::TilePalette getTilePalette() const { return m_Header.m_TilePalette; }
|
||||
const game::TilePalette GetTilePalette() const { return m_Header.m_TilePalette; }
|
||||
|
||||
void setWorldHeader(const WorldHeader& header) { m_Header = header; }
|
||||
};
|
||||
@@ -162,12 +162,12 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
virtual PacketType getType() const { return PacketType::WorldData; }
|
||||
virtual PacketType GetType() const { return PacketType::WorldData; }
|
||||
|
||||
const std::unordered_map<game::ChunkCoord, game::ChunkPtr>& getChunks() const { return m_WorldData.m_Chunks; }
|
||||
const std::unordered_map<game::ChunkCoord, game::ChunkPtr>& GetChunks() const { return m_WorldData.m_Chunks; }
|
||||
|
||||
DataBuffer SerializeCustom() const; // allow serialisation with invalid World member
|
||||
void setWorldData(const WorldData& worldData) { m_WorldData = worldData; }
|
||||
void SetWorldData(const WorldData& worldData) { m_WorldData = worldData; }
|
||||
};
|
||||
|
||||
class UpdateMoneyPacket : public Packet {
|
||||
@@ -178,13 +178,13 @@ public:
|
||||
UpdateMoneyPacket(std::uint32_t newAmount) : m_NewAmount(newAmount) {}
|
||||
virtual ~UpdateMoneyPacket() {}
|
||||
|
||||
std::uint32_t getGold() const { return m_NewAmount; }
|
||||
std::uint32_t GetGold() const { return m_NewAmount; }
|
||||
|
||||
virtual DataBuffer Serialize(bool packetID = true) const;
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdateMoney; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdateMoney; }
|
||||
};
|
||||
|
||||
class UpdateExpPacket : public Packet {
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdateEXP; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdateEXP; }
|
||||
};
|
||||
|
||||
class UpdateLobbyTimePacket : public Packet {
|
||||
@@ -214,9 +214,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::uint32_t getRemainingTime() const { return m_RemainingTime; }
|
||||
std::uint32_t GetRemainingTime() const { return m_RemainingTime; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdateLobbyTime; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdateLobbyTime; }
|
||||
};
|
||||
|
||||
class UpdateGameStatePacket : public Packet {
|
||||
@@ -231,9 +231,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::GameState getGameState() const { return m_GameState; }
|
||||
game::GameState GetGameState() const { return m_GameState; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdateGameState; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdateGameState; }
|
||||
};
|
||||
|
||||
struct PlayerInfo {
|
||||
@@ -253,9 +253,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
const std::map<std::uint8_t, PlayerInfo>& getPlayers() const { return m_Players; }
|
||||
const std::map<std::uint8_t, PlayerInfo>& GetPlayers() const { return m_Players; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::PlayerList; }
|
||||
virtual PacketType GetType() const { return PacketType::PlayerList; }
|
||||
};
|
||||
|
||||
class PlayerJoinPacket : public Packet {
|
||||
@@ -271,10 +271,10 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::uint8_t getPlayerID() const { return m_PlayerID; }
|
||||
const std::string& getPlayerName() const { return m_PlayerName; }
|
||||
std::uint8_t GetPlayerID() const { return m_PlayerID; }
|
||||
const std::string& GetPlayerName() const { return m_PlayerName; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::PlayerJoin; }
|
||||
virtual PacketType GetType() const { return PacketType::PlayerJoin; }
|
||||
};
|
||||
|
||||
class PlayerLeavePacket : public Packet {
|
||||
@@ -289,9 +289,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::uint8_t getPlayerID() const { return m_PlayerID; }
|
||||
std::uint8_t GetPlayerID() const { return m_PlayerID; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::PlayerLeave; }
|
||||
virtual PacketType GetType() const { return PacketType::PlayerLeave; }
|
||||
};
|
||||
|
||||
class ConnexionInfoPacket : public Packet {
|
||||
@@ -306,9 +306,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::uint8_t getConnectionID() const { return m_ConnectionID; }
|
||||
std::uint8_t GetConnectionID() const { return m_ConnectionID; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::ConnectionInfo; }
|
||||
virtual PacketType GetType() const { return PacketType::ConnectionInfo; }
|
||||
};
|
||||
|
||||
class SelectTeamPacket : public Packet {
|
||||
@@ -323,9 +323,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::TeamColor getSelectedTeam() const { return m_SelectedTeam; }
|
||||
game::TeamColor GetSelectedTeam() const { return m_SelectedTeam; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::SelectTeam; }
|
||||
virtual PacketType GetType() const { return PacketType::SelectTeam; }
|
||||
};
|
||||
|
||||
class UpdatePlayerTeamPacket : public Packet {
|
||||
@@ -341,10 +341,10 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::TeamColor getSelectedTeam() const { return m_SelectedTeam; }
|
||||
std::uint8_t getPlayerID() const { return m_PlayerID; }
|
||||
game::TeamColor GetSelectedTeam() const { return m_SelectedTeam; }
|
||||
std::uint8_t GetPlayerID() const { return m_PlayerID; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdatePlayerTeam; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdatePlayerTeam; }
|
||||
};
|
||||
|
||||
class DisconnectPacket : public Packet {
|
||||
@@ -359,9 +359,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
const std::string& getReason() const { return m_Reason; }
|
||||
const std::string& GetReason() const { return m_Reason; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::Disconnect; }
|
||||
virtual PacketType GetType() const { return PacketType::Disconnect; }
|
||||
};
|
||||
|
||||
class ServerTpsPacket : public Packet {
|
||||
@@ -377,10 +377,10 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
float getTPS() const { return m_TPS; }
|
||||
std::uint64_t getPacketSendTime() const { return m_PacketSendTime; }
|
||||
float GetTPS() const { return m_TPS; }
|
||||
std::uint64_t GetPacketSendTime() const { return m_PacketSendTime; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::ServerTps; }
|
||||
virtual PacketType GetType() const { return PacketType::ServerTps; }
|
||||
};
|
||||
|
||||
struct MobSend { // represents a mob send
|
||||
@@ -401,9 +401,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
const std::vector<MobSend>& getMobSends() const { return m_MobSends; }
|
||||
const std::vector<MobSend>& GetMobSends() const { return m_MobSends; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::SendMobs; }
|
||||
virtual PacketType GetType() const { return PacketType::SendMobs; }
|
||||
};
|
||||
|
||||
class SpawnMobPacket : public Packet {
|
||||
@@ -425,15 +425,15 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::MobID getMobID() const { return m_MobID; }
|
||||
game::MobType getMobType() const { return m_MobType; }
|
||||
game::MobLevel getMobLevel() const { return m_MobLevel; }
|
||||
game::Direction getMobDirection() const { return m_MobDirection; }
|
||||
game::PlayerID getSender() const { return m_Sender; }
|
||||
float getMobX() const { return m_MobX; }
|
||||
float getMobY() const { return m_MobY; }
|
||||
game::MobID GetMobID() const { return m_MobID; }
|
||||
game::MobType GetMobType() const { return m_MobType; }
|
||||
game::MobLevel GetMobLevel() const { return m_MobLevel; }
|
||||
game::Direction GetMobDirection() const { return m_MobDirection; }
|
||||
game::PlayerID GetSender() const { return m_Sender; }
|
||||
float GetMobX() const { return m_MobX; }
|
||||
float GetMobY() const { return m_MobY; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::SpawnMob; }
|
||||
virtual PacketType GetType() const { return PacketType::SpawnMob; }
|
||||
};
|
||||
|
||||
class PlaceTowerPacket : public Packet {
|
||||
@@ -450,11 +450,11 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::int32_t getTowerX() const { return m_TowerX; }
|
||||
std::int32_t getTowerY() const { return m_TowerY; }
|
||||
game::TowerType getTowerType() const { return m_TowerType; }
|
||||
std::int32_t GetTowerX() const { return m_TowerX; }
|
||||
std::int32_t GetTowerY() const { return m_TowerY; }
|
||||
game::TowerType GetTowerType() const { return m_TowerType; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::PlaceTower; }
|
||||
virtual PacketType GetType() const { return PacketType::PlaceTower; }
|
||||
};
|
||||
|
||||
class WorldAddTowerPacket : public Packet {
|
||||
@@ -473,13 +473,13 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::TowerID getTowerID() const { return m_TowerID; }
|
||||
std::int32_t getTowerX() const { return m_TowerX; }
|
||||
std::int32_t getTowerY() const { return m_TowerY; }
|
||||
game::TowerType getTowerType() const { return m_TowerType; }
|
||||
game::PlayerID getBuilder() const { return m_Builder; }
|
||||
game::TowerID GetTowerID() const { return m_TowerID; }
|
||||
std::int32_t GetTowerX() const { return m_TowerX; }
|
||||
std::int32_t GetTowerY() const { return m_TowerY; }
|
||||
game::TowerType GetTowerType() const { return m_TowerType; }
|
||||
game::PlayerID GetBuilder() const { return m_Builder; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::WorldAddTower; }
|
||||
virtual PacketType GetType() const { return PacketType::WorldAddTower; }
|
||||
};
|
||||
|
||||
class RemoveTowerPacket : public Packet {
|
||||
@@ -494,9 +494,9 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::TowerID getTowerID() const { return m_TowerID; }
|
||||
game::TowerID GetTowerID() const { return m_TowerID; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::RemoveTower; }
|
||||
virtual PacketType GetType() const { return PacketType::RemoveTower; }
|
||||
};
|
||||
|
||||
class UpgradeTowerPacket : public Packet {
|
||||
@@ -512,10 +512,10 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::TowerID getTowerID() const { return m_TowerID; }
|
||||
game::TowerLevel getTowerLevel() const { return m_TowerLevel; }
|
||||
game::TowerID GetTowerID() const { return m_TowerID; }
|
||||
game::TowerLevel GetTowerLevel() const { return m_TowerLevel; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpgradeTower; }
|
||||
virtual PacketType GetType() const { return PacketType::UpgradeTower; }
|
||||
};
|
||||
|
||||
class MobState {
|
||||
@@ -530,10 +530,10 @@ public:
|
||||
MobState(game::MobID id, const Point& position, float life, game::Direction direction) :
|
||||
m_MobID(id), m_MobPosition(position), m_MobLife(life), m_MobDirection(direction) {}
|
||||
|
||||
game::MobID getMobId() const { return m_MobID; }
|
||||
Point getMobPosition() const { return m_MobPosition; }
|
||||
float getMobLife() const { return m_MobLife; }
|
||||
game::Direction getMobDirection() const { return m_MobDirection; }
|
||||
game::MobID GetMobId() const { return m_MobID; }
|
||||
Point GetMobPosition() const { return m_MobPosition; }
|
||||
float GetMobLife() const { return m_MobLife; }
|
||||
game::Direction GetMobDirection() const { return m_MobDirection; }
|
||||
};
|
||||
|
||||
class UpdateMobStatesPacket : public Packet {
|
||||
@@ -549,9 +549,9 @@ public:
|
||||
|
||||
void addMobState(MobState mobState) { m_MobStates.push_back(mobState); }
|
||||
|
||||
const std::vector<MobState>& getMobStates() const { return m_MobStates; }
|
||||
const std::vector<MobState>& GetMobStates() const { return m_MobStates; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdateMobStates; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdateMobStates; }
|
||||
};
|
||||
|
||||
class UpdateCastleLifePacket : public Packet {
|
||||
@@ -567,10 +567,10 @@ public:
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
std::uint16_t getCastleLife() const { return m_CastleLife; }
|
||||
game::TeamColor getTeamColor() const { return m_Team; }
|
||||
std::uint16_t GetCastleLife() const { return m_CastleLife; }
|
||||
game::TeamColor GetTeamColor() const { return m_Team; }
|
||||
|
||||
virtual PacketType getType() const { return PacketType::UpdateCastleLife; }
|
||||
virtual PacketType GetType() const { return PacketType::UpdateCastleLife; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/*
|
||||
* Renderer.h
|
||||
*
|
||||
* Created on: 4 nov. 2020
|
||||
* Author: simon
|
||||
*/
|
||||
|
||||
#ifndef RENDER_RENDERER_H_
|
||||
#define RENDER_RENDERER_H_
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <memory>
|
||||
@@ -26,8 +18,8 @@ public:
|
||||
glm::vec2 positon;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<WorldShader> m_WorldShader;
|
||||
std::unique_ptr<EntityShader> m_EntityShader;
|
||||
std::unique_ptr<shader::WorldShader> m_WorldShader;
|
||||
std::unique_ptr<shader::EntityShader> m_EntityShader;
|
||||
|
||||
glm::vec3 m_BackgroundColor;
|
||||
|
||||
@@ -38,29 +30,27 @@ public:
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
||||
bool init();
|
||||
bool Init();
|
||||
|
||||
void prepare();
|
||||
void resize(const int width, const int height);
|
||||
void Prepare();
|
||||
void Resize(const int width, const int height);
|
||||
|
||||
void renderVAO(const GL::VertexArray& vao);
|
||||
void renderModel(const Model& model);
|
||||
void RenderVAO(const GL::VertexArray& vao);
|
||||
void RenderModel(const Model& model);
|
||||
|
||||
void setZoom(float zoom);
|
||||
void setCamMovement(const glm::vec2& mov);
|
||||
void setCamPos(const glm::vec2& newPos);
|
||||
void setIsometricView(bool isometric); // false = 2D true = Isometric
|
||||
void SetZoom(float zoom);
|
||||
void SetCamMovement(const glm::vec2& mov);
|
||||
void SetCamPos(const glm::vec2& newPos);
|
||||
void SetIsometricView(bool isometric); // false = 2D true = Isometric
|
||||
|
||||
void setBackgroundColor(const glm::vec3& color) { m_BackgroundColor = color; }
|
||||
void SetBackgroundColor(const glm::vec3& color) { m_BackgroundColor = color; }
|
||||
|
||||
glm::vec2 getCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
||||
glm::vec2 GetCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
||||
private:
|
||||
void updateIsometricView();
|
||||
void updateIsometricFade();
|
||||
void initShader();
|
||||
void UpdateIsometricView();
|
||||
void UpdateIsometricFade();
|
||||
void InitShaders();
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
} // namespace td
|
||||
|
||||
#endif /* RENDER_RENDERER_H_ */
|
||||
|
||||
@@ -25,13 +25,13 @@ private:
|
||||
public:
|
||||
VertexCache() : m_VertexCount(0) {}
|
||||
|
||||
void addData(std::uint64_t index, std::vector<float> positions, std::vector<float> colors);
|
||||
void removeData(std::uint64_t index);
|
||||
void clear();
|
||||
void updateVertexArray();
|
||||
void AddData(std::uint64_t index, std::vector<float> positions, std::vector<float> colors);
|
||||
void RemoveData(std::uint64_t index);
|
||||
void Clear();
|
||||
void UpdateVertexArray();
|
||||
|
||||
const GL::VertexArray& getVertexArray() const { return *m_VertexArray; }
|
||||
bool isEmpty() const { return m_VertexArray == nullptr; }
|
||||
const GL::VertexArray& GetVertexArray() const { return *m_VertexArray; }
|
||||
bool IsEmpty() const { return m_VertexArray == nullptr; }
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -46,41 +46,41 @@ public:
|
||||
WorldRenderer(game::World* world, client::ClientGame* client);
|
||||
~WorldRenderer();
|
||||
|
||||
void loadModels();
|
||||
void LoadModels();
|
||||
|
||||
static ImVec4 getImGuiTeamColor(game::TeamColor color);
|
||||
static ImVec4 GetImGuiTeamColor(game::TeamColor color);
|
||||
|
||||
void update();
|
||||
void render();
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
void setCamPos(float camX, float camY);
|
||||
void SetCamPos(float camX, float camY);
|
||||
|
||||
void moveCam(float relativeX, float relativeY, float aspectRatio);
|
||||
void changeZoom(float zoom);
|
||||
void MoveCam(float relativeX, float relativeY, float aspectRatio);
|
||||
void ChangeZoom(float zoom);
|
||||
|
||||
// WorldListener
|
||||
|
||||
virtual void OnTowerAdd(game::TowerPtr tower);
|
||||
virtual void OnTowerRemove(game::TowerPtr tower);
|
||||
private:
|
||||
void click();
|
||||
void renderWorld() const;
|
||||
void renderTowers() const;
|
||||
void renderMobs() const;
|
||||
void renderTileSelect() const;
|
||||
void renderPopups();
|
||||
void renderTowerUpgradePopup();
|
||||
void renderMobTooltip() const;
|
||||
void renderCastleTooltip() const;
|
||||
void detectClick();
|
||||
void detectMobHovering() const;
|
||||
void detectCastleHovering() const;
|
||||
void renderTooltips() const;
|
||||
void removeTower();
|
||||
glm::vec2 getCursorWorldPos() const;
|
||||
glm::vec2 getClickWorldPos() const;
|
||||
void Click();
|
||||
void RenderWorld() const;
|
||||
void RenderTowers() const;
|
||||
void RenderMobs() const;
|
||||
void RenderTileSelect() const;
|
||||
void RenderPopups();
|
||||
void RenderTowerUpgradePopup();
|
||||
void RenderMobTooltip() const;
|
||||
void RenderCastleTooltip() const;
|
||||
void DetectClick();
|
||||
void DetectMobHovering() const;
|
||||
void DetectCastleHovering() const;
|
||||
void RenderTooltips() const;
|
||||
void RemoveTower();
|
||||
glm::vec2 GetCursorWorldPos() const;
|
||||
glm::vec2 GetClickWorldPos() const;
|
||||
|
||||
void updateCursorPos();
|
||||
void UpdateCursorPos();
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -18,10 +18,10 @@ private:
|
||||
public:
|
||||
CastleTooltip(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
|
||||
void setCastle(const game::TeamCastle* castle) { m_Castle = castle; }
|
||||
bool isShown() { return m_Castle != nullptr; }
|
||||
void SetCastle(const game::TeamCastle* castle) { m_Castle = castle; }
|
||||
bool IsShown() { return m_Castle != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -13,7 +13,7 @@ private:
|
||||
public:
|
||||
FrameMenu(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -11,13 +11,13 @@ private:
|
||||
public:
|
||||
GameMenu(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
private:
|
||||
void showTPS();
|
||||
void showStats();
|
||||
void showPlayers();
|
||||
void showLobbyProgress();
|
||||
void showTeamSelection();
|
||||
void ShowTPS();
|
||||
void ShowStats();
|
||||
void ShowPlayers();
|
||||
void ShowLobbyProgress();
|
||||
void ShowTeamSelection();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -12,15 +12,15 @@ class GuiManager {
|
||||
private:
|
||||
std::vector<std::unique_ptr<GuiWidget>> m_Widgets;
|
||||
public:
|
||||
GuiManager(){}
|
||||
GuiManager() {}
|
||||
|
||||
void renderWidgets() {
|
||||
void RenderWidgets() {
|
||||
for (auto& widget : m_Widgets) {
|
||||
widget->render();
|
||||
widget->Render();
|
||||
}
|
||||
}
|
||||
|
||||
void addWidget(std::unique_ptr<GuiWidget>&& widget) {
|
||||
void AddWidget(std::unique_ptr<GuiWidget>&& widget) {
|
||||
m_Widgets.push_back(std::move(widget));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,9 +14,9 @@ protected:
|
||||
public:
|
||||
GuiWidget(client::Client* client) : m_Client(client) {}
|
||||
|
||||
client::Client* getClient() { return m_Client; }
|
||||
client::Client* GetClient() { return m_Client; }
|
||||
|
||||
virtual void render() = 0;
|
||||
virtual void Render() = 0;
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -26,11 +26,11 @@ public:
|
||||
MainMenu(client::Client* client);
|
||||
~MainMenu();
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
|
||||
const server::Server* getServer() const { return m_Server.get(); }
|
||||
const server::Server* GetServer() const { return m_Server.get(); }
|
||||
private:
|
||||
bool startServer();
|
||||
bool StartServer();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -18,10 +18,10 @@ private:
|
||||
public:
|
||||
MobTooltip(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
|
||||
void setMob(const game::Mob* mob) { m_Mob = mob; }
|
||||
bool isShown() { return m_Mob != nullptr; }
|
||||
void SetMob(const game::Mob* mob) { m_Mob = mob; }
|
||||
bool IsShown() { return m_Mob != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -17,9 +17,9 @@ private:
|
||||
public:
|
||||
SummonMenu(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
private:
|
||||
void setSummonMax(int valueIndex);
|
||||
void SetSummonMax(int valueIndex);
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -37,12 +37,12 @@ public:
|
||||
TowerGui(SDL_Window* wndow, SDL_GLContext glContext, td::render::Renderer* renderer);
|
||||
~TowerGui();
|
||||
|
||||
void render();
|
||||
void Render();
|
||||
private:
|
||||
void initWidgets();
|
||||
void tick();
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
void InitWidgets();
|
||||
void Tick();
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
||||
@@ -13,9 +13,9 @@ private:
|
||||
public:
|
||||
TowerPlacePopup(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
|
||||
void setClickPos(const glm::vec2& worldPos);
|
||||
void SetClickPos(const glm::vec2& worldPos);
|
||||
private:
|
||||
static constexpr float m_TowerPopupTileWidth = 200.0f;
|
||||
static constexpr float m_TowerPopupTileHeight = 200.0f;
|
||||
|
||||
@@ -18,11 +18,11 @@ private:
|
||||
public:
|
||||
UpdateMenu(client::Client* client);
|
||||
|
||||
virtual void render();
|
||||
virtual void Render();
|
||||
private:
|
||||
void checkUpdates();
|
||||
bool isUpdateChecked();
|
||||
void renderErrorPopup();
|
||||
void CheckUpdates();
|
||||
bool IsUpdateChecked();
|
||||
void RenderErrorPopup();
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -28,6 +28,7 @@ private:
|
||||
std::vector<VertexAttribPointer> m_VertexAttribs;
|
||||
public:
|
||||
REMOVE_COPY(VertexBuffer);
|
||||
|
||||
VertexBuffer(VertexBuffer&& other) {
|
||||
m_VertexAttribs = std::move(other.m_VertexAttribs);
|
||||
m_ID = other.m_ID;
|
||||
@@ -35,12 +36,14 @@ public:
|
||||
other.m_ID = 0;
|
||||
other.m_DataStride = 0;
|
||||
}
|
||||
|
||||
VertexBuffer(const std::vector<float>& data, unsigned int stride);
|
||||
~VertexBuffer();
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
void addVertexAttribPointer(unsigned int index, unsigned int coordinateSize, unsigned int offset);
|
||||
void bindVertexAttribs() const;
|
||||
|
||||
void Bind() const;
|
||||
void Unbind() const;
|
||||
void AddVertexAttribPointer(unsigned int index, unsigned int coordinateSize, unsigned int offset);
|
||||
void BindVertexAttribs() const;
|
||||
};
|
||||
|
||||
class VertexArray {
|
||||
@@ -49,6 +52,7 @@ private:
|
||||
std::vector<VertexBuffer> m_VertexBuffers; //use to destroy vbos when become unused
|
||||
public:
|
||||
REMOVE_COPY(VertexArray);
|
||||
|
||||
VertexArray(VertexArray&& other) {
|
||||
m_ID = other.m_ID;
|
||||
m_VertexCount = other.m_VertexCount;
|
||||
@@ -56,12 +60,14 @@ public:
|
||||
other.m_VertexCount = 0;
|
||||
other.m_ID = 0;
|
||||
}
|
||||
|
||||
VertexArray(unsigned int vertexCount);
|
||||
~VertexArray();
|
||||
unsigned int getVertexCount() const { return m_VertexCount; }
|
||||
void bindVertexBuffer(VertexBuffer& vbo);
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
unsigned int GetVertexCount() const { return m_VertexCount; }
|
||||
void BindVertexBuffer(VertexBuffer& vbo);
|
||||
void Bind() const;
|
||||
void Unbind() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace TextureLoader {
|
||||
|
||||
unsigned int loadGLTexture(const char* fileName);
|
||||
unsigned int LoadGLTexture(const char* fileName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ struct RenderData {
|
||||
std::vector<float> colors;
|
||||
};
|
||||
|
||||
GL::VertexArray loadMobModel();
|
||||
GL::VertexArray loadWorldModel(const td::game::World* world);
|
||||
GL::VertexArray loadTileSelectModel();
|
||||
RenderData loadTowerModel(game::TowerPtr tower);
|
||||
GL::VertexArray LoadMobModel();
|
||||
GL::VertexArray LoadWorldModel(const td::game::World* world);
|
||||
GL::VertexArray LoadTileSelectModel();
|
||||
RenderData LoadTowerModel(game::TowerPtr tower);
|
||||
|
||||
} // namespace WorldLoader
|
||||
|
||||
|
||||
@@ -2,17 +2,29 @@
|
||||
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
namespace td {
|
||||
namespace shader {
|
||||
|
||||
class EntityShader : public ShaderProgram {
|
||||
|
||||
private:
|
||||
unsigned int location_cam = 0, location_zoom = 0, location_aspect_ratio = 0, location_translation = 0, location_viewtype = 0;
|
||||
unsigned int m_LocationCam = 0;
|
||||
unsigned int m_LocationZoom = 0;
|
||||
unsigned int m_LocationAspectRatio = 0;
|
||||
unsigned int m_LocationTranslation = 0;
|
||||
unsigned int m_LocationViewtype = 0;
|
||||
protected:
|
||||
void getAllUniformLocation();
|
||||
virtual void GetAllUniformLocation();
|
||||
public:
|
||||
EntityShader();
|
||||
void loadShader();
|
||||
void setCamPos(const glm::vec2& camPos);
|
||||
void setZoom(float zoom);
|
||||
void setAspectRatio(float aspectRatio);
|
||||
void setModelPos(const glm::vec2& modelPos);
|
||||
void setIsometricView(float isometric);
|
||||
|
||||
void LoadShader();
|
||||
void SetCamPos(const glm::vec2& camPos);
|
||||
void SetZoom(float zoom);
|
||||
void SetAspectRatio(float aspectRatio);
|
||||
void SetModelPos(const glm::vec2& modelPos);
|
||||
void SetIsometricView(float isometric);
|
||||
};
|
||||
|
||||
} // namespace shader
|
||||
} // namespace td
|
||||
|
||||
@@ -1,46 +1,44 @@
|
||||
/*
|
||||
* ShaderProgram.h
|
||||
*
|
||||
* Created on: 31 janv. 2020
|
||||
* Author: simon
|
||||
*/
|
||||
|
||||
#ifndef RENDER_SHADERS_SHADERPROGRAM_H_
|
||||
#define RENDER_SHADERS_SHADERPROGRAM_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <glm/glm.hpp>
|
||||
#include "render/GL.h"
|
||||
|
||||
namespace td {
|
||||
namespace shader {
|
||||
|
||||
class ShaderProgram {
|
||||
public:
|
||||
ShaderProgram();
|
||||
virtual ~ShaderProgram();
|
||||
void start() const;
|
||||
void stop() const;
|
||||
void loadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
|
||||
void loadProgram(const std::string& vertexSource, const std::string& fragmentSource);
|
||||
|
||||
void Start() const;
|
||||
void Stop() const;
|
||||
|
||||
void LoadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
|
||||
void LoadProgram(const std::string& vertexSource, const std::string& fragmentSource);
|
||||
|
||||
protected:
|
||||
virtual void getAllUniformLocation() = 0;
|
||||
int getUniformLocation(const std::string& uniformName) const;
|
||||
virtual void GetAllUniformLocation() = 0;
|
||||
int GetUniformLocation(const std::string& uniformName) const;
|
||||
|
||||
void loadFloat(unsigned int location, float value) const;
|
||||
void loadInt(unsigned int location, int value) const;
|
||||
void loadVector(unsigned int location, const glm::vec2& vector) const;
|
||||
void loadVector(unsigned int location, const glm::vec3& vector) const;
|
||||
void loadVector(unsigned int location, const glm::vec4& vector) const;
|
||||
void loadBoolean(unsigned int location, bool value) const;
|
||||
void loadMatrix(unsigned int location, const glm::mat4& matrix) const;
|
||||
void cleanUp() const;
|
||||
void LoadFloat(unsigned int location, float value) const;
|
||||
void LoadInt(unsigned int location, int value) const;
|
||||
void LoadVector(unsigned int location, const glm::vec2& vector) const;
|
||||
void LoadVector(unsigned int location, const glm::vec3& vector) const;
|
||||
void LoadVector(unsigned int location, const glm::vec4& vector) const;
|
||||
void LoadBoolean(unsigned int location, bool value) const;
|
||||
void LoadMatrix(unsigned int location, const glm::mat4& matrix) const;
|
||||
void CleanUp() const;
|
||||
|
||||
private:
|
||||
unsigned int m_ProgramID;
|
||||
unsigned int m_VertexShaderID;
|
||||
unsigned int m_FragmentShaderID;
|
||||
|
||||
unsigned int loadShaderFromFile(const std::string& file, GLenum type);
|
||||
unsigned int loadShader(const std::string& source, GLenum type);
|
||||
unsigned int LoadShaderFromFile(const std::string& file, GLenum type);
|
||||
unsigned int LoadShader(const std::string& source, GLenum type);
|
||||
};
|
||||
|
||||
#endif /* RENDER_SHADERS_SHADERPROGRAM_H_ */
|
||||
} // namespace shader
|
||||
} // namespace td
|
||||
@@ -1,27 +1,23 @@
|
||||
/*
|
||||
* GameShader.h
|
||||
*
|
||||
* Created on: 4 nov. 2020
|
||||
* Author: simon
|
||||
*/
|
||||
|
||||
#ifndef RENDER_SHADERS_GAMESHADER_H_
|
||||
#define RENDER_SHADERS_GAMESHADER_H_
|
||||
#pragma once
|
||||
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
namespace td {
|
||||
namespace shader {
|
||||
|
||||
class WorldShader : public ShaderProgram {
|
||||
private:
|
||||
unsigned int location_cam = 0, location_zoom = 0, location_aspect_ratio = 0, location_viewtype = 0;
|
||||
unsigned int m_LocationCam = 0, m_LocationZoom = 0, m_LocationAspectRatio = 0, m_LocationViewtype = 0;
|
||||
protected:
|
||||
void getAllUniformLocation();
|
||||
void GetAllUniformLocation();
|
||||
public:
|
||||
WorldShader();
|
||||
void loadShader();
|
||||
void setCamPos(const glm::vec2& camPos);
|
||||
void setZoom(float zoom);
|
||||
void setAspectRatio(float aspectRatio);
|
||||
void setIsometricView(float isometric);
|
||||
void LoadShader();
|
||||
void SetCamPos(const glm::vec2& camPos);
|
||||
void SetZoom(float zoom);
|
||||
void SetAspectRatio(float aspectRatio);
|
||||
void SetIsometricView(float isometric);
|
||||
};
|
||||
|
||||
#endif /* RENDER_SHADERS_GAMESHADER_H_ */
|
||||
} // namespace shader
|
||||
} // namespace td
|
||||
|
||||
@@ -18,26 +18,26 @@ private:
|
||||
public:
|
||||
Updater() : m_Progress(0), m_DownloadComplete(false), m_FileWrited(false), m_CancelDownload(false) {}
|
||||
|
||||
bool checkUpdate();
|
||||
void downloadUpdate();
|
||||
void cancelDownload() { m_CancelDownload = true; m_Progress = 0.0f; m_DownloadComplete = false; }
|
||||
bool writeFile();
|
||||
bool CheckUpdate();
|
||||
void DownloadUpdate();
|
||||
void CancelDownload() { m_CancelDownload = true; m_Progress = 0.0f; m_DownloadComplete = false; }
|
||||
bool WriteFile();
|
||||
|
||||
void clearCache() { m_FileBuffer.Clear(); }
|
||||
void ClearCache() { m_FileBuffer.Clear(); }
|
||||
|
||||
float getDownloadProgress() { return m_Progress; }
|
||||
bool isDownloadComplete() { return m_DownloadComplete; }
|
||||
bool isFileWrited() { return m_FileWrited; }
|
||||
float GetDownloadProgress() { return m_Progress; }
|
||||
bool IsDownloadComplete() { return m_DownloadComplete; }
|
||||
bool IsFileWrited() { return m_FileWrited; }
|
||||
|
||||
static std::string getLocalFilePath();
|
||||
static void removeOldFile();
|
||||
static std::string GetLocalFilePath();
|
||||
static void RemoveOldFile();
|
||||
|
||||
static std::string getCurrentVersion() { return TD_VERSION; }
|
||||
std::string getLastVersion() { return m_LastVersion; }
|
||||
static std::string GetCurrentVersion() { return TD_VERSION; }
|
||||
std::string GetLastVersion() { return m_LastVersion; }
|
||||
|
||||
bool canUpdate();
|
||||
bool CanUpdate();
|
||||
private:
|
||||
std::string getDownloadFileURL();
|
||||
std::string GetDownloadFileURL();
|
||||
};
|
||||
|
||||
} // namespace utils
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
|
||||
namespace Display {
|
||||
|
||||
bool create();
|
||||
void render();
|
||||
void update();
|
||||
void destroy();
|
||||
void pollEvents();
|
||||
bool Create();
|
||||
void Render();
|
||||
void Update();
|
||||
void Destroy();
|
||||
void PollEvents();
|
||||
|
||||
bool isCloseRequested();
|
||||
bool IsCloseRequested();
|
||||
|
||||
bool isMouseDown(int button);
|
||||
bool IsMouseDown(int button);
|
||||
|
||||
float getAspectRatio();
|
||||
int getWindowWidth();
|
||||
int getWindowHeight();
|
||||
float GetAspectRatio();
|
||||
int GetWindowWidth();
|
||||
int GetWindowHeight();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user