virtual void OnHUDEvent(const SHUDEvent& event) { int eventID = GetPortInt(&m_pActInfo, 0); if(event.eventType == eventID) { ActivateOutput(&m_pActInfo, eOP_EventFired, 1); for(unsigned int i = 0; i < event.GetDataSize(); i++) { switch(event.GetData(i).m_type) { case SHUDEventData::eSEDT_voidptr: break; case SHUDEventData::eSEDT_bool: break; case SHUDEventData::eSEDT_int: break; case SHUDEventData::eSEDT_float: { if(eventID == eHUDEvent_LeavingBattleArea) { float fDeathTimer = event.GetData(i).GetFloat(); ActivateOutput(&m_pActInfo, eOP_DeathTimer, fDeathTimer); } } break; case SHUDEventData::eSEDT_undef: default: CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "[CFlowNode_BattleAreaListener] HudEvent data unknown."); break; } } } }
virtual void OnHUDEvent(const SHUDEvent& event) { // Only add/remove entity is handled here, so we only care about the int param EntityId entityId = 0; if(event.eventType == eHUDEvent_AddEntity || event.eventType == eHUDEvent_RemoveEntity) { for(unsigned int i = 0; i < event.GetDataSize(); i++) { switch(event.GetData(i).m_type) { case SHUDEventData::eSEDT_voidptr: break; case SHUDEventData::eSEDT_bool: break; case SHUDEventData::eSEDT_int: entityId = event.GetData(i).GetInt(); break; case SHUDEventData::eSEDT_float: break; case SHUDEventData::eSEDT_undef: default: CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "[CFlowNode_EntityTrackedListener] HudEvent data unknown."); break; } } if(entityId != 0) { CHUDMissionObjective* pMO = NULL; pMO = g_pGame->GetMOSystem()->GetMissionObjectiveByEntityId(entityId); string entityClassName = gEnv->pEntitySystem->GetEntity(entityId)->GetClass()->GetName(); bool bMissionOnly = GetPortBool(&m_pActInfo, eIP_MissionOnly); bool bTrigger = false; if(bMissionOnly) { bTrigger = IsClassAllowed(entityClassName) && pMO; } else { bTrigger = IsClassAllowed(entityClassName); } if(bTrigger) { // activate outputport if(event.eventType == eHUDEvent_AddEntity) ActivateOutput(&m_pActInfo, eOP_EntityAdded, 1); else ActivateOutput(&m_pActInfo, eOP_EntityRemoved, 1); ActivateOutput<EntityId>(&m_pActInfo, eOP_EntityId, entityId); } } } }
virtual void OnHUDEvent(const SHUDEvent& event) { // Since I only handle OnObjectiveChanged I only expect a void pointer and a boolean, fail in other cases. CHUDMissionObjective* pMissionObjective = NULL; bool bIsSilent = false; if(event.eventType == eHUDEvent_OnObjectiveChanged) { for(unsigned int i = 0; i < event.GetDataSize(); i++) { switch(event.GetData(i).m_type) { case SHUDEventData::eSEDT_voidptr: pMissionObjective = (CHUDMissionObjective*)event.GetData(i).GetPtr(); break; case SHUDEventData::eSEDT_bool: bIsSilent = event.GetData(i).GetBool(); break; case SHUDEventData::eSEDT_int: // not necessary now break; case SHUDEventData::eSEDT_float: // not necessary now break; case SHUDEventData::eSEDT_undef: default: CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "[CFlowNode_MissionStateListener] HudEvent data unknown."); break; } } if(pMissionObjective && !bIsSilent) { // activate outputport ActivateOutput(&m_pActInfo, eOP_StateChanged, 1); ActivateOutput<string>(&m_pActInfo, !pMissionObjective->IsSecondary() ? eOP_NamePrimary : eOP_NameSecondary, string(pMissionObjective->GetShortDescription())); ActivateOutput<string>(&m_pActInfo, !pMissionObjective->IsSecondary() ? eOP_DescPrimary : eOP_DescSecondary, string(pMissionObjective->GetMessage())); ActivateOutput<int>(&m_pActInfo, eOP_State, pMissionObjective->GetStatus()); ActivateOutput<bool>(&m_pActInfo, eOP_IsSecondary, pMissionObjective->IsSecondary()); } } }