/
CheckpointChecker.cpp
57 lines (46 loc) · 1.23 KB
/
CheckpointChecker.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
#include "precompiled.h"
#include "CheckpointChecker.h"
#include "Game.h"
#include "Unit.h"
#include "UnitList.h"
#include "../util/Debug_MemoryManager.h"
namespace game
{
bool CheckpointChecker::isEveryUnitNearCheckpoint(Game *game, float range,
int player)
{
LinkedList *ulist = game->units->getOwnedUnits(player);
LinkedListIterator iter = LinkedListIterator(ulist);
while (iter.iterateAvailable())
{
Unit *u = (Unit *)iter.iterateNext();
if (u->isActive() && !u->isDestroyed())
{
if (!game->checkpoints->isNearCheckpoint(0, u->getPosition(), range))
return false;
}
}
return true;
}
bool CheckpointChecker::isAnyUnitNearCheckpoint(Game *game, float range,
int player)
{
LinkedList *ulist = game->units->getOwnedUnits(player);
LinkedListIterator iter = LinkedListIterator(ulist);
while (iter.iterateAvailable())
{
Unit *u = (Unit *)iter.iterateNext();
if (u->isActive() && !u->isDestroyed())
{
if (game->checkpoints->isNearCheckpoint(0, u->getPosition(), range))
return true;
}
}
return false;
}
bool CheckpointChecker::isPositionNearCheckpoint(Game *game, float range,
VC3 &position)
{
return game->checkpoints->isNearCheckpoint(0, position, range);
}
}