forked from yanntm/YoBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitData.h
More file actions
71 lines (56 loc) · 1.48 KB
/
UnitData.h
File metadata and controls
71 lines (56 loc) · 1.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
#pragma once
#include "Common.h"
struct UnitInfo
{
// we need to store all of this data because if the unit is not visible, we
// can't reference it from the unit pointer
UnitTag tag;
float lastHealth;
float lastShields;
int player;
const sc2::Unit * unit;
sc2::Point3D lastPosition;
sc2::UnitTypeID type;
float progress;
UnitInfo()
: tag(0)
, lastHealth(0)
, player(-1)
, lastPosition(sc2::Point3D(0, 0, 0))
, type(0)
, progress(1.0)
{
}
bool operator == (sc2::Unit * unit) const
{
return tag == unit->tag;
}
bool operator == (const UnitInfo & rhs) const
{
return (tag == rhs.tag);
}
bool operator < (const UnitInfo & rhs) const
{
return (tag < rhs.tag);
}
};
typedef std::vector<UnitInfo> UnitInfoVector;
class UnitData
{
std::map<const sc2::Unit *, UnitInfo> m_unitMap;
std::vector<int> m_numDeadUnits;
std::vector<int> m_numUnits;
int m_mineralsLost;
int m_gasLost;
bool badUnitInfo(const UnitInfo & ui) const;
public:
UnitData();
void updateUnit(const sc2::Unit * unit);
void killUnit(const sc2::Unit * unit);
void removeBadUnits();
int getGasLost() const;
int getMineralsLost() const;
int getNumUnits(sc2::UnitTypeID t) const;
int getNumDeadUnits(sc2::UnitTypeID t) const;
const std::map<const sc2::Unit *, UnitInfo> & getUnitInfoMap() const;
};