本文整理汇总了C++中CreatureVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CreatureVector::size方法的具体用法?C++ CreatureVector::size怎么用?C++ CreatureVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreatureVector
的用法示例。
在下文中一共展示了CreatureVector::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushCreatures
void Monster::pushCreatures(Tile* tile)
{
CreatureVector* creatures = tile->getCreatures();
if(!creatures)
return;
bool effect = false;
Monster* monster = NULL;
for(uint32_t i = 0; i < creatures->size();)
{
if((monster = creatures->at(i)->getMonster()) && monster->isPushable())
{
if(pushCreature(monster))
continue;
monster->setDropLoot(LOOT_DROP_NONE);
monster->changeHealth(-monster->getHealth());
if(!effect)
effect = true;
}
++i;
}
if(effect)
g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_BLOCKHIT);
}
示例2: replaceThing
void Tile::replaceThing(uint32_t index, Thing* thing)
{
int32_t pos = index;
Item* item = thing->getItem();
if (item == nullptr) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
Item* oldItem = nullptr;
bool isInserted = false;
if (ground) {
if (pos == 0) {
oldItem = ground;
ground = item;
isInserted = true;
}
--pos;
}
TileItemVector* items = getItemList();
if (items && !isInserted) {
int32_t topItemSize = getTopItemCount();
if (pos < topItemSize) {
ItemVector::iterator it = items->getBeginTopItem();
it += pos;
oldItem = (*it);
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
pos -= topItemSize;
}
CreatureVector* creatures = getCreatures();
if (creatures) {
if (!isInserted && pos < static_cast<int32_t>(creatures->size())) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
pos -= static_cast<uint32_t>(creatures->size());
}
if (items && !isInserted) {
int32_t downItemSize = getDownItemCount();
if (pos < downItemSize) {
ItemVector::iterator it = items->getBeginDownItem() + pos;
oldItem = *it;
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
}
if (isInserted) {
item->setParent(this);
resetTileFlags(oldItem);
setTileFlags(item);
const ItemType& oldType = Item::items[oldItem->getID()];
const ItemType& newType = Item::items[item->getID()];
onUpdateTileItem(oldItem, oldType, item, newType);
oldItem->setParent(nullptr);
return /*RETURNVALUE_NOERROR*/;
}
}
示例3: __replaceThing
void Tile::__replaceThing(uint32_t index, Thing* thing)
{
int32_t pos = index;
Item* item = thing->getItem();
if (item == NULL) {
return /*RET_NOTPOSSIBLE*/;
}
Item* oldItem = NULL;
bool isInserted = false;
if (ground) {
if (pos == 0) {
oldItem = ground;
ground = item;
isInserted = true;
}
--pos;
}
TileItemVector* items = getItemList();
if (items && !isInserted) {
int32_t topItemSize = getTopItemCount();
if (pos < topItemSize) {
ItemVector::iterator it = items->getBeginTopItem();
it += pos;
oldItem = (*it);
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
pos -= topItemSize;
}
CreatureVector* creatures = getCreatures();
if (creatures) {
if (!isInserted && pos < (int32_t)creatures->size()) {
return /*RET_NOTPOSSIBLE*/;
}
pos -= (uint32_t)creatures->size();
}
if (items && !isInserted) {
int32_t downItemSize = getDownItemCount();
if (pos < downItemSize) {
ItemVector::iterator it = items->begin();
it += pos;
pos = 0;
oldItem = (*it);
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
}
if (isInserted) {
item->setParent(this);
updateTileFlags(oldItem, true);
updateTileFlags(item, false);
const ItemType& oldType = Item::items[oldItem->getID()];
const ItemType& newType = Item::items[item->getID()];
onUpdateTileItem(oldItem, oldType, item, newType);
oldItem->setParent(NULL);
return /*RET_NOERROR*/;
}
}