本文整理汇总了C++中MagicField::isReplaceable方法的典型用法代码示例。如果您正苦于以下问题:C++ MagicField::isReplaceable方法的具体用法?C++ MagicField::isReplaceable怎么用?C++ MagicField::isReplaceable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MagicField
的用法示例。
在下文中一共展示了MagicField::isReplaceable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addThing
void Tile::addThing(int32_t, Thing* thing)
{
Creature* creature = thing->getCreature();
if (creature) {
g_game.map.clearSpectatorCache();
creature->setParent(this);
CreatureVector* creatures = makeCreatures();
creatures->insert(creatures->begin(), creature);
} else {
Item* item = thing->getItem();
if (item == nullptr) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
TileItemVector* items = getItemList();
if (items && items->size() >= 0xFFFF) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
item->setParent(this);
const ItemType& itemType = Item::items[item->getID()];
if (itemType.isGroundTile()) {
if (ground == nullptr) {
ground = item;
onAddTileItem(item);
} else {
const ItemType& oldType = Item::items[ground->getID()];
Item* oldGround = ground;
ground->setParent(nullptr);
g_game.ReleaseItem(ground);
ground = item;
resetTileFlags(oldGround);
setTileFlags(item);
onUpdateTileItem(oldGround, oldType, item, itemType);
postRemoveNotification(oldGround, nullptr, 0);
}
} else if (itemType.alwaysOnTop) {
if (itemType.isSplash() && items) {
//remove old splash if exists
for (ItemVector::const_iterator it = items->getBeginTopItem(), end = items->getEndTopItem(); it != end; ++it) {
Item* oldSplash = *it;
if (!Item::items[oldSplash->getID()].isSplash()) {
continue;
}
removeThing(oldSplash, 1);
oldSplash->setParent(nullptr);
g_game.ReleaseItem(oldSplash);
postRemoveNotification(oldSplash, nullptr, 0);
break;
}
}
bool isInserted = false;
if (items) {
for (ItemVector::iterator it = items->getBeginTopItem(), end = items->getEndTopItem(); it != end; ++it) {
//Note: this is different from internalAddThing
if (itemType.alwaysOnTopOrder <= Item::items[(*it)->getID()].alwaysOnTopOrder) {
items->insert(it, item);
isInserted = true;
break;
}
}
} else {
items = makeItemList();
}
if (!isInserted) {
items->push_back(item);
}
onAddTileItem(item);
} else {
if (itemType.isMagicField()) {
//remove old field item if exists
if (items) {
for (ItemVector::const_iterator it = items->getBeginDownItem(), end = items->getEndDownItem(); it != end; ++it) {
MagicField* oldField = (*it)->getMagicField();
if (oldField) {
if (oldField->isReplaceable()) {
removeThing(oldField, 1);
oldField->setParent(nullptr);
g_game.ReleaseItem(oldField);
postRemoveNotification(oldField, nullptr, 0);
break;
} else {
//This magic field cannot be replaced.
item->setParent(nullptr);
g_game.ReleaseItem(item);
return;
}
}
}
}
}
//.........这里部分代码省略.........
示例2: __addThing
//.........这里部分代码省略.........
ground = item;
updateTileFlags(oldGround, true);
updateTileFlags(item, false);
onUpdateTileItem(oldGround, oldType, item, newType);
postRemoveNotification(oldGround, NULL, oldGroundIndex, true);
}
}
else if (item->isAlwaysOnTop())
{
if (item->isSplash())
{
//remove old splash if exists
if (items)
{
for (ItemVector::iterator it = items->getBeginTopItem(); it != items->getEndTopItem(); ++it)
{
if ((*it)->isSplash())
{
int32_t oldSplashIndex = __getIndexOfThing(*it);
Item* oldSplash = *it;
__removeThing(oldSplash, 1);
oldSplash->setParent(NULL);
g_game.FreeThing(oldSplash);
postRemoveNotification(oldSplash, NULL, oldSplashIndex, true);
break;
}
}
}
}
bool isInserted = false;
if (items)
{
for (ItemVector::iterator it = items->getBeginTopItem(); it != items->getEndTopItem(); ++it)
{
//Note: this is different from internalAddThing
if (Item::items[item->getID()].alwaysOnTopOrder <= Item::items[(*it)->getID()].alwaysOnTopOrder)
{
items->insert(it, item);
++thingCount;
isInserted = true;
break;
}
}
}
else
{
items = makeItemList();
}
if (!isInserted)
{
items->push_back(item);
++thingCount;
}
onAddTileItem(item);
}
else
{
if (item->isMagicField())
{
//remove old field item if exists
if (items)
{
MagicField* oldField = NULL;
for (ItemVector::iterator it = items->getBeginDownItem(); it != items->getEndDownItem(); ++it)
{
if ((oldField = (*it)->getMagicField()))
{
if (oldField->isReplaceable())
{
int32_t oldFieldIndex = __getIndexOfThing(*it);
__removeThing(oldField, 1);
oldField->setParent(NULL);
g_game.FreeThing(oldField);
postRemoveNotification(oldField, NULL, oldFieldIndex, true);
break;
}
else
{
//This magic field cannot be replaced.
item->setParent(NULL);
g_game.FreeThing(item);
return;
}
}
}
}
}
items = makeItemList();
items->insert(items->getBeginDownItem(), item);
++items->downItemCount;
++thingCount;
onAddTileItem(item);
}
}