2011-08-15 16:11:24 +02:00
|
|
|
#include "tile.h"
|
|
|
|
#include "item.h"
|
2011-08-15 21:15:49 +02:00
|
|
|
#include "datmanager.h"
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
Tile::Tile()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tile::addThing(ThingPtr thing, uint8 stackpos)
|
|
|
|
{
|
|
|
|
if(!thing)
|
|
|
|
return;
|
|
|
|
|
2011-08-15 21:15:49 +02:00
|
|
|
const ThingAttributes& thingAttributes = thing->getAttributes();
|
2011-08-15 23:02:52 +02:00
|
|
|
if(thing->asItem()) {
|
2011-08-15 21:15:49 +02:00
|
|
|
if(thingAttributes.group == THING_GROUP_GROUND)
|
|
|
|
m_ground = thing;
|
|
|
|
else {
|
|
|
|
if(thingAttributes.alwaysOnTop)
|
|
|
|
m_itemsTop.push_back(thing);
|
|
|
|
else
|
2011-08-16 02:30:31 +02:00
|
|
|
m_itemsBottom.push_back(thing);
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
2011-08-15 23:02:52 +02:00
|
|
|
} else if(thing->asCreature()) {
|
2011-08-15 21:15:49 +02:00
|
|
|
m_creatures.push_back(thing);
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tile::draw(int x, int y)
|
|
|
|
{
|
|
|
|
if(m_ground)
|
|
|
|
m_ground->draw(x, y);
|
|
|
|
|
2011-08-16 02:30:31 +02:00
|
|
|
for(const ThingPtr& thing : m_itemsBottom)
|
2011-08-15 21:15:49 +02:00
|
|
|
thing->draw(x, y);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-08-15 21:15:49 +02:00
|
|
|
for(const ThingPtr& thing : m_creatures)
|
|
|
|
thing->draw(x, y);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-08-15 21:15:49 +02:00
|
|
|
for(const ThingPtr& thing : m_itemsTop)
|
|
|
|
thing->draw(x, y);
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int Tile::getStackSize()
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
if(m_ground)
|
|
|
|
ret++;
|
2011-08-16 02:30:31 +02:00
|
|
|
ret += m_itemsBottom.size();
|
2011-08-15 16:11:24 +02:00
|
|
|
ret += m_creatures.size();
|
|
|
|
ret += m_itemsTop.size();
|
|
|
|
return ret;
|
|
|
|
}
|