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;
	}
}
Esempio n. 2
0
void CJaw::OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 &pos, const Vec3 &dir, const Vec3 &vel)
{
	BaseClass::OnShoot(shooterId, ammoId, pAmmoType, pos, dir, vel);

	CActor *pOwnerActor = GetOwnerActor();
	if (pOwnerActor)
	{
		// Set the projectile to target the forced entity
		if (m_forcedTargetId > 0)
		{
			CProjectile *pProjectile = g_pGame->GetWeaponSystem()->GetProjectile(ammoId);
			if (pProjectile)
			{
				pProjectile->SetDestination(m_forcedTargetId);
			}
		}

		if (pOwnerActor->IsClient() && m_laserGuider.IsLaserActivated())
		{
			SHUDEvent event(eHUDEvent_InfoSystemsEvent);
			event.AddData(SHUDEventData(1));
			event.AddData(SHUDEventData(2.f));
			event.AddData(SHUDEventData("@hud_guided"));
			CHUDEventDispatcher::CallEvent(event);
		}

		if (pOwnerActor->IsClient())
			m_fired = true;
	}

	SvActivateMissileCountermeasures(shooterId, pos, dir);
}
Esempio n. 3
0
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		switch (event)
		{
		case eFE_Activate:
			{
				if(IsPortActive(pActInfo, EIP_FailCurrentScan))
				{
					SHUDEvent _event(eHUDEvent_OnControlCurrentTacticalScan);
					_event.AddData(SHUDEventData(false)); // Delay result
					_event.AddData(SHUDEventData(false));
					CHUDEventDispatcher::CallEvent(_event);

					ActivateOutput(pActInfo, EOP_Failed, true);
				}
				else if(IsPortActive(pActInfo, EIP_SucceedCurrentScan))
				{
					SHUDEvent _event(eHUDEvent_OnControlCurrentTacticalScan);
					_event.AddData(SHUDEventData(false)); // Delay result
					_event.AddData(SHUDEventData(true));
					CHUDEventDispatcher::CallEvent(_event);

					ActivateOutput(pActInfo, EOP_Succeeded, true);
				}
				break;
			}
		}
	}
//------------------------------------------------------------------------
void CThrowIndicator::StopZoom()
{
	if (m_pWeapon->IsOwnerClient())
	{
		SHUDEvent trajectoryEvent(eHUDEvent_DisplayTrajectory);
		trajectoryEvent.AddData(SHUDEventData(false));
		trajectoryEvent.AddData(SHUDEventData(0.0f));
		CHUDEventDispatcher::CallEvent(trajectoryEvent);
		m_indicatorShowing = false;
	}
}
void CHUDMissionObjective::NotifyStatusChange()
{
	assert (m_pMOS != 0);

	SHUDEvent objectiveEvent(eHUDEvent_OnObjectiveChanged);
	objectiveEvent.AddData(SHUDEventData((void*)this));
	objectiveEvent.AddData(SHUDEventData(IsSilent()));
	CHUDEventDispatcher::CallEvent(objectiveEvent);

	SendRadarEvent();

	m_lastTimeChanged = gEnv->pTimer->GetFrameStartTime().GetSeconds();
}
Esempio n. 6
0
bool CGodMode::RespawnPlayerIfDead() const
{
    CActor* player = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetClientActor());
    bool result = RespawnIfDead(player);
    if (result)
    {
        SHUDEvent event;
        event.eventType = eHUDEvent_OnHUDReload;
        event.AddData(SHUDEventData(true));
        event.AddData( SHUDEventData(false)); // Dynamically loaded
        CHUDEventDispatcher::CallEvent(event);
    }
    return result;
}
Esempio n. 7
0
	void OnHUDEvent(const SHUDEvent& event)
	{
		switch(event.eventType)
		{
		case eHUDEvent_OnScanningComplete:
			{
				if(m_enabled)
				{
					EntityId scannedEntityId = static_cast<EntityId>(event.GetData(0).m_int);

					if (scannedEntityId != m_entityId) // Only selected entity
						break;

					IEntity* pScannedEntity = gEnv->pEntitySystem->GetEntity(scannedEntityId);
					if(!pScannedEntity)
					{
						SetEnabled(false);
						break;
					}
						
					if (m_delayResult)
					{
						SHUDEvent _event(eHUDEvent_OnControlCurrentTacticalScan);
						_event.AddData(SHUDEventData(true)); // Delay result
						CHUDEventDispatcher::CallEvent(_event);
					}

					ActivateOutput(&m_actInfo, EOP_OnEvent, true);
					ActivateOutput(&m_actInfo, EOP_EntityID, m_entityId);
				}
				break;
			}
		}
	}
