summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/act-iter.h
blob: a9a69b7405b6ed51079950e906ae41fc0752f219 (plain) (blame)
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
/**
 * @file
 * @brief Provide a way to iterator over all actors, subject to a few common restrictions.
**/

#ifndef ACT_ITER_H
#define ACT_ITER_H

class actor_near_iterator
{
public:
    actor_near_iterator(coord_def c, los_type los = LOS_DEFAULT);
    actor_near_iterator(const actor* a, los_type los = LOS_DEFAULT);

    operator bool() const;
    actor* operator*() const;
    actor* operator->() const;
    actor_near_iterator& operator++();
    actor_near_iterator operator++(int);

protected:
    const coord_def center;
    los_type _los;
    const actor* viewer;
    int i;

    bool valid(const actor* a) const;
    void advance();
};

class monster_near_iterator
{
public:
    monster_near_iterator(coord_def c, los_type los = LOS_DEFAULT);
    monster_near_iterator(const actor* a, los_type los = LOS_DEFAULT);

    operator bool() const;
    monster* operator*() const;
    monster* operator->() const;
    monster_near_iterator& operator++();
    monster_near_iterator operator++(int);

protected:
    const coord_def center;
    los_type _los;
    const actor* viewer;
    int i;

    bool valid(const monster* a) const;
    void advance();
};

class monster_iterator
{
public:
    monster_iterator();

    operator bool() const;
    monster* operator*() const;
    monster* operator->() const;
    monster_iterator& operator++();
    monster_iterator operator++(int);

protected:
    int i;
    void advance();
};

#endif