ManaPlus
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Private Attributes
Actor Class Referenceabstract

#include <actor.h>

Inheritance diagram for Actor:
ActorSprite CastingEffect Particle Being FloorItem ImageParticle TextParticle LocalPlayer AnimationParticle RotationalParticle

Public Member Functions

virtual ~Actor ()
 
virtual void draw (Graphics *const graphics, const int offsetX, const int offsetY) const =0
 
virtual int getWidth () const
 
virtual int getHeight () const
 
const VectorgetPixelPositionF () const
 
virtual void setPixelPositionF (const Vector &pos)
 
int getPixelX () const
 
virtual int getPixelY () const
 
virtual int getSortPixelY () const
 
virtual int getTileX () const
 
virtual int getTileY () const
 
virtual int getNumberOfLayers () const
 
virtual float getAlpha () const =0
 
virtual void setAlpha (float alpha)=0
 
virtual void setMap (Map *const map)
 
const MapgetMap () const
 

Data Fields

int mPixelX
 
int mPixelY
 

Protected Member Functions

 Actor ()
 

Protected Attributes

MapmMap
 
Vector mPos
 
int mYDiff
 

Private Attributes

Actors::iterator mMapActor
 

Detailed Description

Definition at line 41 of file actor.h.

Constructor & Destructor Documentation

◆ ~Actor()

Actor::~Actor ( )
virtual

Definition at line 39 of file actor.cpp.

40 {
41  if (mMap != nullptr)
42  {
44  mMap = nullptr;
45  }
46 }
Actors::iterator mMapActor
Definition: actor.h:144
Map * mMap
Definition: actor.h:139
void removeActor(const Actors::iterator &iterator)
Definition: map.cpp:829

References mMap, mMapActor, and Map::removeActor().

◆ Actor()

Actor::Actor ( )
protected

Definition at line 29 of file actor.cpp.

29  :
30  mPixelX(0),
31  mPixelY(0),
32  mMap(nullptr),
33  mPos(),
34  mYDiff(0),
35  mMapActor()
36 {
37 }
int mPixelX
Definition: actor.h:133
Vector mPos
Definition: actor.h:140
int mYDiff
Definition: actor.h:141
int mPixelY
Definition: actor.h:134

Member Function Documentation

◆ draw()

virtual void Actor::draw ( Graphics *const  graphics,
const int  offsetX,
const int  offsetY 
) const
pure virtual

Draws the Actor to the given graphics context.

Note: this function could be simplified if the graphics context would support setting a translation offset. It already does this partly with the clipping rectangle support.

Implemented in TextParticle, Particle, ImageParticle, FloorItem, CastingEffect, and Being.

◆ getAlpha()

virtual float Actor::getAlpha ( ) const
pure virtual

Returns the current alpha value used to draw the actor.

Implemented in Particle, CastingEffect, and ActorSprite.

◆ getHeight()

virtual int Actor::getHeight ( ) const
inlinevirtual

Returns the vertical size of the actors graphical representation in pixels or 0 when it is undefined.

Reimplemented in Being, and ActorSprite.

Definition at line 70 of file actor.h.

71  { return 0; }

◆ getMap()

const Map* Actor::getMap ( ) const
inline

Definition at line 130 of file actor.h.

131  { return mMap; }

References mMap.

Referenced by CrazyMoves::crazyMove8().

◆ getNumberOfLayers()

virtual int Actor::getNumberOfLayers ( ) const
inlinevirtual

Returns the number of Image layers used to draw the actor.

Reimplemented in Particle, and Being.

Definition at line 115 of file actor.h.

116  { return 0; }

◆ getPixelPositionF()

const Vector& Actor::getPixelPositionF ( ) const
inline

Returns the pixel position of this actor.

Definition at line 76 of file actor.h.

77  { return mPos; }

References mPos.

Referenced by FindBeingFunctor::operator()().

◆ getPixelX()

int Actor::getPixelX ( ) const
inline

Returns the pixels X coordinate of the actor.

Definition at line 87 of file actor.h.

88  { return CAST_S32(mPos.x); }
#define CAST_S32
Definition: cast.h:30
float x
Definition: vector.h:209

References CAST_S32, mPos, and Vector::x.

Referenced by DebugWindow::draw(), MapLayer::drawFringe(), ActorManager::findBeingByPixel(), ActorManager::findBeingsByPixel(), ActorSprite::getActorX(), getTileX(), and DebugWindow::safeDraw().

