-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAbstractGunDecorator.cpp
More file actions
50 lines (43 loc) · 942 Bytes
/
AbstractGunDecorator.cpp
File metadata and controls
50 lines (43 loc) · 942 Bytes
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
#include "AbstractGunDecorator.h"
#include <iostream>
AbstractGunDecorator::AbstractGunDecorator(AbstractGun *gun):AbstractGun(*gun),gun(gun){}
void AbstractGunDecorator::Update()
{
if (destroyThis && gun->WillDestroy())
{
gun->Update();
delete this;
return;
}
if (destroyThis)
std::cerr << "Gun decorator will be destroyed before gun\n";
if (gun->WillDestroy())
{
Detonate();
return;
}
gun->Update();
}
void AbstractGunDecorator::Detonate()
{
destroyThis = true;
gun->Detonate();
}
void AbstractGunDecorator::Action(Character * character)
{
gun->Action(character);
if (gun->WillDestroy())
Detonate();
}
int AbstractGunDecorator::GetX() const
{
return gun->GetX();
}
int AbstractGunDecorator::GetY() const
{
return gun->GetY();
}
WeaponProperties &AbstractGunDecorator::GetProperties()
{
return gun->GetProperties();
}