GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/being/actor.h Lines: 0 12 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2010  The Mana Developers
4
 *  Copyright (C) 2011-2017  The ManaPlus Developers
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#ifndef BEING_ACTOR_H
23
#define BEING_ACTOR_H
24
25
#include "vector.h"
26
27
#include "utils/cast.h"
28
29
#include <list>
30
31
#include "localconsts.h"
32
33
class Actor;
34
class Graphics;
35
class Map;
36
37
typedef std::list<Actor*> Actors;
38
typedef Actors::const_iterator ActorsCIter;
39
40
class Actor notfinal
41
{
42
    public:
43
        A_DELETE_COPY(Actor)
44
45
        virtual ~Actor();
46
47
        /**
48
         * Draws the Actor to the given graphics context.
49
         *
50
         * Note: this function could be simplified if the graphics context
51
         * would support setting a translation offset. It already does this
52
         * partly with the clipping rectangle support.
53
         */
54
        virtual void draw(Graphics *const graphics,
55
                          const int offsetX,
56
                          const int offsetY) const A_NONNULL(2) = 0;
57
58
        /**
59
         * Returns the horizontal size of the actors graphical representation
60
         * in pixels or 0 when it is undefined.
61
         */
62
        virtual int getWidth() const A_WARN_UNUSED
63
        { return 0; }
64
65
        /**
66
         * Returns the vertical size of the actors graphical representation
67
         * in pixels or 0 when it is undefined.
68
         */
69
        virtual int getHeight() const A_WARN_UNUSED
70
        { return 0; }
71
72
        /**
73
         * Returns the pixel position of this actor.
74
         */
75
        const Vector &getPixelPositionF() const noexcept2 A_WARN_UNUSED
76
        { return mPos; }
77
78
        /**
79
         * Sets the pixel position of this actor.
80
         */
81
        virtual void setPixelPositionF(const Vector &restrict pos) restrict2;
82
83
        /**
84
         * Returns the pixels X coordinate of the actor.
85
         */
86
        int getPixelX() const noexcept2 A_WARN_UNUSED
87
        { return CAST_S32(mPos.x); }
88
89
        /**
90
         * Returns the pixel Y coordinate of the actor.
91
         */
92
        virtual int getPixelY() const A_WARN_UNUSED
93
        { return CAST_S32(mPos.y); }
94
95
        /**
96
         * Returns the pixel Y coordinate of the actor for sorting only.
97
         */
98
        virtual int getSortPixelY() const A_WARN_UNUSED
99
        { return CAST_S32(mPos.y) - mYDiff; }
100
101
        /**
102
         * Returns the x coordinate in tiles of the actor.
103
         */
104
        virtual int getTileX() const A_WARN_UNUSED;
105
106
        /**
107
         * Returns the y coordinate in tiles of the actor.
108
         */
109
        virtual int getTileY() const A_WARN_UNUSED;
110
111
        /**
112
         * Returns the number of Image layers used to draw the actor.
113
         */
114
        virtual int getNumberOfLayers() const A_WARN_UNUSED
115
        { return 0; }
116
117
        /**
118
         * Returns the current alpha value used to draw the actor.
119
         */
120
        virtual float getAlpha() const A_WARN_UNUSED = 0;
121
122
        /**
123
         * Sets the alpha value used to draw the actor.
124
         */
125
        virtual void setAlpha(float alpha) = 0;
126
127
        virtual void setMap(Map *const map);
128
129
        const Map* getMap() const noexcept2 A_WARN_UNUSED
130
        { return mMap; }
131
132
        int mPixelX;
133
        int mPixelY;
134
135
    protected:
136
        Actor();
137
138
        Map *mMap;
139
        Vector mPos;                /**< Position in pixels relative to map. */
140
        int mYDiff;
141
142
    private:
143
        Actors::iterator mMapActor;
144
};
145
146
#endif  // BEING_ACTOR_H