当前位置: 首页>>代码示例>>C++>>正文


C++ IAIObject类代码示例

本文整理汇总了C++中IAIObject的典型用法代码示例。如果您正苦于以下问题:C++ IAIObject类的具体用法?C++ IAIObject怎么用?C++ IAIObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IAIObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetActor

//------------------------------------------------------------------------
int CScriptBind_Actor::Fall(IFunctionHandler *pH, Vec3 hitPos)
{
	CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();

	// [Mikko] 11.10.2007 - Moved the check here, since it was causing too much trouble in CActor.Fall().
	// The point of this filtering is to mostly mask out self-induced collision damage on friendly NPCs
	// which are playing special animations.
	if(!g_pGameCVars->g_enableFriendlyFallAndPlay)
	{
		if (IAnimatedCharacter* pAC = pActor->GetAnimatedCharacter())
		{
			if ((pAC->GetPhysicalColliderMode() == eColliderMode_NonPushable) ||
				(pAC->GetPhysicalColliderMode() == eColliderMode_PushesPlayersOnly))
			{
				// Only mask for player friendly NPCs.
				if (pActor->GetEntity() && pActor->GetEntity()->GetAI())
				{
					IAIObject* pAI = pActor->GetEntity()->GetAI();
					IAIActor* pAIActor = pAI->CastToIAIActor();
					if (pAIActor && pAIActor->GetParameters().m_nSpecies == 0)
					{
						return pH->EndFunction();
					}
				}
			}
		}
	}

	pActor->Fall(hitPos);

	return pH->EndFunction();
}
开发者ID:mrwonko,项目名称:CrysisVR,代码行数:35,代码来源:ScriptBind_Actor.cpp

示例2: DoLookAt

