Esempio n. 1
0
//------------------------------------------------------------------------------//
void InventoryReceiver::removeItem(InventoryItem& item)
{
    if (item.getParent() != this ||
        item.locationOnReceiverX() == -1 ||
        item.locationOnReceiverY() == -1)
            return;

    eraseItemFromContentMap(item);
    item.setLocationOnReceiver(-1, -1);
    removeChild(&item);
}
Esempio n. 2
0
//------------------------------------------------------------------------------//
void InventoryReceiver::writeItemToContentMap(const InventoryItem& item)
{
    if (item.locationOnReceiverX() == -1 || item.locationOnReceiverY() == -1)
        return;

    for (int y = 0; y < item.contentHeight(); ++y)
    {
        const int map_y = item.locationOnReceiverY() + y;

        for (int x = 0; x < item.contentWidth(); ++x)
        {
            const int map_x = item.locationOnReceiverX() + x;

            bool val = d_content.elementAtLocation(map_x, map_y) |
                       item.isSolidAtLocation(x, y);
            d_content.setElementAtLocation(map_x, map_y, val);
        }
    }

    invalidate();
}