tibia-client/src/tile.cpp

68 lines
1.4 KiB
C++
Raw Normal View History

2011-08-11 07:52:30 +02:00
#include "tile.h"
#include "item.h"
#include "tibiadat.h"
2011-08-12 02:06:01 +02:00
Tile::Tile()
{
m_ground = NULL;
}
2011-08-11 07:52:30 +02:00
void Tile::addThing(Thing *thing)
{
if(!thing)
return;
if(thing->getType() == Thing::TYPE_ITEM) {
2011-08-12 02:06:01 +02:00
Item *item = thing->getItem();
2011-08-11 07:52:30 +02:00
if(item) {
ItemAttributes *itemAttributes = g_tibiaDat.getItemAttributes(item->getId());
2011-08-12 02:06:01 +02:00
if(itemAttributes->group == ITEM_GROUP_GROUND)
m_ground = item;
else {
if(itemAttributes->alwaysOnTop)
m_itemsTop.push_back(thing);
else
m_itemsBot.push_back(thing);
}
2011-08-11 07:52:30 +02:00
}
}
else if(thing->getType() == Thing::TYPE_CREATURE) {
}
}
2011-08-12 02:06:01 +02:00
void Tile::draw(int x, int y, int z)
2011-08-11 07:52:30 +02:00
{
2011-08-12 02:06:01 +02:00
if(m_ground)
m_ground->draw(x, y, z);
2011-08-11 07:52:30 +02:00
for(auto it = m_itemsTop.begin(), end = m_itemsTop.end(); it != end; ++it)
2011-08-12 02:06:01 +02:00
(*it)->draw(x, y, z);
for(auto it = m_creatures.begin(), end = m_creatures.end(); it != end; ++it)
(*it)->draw(x, y, z);
for(auto it = m_itemsBot.begin(), end = m_itemsBot.end(); it != end; ++it)
(*it)->draw(x, y, z);
2011-08-11 07:52:30 +02:00
}
2011-08-12 06:34:21 +02:00
bool Tile::hasGround()
{
return m_ground != 0;
}
int Tile::getStackSize()
{
int ret = 0;
if(m_ground)
ret++;
ret += m_itemsBot.size();
ret += m_creatures.size();
ret += m_itemsTop.size();
return ret;
}