bool CDialogActorContext::DoLookAt(IEntity *pEntity, IEntity *pLookAtEntity, bool& bReachedTarget)
{
	bReachedTarget = false;
	IAIObject* pAI = pEntity->GetAI();
	if (pAI == 0)
		return false;

	IAIActor* pAIActor = pAI->CastToIAIActor();
	if (!pAIActor)
	{
		return false;
	}

	if (pLookAtEntity == 0)
	{
		pAIActor->ResetLookAt();
		bReachedTarget = true;
		m_bLookAtNeedsReset = false;
	}
	else
	{
		IAIObject* pTargetAI = pLookAtEntity->GetAI();
		Vec3 pos = pTargetAI ? pTargetAI->GetPos() : pLookAtEntity->GetWorldPos();
		bReachedTarget = pAIActor->SetLookAtPointPos(pos, true);
		m_bLookAtNeedsReset = true;
	}

	return true;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:29,代码来源:DialogActorContext.cpp

示例3: FilterFriendlyAIHit

bool CCannonBall::FilterFriendlyAIHit(IEntity* pHitTarget)
{
	bool bResult = false;

	if (!gEnv->bMultiplayer && pHitTarget)
	{
		const bool bIsClient = (m_ownerId == g_pGame->GetIGameFramework()->GetClientActorId());
		IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(m_ownerId);

		//Filter client hits against friendly AI
		if (pOwnerEntity && bIsClient)
		{
			IAIObject *pOwnerAI = pOwnerEntity->GetAI();
			IAIObject *pTargetAI = pHitTarget->GetAI();
			if (pOwnerAI && pTargetAI && !pTargetAI->IsHostile(pOwnerAI))
			{
				const bool bEnableFriendlyHit = g_pGameCVars->g_enableFriendlyPlayerHits != 0;
				if (!bEnableFriendlyHit)
				{
					g_pGame->GetGameRules()->SetEntityToIgnore(pHitTarget->GetId());
					bResult = true;
				}
			}
		}
	}

	return bResult;
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:28,代码来源:CannonBall.cpp

示例4: ExecuteAI

bool CDialogActorContext::ExecuteAI(int& goalPipeID, const char* signalText, IAISignalExtraData* pExtraData, bool bRegisterAsListener)
{
	IEntitySystem* pSystem = gEnv->pEntitySystem;
	IEntity* pEntity = pSystem->GetEntity(m_entityID);
	if (pEntity == 0)
		return false;

	IAIObject* pAI = pEntity->GetAI();
	if (pAI == 0)
		return false;

	unsigned short nType=pAI->GetAIType();
	if ( nType != AIOBJECT_ACTOR )
	{
		if ( nType == AIOBJECT_PLAYER )
		{
			goalPipeID = -1;

			// not needed for player 
			// pAI->SetSignal( 10, signalText, pEntity, NULL ); // 10 means this signal must be sent (but sent[!], not set)
			// even if the same signal is already present in the queue
			return true;
		}

		// invalid AIObject type
		return false;
	}

	IPipeUser* pPipeUser = pAI->CastToIPipeUser();
	if (pPipeUser)
	{
		if (goalPipeID > 0)
		{
			pPipeUser->RemoveSubPipe(goalPipeID, true);
			pPipeUser->UnRegisterGoalPipeListener( this, goalPipeID );
			goalPipeID = 0;
		}
	}

	goalPipeID = gEnv->pAISystem->AllocGoalPipeId();
	if (pExtraData == 0)
		pExtraData = gEnv->pAISystem->CreateSignalExtraData();
	pExtraData->iValue = goalPipeID;
	
	if (pPipeUser && bRegisterAsListener)
	{
		pPipeUser->RegisterGoalPipeListener( this, goalPipeID, "CDialogActorContext::ExecuteAI");
	}

	IAIActor* pAIActor = CastToIAIActorSafe(pAI);
	if(pAIActor)
		pAIActor->SetSignal( 10, signalText, pEntity, pExtraData ); // 10 means this signal must be sent (but sent[!], not set)
	// even if the same signal is already present in the queue
	return true;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:55,代码来源:DialogActorContext.cpp

示例5: GetActorOfName

void CGameStateRecorder::StartSession()
{
	m_GameStates.clear();
	m_itSingleActorGameState = m_GameStates.end();
	m_IgnoredEvents.clear();

	const char* filterName = m_demo_actorFilter->GetString();
	// send game events to record the initial game state
/*	if(m_mode)
	{
		CActor *pActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
*/
		
	m_pSingleActor = GetActorOfName(filterName);
	if(m_pSingleActor)// && !pActor->GetSpectatorMode() && pActor->IsPlayer())
	{
		m_mode = GPM_SingleActor;
		AddActorToStats(m_pSingleActor);
		m_itSingleActorGameState = m_GameStates.begin();// position of requested actor's id (player by default)
	}
//	}
	else if (!strcmpi(filterName,"all"))
	{
		IAIObjectManager* pAIObjMgr = gEnv->pAISystem->GetAIObjectManager();

		m_mode = GPM_AllActors;
		{
			AutoAIObjectIter it(pAIObjMgr->GetFirstAIObject(OBJFILTER_TYPE, AIOBJECT_ACTOR));
			for(; it->GetObject(); it->Next())
			{
				IAIObject* pObject = it->GetObject();
				if(pObject)
				{
					CActor* pActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pObject->GetEntityID()));
					if(pActor)
						AddActorToStats(pActor);
				}
			}
		}
		
		{
			AutoAIObjectIter it(pAIObjMgr->GetFirstAIObject(OBJFILTER_TYPE, AIOBJECT_VEHICLE));
			for(; it->GetObject(); it->Next())
			{
				IAIObject* pObject = it->GetObject();
				if(pObject)
				{
					CActor* pActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pObject->GetEntityID()));
					if(pActor)
						AddActorToStats(pActor);
				}
			}
		}
	}
}
开发者ID:kitnet,项目名称:project-o,代码行数:55,代码来源:GameStateRecorder.cpp

示例6: SetAimQueryMode

//------------------------------------------------------------------------
int CScriptBind_Action::SetAimQueryMode(IFunctionHandler* pH, ScriptHandle entityId, int mode)
{
	IEntity* entity = gEnv->pEntitySystem->GetEntity(static_cast<EntityId>(entityId.n));
	IAIObject* ai = entity ? entity->GetAI() : NULL;
	CAIProxy* proxy = ai ? static_cast<CAIProxy*>(ai->GetProxy()) : NULL;

	if (proxy)
		proxy->SetAimQueryMode(static_cast<CAIProxy::AimQueryMode>(mode));

	return pH->EndFunction();
}
开发者ID:aronarts,项目名称:FireNET,代码行数:12,代码来源:ScriptBind_Action.cpp

示例7: GetBattleFrontObject

