2011-08-15 16:11:24 +02:00
|
|
|
#include "item.h"
|
2011-08-15 21:15:49 +02:00
|
|
|
#include "datmanager.h"
|
|
|
|
#include "spritemanager.h"
|
2011-08-15 16:11:24 +02:00
|
|
|
#include "thing.h"
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
Item::Item() : Thing(THING_ITEM)
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
2011-08-15 23:02:52 +02:00
|
|
|
m_count = 0;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Item::draw(int x, int y)
|
|
|
|
{
|
2011-08-15 23:02:52 +02:00
|
|
|
const ThingAttributes& attributes = g_dat.getItemAttributes(m_id);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
int xdiv = 0, ydiv = 0, zdiv = 0, anim = 0;
|
|
|
|
|
2011-08-24 05:58:23 +02:00
|
|
|
if(attributes.group == THING_GROUP_SPLASH || attributes.group == THING_GROUP_FLUID) {
|
|
|
|
//xdiv = m_count % attributes.xdiv;
|
|
|
|
//ydiv = m_count / attributes.ydiv;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(attributes.stackable) {
|
|
|
|
if(m_count < 5) {
|
|
|
|
xdiv = m_count-1;
|
|
|
|
ydiv = 0;
|
|
|
|
}
|
|
|
|
else if(m_count < 10) {
|
|
|
|
xdiv = 0;
|
|
|
|
ydiv = 1;
|
|
|
|
}
|
|
|
|
else if(m_count < 25) {
|
|
|
|
xdiv = 1;
|
|
|
|
ydiv = 1;
|
|
|
|
}
|
|
|
|
else if(m_count < 50) {
|
|
|
|
xdiv = 2;
|
|
|
|
ydiv = 1;
|
|
|
|
}
|
|
|
|
else if(m_count <= 100) {
|
|
|
|
xdiv = 3;
|
|
|
|
ydiv = 1;
|
|
|
|
}
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
2011-08-15 21:15:49 +02:00
|
|
|
else if(!attributes.moveable) {
|
|
|
|
xdiv = m_position.x % attributes.xdiv;
|
|
|
|
ydiv = m_position.y % attributes.ydiv;
|
|
|
|
zdiv = m_position.z % attributes.zdiv;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
2011-08-15 21:15:49 +02:00
|
|
|
for(int b = 0; b < attributes.blendframes; b++)
|
2011-08-15 16:11:24 +02:00
|
|
|
internalDraw(x, y, b, xdiv, ydiv, zdiv, anim);
|
|
|
|
}
|
2011-08-15 23:02:52 +02:00
|
|
|
|
|
|
|
const ThingAttributes& Item::getAttributes()
|
|
|
|
{
|
|
|
|
return g_dat.getItemAttributes(m_id);
|
|
|
|
}
|