◆ getPixelY()

virtual int Actor::getPixelY ( ) const
inlinevirtual

Returns the pixel Y coordinate of the actor.

Reimplemented in TextParticle, and Particle.

Definition at line 93 of file actor.h.

94  { return CAST_S32(mPos.y); }
float y
Definition: vector.h:209

References CAST_S32, mPos, and Vector::y.

Referenced by DebugWindow::draw(), MapLayer::drawFringe(), ActorManager::findBeingByPixel(), ActorManager::findBeingsByPixel(), ActorSprite::getActorY(), getTileY(), and DebugWindow::safeDraw().

◆ getSortPixelY()

virtual int Actor::getSortPixelY ( ) const
inlinevirtual

Returns the pixel Y coordinate of the actor for sorting only.

Reimplemented in TextParticle, Particle, CastingEffect, and Being.

Definition at line 99 of file actor.h.

100  { return CAST_S32(mPos.y) - mYDiff; }

References CAST_S32, mPos, mYDiff, and Vector::y.

◆ getTileX()

int Actor::getTileX ( ) const
virtual

Returns the x coordinate in tiles of the actor.

Reimplemented in FloorItem, and Being.

Definition at line 61 of file actor.cpp.

62 {
63  if (mMap == nullptr ||
64  mMap->getTileWidth() == 0)
65  {
66  return 0;
67  }
68 
69  return getPixelX() / mMap->getTileWidth();
70 }
int getPixelX() const
Definition: actor.h:87
int getTileWidth() const
Definition: map.h:178

References getPixelX(), Map::getTileWidth(), and mMap.

◆ getTileY()

int Actor::getTileY ( ) const
virtual

Returns the y coordinate in tiles of the actor.

Reimplemented in FloorItem, and Being.

Definition at line 72 of file actor.cpp.

73 {
74  if (mMap == nullptr ||
75  mMap->getTileHeight() == 0)
76  {
77  return 0;
78  }
79 
80  return getPixelY() / mMap->getTileHeight();
81 }
virtual int getPixelY() const
Definition: actor.h:93
int getTileHeight() const
Definition: map.h:184

References getPixelY(), Map::getTileHeight(), and mMap.

◆ getWidth()

virtual int Actor::getWidth ( ) const
inlinevirtual

Returns the horizontal size of the actors graphical representation in pixels or 0 when it is undefined.

Reimplemented in Being, and ActorSprite.

Definition at line 63 of file actor.h.

64  { return 0; }

◆ setAlpha()

virtual void Actor::setAlpha ( float  alpha)
pure virtual

Sets the alpha value used to draw the actor.

Implemented in Particle, ImageParticle, CastingEffect, and ActorSprite.

◆ setMap()

void Actor::setMap ( Map *const  map)
virtual

Reimplemented in LocalPlayer, Being, and ActorSprite.

Definition at line 48 of file actor.cpp.

49 {
50  // Remove Actor from potential previous map
51  if (mMap != nullptr)
53 
54  mMap = map;
55 
56  // Add Actor to potential new map
57  if (mMap != nullptr)
58  mMapActor = mMap->addActor(this);
59 }
Actors::iterator addActor(Actor *const actor)
Definition: map.cpp:822

References Map::addActor(), mMap, mMapActor, and Map::removeActor().

Referenced by Being::addCast(), Particle::addEffect(), ParticleEngine::addEffect(), ParticleEngine::addTextRiseFadeOutEffect(), ParticleEngine::addTextSplashEffect(), ParticleEngine::createChild(), ParticleEmitter::createParticles(), and ActorSprite::setMap().

◆ setPixelPositionF()

void Actor::setPixelPositionF ( const Vector pos)
virtual

Sets the pixel position of this actor.

Reimplemented in Being.

Definition at line 83 of file actor.cpp.

84 {
85  mPos = pos;
88 }

References CAST_S32, and anonymous_namespace{mrand.cpp}::mPos.

Referenced by Being::setPixelPositionF().

Field Documentation

◆ mMap

Map* Actor::mMap
protected

◆ mMapActor

Actors::iterator Actor::mMapActor
private

Definition at line 144 of file actor.h.

Referenced by setMap(), and ~Actor().

◆ mPixelX

int Actor::mPixelX

◆ mPixelY

int Actor::mPixelY

◆ mPos

Vector Actor::mPos
protected

◆ mYDiff

int Actor::mYDiff
protected

The documentation for this class was generated from the following files: