ManaPlus
Public Member Functions | Protected Attributes
CastingEffect Class Reference

#include <castingeffect.h>

Inheritance diagram for CastingEffect:
Actor

Public Member Functions

 CastingEffect (const int skillId, const int skillLevel, const std::string &animation, const int x, const int y, const int range)
 
 ~CastingEffect ()
 
virtual ActorTypeT getType () const
 
void draw (Graphics *const graphics, const int offsetX, const int offsetY) const
 
int getSortPixelY () const
 
void update (const int time)
 
bool isTerminated () const
 
float getAlpha () const
 
void setAlpha (const float alpha)
 
- Public Member Functions inherited from Actor
virtual ~Actor ()
 
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 getTileX () const
 
virtual int getTileY () const
 
virtual int getNumberOfLayers () const
 
virtual void setMap (Map *const map)
 
const MapgetMap () const
 

Protected Attributes

AnimatedSpritemSprite
 
int mRectX
 
int mRectY
 
int mRectSize
 
int mAnimationX
 
int mAnimationY
 
- Protected Attributes inherited from Actor
MapmMap
 
Vector mPos
 
int mYDiff
 

Additional Inherited Members

- Data Fields inherited from Actor
int mPixelX
 
int mPixelY
 
- Protected Member Functions inherited from Actor
 Actor ()
 

Detailed Description

Definition at line 33 of file castingeffect.h.

Constructor & Destructor Documentation

◆ CastingEffect()

CastingEffect::CastingEffect ( const int  skillId,
const int  skillLevel,
const std::string &  animation,
const int  x,
const int  y,
const int  range 
)

Definition at line 39 of file castingeffect.cpp.

44  :
45  Actor(),
46  mSprite(animation.empty() ? nullptr :
47  AnimatedSprite::load(paths.getStringValue("sprites") + animation, 0)),
48  mRectX((x - range) * mapTileSize),
49  mRectY((y - range) * mapTileSize),
50  mRectSize(range * mapTileSize * 2 + mapTileSize),
51  mAnimationX(mRectX + (mRectSize - (mSprite != nullptr ?
52  mSprite->getWidth() : 0)) / 2),
53  mAnimationY(mRectY + (mRectSize - (mSprite != nullptr ?
54  mSprite->getHeight() : 0)) / 2)
55 {
56  mPixelX = x * mapTileSize;
57  mPixelY = y * mapTileSize;
58  mYDiff = range * mapTileSize + 31;
59  if (mSprite == nullptr)
60  {
61  reportAlways("Skill %d/%d casting animation '%s' load failed",
62  skillId,
63  skillLevel,
64  animation.c_str())
65  }
66 }
#define reportAlways(...)
Definition: checkutils.h:253
Actor()
Definition: actor.cpp:29
int mPixelX
Definition: actor.h:133
int mYDiff
Definition: actor.h:141
int mPixelY
Definition: actor.h:134
int getHeight() const
int getWidth() const
static AnimatedSprite * load(const std::string &filename, const int variant)
AnimatedSprite * mSprite
Definition: castingeffect.h:68
std::string getStringValue(const std::string &key) const
Configuration paths
static const int mapTileSize
Definition: map.h:27

References mapTileSize, Actor::mPixelX, Actor::mPixelY, mSprite, Actor::mYDiff, reportAlways, x, and y.

◆ ~CastingEffect()

CastingEffect::~CastingEffect ( )

Definition at line 68 of file castingeffect.cpp.

69 {
71 }
#define delete2(var)
Definition: delete2.h:25

References delete2, and mSprite.

Member Function Documentation

◆ draw()

void CastingEffect::draw ( Graphics *const  graphics,
const int  offsetX,
const int  offsetY 
) const
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.

Implements Actor.

Definition at line 73 of file castingeffect.cpp.

76 {
79 
80  graphics->drawRectangle(Rect(
81  mRectX + offsetX,
82  mRectY + offsetY,
83  mRectSize,
84  mRectSize));
85  if (mSprite != nullptr)
86  {
87  mSprite->drawRescaled(graphics,
88  mRectX + offsetX,
89  mRectY + offsetY,
90  mRectSize,
91  mRectSize);
92  }
93 }
void drawRescaled(Graphics *const graphics, const int posX, const int posY, const int dx, const int dy) const
virtual void setColor(const Color &color)
Definition: graphics.h:320
virtual void drawRectangle(const Rect &rectangle)=0
Definition: rect.h:74
const Color & getColorWithAlpha(const UserColorIdT type)
Definition: userpalette.h:200
@ ATTACK_RANGE_BORDER
Definition: usercolorid.h:89
UserPalette * userPalette
Definition: userpalette.cpp:34

References UserColorId::ATTACK_RANGE_BORDER, Graphics::drawRectangle(), AnimatedSprite::drawRescaled(), UserPalette::getColorWithAlpha(), mRectSize, mRectX, mRectY, mSprite, Graphics::setColor(), and userPalette.

◆ getAlpha()

float CastingEffect::getAlpha ( ) const
inlinevirtual

Returns the current alpha value used to draw the actor.

Implements Actor.

Definition at line 61 of file castingeffect.h.

62  { return 1.0F; }

◆ getSortPixelY()

int CastingEffect::getSortPixelY ( ) const
inlinevirtual

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

Reimplemented from Actor.

Definition at line 54 of file castingeffect.h.

55  { return mPixelY - mYDiff; }

References Actor::mPixelY, and Actor::mYDiff.

◆ getType()

virtual ActorTypeT CastingEffect::getType ( ) const
inlinevirtual

Definition at line 47 of file castingeffect.h.

48  { return ActorType::Unknown; }

References ActorType::Unknown.

◆ isTerminated()

bool CastingEffect::isTerminated ( ) const

Definition at line 101 of file castingeffect.cpp.

102 {
103  if (mSprite != nullptr)
104  return mSprite->isTerminated();
105  return false;
106 }
bool isTerminated() const

References AnimatedSprite::isTerminated(), and mSprite.

Referenced by Being::logic().

◆ setAlpha()

void CastingEffect::setAlpha ( const float  alpha)
inlinevirtual

Sets the alpha value used to draw the actor.

Implements Actor.

Definition at line 64 of file castingeffect.h.

65  { }

◆ update()

void CastingEffect::update ( const int  time)

Definition at line 95 of file castingeffect.cpp.

96 {
97  if (mSprite != nullptr)
98  mSprite->update(time);
99 }
bool update(const int time)

References mSprite, and AnimatedSprite::update().

Referenced by Being::logic().

Field Documentation

◆ mAnimationX

int CastingEffect::mAnimationX
protected

Definition at line 72 of file castingeffect.h.

◆ mAnimationY

int CastingEffect::mAnimationY
protected

Definition at line 73 of file castingeffect.h.

◆ mRectSize

int CastingEffect::mRectSize
protected

Definition at line 71 of file castingeffect.h.

Referenced by draw().

◆ mRectX

int CastingEffect::mRectX
protected

Definition at line 69 of file castingeffect.h.

Referenced by draw().

◆ mRectY

int CastingEffect::mRectY
protected

Definition at line 70 of file castingeffect.h.

Referenced by draw().

◆ mSprite

AnimatedSprite* CastingEffect::mSprite
protected

Definition at line 68 of file castingeffect.h.

Referenced by CastingEffect(), draw(), isTerminated(), update(), and ~CastingEffect().


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