本文整理汇总了C++中EntityManager::GetCurrentEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::GetCurrentEntity方法的具体用法?C++ EntityManager::GetCurrentEntity怎么用?C++ EntityManager::GetCurrentEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::GetCurrentEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FireAtTarget
void FireAtTarget(const MyEventReceiver& Receiver, EntityManager& PlayerManager, EntityManager& EnemyManager,
MazeRenderer& MR, irr::scene::ISceneManager *smgr, irr::scene::ISceneNode *Cursor)
{
if (PlayerManager.GetCurrentEntity()->CanShoot( Cursor->getPosition(), smgr->getSceneCollisionManager(), MR.MetaTriangleSelector ) )
{
//check if entity in target position (for now allow friendly fire)
if (EnemyManager.GetEntityThatResidesOnCell( irr::core::position2di( (int)(Cursor->getPosition().X)/10, (int)(Cursor->getPosition().Z)/10) ) != NULL)
{
Entity *Target = EnemyManager.GetEntityThatResidesOnCell( irr::core::position2di( (int)(Cursor->getPosition().X)/10, (int)(Cursor->getPosition().Z)/10 ) );
attackResult AR;
//cover only works if the target is adjacent to it
//check adjacency
//pointer to make code shorter
vector<std::string> *m = &Target->PathFinder.Map;
//have to look at each individually as multiple covers can be surrounding a cell........
irr::core::position2di TargetVec((int)(Target->Node->getPosition().Z/10), (int)(Target->Node->getPosition().X/10) );
bool coverHit = false;
//checks all the cells around the enemy and accounts for cover - to be honest i don't know wtf is going on, it works, and as long as i don't have to fix it, i'm not reading it again
for (int y = -1; y < 2 && !coverHit; y++)
{
for (int x = -1; x < 2 && !coverHit; x++)
{
if (!(y == 0 && x == 0)) //not middle
{
if ((*m)[TargetVec.Y+y][TargetVec.X+x] == 'C')
{
if (PlayerManager.GetCurrentEntity()->CoverHit(Target->Node->getPosition(),
smgr->getSceneCollisionManager(),
MR.MetaCoverTriangleSelector,
irr::core::vector3df(TargetVec.Y*10,
5,
TargetVec.X*10),x,y))
{
coverHit = true;
//make sure to break
x = 3;
y = 3;
break;
}
}
}
}
}
//get the attack result struct
AR = PlayerManager.GetCurrentEntity()->Stats.CalculateDamageOnTarget( Target->Stats, coverHit);
//calculate the result of the attack
if (!AR.Missed)
{
if (AR.Damage > 0)
{
Target->Stats.CurrentHealth -= AR.Damage;
Target->CheckIfDead();
}
else
{
//inform enemy too powerful
}
}
else
{
//inform of a miss!
}
}
}
return;
}