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  *
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 "utils/cast.h"
26 
27 #include "resources/vector.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 
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
Actor::getMap
const Map * getMap() const
Definition: actor.h:129
cast.h
Actor::getPixelPositionF
const Vector & getPixelPositionF() const
Definition: actor.h:75
restrict2
#define restrict2
Definition: localconsts.h:165
Vector::x
float x
Definition: vector.h:208
Actor::mMap
Map * mMap
Definition: actor.h:138
Actor::mPos
Vector mPos
Definition: actor.h:139
Actors
std::list< Actor * > Actors
Definition: actor.h:35
Actor::getNumberOfLayers
virtual int getNumberOfLayers() const
Definition: actor.h:114
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
Actor::mMapActor
Actors::iterator mMapActor
Definition: actor.h:143
Actor
Definition: actor.h:40
notfinal
#define notfinal
Definition: localconsts.h:260
Graphics
Definition: graphics.h:107
localconsts.h
Actor::draw
virtual void draw(Graphics *const graphics, const int offsetX, const int offsetY) const =0
Actor::Actor
Actor()
Definition: actor.cpp:28
noexcept2
#define noexcept2
Definition: localconsts.h:49
ActorsCIter
Actors::const_iterator ActorsCIter
Definition: actor.h:38
Actor::mPixelY
int mPixelY
Definition: actor.h:133
vector.h
Actor::getWidth
virtual int getWidth() const
Definition: actor.h:62
Actor::getPixelY
virtual int getPixelY() const
Definition: actor.h:92
Actor::~Actor
virtual ~Actor()
Definition: actor.cpp:38
Actor::setAlpha
virtual void setAlpha(float alpha)=0
Actor::mPixelX
int mPixelX
Definition: actor.h:132
Actor::mYDiff
int mYDiff
Definition: actor.h:140
Actor::getPixelX
int getPixelX() const
Definition: actor.h:86
Actor::getTileY
virtual int getTileY() const
Definition: actor.cpp:71
Actor::setMap
virtual void setMap(Map *const map)
Definition: actor.cpp:47
Actor::getAlpha
virtual float getAlpha() const =0
Actor::getTileX
virtual int getTileX() const
Definition: actor.cpp:60
Actor::getHeight
virtual int getHeight() const
Definition: actor.h:69
Map
Definition: map.h:71
restrict
#define restrict
Definition: localconsts.h:164
Vector::y
float y
Definition: vector.h:208
Actor::getSortPixelY
virtual int getSortPixelY() const
Definition: actor.h:98
CAST_S32
#define CAST_S32
Definition: cast.h:29
A_WARN_UNUSED
#define A_WARN_UNUSED
Definition: localconsts.h:160
Actor::setPixelPositionF
virtual void setPixelPositionF(const Vector &pos)
Definition: actor.cpp:82
Vector
Definition: vector.h:38
A_NONNULL
#define A_NONNULL(...)
Definition: localconsts.h:167