当前位置: 首页>>代码示例>>C++>>正文


C++ BedItem类代码示例

本文整理汇总了C++中BedItem的典型用法代码示例。如果您正苦于以下问题:C++ BedItem类的具体用法?C++ BedItem怎么用?C++ BedItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BedItem类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: itemFromIndex

void BedItemModel::slotInsertProfileBelow(Profile* p, const QModelIndex& idx) {
    //FIXME: this is seriously buggy and currently not available in the gui
    BedItem* itm = (BedItem*) itemFromIndex(idx);

    if (!itm) {
        return;
    }

    int lastPos = itm->getBed()->getPosition() - 1;

    QList<Bed*>::iterator it = p->getLastBed();
    QList<Bed*> beds;
    
    for (QList<Bed*>::iterator it = p->getLastBed(); it != p->getFirstBed(); it--) {
        beds.prepend(*it);
        
    }

    for(int i = 0; i < beds.size(); i++) {
        Bed* b = beds.at(i);
        lastPos += i;
        (void) _profile->copyBed(b, 0, lastPos);
    }

    reload();
}
开发者ID:BackupTheBerlios,项目名称:profilelogger-svn,代码行数:26,代码来源:BedItemModel.cpp

示例2: regeneratePlayer

void BedItem::wakeUp()
{
	if(!house)
		return;

	if(sleeper)
	{
		if(Player* player = g_game.getPlayerByGuidEx(sleeper))
		{
			regeneratePlayer(player);
			if(player->isVirtual())
			{
				IOLoginData::getInstance()->savePlayer(player);
				delete player;
			}
			else
				g_game.addCreatureHealth(player);
		}
	}

	Beds::getInstance().setBedSleeper(NULL, sleeper);
	internalRemoveSleeper();

	BedItem* nextBedItem = getNextBedItem();
	if(nextBedItem)
		nextBedItem->internalRemoveSleeper();

	updateAppearance(NULL);
	if(nextBedItem)
		nextBedItem->updateAppearance(NULL);
}
开发者ID:Fir3element,项目名称:035,代码行数:31,代码来源:beds.cpp

示例3: internalSetSleeper

void BedItem::sleep(Player* player)
{
	if(!house || !player || player->isRemoved())
		return;

	if(!sleeper)
	{
		Beds::getInstance().setBedSleeper(this, player->getGUID());
		internalSetSleeper(player);

		BedItem* nextBedItem = getNextBedItem();
		if(nextBedItem)
			nextBedItem->internalSetSleeper(player);

		updateAppearance(player);
		if(nextBedItem)
			nextBedItem->updateAppearance(player);

		player->getTile()->moveCreature(NULL, player, getTile());
		g_game.addMagicEffect(player->getPosition(), NM_ME_SLEEP);
		Scheduler::getScheduler().addEvent(createSchedulerTask(SCHEDULER_MINTICKS, boost::bind(&Game::kickPlayer, &g_game, player->getID(), false)));
	}
	else if(Item::items[getID()].transformToFree)
	{
		wakeUp();
		g_game.addMagicEffect(player->getPosition(), NM_ME_POFF);
	}
	else
		player->sendCancelMessage(RET_NOTPOSSIBLE);
}
开发者ID:Fir3element,项目名称:035,代码行数:30,代码来源:beds.cpp

示例4: rowCount

BedItem* BedItemModel::findItemForBed(Bed* b) {
    if (!b) {
        return 0;
    }

    int max = rowCount();
    for (int r = 0; r < max; r++) {
        BedItem* itm = (BedItem*) item(r);
        if (itm->getBed()->getId() == b->getId()) {
            return itm;
        }
    }
    return 0;
}
开发者ID:BackupTheBerlios,项目名称:profilelogger-svn,代码行数:14,代码来源:BedItemModel.cpp

示例5: Player

void BedItem::wakeUp(Player* player)
{
	// avoid crashes
	if (!house) {
		return;
	}

	if (sleeperGUID != 0) {
		if (!player) {
			std::string name;

			if (IOLoginData::getInstance()->getNameByGuid(sleeperGUID, name)) {
				Player* _player = new Player(name, NULL);

				if (IOLoginData::getInstance()->loadPlayer(_player, name)) {
					regeneratePlayer(_player);
					IOLoginData::getInstance()->savePlayer(_player);
				}

				delete _player;
				_player = NULL;
			}
		} else {
			regeneratePlayer(player);
			g_game.addCreatureHealth(player);
		}
	}

	// update the BedSleepersMap
	Beds::getInstance().setBedSleeper(NULL, sleeperGUID);

	BedItem* nextBedItem = getNextBedItem();

	// unset sleep info
	internalRemoveSleeper();

	if (nextBedItem) {
		nextBedItem->internalRemoveSleeper();
	}

	// change self and partner's appearance
	updateAppearance(NULL);

	if (nextBedItem) {
		nextBedItem->updateAppearance(NULL);
	}
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:47,代码来源:beds.cpp

示例6: getNextBedItem

bool BedItem::sleep(Player* player)
{
	if (!house || !player || player->isRemoved()) {
		return false;
	}

	if (sleeperGUID != 0) {
		return false;
	}

	BedItem* nextBedItem = getNextBedItem();

	internalSetSleeper(player);

	if (nextBedItem) {
		nextBedItem->internalSetSleeper(player);
	}

	// update the BedSleepersMap
	Beds::getInstance().setBedSleeper(this, player->getGUID());

	// make the player walk onto the bed
	player->getTile()->moveCreature(player, getTile());

	// display 'Zzzz'/sleep effect
	g_game.addMagicEffect(player->getPosition(), NM_ME_SLEEP);

	// kick player after he sees himself walk onto the bed and it change id
	uint32_t playerId = player->getID();
	g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, boost::bind(&Game::kickPlayer, &g_game, playerId, false)));

	// change self and partner's appearance
	updateAppearance(player);

	if (nextBedItem) {
		nextBedItem->updateAppearance(player);
	}

	return true;
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:40,代码来源:beds.cpp

示例7: _player

void BedItem::wakeUp(Player* player)
{
	// avoid crashes
	if (!house) {
		return;
	}

	if (sleeperGUID != 0) {
		if (!player) {
			Player _player(nullptr);
			if (IOLoginData::loadPlayerById(&_player, sleeperGUID)) {
				regeneratePlayer(&_player);
				IOLoginData::savePlayer(&_player);
			}
		} else {
			regeneratePlayer(player);
			g_game.addCreatureHealth(player);
		}
	}

	// update the BedSleepersMap
	Beds::getInstance().setBedSleeper(nullptr, sleeperGUID);

	BedItem* nextBedItem = getNextBedItem();

	// unset sleep info
	internalRemoveSleeper();

	if (nextBedItem) {
		nextBedItem->internalRemoveSleeper();
	}

	// change self and partner's appearance
	updateAppearance(nullptr);

	if (nextBedItem) {
		nextBedItem->updateAppearance(nullptr);
	}
}
开发者ID:EmanuelEkstrom,项目名称:forgottenserver,代码行数:39,代码来源:beds.cpp


注:本文中的BedItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。