本文整理汇总了C++中ThingPtr::asMissile方法的典型用法代码示例。如果您正苦于以下问题:C++ ThingPtr::asMissile方法的具体用法?C++ ThingPtr::asMissile怎么用?C++ ThingPtr::asMissile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThingPtr
的用法示例。
在下文中一共展示了ThingPtr::asMissile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeThing
void Map::removeThing(const ThingPtr& thing)
{
if(!thing)
return;
if(MissilePtr shot = thing->asMissile()) {
auto it = std::find(m_missilesAtFloor[shot->getPos().z].begin(), m_missilesAtFloor[shot->getPos().z].end(), shot);
if(it != m_missilesAtFloor[shot->getPos().z].end()) {
m_missilesAtFloor[shot->getPos().z].erase(it);
}
return;
}
else if(AnimatedTextPtr animatedText = thing->asAnimatedText()) {
auto it = std::find(m_animatedTexts.begin(), m_animatedTexts.end(), animatedText);
if(it != m_animatedTexts.end())
m_animatedTexts.erase(it);
return;
}
else if(StaticTextPtr staticText = thing->asStaticText()) {
auto it = std::find(m_staticTexts.begin(), m_staticTexts.end(), staticText);
if(it != m_staticTexts.end())
m_staticTexts.erase(it);
return;
}
if(TilePtr& tile = m_tiles[thing->getPos()])
tile->removeThing(thing);
}
示例2: addThing
void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
{
if(!thing)
return;
Position oldPos = thing->getPos();
bool teleport = false;
if(oldPos.isValid() && !oldPos.isInRange(pos,1,1,0))
teleport = true;
TilePtr tile = getTile(pos);
if(CreaturePtr creature = thing->asCreature()) {
tile->addThing(thing, stackPos);
m_creatures[creature->getId()] = creature;
if(teleport)
g_game.processCreatureTeleport(creature);
}
else if(MissilePtr shot = thing->asMissile()) {
m_missilesAtFloor[shot->getPos().z].push_back(shot);
}
else if(AnimatedTextPtr animatedText = thing->asAnimatedText()) {
m_animatedTexts.push_back(animatedText);
}
else if(StaticTextPtr staticText = thing->asStaticText()) {
bool mustAdd = true;
for(auto it = m_staticTexts.begin(), end = m_staticTexts.end(); it != end; ++it) {
StaticTextPtr cStaticText = *it;
if(cStaticText->getPos() == pos) {
// try to combine messages
if(cStaticText->addMessage(staticText->getName(), staticText->getMessageType(), staticText->getFirstMessage())) {
mustAdd = false;
break;
}
else {
// must add another message and rearrenge current
}
}
}
if(mustAdd)
m_staticTexts.push_back(staticText);
}
else {
tile->addThing(thing, stackPos);
}
thing->start();
thing->setPos(pos);
}
示例3: removeThing
void Map::removeThing(const ThingPtr& thing)
{
if(!thing)
return;
if(MissilePtr shot = thing->asMissile()) {
auto it = std::find(m_missilesAtFloor[shot->getPosition().z].begin(), m_missilesAtFloor[shot->getPosition().z].end(), shot);
if(it != m_missilesAtFloor[shot->getPosition().z].end()) {
m_missilesAtFloor[shot->getPosition().z].erase(it);
}
return;
}
if(TilePtr& tile = m_tiles[thing->getPosition()])
tile->removeThing(thing);
}
示例4: addThing
void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
{
if(!thing)
return;
if(MissilePtr shot = thing->asMissile()) {
m_missilesAtFloor[shot->getPosition().z].push_back(shot);
return;
}
TilePtr tile = getTile(pos);
tile->addThing(thing, stackPos);
if(CreaturePtr creature = thing->asCreature())
m_creatures[creature->getId()] = creature;
}