本文整理汇总了C++中IAIObject::GetEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ IAIObject::GetEntity方法的具体用法?C++ IAIObject::GetEntity怎么用?C++ IAIObject::GetEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAIObject
的用法示例。
在下文中一共展示了IAIObject::GetEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsMountedWeaponUsableWithTarget
//////////////////////////////////////////////////////////////////////////
// IsMountedWeaponUsableWithTarget
// A piece of game-code moved from CryAction when scriptbind_AI moved to the AI system
//////////////////////////////////////////////////////////////////////////
int CScriptBind_Game::IsMountedWeaponUsableWithTarget(IFunctionHandler *pH)
{
int paramCount = pH->GetParamCount();
if(paramCount<2)
{
GameWarning("%s: too few parameters.", __FUNCTION__);
return pH->EndFunction();
}
GET_ENTITY(1);
if(!pEntity)
{
GameWarning("%s: wrong entity id in parameter 1.", __FUNCTION__);
return pH->EndFunction();
}
IAIObject* pAI = pEntity->GetAI();
if (!pAI)
{
GameWarning("%s: Entity '%s' does not have AI.",__FUNCTION__, pEntity->GetName());
return pH->EndFunction();
}
EntityId itemEntityId;
ScriptHandle hdl2;
if(!pH->GetParam(2,hdl2))
{
GameWarning("%s: wrong parameter 2 format.", __FUNCTION__);
return pH->EndFunction();
}
itemEntityId = (EntityId)hdl2.n;
if (!itemEntityId)
{
GameWarning("%s: wrong entity id in parameter 2.", __FUNCTION__);
return pH->EndFunction();
}
IGameFramework *pGameFramework = gEnv->pGame->GetIGameFramework();
IItem* pItem = pGameFramework->GetIItemSystem()->GetItem(itemEntityId);
if (!pItem)
{
//gEnv->pAISystem->Warning("<CScriptBind> ", "entity in parameter 2 is not an item/weapon");
GameWarning("%s: entity in parameter 2 is not an item/weapon.", __FUNCTION__);
return pH->EndFunction();
}
float minDist = 7;
bool bSkipTargetCheck = false;
Vec3 targetPos(ZERO);
if(paramCount > 2)
{
for(int i=3;i <= paramCount ; i++)
{
if(pH->GetParamType(i) == svtBool)
pH->GetParam(i,bSkipTargetCheck);
else if(pH->GetParamType(i) == svtNumber)
pH->GetParam(i,minDist);
else if(pH->GetParamType(i) == svtObject)
pH->GetParam(i,targetPos);
}
}
IAIActor* pAIActor = CastToIAIActorSafe(pAI);
if (!pAIActor)
{
GameWarning("%s: entity '%s' in parameter 1 is not an AI actor.", __FUNCTION__, pEntity->GetName());
return pH->EndFunction();
}
IEntity* pItemEntity = pItem->GetEntity();
if(!pItemEntity)
return pH->EndFunction();
if(!pItem->GetOwnerId())
{
// weapon is not used, check if it is on a vehicle
IEntity* pParentEntity = pItemEntity->GetParent();
if(pParentEntity)
{
IAIObject* pParentAI = pParentEntity->GetAI();
if(pParentAI && pParentAI->GetAIType()==AIOBJECT_VEHICLE)
{
// (MATT) Feature was cut and code was tricky, hence ignore weapons in vehicles {2008/02/15:11:08:51}
return pH->EndFunction();
}
}
}
else if( pItem->GetOwnerId()!= pEntity->GetId()) // item is used by someone else?
return pH->EndFunction(false);
//.........这里部分代码省略.........