Repository navigation
Expand file tree
/
Copy pathBuilding.h
More file actions
98 lines (73 loc) · 2.48 KB
/
Copy pathBuilding.h
File metadata and controls
98 lines (73 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once
#include <glm/glm.hpp>
#include <GL/glew.h>
#include <glm/gtc/matrix_transform.hpp>
#include <string>
class Mesh;
enum class UnitType;
enum class BuildingType {
TOWN_CENTER,
BARRACKS,
SHOOTING_RANGE
};
struct ResourceCost {
int wood;
int rock;
};
struct BuildingStats {
float maxHealth;
float buildTime;
ResourceCost buildCost;
ResourceCost repairCost;
};
class Building {
public:
// Constructor
Building(BuildingType type, const glm::vec3& pos, int teamID, const std::string& meshPath = "");
~Building();
void draw(const glm::mat4& view, const glm::mat4& projection,
GLuint shaderProgram, float passedAlpha,
glm::vec3 tint = glm::vec3(0.8f, 0.8f, 0.8f));
float getBuildingHeight() const;
glm::vec3 getBasePosition() const { return basePosition_; }
// Getters
BuildingType getType() const { return type_; }
glm::vec3 getPosition() const { return position_; }
Mesh* getMesh() const { return mesh_; }
// Stats
float getCurrentHealth() const { return currentHealth_; }
float getMaxHealth() const { return stats_.maxHealth; }
float getBuildProgress() const { return buildProgress_; }
bool isConstructed() const { return isConstructed_; }
const BuildingStats& getStats() const { return stats_; }
// Team Logic
int getTeam() const { return teamID_; }
bool isDead() const { return currentHealth_ <= 0; }
UnitType updateAutoSpawning(float dt);
// Cap Logic
int getSpawnedCount() const { return spawnedCount_; }
bool isCapReached() const { return spawnedCount_ >= MAX_UNIT_CAP; }
void setPosition(const glm::vec3& pos);
void updateConstruction(float deltaTime);
void takeDamage(float damage);
void repair(float amount);
ResourceCost getBuildCost() const { return stats_.buildCost; }
ResourceCost getRepairCost() const { return stats_.repairCost; }
static ResourceCost getStaticCost(BuildingType type);
private:
BuildingType type_;
glm::vec3 position_;
Mesh* mesh_;
int teamID_;
BuildingStats stats_;
float currentHealth_;
float buildProgress_;
bool isConstructed_;
glm::vec3 basePosition_;
float buildingHeight_;
float autoSpawnTimer_ = 0.0f;
const float SPAWN_INTERVAL = 2.0f; // Seconds between units
int spawnedCount_ = 0;
const int MAX_UNIT_CAP = 10;
void initializeStats();
};