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