ManaPlus
actor.h
Go to the documentation of this file.
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 
42 {
43  public:
45 
46  virtual ~Actor();
47 
55  virtual void draw(Graphics *const graphics,
56  const int offsetX,
57  const int offsetY) const A_NONNULL(2) = 0;
58 
63  virtual int getWidth() const A_WARN_UNUSED
64  { return 0; }
65 
70  virtual int getHeight() const A_WARN_UNUSED
71  { return 0; }
72 
77  { return mPos; }
78 
82  virtual void setPixelPositionF(const Vector &restrict pos) restrict2;
83 
88  { return CAST_S32(mPos.x); }
89 
93  virtual int getPixelY() const A_WARN_UNUSED
94  { return CAST_S32(mPos.y); }
95 
99  virtual int getSortPixelY() const A_WARN_UNUSED
100  { return CAST_S32(mPos.y) - mYDiff; }
101 
105  virtual int getTileX() const A_WARN_UNUSED;
106 
110  virtual int getTileY() const A_WARN_UNUSED;
111 
115  virtual int getNumberOfLayers() const A_WARN_UNUSED
116  { return 0; }
117 
121  virtual float getAlpha() const A_WARN_UNUSED = 0;
122 
126  virtual void setAlpha(float alpha) = 0;
127 
128  virtual void setMap(Map *const map);
129 
131  { return mMap; }
132 
133  int mPixelX;
134  int mPixelY;
135 
136  protected:
137  Actor();
138 
141  int mYDiff;
142 
143  private:
144  Actors::iterator mMapActor;
145 };
146 
147 #endif // BEING_ACTOR_H
Actors::const_iterator ActorsCIter
Definition: actor.h:39
std::list< Actor * > Actors
Definition: actor.h:36
#define CAST_S32
Definition: cast.h:30
Definition: actor.h:42
virtual int getSortPixelY() const
Definition: actor.h:99
virtual int getPixelY() const
Definition: actor.h:93
virtual int getWidth() const
Definition: actor.h:63
int getPixelX() const
Definition: actor.h:87
Actor()
Definition: actor.cpp:29
virtual int getTileY() const
Definition: actor.cpp:72
virtual int getHeight() const
Definition: actor.h:70
virtual void setPixelPositionF(const Vector &pos)
Definition: actor.cpp:83
virtual int getTileX() const
Definition: actor.cpp:61
virtual int getNumberOfLayers() const
Definition: actor.h:115
Actors::iterator mMapActor
Definition: actor.h:144
int mPixelX
Definition: actor.h:133
virtual void setMap(Map *const map)
Definition: actor.cpp:48
const Vector & getPixelPositionF() const
Definition: actor.h:76
Vector mPos
Definition: actor.h:140
int mYDiff
Definition: actor.h:141
Map * mMap
Definition: actor.h:139
virtual ~Actor()
Definition: actor.cpp:39
virtual void setAlpha(float alpha)=0
virtual float getAlpha() const =0
virtual void draw(Graphics *const graphics, const int offsetX, const int offsetY) const =0
const Map * getMap() const
Definition: actor.h:130
int mPixelY
Definition: actor.h:134
Definition: map.h:75
Definition: vector.h:40
float y
Definition: vector.h:209
float x
Definition: vector.h:209
#define restrict
Definition: localconsts.h:165
#define restrict2
Definition: localconsts.h:166
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_NONNULL(...)
Definition: localconsts.h:168
#define noexcept2
Definition: localconsts.h:50
#define A_DELETE_COPY(func)
Definition: localconsts.h:53