summaryrefslogtreecommitdiff
path: root/src/flooritem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/flooritem.cpp')
-rw-r--r--src/flooritem.cpp57
1 files changed, 16 insertions, 41 deletions
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index c3442a86..84e07f35 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -21,59 +21,34 @@
#include "flooritem.h"
-#include "graphics.h"
-#include "item.h"
-#include "map.h"
+#include "net/net.h"
-#include "resources/image.h"
+#include "resources/itemdb.h"
+#include "resources/iteminfo.h"
FloorItem::FloorItem(int id,
int itemId,
int x,
int y,
Map *map):
- mId(id),
+ ActorSprite(id),
+ mItemId(itemId),
mX(x),
- mY(y),
- mMap(map),
- mAlpha(1.0f)
+ mY(y)
{
- // Create a corresponding item instance
- mItem = new Item(itemId);
+ setMap(map);
- // Add ourselves to the map
- mMapSprite = mMap->addSprite(this);
-}
-
-FloorItem::~FloorItem()
-{
- // Remove ourselves from the map
- mMap->removeSprite(mMapSprite);
+ // TODO: Eventually, we probably should fix all sprite offsets so that
+ // these translations aren't necessary anymore. The sprites know
+ // best where their base point should be.
+ mPos.x = x * map->getTileWidth() + 16;
+ mPos.y = y * map->getTileHeight() +
+ ((Net::getNetworkType() == ServerInfo::MANASERV) ? 15 : 32);
- delete mItem;
-}
-
-int FloorItem::getItemId() const
-{
- return mItem->getId();
+ setupSpriteDisplay(ItemDB::get(itemId).getDisplay());
}
-Item *FloorItem::getItem() const
+const ItemInfo &FloorItem::getInfo() const
{
- return mItem;
-}
-
-void FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
-{
- if (mItem)
- {
- Image *image = mItem->getDrawImage();
-
- if (image)
- if (mAlpha != image->getAlpha())
- image->setAlpha(mAlpha);
-
- graphics->drawImage(image, mX * mMap->getTileWidth() + offsetX,
- mY * mMap->getTileHeight() + offsetY);
- }
+ return ItemDB::get(mId);
}