//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::InitEntityAudio( SHoldEntityDetails *pDetails )
{
	IEntity* pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
	if(pEntity)
	{
		pEntity->CreateProxy(ENTITY_PROXY_SOUND);
		UpdateEntityAudio(pDetails);
	}
}
void CLipSync_TransitionQueue::InjectLipSyncProvider()
{
	IEntity*           pEntity     = GetEntity();
	IEntityAudioProxy* pSoundProxy = static_cast<IEntityAudioProxy*>(pEntity->CreateProxy(ENTITY_PROXY_AUDIO).get());
	CRY_ASSERT(pSoundProxy);
	m_pLipSyncProvider.reset(new CLipSyncProvider_TransitionQueue(pEntity->GetId()));
	REINST(add SetLipSyncProvider to interface)
	//pSoundProxy->SetLipSyncProvider(m_pLipSyncProvider);
}
Beispiel #3
0
void CBoidObject::PlaySound( int nIndex )
{
	if (nIndex >= 0 && nIndex < (int)m_flock->m_bc.sounds.size())
	{
		IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entity);
		if (pEntity)
		{
			IEntitySoundProxy* pSndProxy = (IEntitySoundProxy*)pEntity->CreateProxy(ENTITY_PROXY_SOUND);
			Vec3 ofs(0,0,0),dir(FORWARD_DIRECTION);
			pSndProxy->PlaySound( m_flock->m_bc.sounds[nIndex],ofs,dir,FLAG_SOUND_DEFAULT_3D, 0, eSoundSemantic_Living_Entity );
		}
	}
}
Beispiel #4
0
void CBoidObject::ExecuteTrigger(int nIndex)
{
	if ((nIndex >= 0) && (nIndex < (int)m_flock->m_bc.audio.size()))
	{
		const TAudioControlID id = m_flock->m_bc.audio[nIndex];
		if (id != INVALID_AUDIO_CONTROL_ID)
		{
			IEntity* pEntity = gEnv->pEntitySystem->GetEntity(m_entity);
			if (pEntity)
			{
				IEntityAudioProxyPtr audioProxy = crycomponent_cast<IEntityAudioProxyPtr>(pEntity->CreateProxy(ENTITY_PROXY_AUDIO));

				if (audioProxy.get())
				{
					audioProxy->ExecuteTrigger(id, eLSM_None);
				}
			}
		}
	}
}
Beispiel #5
0
//------------------------------------------------------------------------
void CItem::FixResourceName(const ItemString &inName, TempResourceName &name, int flags, const char *hand, const char *suffix, const char *pose, const char *pov, const char *env)
{
	// the whole thing of fixing is not nice, but at least we don't allocate too often
	// StringHelper<TempResourceName::SIZE> name (inName.c_str(), inName.length());
	name.assign(inName.c_str(), inName.length());

	if(!hand)
	{
		if(m_stats.hand == eIH_Left)
			hand = "left";
		else
			hand = "right";
	}

	name.replace("%hand%", hand);

	if(m_stats.hand == eIH_Left)
		name.replace("%offhand%", "right");
	else
		name.replace("%offhand%", "left");

	if(!suffix)
		suffix = m_actionSuffix.c_str();

	name.replace("%suffix%", suffix);

	if(!pose)
	{
		if(!m_sharedparams->params.pose.empty())
			pose = m_sharedparams->params.pose.c_str();
		else
			pose = "";
	}

	name.replace("%pose%", "");

	if(!pov)
	{
		if((m_stats.fp || flags&eIPAF_ForceFirstPerson) && !(flags&eIPAF_ForceThirdPerson))
			pov = ITEM_FIRST_PERSON_TOKEN;
		else
			pov = ITEM_THIRD_PERSON_TOKEN;
	}

	name.replace("%pov%", pov);

	if(!env)
	{
		// Instead if the weapons sound proxy, the owners is used to retrieve the tail name
		IEntity *pOwner = GetOwner();

		if(GetIWeapon() && pOwner)  // restricting to weapon sounds only
		{
			if(pOwner)
			{
				IEntitySoundProxy *pSoundProxy = (IEntitySoundProxy *)pOwner->GetProxy(ENTITY_PROXY_SOUND);

				if(!pSoundProxy)
					pSoundProxy = (IEntitySoundProxy *)pOwner->CreateProxy(ENTITY_PROXY_SOUND);

				if(pSoundProxy)
				{
					// check for a roof 10m above the Owner
					// recalculate visibility when owner move more than 2 meters
					pSoundProxy->CheckVisibilityForTailName(10.0f, 2.0f);
					env = pSoundProxy->GetTailName();
				}
			}
		}


		if(!env || !env[0] || !stricmp("indoor", env))
			name.replace("%env%", "");
		else
		{
			static const size_t MAX_LEN = 256;
			char envstr[MAX_LEN];
			envstr[0] = '_';
			strncpy(envstr+1, env, MAX_LEN-1); // no 0 pad, if MAX_LEN-1 are copied
			envstr[MAX_LEN-1] = '\0'; // always zero-terminate
			name.replace("%env%", envstr);
		}
	}
	else
		name.replace("%env%", env);
}
//------------------------------------------------------------------------
EntityId CVehicleActionDeployRope::CreateRope(IPhysicalEntity* pLinkedEntity, const Vec3& highPos, const Vec3& lowPos)
{
	IEntitySystem* pEntitySystem = gEnv->pEntitySystem;
	assert(pEntitySystem);

	char pRopeName[256];
	_snprintf(pRopeName, 256, "%s_rope_%d", m_pVehicle->GetEntity()->GetName(), m_seatId);
	pRopeName[sizeof(pRopeName)-1] = '\0';

	SEntitySpawnParams params;
	params.sName = pRopeName;
	params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
	params.pClass = pEntitySystem->GetClassRegistry()->FindClass("RopeEntity");

	IEntity* pRopeEntity = pEntitySystem->SpawnEntity(params, true);
	if (!pRopeEntity)
		return 0;

	pRopeEntity->SetFlags(pRopeEntity->GetFlags() | ENTITY_FLAG_CASTSHADOW );

	pRopeEntity->CreateProxy(ENTITY_PROXY_ROPE);

	IEntityRopeProxy* pEntityRopeProxy = (IEntityRopeProxy*) pRopeEntity->GetProxy(ENTITY_PROXY_ROPE);
	if (!pEntityRopeProxy)
	{
		pEntitySystem->RemoveEntity(pRopeEntity->GetId());
		return 0;
	}

	IRopeRenderNode* pRopeNode = pEntityRopeProxy->GetRopeRendeNode();
	assert(pRopeNode);

	Vec3 ropePoints[2];
	ropePoints[0] = highPos;
	ropePoints[1] = lowPos;

	IRopeRenderNode::SRopeParams m_ropeParams;

	m_ropeParams.nFlags = IRopeRenderNode::eRope_CheckCollisinos | IRopeRenderNode::eRope_Smooth;
	m_ropeParams.fThickness = 0.05f;
	m_ropeParams.fAnchorRadius = 0.1f;
	m_ropeParams.nNumSegments = 8;
	m_ropeParams.nNumSides = 4;
	m_ropeParams.nMaxSubVtx = 3;
	m_ropeParams.nPhysSegments = 8;
	m_ropeParams.mass = 1.0f;
	m_ropeParams.friction = 2;
	m_ropeParams.frictionPull = 2;
	m_ropeParams.wind.Set(0,0,0);
	m_ropeParams.windVariance = 0;
	m_ropeParams.waterResistance = 0;
	m_ropeParams.jointLimit = 0;
	m_ropeParams.maxForce = 0;
	m_ropeParams.airResistance = 0;
	m_ropeParams.fTextureTileU = 1.0f;
	m_ropeParams.fTextureTileV = 10.0f;

	pRopeNode->SetParams(m_ropeParams);
	pRopeNode->SetPoints(ropePoints, 2);
	pRopeNode->SetEntityOwner(m_pVehicle->GetEntity()->GetId());

	pRopeNode->LinkEndEntities(m_pVehicle->GetEntity()->GetPhysics(), NULL);

	return pRopeEntity->GetId();
}
Beispiel #7
0
void CMFXEffect::Execute(SMFXRunTimeEffectParams& params)
{
	FUNCTION_PROFILER(gEnv->pSystem, PROFILE_ACTION);

	// TEMP Code: testing footsteps; can this stay here???
	IEntity *pEnt = NULL;

	if (m_effectParams.libName == "footstep_player")
	{
		if (params.audioProxyEntityId != 0)
		{
			pEnt = gEnv->pEntitySystem->GetEntity(params.audioProxyEntityId);

			if (pEnt != NULL)
			{
				IEntityAudioProxyPtr pIEntityAudioProxy = crycomponent_cast<IEntityAudioProxyPtr>(pEnt->CreateProxy(ENTITY_PROXY_AUDIO));

				TAudioControlID nFootstepTriggerID = INVALID_AUDIO_CONTROL_ID;
				gEnv->pAudioSystem->GetAudioTriggerID(m_effectParams.libName, nFootstepTriggerID);

				TAudioControlID nFirstPersonSwitchID		= INVALID_AUDIO_CONTROL_ID;
				TAudioSwitchStateID nFirstPersonStateID	= INVALID_AUDIO_SWITCH_STATE_ID;
				gEnv->pAudioSystem->GetAudioSwitchID("1stOr3rdP", nFirstPersonSwitchID);
				gEnv->pAudioSystem->GetAudioSwitchStateID(nFirstPersonSwitchID, params.playSoundFP ? "1stP" : "3rdP", nFirstPersonStateID);

				TAudioControlID nSurfaceSwitchID		= INVALID_AUDIO_CONTROL_ID;
				TAudioSwitchStateID nSurfaceStateID	= INVALID_AUDIO_SWITCH_STATE_ID;
				gEnv->pAudioSystem->GetAudioSwitchID("SurfaceType", nSurfaceSwitchID);
				gEnv->pAudioSystem->GetAudioSwitchStateID(nSurfaceSwitchID, m_effectParams.name, nSurfaceStateID);

				TAudioControlID nSpeedRtpcId = INVALID_AUDIO_CONTROL_ID;
				gEnv->pAudioSystem->GetAudioRtpcID("character_speed", nSpeedRtpcId);

				float fSpeed = 0.0f;

				for (int i=0; i < params.MAX_SOUND_PARAMS; ++i)
				{
					const char* soundParamName = params.soundParams[i].paramName;
					
					if ((soundParamName != NULL) && (soundParamName[0] != '\0') && (_stricmp(soundParamName, "speed") == 0))
					{
						float const fValue = params.soundParams[i].paramValue;
						CRY_ASSERT(NumberValid(fValue));

						fSpeed = fValue;
						break;
					}
				} 

				pIEntityAudioProxy->SetSwitchState(nFirstPersonSwitchID, nFirstPersonStateID);
				pIEntityAudioProxy->SetSwitchState(nSurfaceSwitchID, nSurfaceStateID);
				pIEntityAudioProxy->SetRtpcValue(nSpeedRtpcId, fSpeed);
				pIEntityAudioProxy->ExecuteTrigger(nFootstepTriggerID, eLSM_None);
			}
		}
	}
	else if ((m_effectParams.libName == "bulletimpacts") && ((params.playflags & MFX_PLAY_SOUND) != 0))
	{
		TAudioControlID nAudioTriggerID = INVALID_AUDIO_CONTROL_ID;
		gEnv->pAudioSystem->GetAudioTriggerID(m_effectParams.name, nAudioTriggerID);

		if (nAudioTriggerID != INVALID_AUDIO_CONTROL_ID)
		{
			IAudioProxy* const pIAudioProxy = gEnv->pAudioSystem->GetFreeAudioProxy();

			if (pIAudioProxy != NULL)
			{
				pIAudioProxy->Initialize("Projectile");
				pIAudioProxy->SetPosition(params.pos);
				pIAudioProxy->SetObstructionCalcType(eAOOCT_SINGLE_RAY);
				pIAudioProxy->SetCurrentEnvironments();
				pIAudioProxy->ExecuteTrigger(nAudioTriggerID, eLSM_None);
				pIAudioProxy->Release();
			}
		}
	}
	else if ((m_effectParams.libName == "collisions") && ((params.playflags & MFX_PLAY_SOUND) != 0))
	{
		TAudioControlID nAudioTriggerID = INVALID_AUDIO_CONTROL_ID;
		gEnv->pAudioSystem->GetAudioTriggerID(m_effectParams.name, nAudioTriggerID);

		if (nAudioTriggerID != INVALID_AUDIO_CONTROL_ID)
		{
			IAudioProxy* const pIAudioProxy = gEnv->pAudioSystem->GetFreeAudioProxy();

			if (pIAudioProxy != NULL)
			{
				pIAudioProxy->Initialize("Collision");
				pIAudioProxy->SetPosition(params.pos);
				pIAudioProxy->SetObstructionCalcType(eAOOCT_SINGLE_RAY);
				pIAudioProxy->SetCurrentEnvironments();
				pIAudioProxy->ExecuteTrigger(nAudioTriggerID, eLSM_None);
				pIAudioProxy->Release();
			}
		}
	}

	std::vector<IMFXEffectPtr>::iterator iter = m_effects.begin();
	std::vector<IMFXEffectPtr>::iterator iterEnd = m_effects.end();
	while (iter != iterEnd)
	{
		IMFXEffectPtr& cur = *iter;
		if (cur)
		{
			if (cur->CanExecute(params))
				cur->Execute(params);
		}
		++iter;
	}
}