IAIObject* CTacticalPointLanguageExtender::GetBattleFrontObject() const
{
	IAIObjectManager* pAIObjMgr = gEnv->pAISystem->GetAIObjectManager();
	IAIObject *pObj = pAIObjMgr->GetAIObject(m_battlefrontAIObject);

	if (!pObj)
	{
		// Not created or has been removed (by reset, etc), so create one
		ITacticalPointSystem& tacticalPointSystem = *gEnv->pAISystem->GetTacticalPointSystem();
		pObj = tacticalPointSystem.CreateExtenderDummyObject("Game_BattleFront");
		assert(pObj);
		m_battlefrontAIObject = pObj ? pObj->GetAIObjectID() : 0;
	}
	return pObj;
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:15,代码来源:TacticalPointLanguageExtender.cpp

示例8: DoAnimActionEP

bool CDialogActorContext::DoAnimActionEP(IEntity* pEntity, const char* sAction)
{
	IAIObject* pAI = pEntity->GetAI();
	if (pAI == 0)
		return false;

	IPipeUser* pPipeUser = pAI->CastToIPipeUser();
	if (!pPipeUser)
	{
		return false;
	}

	Vec3 pos = pEntity->GetWorldPos();
	Vec3 dir = pAI->GetMoveDir();

	// EP Direction is either lookat direction or forward direction
	CDialogScript::TActorID lookAt = m_pCurLine->m_lookatActor;
	if (lookAt != CDialogScript::NO_ACTOR_ID)
	{
		IEntity* pLookAtEntity = m_pSession->GetActorEntity(lookAt);
		if (pLookAtEntity != 0)
		{
			dir = pLookAtEntity->GetWorldPos();
			dir -= pos;
			dir.z = 0;
			dir.NormalizeSafe(pAI->GetMoveDir());
		}
	}
	pPipeUser->SetRefPointPos(pos, dir);

	static const Vec3 startRadius (0.1f,0.1f,0.1f);
	static const float dirTolerance = 5.f;
	static const float targetRadius = 0.05f;

	IAISignalExtraData* pData = gEnv->pAISystem->CreateSignalExtraData();
	pData->iValue2 = m_bAnimUseAGSignal ? 1 : 0;
	pData->SetObjectName(sAction);
	pData->point = startRadius;
	pData->fValue = dirTolerance;
	pData->point2.x = targetRadius;

	const bool ok = ExecuteAI(m_exPosAnimPipeID, "ACT_ANIMEX", pData);
	return ok;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:44,代码来源:DialogActorContext.cpp

示例9: GetEntity

// Description:
//
// Arguments:
//
// Return:
//
void CPersonalSignalTimer::SetListener(bool bAdd)
{
	IEntity *pEntity = GetEntity();;
	if (pEntity)
	{
		IAIObject *pAIObject = pEntity->GetAI();
		if (pAIObject)
		{
			CAIProxy* pAIProxy = (CAIProxy*)pAIObject->GetProxy();
			if (pAIProxy)
			{
				if (bAdd)
					pAIProxy->AddListener(this);
				else
					pAIProxy->RemoveListener(this);
			}
		}
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:25,代码来源:PersonalSignalTimer.cpp

示例10: GetEntity

//------------------------------------------------------------------------
void CProjectile::SetParams(EntityId ownerId, EntityId hostId, EntityId weaponId, int damage, int hitTypeId, float damageDrop /*= 0.0f*/, float damageDropMinR /*=0.0f*/)
{
	m_ownerId = ownerId;
	m_weaponId = weaponId;
	m_hostId = hostId;
	m_damage = damage;
	m_hitTypeId = hitTypeId;
	m_damageDropPerMeter = damageDrop;
	m_damageDropMinDisSqr = damageDropMinR*damageDropMinR;

	if(m_hostId || m_ownerId)
	{
		IEntity *pSelfEntity = GetEntity();

		if(pSelfEntity)
			pSelfEntity->AddEntityLink("Shooter", m_ownerId);

		IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_hostId?m_hostId:m_ownerId);

		if(pEntity)
		{
			if(pSelfEntity)
			{
				//need to set AI species to the shooter - not to be scared of it's own rockets
				IAIObject *projectileAI = pSelfEntity->GetAI();
				IAIObject *shooterAI = pEntity->GetAI();

				if(projectileAI && shooterAI)
					projectileAI->SetFactionID(shooterAI->GetFactionID());
			}

			if(m_pPhysicalEntity && m_pPhysicalEntity->GetType()==PE_PARTICLE)
			{
				pe_params_particle pparams;
				pparams.pColliderToIgnore = pEntity->GetPhysics();

				m_pPhysicalEntity->SetParams(&pparams);
			}
		}
	}
}
开发者ID:Hellraiser666,项目名称:CryGame,代码行数:42,代码来源:Projectile.cpp

示例11: stalker

void StalkerModule::UpdateInstance(StalkerInstance& instance, float frameTime)
{
	Agent stalker(instance.GetEntityID());

	IAIObject* liveTarget = (stalker.IsValid() ? stalker.GetLiveTarget() : NULL);
	if (liveTarget)
	{
		if (instance.asyncState == AsyncReady)
		{
			instance.asyncState = AsyncInProgress;
			QueueLineOfSightRay(stalker, liveTarget, instance);
		}

		bool inTargetFov = liveTarget->IsPointInFOV(stalker.GetPos()) == IAIObject::eFOV_Primary;
		if (instance.lastInTargetFov != inTargetFov)
		{
			instance.lastInTargetFov = inTargetFov;
			instance.SendSignal(inTargetFov ? "OnInTargetFov" : "OnNotInTargetFov");
		}
	}
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:21,代码来源:StalkerModule.cpp

示例12: GetLocalPlayerFaction

uint8 CAutoAimManager::GetLocalPlayerFaction() const
{
	if (m_localPlayerFaction != IFactionMap::InvalidFactionID)
	{
		return m_localPlayerFaction;
	}
	else
	{
		IEntity* pLocalPlayerEntity = gEnv->pEntitySystem->GetEntity(g_pGame->GetIGameFramework()->GetClientActorId());
		if (pLocalPlayerEntity)
		{
			IAIObject* pAIObject = pLocalPlayerEntity->GetAI();
			if (pAIObject)
			{
				m_localPlayerFaction = pAIObject->GetFactionID();
			}
		}
	}

	return m_localPlayerFaction;
}
开发者ID:Xydrel,项目名称:Infected,代码行数:21,代码来源:AutoAimManager.cpp

示例13: GetAlertnessAffectedByVisibility

CAIAwarenessToPlayerHelper::VisorIconColor CAIAwarenessToPlayerHelper::GetMarkerColorForAgent(const EntityId entityId) const
{
	CAIAwarenessToPlayerHelper::VisorIconColor defaultColor = Green;
	IEntity* entity = gEnv->pEntitySystem->GetEntity(entityId);
	const IAIObject* ai = entity ? entity->GetAI() : NULL;
	const IAIActor* aiActor = ai ? ai->CastToIAIActor() : NULL;
	IAIObject* playerAiObject = NULL;
	CActor* playerActor = static_cast<CActor*>(gEnv->pGame->GetIGameFramework()->GetClientActor());
	if (playerActor)
	{
		if (IEntity* playerEntity = playerActor->GetEntity())
		{
			playerAiObject = playerEntity->GetAI();
		}
	}
	if (!playerActor || !playerAiObject)
		return defaultColor;

	const bool playerIsCloaked = playerActor->IsCloaked();

	if (aiActor)
	{
		const int alertness = GetAlertnessAffectedByVisibility(*aiActor, *playerAiObject, playerIsCloaked);

		if (alertness == 0)
			return Green;
		else if (alertness == 1)
			return Orange;
		else
			return Red;
	}
	else
	{
		// Turrets are not AI actors so they are treated a bit differently
		// TODO: extend this to generic IAwarenessEntity. for now in C3 is fine as we dont want Towers to be show here.
		if (CTurret* turret = TurretHelpers::FindTurret(entityId))
		{
			if (IEntity* turretEntity = turret->GetEntity())
			{
				if (IAIObject* turretAI = turretEntity->GetAI())
				{
					const bool turretIsDeployed = (turret->GetStateId() == eTurretBehaviorState_Deployed);
					if (!playerIsCloaked && turretIsDeployed && turretAI->IsHostile(playerAiObject) && turret->IsVisionIdInVisionRange(playerAiObject->GetVisionID()))
						return Red;
					else
						return Green;
				}
			}
		}
	}

	return defaultColor;
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:53,代码来源:AIAwarenessToPlayerHelper.cpp

示例14: assert

bool CTacticalPointLanguageExtender::GetObject(TObjectParameters& parameters) const
{
	CAIBattleFrontGroup* battleFrontGroup = gGameAIEnv.battleFrontModule
		->GetGroupForEntity(parameters.pOwner.actorEntityId);

	assert(battleFrontGroup);
	if (!battleFrontGroup)
	{
		gEnv->pLog->LogError("CTacticalPointLanguageExtender::GetObject: Couldn't get battlefront group for entity %d", parameters.pOwner.actorEntityId);
		return false;
	}

	IAIObject * pBattleFrontAIObject = GetBattleFrontObject();
	assert(pBattleFrontAIObject);
	if (!pBattleFrontAIObject)
			return false;

	pBattleFrontAIObject->SetPos(battleFrontGroup->GetBattleFrontPosition());

	// Return the result
	// (MATT) The interface is poor for this - it shouldn't need a pointer {2009/12/01}
	parameters.result = pBattleFrontAIObject;
	return true;
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:24,代码来源:TacticalPointLanguageExtender.cpp

示例15: GetTargetFaction

uint8 CAutoAimManager::GetTargetFaction( IEntity& targetEntity ) const
{
	IAIObject* pAIObject = targetEntity.GetAI();
	return pAIObject ? pAIObject->GetFactionID() : IFactionMap::InvalidFactionID;
}
开发者ID:Xydrel,项目名称:Infected,代码行数:5,代码来源:AutoAimManager.cpp


注:本文中的IAIObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。