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-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 
41 {
42  public:
44 
45  virtual ~Actor();
46 
54  virtual void draw(Graphics *const graphics,
55  const int offsetX,
56  const int offsetY) const A_NONNULL(2) = 0;
57 
62  virtual int getWidth() const A_WARN_UNUSED
63  { return 0; }
64 
69  virtual int getHeight() const A_WARN_UNUSED
70  { return 0; }
71 
76  { return mPos; }
77 
81  virtual void setPixelPositionF(const Vector &restrict pos) restrict2;
82 
87  { return CAST_S32(mPos.x); }
88 
92  virtual int getPixelY() const A_WARN_UNUSED
93  { return CAST_S32(mPos.y); }
94 
98  virtual int getSortPixelY() const A_WARN_UNUSED
99  { return CAST_S32(mPos.y) - mYDiff; }
100 
104  virtual int getTileX() const A_WARN_UNUSED;
105 
109  virtual int getTileY() const A_WARN_UNUSED;
110 
114  virtual int getNumberOfLayers() const A_WARN_UNUSED
115  { return 0; }
116 
120  virtual float getAlpha() const A_WARN_UNUSED = 0;
121 
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 
140  int mYDiff;
141 
142  private:
143  Actors::iterator mMapActor;
144 };
145 
146 #endif // BEING_ACTOR_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
Definition: vector.h:38
virtual void draw(Graphics *const graphics, const int offsetX, const int offsetY) const =0
#define A_WARN_UNUSED
Definition: localconsts.h:172
Vector mPos
Definition: actor.h:139
virtual int getNumberOfLayers() const
Definition: actor.h:114
const Vector & getPixelPositionF() const
Definition: actor.h:75
std::list< Actor * > Actors
Definition: actor.h:35
#define A_NONNULL(...)
Definition: localconsts.h:179
Actors::iterator mMapActor
Definition: actor.h:143
int mPixelX
Definition: actor.h:132
virtual int getPixelY() const
Definition: actor.h:92
#define CAST_S32
Definition: cast.h:29
Actor()
Definition: actor.cpp:28
virtual ~Actor()
Definition: actor.cpp:38
virtual void setAlpha(float alpha)=0
#define notfinal
Definition: localconsts.h:289
virtual void setMap(Map *const map)
Definition: actor.cpp:47
int mPixelY
Definition: actor.h:133
int getPixelX() const
Definition: actor.h:86
virtual int getWidth() const
Definition: actor.h:62
Definition: map.h:68
float x
Definition: vector.h:208
virtual int getTileY() const
Definition: actor.cpp:71
int mYDiff
Definition: actor.h:140
virtual int getTileX() const
Definition: actor.cpp:60
virtual void setPixelPositionF(const Vector &pos)
Definition: actor.cpp:82
float y
Definition: vector.h:208
Definition: actor.h:40
#define restrict
Definition: localconsts.h:176
virtual int getHeight() const
Definition: actor.h:69
Actors::const_iterator ActorsCIter
Definition: actor.h:38
virtual float getAlpha() const =0
#define noexcept2
Definition: localconsts.h:49
#define restrict2
Definition: localconsts.h:177
const Map * getMap() const
Definition: actor.h:129
virtual int getSortPixelY() const
Definition: actor.h:98
Map * mMap
Definition: actor.h:138