-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject.cpp
57 lines (44 loc) · 980 Bytes
/
GameObject.cpp
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
#include "GameObject.h"
GameObject::GameObject()
{
behaviourCount = 0;
}
void GameObject::AddBehaviour(ObjectBehaviour& newBehaviour)
{
newBehaviour.SetTransform(&transform);
behaviours.insert(&newBehaviour);
behaviourCount++;
}
int GameObject::GetBehaviourCount()
{
return behaviourCount;
}
void GameObject::StartObject()
{
std::unordered_set<ObjectBehaviour*>::iterator start;
for (start = behaviours.begin(); start != behaviours.end(); start++)
{
start._Ptr->_Myval->Start();
}
}
void GameObject::UpdateObject()
{
std::unordered_set<ObjectBehaviour*>::iterator start;
for (start = behaviours.begin(); start != behaviours.end(); start++)
{
start._Ptr->_Myval->Update();
}
}
void GameObject::DestroyObject()
{
std::unordered_set<ObjectBehaviour*>::iterator start;
for (start = behaviours.begin(); start != behaviours.end(); start++)
{
start._Ptr->_Myval->Destroy();
}
}
GameObject::~GameObject()
{
behaviourCount = 0;
behaviours.clear();
}