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


C++ IEntity::GetAI方法代码示例

本文整理汇总了C++中IEntity::GetAI方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntity::GetAI方法的具体用法?C++ IEntity::GetAI怎么用?C++ IEntity::GetAI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEntity的用法示例。


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

示例1: AddRecordComment

void CGameAIRecorder::AddRecordComment(EntityId requesterId, const char* szComment)
{
	assert(szComment && szComment[0]);
	assert(requesterId > 0);
	assert(gEnv->bServer);

	if (m_bIsRecording && szComment && szComment[0])
	{
		if (!gEnv->bServer)
		{
			CryLogAlways("[AI] Recorder comment requested on Client. Only the Server can do this!");
			return;
		}

		IEntity *pEntity = gEnv->pEntitySystem->GetEntity(requesterId);
		IAIObject *pAI = pEntity ? pEntity->GetAI() : NULL;
		if (!pAI)
		{
			CryLogAlways("[AI] Attempting to add recorder comment, but the requester does not have an AI!");
			return;
		}

		// Output to log
		CryLogAlways("[AI] --- RECORDER COMMENT ADDED ---");
		CryLogAlways("[AI] By: %s", pEntity->GetName());
		CryLogAlways("[AI] Comment: %s", szComment);

		// Add comment to stream
		RecordLuaComment(pAI, "Comment: %s", szComment);
	}
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:31,代码来源:GameAIRecorder.cpp

示例2: 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

示例3: GetEntityType

EEntityType GetEntityType(EntityId id)
{
	int type = eET_Unknown;

	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	if (pEntitySystem)
	{
		IEntity *pEntity = pEntitySystem->GetEntity(id);
		if (pEntity)
		{
			type = eET_Valid;

			IEntityClass *pClass = pEntity->GetClass();
			if (pClass)
			{
				const char* className = pClass->GetName();

				// Check AI
				if (pEntity->GetAI())
				{
					type |= eET_AI;
				}
				
				// Check actor
				IActorSystem *pActorSystem = gEnv->pGame->GetIGameFramework()->GetIActorSystem();
				if (pActorSystem)
				{
					IActor *pActor = pActorSystem->GetActor(id);
					if (pActor)
					{
						type |= eET_Actor;
					}
				}

				// Check vehicle
				IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
				if (pVehicleSystem)
				{
					if (pVehicleSystem->IsVehicleClass(className))
					{
						type |= eET_Vehicle;
					}
				}

				// Check item
				IItemSystem *pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();
				if (pItemSystem)
				{
					if (pItemSystem->IsItemClass(className))
					{
						type |= eET_Item;
					}
				}
			}
		}
	}

	return (EEntityType)type;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:59,代码来源:FlowEntityIterator.cpp

示例4: AddEntityTag

void CPersistantDebug::AddEntityTag(const SEntityTagParams& params, const char *tagContext)
{
    // Create tag
    SEntityTag tag;
    tag.params = params;
    tag.params.column = max(1, tag.params.column);
    tag.params.visibleTime = max(0.f, tag.params.visibleTime);
    tag.params.fadeTime = max(0.f, tag.params.fadeTime);
    if (tagContext != NULL && *tagContext != '\0')
        tag.params.tagContext = tagContext;
    tag.totalTime = tag.params.visibleTime + tag.params.fadeTime;
    tag.totalFadeTime = tag.params.fadeTime;
    tag.vScreenPos.zero();

    SObj *obj = FindObj(params.entity);
    if (!obj)
    {
        // Create new object to push back
        SObj sobj;
        sobj.obj = eOT_EntityTag;
        sobj.entityId = params.entity;
        sobj.entityHeight = 0.f;
        sobj.timeRemaining = tag.totalTime;
        sobj.totalTime = tag.totalTime;
        sobj.columns.resize(params.column);
        AddToTagList(sobj.tags, tag);

        m_objects[entityTagsContext].push_back(sobj);
    }
    else
    {
        obj->timeRemaining = max(obj->timeRemaining, tag.totalTime);
        obj->totalTime = obj->timeRemaining;
        int size = max(int(obj->columns.size()), params.column);
        if (obj->columns.size() < size)
            obj->columns.resize(size);

        AddToTagList(obj->tags, tag);
    }

    if (m_pETLog->GetIVal() > 0)
    {
        IEntity *ent = gEnv->pEntitySystem->GetEntity(params.entity);
        if (ent)
        {
            CryLog("[Entity Tag] %s added tag: %s", ent->GetName(), params.text.c_str());

            if (m_pETLog->GetIVal() > 1)
            {
                char text[256];
                _snprintf(text, sizeof(text), "[Entity Tag] %s", params.text.c_str());
                gEnv->pAISystem->Record(ent->GetAI(), IAIRecordable::E_NONE, text);
            }
        }
    }
}
开发者ID:souxiaosou,项目名称:FireNET,代码行数:56,代码来源:EntityTags.cpp

示例5: 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

示例6: InitWithAI

//------------------------------------------------------------------------
void CProjectile::InitWithAI()
{
	// register with ai if needed
	//FIXME
	//make AI ignore grenades thrown by AI; needs proper/readable grenade reaction
	if (m_pAmmoParams->aiType!=AIOBJECT_NONE)
	{
		bool	isFriendlyGrenade(true);
		IEntity *pOwnerEntity = gEnv->pEntitySystem->GetEntity(m_ownerId);

		if (pOwnerEntity && pOwnerEntity->GetAI())
			isFriendlyGrenade = (pOwnerEntity->GetAI()->GetAIType() == AIOBJECT_ACTOR);

		if (!isFriendlyGrenade)
		{
			GetEntity()->RegisterInAISystem(AIObjectParams(m_pAmmoParams->aiType));
		}
	}
	GetGameObject()->SetAIActivation(eGOAIAM_Always);
}
开发者ID:nhnam,项目名称:Seasons,代码行数:21,代码来源:Projectile.cpp

示例7: 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

示例8: SetParams

//------------------------------------------------------------------------
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

示例9: GetMarkerColorForAgent

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

示例10: GetEntityAI

// Description:
//
// Arguments:
//
// Return:
//
IAIObject const* CPersonalRangeSignaling::GetEntityAI(EntityId entityId) const
{
	IAIObject const* pAIObject = NULL;

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(entityId);
	if (pEntity)
	{
		pAIObject = pEntity->GetAI();
	}

	return pAIObject;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:18,代码来源:PersonalRangeSignaling.cpp

示例11: SetParams

//------------------------------------------------------------------------
void CProjectile::SetParams(EntityId ownerId, EntityId hostId, EntityId weaponId, int fmId, int damage, int hitTypeId)
{
	m_ownerId = ownerId;
	m_weaponId = weaponId;
	m_fmId = fmId;
	m_hostId = hostId;
	m_damage = damage;
  m_hitTypeId = hitTypeId;

	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 
				IAIActor* pAIActor = CastToIAIActorSafe(pSelfEntity->GetAI());
				IAIActor* pShooterAIActor = CastToIAIActorSafe(pEntity->GetAI());
				if (pAIActor && pShooterAIActor)
				{
					AgentParameters ap = pAIActor->GetParameters();
					ap.m_nSpecies = pShooterAIActor->GetParameters().m_nSpecies;
					pAIActor->SetParameters(ap);
				}
			}
			if (m_pPhysicalEntity && m_pPhysicalEntity->GetType()==PE_PARTICLE)
			{
				pe_params_particle pparams;
				pparams.pColliderToIgnore = pEntity->GetPhysics();

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

示例12: HasAI

//------------------------------------------------------------------------
int CScriptBind_Action::HasAI(IFunctionHandler* pH, ScriptHandle entityId)
{
	bool bResult = false;

	const EntityId id = (EntityId)entityId.n;
	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(id);
	if (pEntity)
	{
		bResult = (pEntity->GetAI() != 0);
	}

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

示例13: SendSignal

// Description:
//
// Arguments:
//
// Return:
//
void CPersonalSignalTimer::SendSignal()
{
  CRY_ASSERT( m_bInit == true );

  IEntity *pEntity = GetEntity();
  if (pEntity && gEnv->pAISystem)
  {
    IAISignalExtraData*   pData = gEnv->pAISystem->CreateSignalExtraData();
    pData->iValue = ++m_iSignalsSinceLastReset;
    pData->fValue = m_fTimerSinceLastReset;

    gEnv->pAISystem->SendSignal( SIGNALFILTER_SENDER, 1, m_sSignal, pEntity->GetAI(), pData );
  }
}
开发者ID:aronarts,项目名称:FireNET,代码行数:20,代码来源:PersonalSignalTimer.cpp

示例14: GetAngleTo

// Description:
//
// Arguments:
//
// Return:
//
float CAngleAlert::GetAngleTo( const Vec3& vPos ) const
{
    float fResult = 0.0f;
    IEntity* pEntity = m_pPersonal->GetEntity();
    CRY_ASSERT(pEntity);
    if (pEntity)
    {
        const Vec3&  vEntityPos = pEntity->GetPos();
        const Vec3&  vEntityDir = pEntity->GetAI()->GetViewDir();
        Vec3  vDiff = vPos - vEntityPos;
        vDiff.NormalizeSafe();
        fResult = acosf(vEntityDir.Dot(vDiff));
    }
    return fResult;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:21,代码来源:AngleAlert.cpp

示例15: SetListener

// 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


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