ManaPlus
Public Member Functions | Data Fields
FindBeingFunctor Class Reference

Public Member Functions

bool operator() (const ActorSprite *const actor) const
 

Data Fields

uint16_t x
 
uint16_t y
 
ActorTypeT type
 

Detailed Description

Definition at line 83 of file actormanager.cpp.

Member Function Documentation

◆ operator()()

bool FindBeingFunctor::operator() ( const ActorSprite *const  actor) const
inline

Definition at line 88 of file actormanager.cpp.

89  {
90  if ((actor == nullptr)
91  || actor->getType() == ActorType::FloorItem
92  || actor->getType() == ActorType::Portal)
93  {
94  return false;
95  }
96  const Being *const b = static_cast<const Being *>(actor);
97 
98  const unsigned other_y = y
99  + ((b->getType() == ActorType::Npc) ? 1 : 0);
100  const Vector &pos = b->getPixelPositionF();
101  // +++ probably here need use int positions and not float?
102  // but for now correct int positions only in Being
103  return CAST_U32(pos.x) / mapTileSize == x &&
104  (CAST_U32(pos.y) / mapTileSize == y
105  || CAST_U32(pos.y) / mapTileSize == other_y) &&
106  b->isAlive() && (type == ActorType::Unknown
107  || b->getType() == type);
108  }
#define CAST_U32
Definition: cast.h:31
virtual ActorTypeT getType() const
Definition: actorsprite.h:73
const Vector & getPixelPositionF() const
Definition: actor.h:76
Definition: being.h:96
bool isAlive() const
Definition: being.h:488
ActorTypeT getType() const
Definition: being.h:116
Definition: vector.h:40
float y
Definition: vector.h:209
float x
Definition: vector.h:209
static const int mapTileSize
Definition: map.h:27
@ FloorItem
Definition: actortype.h:34

References CAST_U32, ActorType::FloorItem, Actor::getPixelPositionF(), Being::getType(), Being::isAlive(), mapTileSize, ActorType::Npc, ActorType::Portal, type, ActorType::Unknown, x, Vector::x, y, and Vector::y.

Field Documentation

◆ type

ActorTypeT FindBeingFunctor::type

Definition at line 111 of file actormanager.cpp.

Referenced by ActorManager::findBeing(), and operator()().

◆ x

uint16_t FindBeingFunctor::x

Definition at line 110 of file actormanager.cpp.

Referenced by ActorManager::findBeing(), and operator()().

◆ y

uint16_t FindBeingFunctor::y

Definition at line 110 of file actormanager.cpp.

Referenced by ActorManager::findBeing(), and operator()().


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