Esempio n. 8
0
//------------------------------------------------------------------------
void CWeapon::OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 &pos, const Vec3 &dir, const Vec3&vel)
{
	BROADCAST_WEAPON_EVENT(OnShoot, (this, shooterId, ammoId, pAmmoType, pos, dir, vel));

	//FIXME:quick temporary solution
	IActor *pClientActor = m_pGameFramework->GetClientActor();

	CActor *pActor = static_cast<CActor*> (g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(shooterId));

	if (pActor)
	{
		pActor->HandleEvent(SGameObjectEvent(eCGE_OnShoot,eGOEF_ToExtensions));

		if(!gEnv->bMultiplayer && (pActor == pClientActor))
		{
			if (IAIObject *pAIObject = pActor->GetEntity()->GetAI())
			{
				gEnv->pAISystem->SendSignal(SIGNALFILTER_LEADER, 1, "OnEnableFire",	pAIObject, 0);
			}

			gEnv->pAISystem->DisableGlobalPerceptionScaling();
		}
	}

	const bool sendHUDEvent = (shooterId != 0) && ShouldSendOnShootHUDEvent();
	if (sendHUDEvent)
	{
		SHUDEvent event(eHUDEvent_OnShoot);
		event.AddData(SHUDEventData((int)shooterId));
		CHUDEventDispatcher::CallEvent(event);
	}
}
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::UpdateIcon(SHoldEntityDetails * pDetails)
{
	SKotHEntity *pKotHEntity = static_cast<SKotHEntity *>(pDetails->m_pAdditionalData);
	CRY_ASSERT(pKotHEntity);

	const char *pName = NULL;
	const char *pColour = NULL;
	EGameRulesMissionObjectives requestedIcon = GetIcon(pDetails, &pName, &pColour);

	if (requestedIcon != EGRMO_Unknown)
	{
		CCCPOINT(KingOfTheHillObjective_SetNewIcon);

		SHUDEventWrapper::OnNewObjective(pDetails->m_id, requestedIcon, 0.f, 0, pName, pColour);

		pKotHEntity->m_needsIconUpdate = false;

		if(!pKotHEntity->m_isOnRadar)
		{
			SHUDEvent hudevent(eHUDEvent_AddEntity);
			hudevent.AddData(SHUDEventData((int)pDetails->m_id));
			CHUDEventDispatcher::CallEvent(hudevent);
			pKotHEntity->m_isOnRadar = true;
		}
	}
	else if (pKotHEntity->m_currentIcon != EGRMO_Unknown)
	{
		CCCPOINT(KingOfTheHillObjective_RemoveIcon);

		SHUDEventWrapper::OnRemoveObjective(pDetails->m_id, 0);
	}

	pKotHEntity->m_currentIcon = requestedIcon;
}
//------------------------------------------------------------------------
void CWeapon::RequestFireMode(int fmId)
{
    if(fmId==GetCurrentFireMode())
        return;

    CActor *pActor=GetOwnerActor();

    if (gEnv->IsClient() && pActor && pActor->IsClient())
    {
        float animationTime = GetCurrentAnimationTime(eIGS_Owner)/1000.0f;
        m_switchFireModeTimeStap = gEnv->pTimer->GetCurrTime() + animationTime;

        if(gEnv->bServer)
        {
            SetCurrentFireMode(fmId);
        }
        else
        {
            if(m_fm)
            {
                m_fm->Activate(false);
            }
            GetGameObject()->InvokeRMI(SvRequestFireMode(), SvRequestFireModeParams(fmId), eRMI_ToServer);
        }
        StartVerificationSample(gEnv->pTimer->GetAsyncCurTime());
        SHUDEvent event(eHUDEvent_OnWeaponFireModeChanged);
        event.AddData(SHUDEventData(fmId));
        CHUDEventDispatcher::CallEvent(event);
    }
}
//------------------------------------------------------------------------
bool CThrowIndicator::StartZoom(bool stayZoomed, bool fullZoomout, int zoomStep)
{
	if (m_pWeapon->IsOwnerClient())
	{
		CThrow* pThrow = crygti_cast<CThrow*>(m_pWeapon->GetCFireMode(m_pWeapon->GetCurrentFireMode()));
		if((pThrow != NULL) && !pThrow->OutOfAmmo())
		{
			const float lifetime = pThrow->GetProjectileLifeTime();

			SHUDEvent trajectoryEvent(eHUDEvent_DisplayTrajectory);
			trajectoryEvent.AddData(SHUDEventData(true));
			trajectoryEvent.AddData(SHUDEventData(lifetime));
			CHUDEventDispatcher::CallEvent(trajectoryEvent);
			m_indicatorShowing = true;
		}
	}
	return false;
}
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::OnRemoveHoldEntity( SHoldEntityDetails *pDetails )
{
	ClearEntityAudio(pDetails);

	SHUDEventWrapper::OnRemoveObjective(pDetails->m_id, 0);

	SHUDEvent hudevent(eHUDEvent_RemoveEntity);
	hudevent.AddData(SHUDEventData((int)pDetails->m_id));
	CHUDEventDispatcher::CallEvent(hudevent);
}
void CTacticalManager::PostSerialize()
{
	// Radar needs player client entity to be set otherwise edge entity items won't show
	// ENTITY_EVENT_UNHIDE isn't called when loading, since state is already unhided, that usually triggers CActor::ProcessEvent with event type ENTITY_EVENT_UNHIDE
	// Call the hud event here instead
	const EntityId playerEntityID = gEnv->pGame->GetIGameFramework()->GetClientActorId();
	AddEntity(playerEntityID, CTacticalManager::eTacticalEntity_Unit);
	SHUDEvent hudevent(eHUDEvent_AddEntity);
	hudevent.AddData(SHUDEventData((int)playerEntityID));
	CHUDEventDispatcher::CallEvent(hudevent);
}
void ScreenLayoutManager::UpdateHUDCanvasSize( void )
{
	const int renderWidth = gEnv->pRenderer->GetWidth();
	const int renderHeight = gEnv->pRenderer->GetHeight();
	RENDER_SCREEN_WIDTH = (float)renderWidth;
	RENDER_SCREEN_HEIGHT = (float)renderHeight;

	assert(RENDER_SCREEN_WIDTH>0.0f);
	assert(RENDER_SCREEN_HEIGHT>0.0f);
	INV_RENDER_SCREEN_WIDTH = 1.0f*__fres(RENDER_SCREEN_WIDTH);
	INV_RENDER_SCREEN_HEIGHT = 1.0f*__fres(RENDER_SCREEN_HEIGHT);

	// Force update of HUDAssets and other objects.
	const float pa = gEnv->pRenderer->GetPixelAspectRatio();
	Vec2 curCanvasSize( RENDER_SCREEN_WIDTH*__fres(pa), RENDER_SCREEN_HEIGHT );








	SHUDEvent resizeEvent(eHUDEvent_OnResolutionChange);
	resizeEvent.AddData(SHUDEventData(curCanvasSize.x));
	resizeEvent.AddData(SHUDEventData(curCanvasSize.y));
	resizeEvent.AddData(SHUDEventData(RENDER_SCREEN_WIDTH));
	resizeEvent.AddData(SHUDEventData(RENDER_SCREEN_HEIGHT));
	resizeEvent.AddData(SHUDEventData(int_round(RENDER_SCREEN_WIDTH)));
	resizeEvent.AddData(SHUDEventData(int_round(RENDER_SCREEN_HEIGHT)));
	//resizeEvent.AddData(SHUDEventData(pa));
	CHUDEventDispatcher::CallEvent(resizeEvent);

}
void CKVoltEffect::Enter()
{
	m_timer = m_effectTime;

	SHUDEvent eventTempAddToRadar(eHUDEvent_TemporarilyTrackEntity);
	eventTempAddToRadar.AddData(SHUDEventData((int)m_ownerActor->GetEntityId()));
	eventTempAddToRadar.AddData(SHUDEventData(m_effectTime));
	eventTempAddToRadar.AddData(true);
	eventTempAddToRadar.AddData(false);
	CHUDEventDispatcher::CallEvent(eventTempAddToRadar);
	
	if(m_particleEffect)
	{
		IEntity* entity = m_ownerActor->GetEntity();

		const ParticleParams& particleParams = m_particleEffect->GetParticleParams();

		EGeomType geomType = particleParams.eAttachType;
		EGeomForm geomForm = particleParams.eAttachForm;
		SpawnParams	spawnParams( geomType,geomForm );

		m_particleEmitter = m_particleEffect->Spawn(entity->GetWorldTM());
		if(m_particleEmitter)
		{
			m_particleEmitter->AddRef();

			// Set spawn params so that the emitter spawns particles all over the character's physics mesh
			ICharacterInstance* characterInstance = entity->GetCharacter(0);
			if(characterInstance)
			{
				GeomRef geomRef;
				geomRef.m_pChar = characterInstance;
				geomRef.m_pPhysEnt = characterInstance->GetISkeletonPose()->GetCharacterPhysics();
				m_particleEmitter->SetSpawnParams(spawnParams,geomRef);
			}
		}
	}
	ResetScreenEffect();
}
void CHUDMissionObjective::SendRadarEvent()
{
	EntityId trackedEntityId = GetTrackedEntity();
	if (trackedEntityId)
	{
		SHUDEvent radarEvent;
		if(m_eStatus == ACTIVATED)
			radarEvent.eventType = eHUDEvent_AddEntity;
		else
			radarEvent.eventType = eHUDEvent_RemoveEntity;
		radarEvent.AddData(SHUDEventData((int)trackedEntityId));
		CHUDEventDispatcher::CallEvent(radarEvent);
	}
}
Esempio n. 17
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;
		}
	}
}
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 = "";
	}
}
void CLTag::StartChangeFireMode()
{
	if (m_fm == NULL)
		return;

	assert(crygti_isof<CLTagSingle>(m_fm));

	CLTagSingle* pLTagFireMode = static_cast<CLTagSingle*>(m_fm);
	bool changed = pLTagFireMode->NextGrenadeType();

	if(changed)
	{
		CWeapon::OnFireModeChanged(m_firemode);

		SHUDEvent event(eHUDEvent_OnWeaponFireModeChanged);
		event.AddData(SHUDEventData(m_firemode));
		CHUDEventDispatcher::CallEvent(event);
	}
}
void CTacticalManager::RemoveEntity(const EntityId id, ETacticalEntityType type)
{
	CRY_ASSERT(m_allTacticalPoints.size() == eTacticalEntity_Last); // Will always be the case
	CRY_ASSERT(type < eTacticalEntity_Last);
	if (type == eTacticalEntity_Last)
		return;

	TInterestPoints& points = m_allTacticalPoints[type];
	TInterestPoints::iterator it = points.begin();
	TInterestPoints::const_iterator end = points.end();
	for(; it!=end; ++it)
	{
		if(it->m_entityId == id)
		{
			//Removes the silhouette in case it's an actor
			SHUDEvent event(eEHUDEvent_OnScannedEnemyRemove);
			event.AddData(SHUDEventData((int)id));
			CHUDEventDispatcher::CallEvent(event);
			points.erase(it);

			return;
		}
	}
}
Esempio n. 21
0
void CMineField::HandleEvent( const SGameObjectEvent& gameObjectEvent )
{
	const uint32 eventId = gameObjectEvent.event;
	void* pParam = gameObjectEvent.param;
	if ((eventId == eGFE_ScriptEvent) && (pParam != NULL))
	{
		const char* szEventName = static_cast<const char*>(pParam);
		if (strcmp(szEventName, "OnScanned") == 0)
		{
			// Make all mines scanned and tagged
			TMinesData::iterator iter = m_minesData.begin();
			const TMinesData::const_iterator iterEnd = m_minesData.end();
			while (iter != iterEnd)
			{
				const SMineData& mineData = *iter;
				const EntityId mineEntityId = mineData.m_entityId;
				g_pGame->GetTacticalManager()->SetEntityScanned(mineEntityId);
				SHUDEvent scannedEvent(eHUDEvent_OnEntityScanned);
				scannedEvent.AddData(SHUDEventData(static_cast<int>(mineEntityId)));
				CHUDEventDispatcher::CallEvent(scannedEvent);

				g_pGame->GetTacticalManager()->SetEntityTagged(mineEntityId, true);
				SHUDEvent taggedEvent(eHUDEvent_OnEntityTagged);
				taggedEvent.AddData(SHUDEventData(static_cast<int>(mineEntityId)));
				CHUDEventDispatcher::CallEvent(taggedEvent);

				if(IEntity* pEntity = gEnv->pEntitySystem->GetEntity(mineEntityId))
				{
					if(IScriptTable *pScriptTable = pEntity->GetScriptTable())
					{
						Script::CallMethod(pScriptTable, "HasBeenScanned");
					}
				}

				++iter;
			}
		}
		else if (strcmp(szEventName, "OnDestroy") == 0)
		{
			NotifyAllMinesEvent( eMineGameObjectEvent_OnNotifyDestroy );
			UpdateState();
		}
	}
	else if ((eventId == 	eMineEventListenerGameObjectEvent_Enabled) && (pParam != NULL))
	{
		const EntityId mineEntity = *((EntityId*)(pParam));
		CRY_ASSERT(mineEntity != 0);
		if (mineEntity != 0)
		{
				SMineData* pMineData = GetMineData( mineEntity );
				if (pMineData)
				{
					pMineData->m_state |= eMineState_Enabled;
					UpdateState();
				}
				else
				{
					GameWarning( "CMineField::HandleEvent: Failed to find mine entity id: %u", mineEntity );
				}
		}
	}
	else if ((eventId == 	eMineEventListenerGameObjectEvent_Disabled) && (pParam != NULL))
	{
		const EntityId mineEntity = *((EntityId*)(pParam));
		CRY_ASSERT(mineEntity != 0);
		if (mineEntity != 0)
		{
			SMineData* pMineData = GetMineData( mineEntity );
			if (pMineData)
			{
				pMineData->m_state &= ~eMineState_Enabled;
				UpdateState();
			}
			else
			{
				GameWarning( "CMineField::HandleEvent: Failed to find mine entity id: %u", mineEntity );
			}
		}
	}
	else if ((eventId == eMineEventListenerGameObjectEvent_Destroyed) && (pParam != NULL))
	{
		const EntityId mineEntity = *((EntityId*)(pParam));
		CRY_ASSERT(mineEntity != 0);
		if (mineEntity != 0)
		{
			SMineData* pMineData = GetMineData( mineEntity );
			if (pMineData)
			{
				pMineData->m_state |= eMineState_Destroyed;
				UpdateState();
			}
			else
			{
				GameWarning( "CMineField::HandleEvent: Failed to find mine entity id: %u", mineEntity );
			}
		}
	}
}