void CVTOLVehicleManager::OnEntityEvent( IEntity *pEntity, SEntityEvent &event )
{
	if(event.event == ENTITY_EVENT_DONE)
	{
		EntityId entityId = pEntity->GetId();
		m_vtolList.erase(entityId);
		gEnv->pEntitySystem->RemoveEntityEventListener(entityId, ENTITY_EVENT_RESET, this);
		gEnv->pEntitySystem->RemoveEntityEventListener(entityId, ENTITY_EVENT_DONE, this);
		gEnv->pEntitySystem->RemoveEntityEventListener(entityId, ENTITY_EVENT_HIDE, this);
		gEnv->pEntitySystem->RemoveEntityEventListener(entityId, ENTITY_EVENT_UNHIDE, this);
	}
	else if(event.event == ENTITY_EVENT_RESET)
	{
		// Only on leaving the editor gamemode
		if(event.nParam[0] == 0)
		{
			ResetVehicle(m_vtolList[pEntity->GetId()]);
		}
	}
	else if(event.event == ENTITY_EVENT_HIDE)
	{
		// Remove from HUD radar
		SHUDEvent hudEvent(eHUDEvent_RemoveEntity);
		hudEvent.AddData((int)pEntity->GetId());
		CHUDEventDispatcher::CallEvent(hudEvent);
	}
	else if(event.event == ENTITY_EVENT_UNHIDE)
	{
		// Add to HUD radar
		SHUDEvent hudEvent(eHUDEvent_AddEntity);
		hudEvent.AddData((int)pEntity->GetId());
		CHUDEventDispatcher::CallEvent(hudEvent);
	}
}
Example #2
0
void CC4Projectile::SetupUIIcon()
{
	if(GetEntityId())
	{
		const bool dangerous = !m_OnSameTeam || g_pGame->GetGameRules()->GetFriendlyFireRatio() > 0.f;
		//If the C4 can't harm us we show a C4 icon (ThreatAwareness shows enemy C4 as well)
		const CPlayer* pPlayer = static_cast<CPlayer*>(gEnv->pGame->GetIGameFramework()->GetClientActor());
		const bool shouldShow = !dangerous;
		if(shouldShow && !m_isShowingUIIcon)
		{
			SHUDEvent hudEvent(eHUDEvent_OnC4Spawned);
			hudEvent.AddData((int)GetEntityId());
			hudEvent.AddData((bool)dangerous);
			CHUDEventDispatcher::CallEvent(hudEvent);
			m_isShowingUIIcon = true;
		}
		else if(m_isShowingUIIcon && !shouldShow)
		{
			SHUDEvent hudEvent(eHUDEvent_RemoveC4Icon);
			hudEvent.AddData((int)GetEntityId());
			CHUDEventDispatcher::CallEvent(hudEvent);
			m_isShowingUIIcon = false;
		}
	}
}
bool CHUDMissionObjectiveSystem::StartObjectiveAnalysis(const char* szKey, const EObjectiveAnalysisMode analysisMode)
{
	const SObjectiveAnalysisData* pObjectiveAnalysisData = GetObjectiveAnalysisData(szKey);
	if (pObjectiveAnalysisData)
	{
		if (m_currentAnalysis.empty())
		{
			m_currentAnalysis = szKey;
			SHUDEvent hudEvent(eHUDEvent_OnObjectiveAnalysis);
			hudEvent.AddData(SHUDEventData(eOAE_Start));
			hudEvent.AddData(SHUDEventData(szKey));
			hudEvent.AddData(SHUDEventData((const void*)pObjectiveAnalysisData));
			hudEvent.AddData(SHUDEventData((int)analysisMode));
			CHUDEventDispatcher::CallEvent(hudEvent);
			return true;
		}
		else
		{
			GameWarning("CHUDMissionObjectiveSystem::StartObjectiveAnalysis: Can't start analysis: %s, when analysis: %s is already in progress", m_currentAnalysis.c_str(), szKey);
			return false;
		}
	}
	else
	{
		GameWarning("CHUDMissionObjectiveSystem::StartObjectiveAnalysis: Failed to find objective analysis data: %s", szKey);
		return false;
	}
}
//------------------------------------------------------------------------
void CVehicleMountedWeapon::StartUse(EntityId userId)
{
	IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId);
	if (!IsRippingOff() && pVehicle)
	{ 
		m_pOwnerSeat = pVehicle->GetWeaponParentSeat(GetEntityId());
		m_pSeatUser = pVehicle->GetSeatForPassenger(userId);

		IActor* pOwner = GetOwnerActor();
		if (pOwner && !pOwner->IsPlayer())
		{
			SHUDEvent hudEvent(eHUDEvent_AddEntity);
			hudEvent.AddData((int)pVehicle->GetEntityId());
			CHUDEventDispatcher::CallEvent(hudEvent);
		}

		ClearItemFlags(eIF_InformClientsAboutUse);
 	}

	CHeavyMountedWeapon::StartUse(userId);

	CActor* pActor = GetOwnerActor();
	if (pActor && pActor->IsPlayer())
	{
		static_cast<CPlayer*>(pActor)->RefreshVisibilityState();
	}
}
// message from server received on clients
void CVTOLVehicleManager::OnSingleEntityRMI(CGameRules::SModuleRMIEntityParams params)
{
	switch(params.m_data)
	{
		case eRMITypeSingleEntity_vtol_destroyed:
		{
			CryLog("CVTOLVehicleManager::OnSingleEntityRMI() eRMITypeSingleEntity_vtol_destroyed");
			IVehicle* pVehicle = m_pVehicleSystem->GetVehicle( params.m_entityId );
			CRY_ASSERT_MESSAGE(pVehicle, "have received destroyed VTOL RMI, but cannot find the vehicle for specified entity id");
			if (pVehicle)
			{
				DestroyVTOL(pVehicle->GetEntity(), m_vtolList[params.m_entityId]);
			}
			break;
		}
		case eRMITypeSingleEntity_vtol_hidden:				// for late joining clients only
		{

			CryLog("CVTOLVehicleManager::OnSingleEntityRMI() eRMITypeSingleEntity_vtol_hidden");
			IVehicle* pVehicle = m_pVehicleSystem->GetVehicle(params.m_entityId);
			CRY_ASSERT_MESSAGE(pVehicle, "have received hidden VTOL RMI, but cannot find the vehicle for specified entity id");
			if (pVehicle)
			{		
				//Hide existing vehicle
				IEntity* pVehicleEntity = pVehicle->GetEntity();
				pVehicleEntity->SetPos(Vec3(0.f,0.f,0.f));	// TODO - get Gary's fix for this if any
				pVehicleEntity->Hide(true);

				SVTOLInfo& info = m_vtolList[params.m_entityId];
				info.state = EVS_Invisible;
				info.stateTime = 0.f;		// this may allow clients to do their own respawn handling, stopping the need for respawned RMI below

				SHUDEvent hudEvent(eHUDEvent_RemoveEntity);
				hudEvent.AddData((int)params.m_entityId);
				CHUDEventDispatcher::CallEvent(hudEvent);
			}
			break;
		}
		case eRMITypeSingleEntity_vtol_respawned:
		{
			CryLog("CVTOLVehicleManager::OnSingleEntityRMI() eRMITypeSingleEntity_vtol_respawned");
			IVehicle* pVehicle = m_pVehicleSystem->GetVehicle(params.m_entityId);
			CRY_ASSERT_MESSAGE(pVehicle, "have received respawned VTOL RMI, but cannot find the vehicle for specified entity id");
			if (pVehicle)
			{
				RespawnVTOL(pVehicle, m_vtolList[params.m_entityId]);
			}
			break;
		}
		default:
			CRY_ASSERT_MESSAGE(0, string().Format("unhandled RMI data %d", params.m_data));
			break;
	}
}
void CVehicleWeaponControlled::StartUse(EntityId userId)
{
  Base::StartUse(userId);
  m_CurrentTime = 0.5f;

  IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId);
  if (pVehicle)
  {
	  SHUDEvent hudEvent(eHUDEvent_AddEntity);
	  hudEvent.AddData((int)pVehicle->GetEntityId());
	  CHUDEventDispatcher::CallEvent(hudEvent);
  }
}
void CVTOLVehicleManager::OnOwnClientEnteredGame()
{
	for(TVTOLList::const_iterator iter=m_vtolList.begin(), end=m_vtolList.end(); iter!=end; ++iter)
	{
		const EntityId entityId = iter->second.entityId;
		if(IEntity* pEntity = gEnv->pEntitySystem->GetEntity(entityId))
		{
			if(!pEntity->IsHidden())
			{
				SHUDEvent hudEvent(eHUDEvent_AddEntity);
				hudEvent.AddData((int)entityId);
				CHUDEventDispatcher::CallEvent(hudEvent);
			}
		}
	}
}
Example #8
0
void CC4Projectile::OnExplosion( const ExplosionInfo& explosionInfo)
{
	if(explosionInfo.projectileId == GetEntityId())
	{
		RemoveLight();

		bool dangerous = !m_OnSameTeam || g_pGame->GetGameRules()->GetFriendlyFireRatio() > 0.f;
		if(gEnv->bMultiplayer && !dangerous && (!gEnv->bServer || !gEnv->IsDedicated()))
		{
			SHUDEvent hudEvent(eHUDEvent_RemoveC4Icon);
			hudEvent.AddData((int)GetEntityId());
			CHUDEventDispatcher::CallEvent(hudEvent);
		}
	}

	CProjectile::OnExplosion(explosionInfo);
}
void CHUDMissionObjectiveSystem::StopObjectiveAnalysis(const bool bSignalResultingObjective)
{
	if (!m_currentAnalysis.empty())
	{
		CHUDMissionObjective* pMissionObjective = GetMissionObjective(m_currentAnalysis); // May not be one if only showing UI screen anims without actual objectives for world anims
		if (pMissionObjective)
		{
			pMissionObjective->SetStatus(CHUDMissionObjective::ACTIVATED);
		}

		SHUDEvent hudEvent(eHUDEvent_OnObjectiveAnalysis);
		hudEvent.AddData(SHUDEventData(eOAE_Stop));
		CHUDEventDispatcher::CallEvent(hudEvent);

		m_currentAnalysis = "";
	}
}
Example #10
0
void CC4Projectile::Update(SEntityUpdateContext &ctx, int updateSlot)
{
	if(gEnv->bMultiplayer)
	{
		IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerId);
		if(!pActor || pActor->IsDead())
		{
			if(gEnv->bServer)
			{
				Destroy();
			}
			else
			{
				GetEntity()->Hide(true);
			}

			RemoveLight();
			if(m_isShowingUIIcon)
			{
				SHUDEvent hudEvent(eHUDEvent_RemoveC4Icon);
				hudEvent.AddData((int)GetEntityId());
				CHUDEventDispatcher::CallEvent(hudEvent);
				m_isShowingUIIcon = false;
			}
		}
	}

	if(m_pLightSource)
	{
		UpdateLight(ctx.fFrameTime, false);
	}

	if(m_disarmTimer > 0.f)
	{
		m_disarmTimer -= ctx.fFrameTime;
		if(m_disarmTimer <= 0.f)
		{
			m_disarmTimer = 0.f;
			Arm(true);
		}
	}

	BaseClass::Update(ctx, updateSlot);
}
Example #11
0
void CVTOLVehicleManager::DestroyVTOL(IEntity *pVTOL, SVTOLInfo &info)
{
	const Matrix34& mat = pVTOL->GetWorldTM();
	const float k_offsetDist = 5.0f;

	CreateExplosion(m_pExplosionEffect, mat.GetTranslation(), 2.0f, m_explosionSignalId);
	CreateExplosion(m_pExplosionEffect, mat.TransformPoint(Vec3(0.f, k_offsetDist, 0.f)), 2.0f);
	CreateExplosion(m_pExplosionEffect, mat.TransformPoint(Vec3(0.f,-k_offsetDist, 0.f)), 2.0f);

	//Hide existing vehicle
	pVTOL->SetPos(Vec3(0.f,0.f,0.f));
	pVTOL->Hide(true);
	info.state = EVS_Invisible;
	info.stateTime = 0.f;  // this may allow clients to do their own respawn handling, stopping the need for respawned RMI below

	//Remove from HUD radar
	SHUDEvent hudEvent(eHUDEvent_RemoveEntity);
	hudEvent.AddData((int)pVTOL->GetId());
	CHUDEventDispatcher::CallEvent(hudEvent);
}
Example #12
0
void CVTOLVehicleManager::RespawnVTOL(IVehicle* pVehicle, SVTOLInfo& info)
{
	CryLog("CVTOLVehicleManager::RespawnVTOL()");

	//Reset parts and component damage
	int numComponents = pVehicle->GetComponentCount();
	for(int c = 0; c < numComponents; ++c)
	{
		IVehicleComponent* pComponent = pVehicle->GetComponent(c);
		int numParts = pComponent->GetPartCount();
		for(int p = 0; p < numParts; ++p)
		{
			pComponent->GetPart(p)->Reset();
		}
		pComponent->SetDamageRatio(0.f);
	}

	if (IVehicleMovement* pMovement = pVehicle->GetMovement())
	{
		pMovement->Reset();
	}

	SVehicleStatus& status = const_cast<SVehicleStatus&>(pVehicle->GetStatus());
	status.Reset();

	//Activate flowgraph Respawn output
	IScriptTable* pScriptTable = pVehicle->GetEntity()->GetScriptTable();
	Script::CallMethod(pScriptTable, "Respawn", pScriptTable, 0);
	info.state = EVS_Normal;
	info.stateTime = 0.f;

	pVehicle->GetEntity()->Hide(false);
	LockSeats(pVehicle, false);

	SetupMovement(info.entityId);

	//Add to HUD Radar
	SHUDEvent hudEvent(eHUDEvent_AddEntity);
	hudEvent.AddData((int)info.entityId);
	CHUDEventDispatcher::CallEvent(hudEvent);
}
Example #13
0
void CUIManager::SetCurControlScheme( const EControlScheme controlScheme )
{
	if (GetCurControlScheme() == controlScheme)
		return;

	const EControlScheme prevControlScheme = m_curControlScheme;
	m_curControlScheme = controlScheme;

	SHUDEvent hudEvent(eHUDEvent_OnControlSchemeSwitch);
	hudEvent.AddData(SHUDEventData((int)controlScheme));
	hudEvent.AddData(SHUDEventData((int)prevControlScheme));
	CHUDEventDispatcher::CallEvent(hudEvent);

	// Notify listeners (Msg3D entities use this currently)
	for (TUIControlSchemeListeners::Notifier notifier(m_controlSchemeListeners); notifier.IsValid(); notifier.Next())
	{
		bool bHandled = notifier->OnControlSchemeChanged(controlScheme);
		if (bHandled) // Allow blocking
		{
			break;
		}
	}
}