1
/*
2
 *  The Mana World
3
 *  Copyright (C) 2004  The Mana World Development Team
4
 *
5
 *  This file is part of The Mana World.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
#ifndef FLOORITEM_H
23
#define FLOORITEM_H
24
25
#include <list>
26
27
#include "map.h"
28
#include "sprite.h"
29
30
class Graphics;
31
class Image;
32
class Item;
33
34
/**
35
 * An item lying on the floor.
36
 */
37
class FloorItem : public Sprite
38
{
39
    public:
40
        /**
41
         * Constructor.
42
         *
43
         * @param id     the unique ID of this item instance
44
         * @param itemId the item ID
45
         * @param x      the x position in tiles
46
         * @param y      the y position in tiles
47
         * @param map    the map this item is on
48
         */
49
        FloorItem(int id,
50
                  int itemId,
51
                  int x,
52
                  int y,
53
                  Map *map);
54
55
        ~FloorItem();
56
57
        /**
58
         * Returns instance ID of this item.
59
         */
60
        int getId() const { return mId; }
61
62
        /**
63
         * Returns the item ID.
64
         */
65
        int getItemId() const;
66
67
        /**
68
         * Returns the item object. Useful for adding an item link for the
69
         * floor item to chat.
70
         */
71
        Item *getItem() const;
72
73
        /**
74
         * Returns the x coordinate in tiles.
75
         */
76
        int getX() const { return mX; }
77
78
        /**
79
         * Returns the y coordinate in tiles.
80
         */
81
        int getY() const { return mY; }
82
83
        /**
84
         * Returns the pixel y coordinate.
85
         *
86
         * @see Sprite::getPixelY()
87
         */
88
        int getPixelY() const { return mY * 32 + 16; }
89
90
        /**
91
         * Draws this floor item to the given graphics context.
92
         *
93
         * @see Sprite::draw(Graphics, int, int)
94
         */
95
        void draw(Graphics *graphics, int offsetX, int offsetY) const;
96
97
        /**
98
         * Sets the alpha value of the floor item
99
         */
100
        void setAlpha(float alpha)
101
        { mAlpha = alpha; }
102
103
        /**
104
         * Returns the current alpha opacity of the floor item.
105
         */
106
        virtual float getAlpha() const
107
        { return mAlpha; }
108
109
        /** We consider flooritems (at least for now) to be one layer-sprites */
110
        virtual int getNumberOfLayers() const
111
        { return 1; }
112
113
    private:
114
        int mId;
115
        int mX, mY;
116
        Item *mItem;
117
        MapSprite mMapSprite;
118
        Map *mMap;
119
        float mAlpha;
120
};
121
122
#endif