-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntityOOP.hpp
72 lines (67 loc) · 1.48 KB
/
EntityOOP.hpp
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
#pragma once
class Entity {
Transform transform;
bool hasT = false;
Collider collider;
bool hasC = false;
SolidBody solidBody;
bool hasSB = false;
Sprite sprite;
bool hasS = false;
static std::vector< Entity* > allEntities;
public:
Entity();
void setTransform( Transform transform ) {
transform.setEntity( this );
this->transform = transform;
hasT = true;
}
void setCollider( Collider collider ) {
collider.setEntity( this );
this->collider = collider;
hasC = true;
}
void setSolidBody( SolidBody solidBody ) {
solidBody.setEntity( this );
this->solidBody = solidBody;
hasSB = true;
}
void setSprite( Sprite sprite ) {
sprite.setEntity( this );
this->sprite = sprite;
hasS = true;
}
inline bool hasTransform() {
return hasT;
}
inline bool hasCollider() {
return hasC;
}
inline bool hasSolidBody() {
return hasSB;
}
inline bool hasSprite() {
return hasS;
}
Transform& getTransform() {
ASSERT( hasT, "" );
return transform;
}
Collider& getCollider() {
ASSERT( hasC, "" );
return collider;
}
SolidBody& getSolidBody() {
ASSERT( hasSB, "" );
return solidBody;
}
Sprite& getSprite() {
ASSERT( hasS, "" );
return sprite;
}
/*void removeTransform() { transform(); }
void removeCollider() { collider = {}; }
void removeSolidBody() { solidBody = {}; }
void removeSprite() { sprite = {}; }*/
static std::vector< Entity* > getAllEntities();
};