//------------------------------------------------------------------------ bool CVehicleActionEntityAttachment::DetachEntity() { IEntitySystem *pEntitySystem = gEnv->pEntitySystem; assert(pEntitySystem); if(IEntity *pEntity = pEntitySystem->GetEntity(m_entityId)) { IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); assert(pVehicleSystem); // FIXME: remove this workaround, replace by e.g. buddy constraint if(IVehicle *pVehicle = pVehicleSystem->GetVehicle(m_entityId)) { int hitType = g_pGame->GetGameRules()->GetHitTypeId("disableCollisions"); pVehicle->OnHit(m_pVehicle->GetEntityId(), m_pVehicle->GetEntityId(), 10.0f, Vec3(0.0f, 0.0f, 0.0f), 0.0f, hitType, false); } pEntity->DetachThis(); m_isAttached = false; m_timer = g_parachuteTimeMax; m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate); return true; } return false; }
//------------------------------------------------------------------------ CVehicleActionEntityAttachment *CFlowVehicleEntityAttachment::GetVehicleAction() { if(!m_vehicleId) return NULL; IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); assert(pVehicleSystem); if(IVehicle *pVehicle = pVehicleSystem->GetVehicle(m_vehicleId)) { for(int i = 1; i < pVehicle->GetActionCount(); i++) { IVehicleAction *pAction = pVehicle->GetAction(i); assert(pAction); if(CVehicleActionEntityAttachment *pAttachment = CAST_VEHICLEOBJECT(CVehicleActionEntityAttachment, pAction)) { return pAttachment; } } } return NULL; }
//------------------------------------------------------------------------ void CFlowVehicleBase::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo) { if (flowEvent == eFE_SetEntityId) { IEntity* pEntity = pActivationInfo->pEntity; if (pEntity) { IVehicleSystem* pVehicleSystem = CCryAction::GetCryAction()->GetIVehicleSystem(); CRY_ASSERT(pVehicleSystem); if (pEntity->GetId() != m_vehicleId) { if (IVehicle* pVehicle = GetVehicle()) pVehicle->UnregisterVehicleEventListener(this); m_vehicleId = 0; } if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId())) { pVehicle->RegisterVehicleEventListener(this, "FlowVehicleBase"); m_vehicleId = pEntity->GetId(); } } else { if (IVehicle* pVehicle = GetVehicle()) pVehicle->UnregisterVehicleEventListener(this); } } }
//------------------------------------------------------------------------ IVehicle *CFlowVehicleEntityAttachment::GetVehicle() { if(!m_vehicleId) return NULL; IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); assert(pVehicleSystem); return pVehicleSystem->GetVehicle(m_vehicleId); }
bool CHeavyWeapon::AllowInteraction(EntityId interactionEntity, EInteractionType interactionType) { IGameFramework* pGameFramework = g_pGame->GetIGameFramework(); IVehicleSystem* pVehicleSystem = pGameFramework->GetIVehicleSystem(); IVehicle* pInteractiveVehicle = pVehicleSystem->GetVehicle(interactionEntity); if (pInteractiveVehicle != 0) { return false; } else { return BaseClass::AllowInteraction(interactionEntity, interactionType); } }
//------------------------------------------------------------------------ CFlowVehicleEntityAttachment::CFlowVehicleEntityAttachment(SActivationInfo *pActivationInfo) { m_nodeID = pActivationInfo->myID; m_pGraph = pActivationInfo->pGraph; if(IEntity *pEntity = pActivationInfo->pEntity) { IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); assert(pVehicleSystem); if(pVehicleSystem->GetVehicle(pEntity->GetId())) m_vehicleId = pEntity->GetId(); } else m_vehicleId = 0; }
//------------------------------------------------------------------------ void CFlowVehicleBase::Init(SActivationInfo* pActivationInfo) { m_nodeID = pActivationInfo->myID; m_pGraph = pActivationInfo->pGraph; if (IEntity* pEntity = pActivationInfo->pEntity) { IVehicleSystem* pVehicleSystem = CCryAction::GetCryAction()->GetIVehicleSystem(); CRY_ASSERT(pVehicleSystem); if (pVehicleSystem->GetVehicle(pEntity->GetId())) m_vehicleId = pEntity->GetId(); } else m_vehicleId = 0; }
//------------------------------------------------------------------------ void CFlowVehicleEntityAttachment::ProcessEvent(EFlowEvent flowEvent, SActivationInfo *pActivationInfo) { if(flowEvent == eFE_SetEntityId) { if(IEntity *pEntity = pActivationInfo->pEntity) { IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); assert(pVehicleSystem); if(pEntity->GetId() != m_vehicleId) m_vehicleId = 0; if(IVehicle *pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId())) m_vehicleId = pEntity->GetId(); } else { m_vehicleId = 0; } } else if(flowEvent == eFE_Activate) { if(CVehicleActionEntityAttachment *pAction = GetVehicleAction()) { if(IsPortActive(pActivationInfo, IN_DROPATTACHMENTTRIGGER)) { pAction->DetachEntity(); SFlowAddress addr(m_nodeID, OUT_ISATTACHED, true); m_pGraph->ActivatePort(addr, pAction->IsEntityAttached()); } SFlowAddress addr(m_nodeID, OUT_ENTITYID, true); m_pGraph->ActivatePort(addr, pAction->GetAttachmentId()); } } }
// //----------------------------------------------------------------------------------------------------------- // (MATT) Moved here from Scriptbind_AI when that was moved to the AI system {2008/02/15:15:23:16} int CScriptBind_Action::RegisterWithAI(IFunctionHandler *pH) { if (gEnv->bMultiplayer && !gEnv->bServer) return pH->EndFunction(); int type; ScriptHandle hdl; if (!pH->GetParams(hdl, type)) return pH->EndFunction(); EntityId entityID = (EntityId)hdl.n; IEntity *pEntity = gEnv->pEntitySystem->GetEntity(entityID); if(!pEntity) { GameWarning("RegisterWithAI: Tried to set register with AI nonExisting entity with id [%d]. ", entityID); return pH->EndFunction(); } // Apparently we can't assume that there is just one IGameObject to an entity, because we choose between (at least) Actor and Vehicle objects. // (MATT) Do we really need to check on the actor system here? {2008/02/15:18:38:34} IGameFramework *pGameFramework = gEnv->pGame->GetIGameFramework(); IVehicleSystem* pVSystem = pGameFramework->GetIVehicleSystem(); IActorSystem* pASystem = pGameFramework->GetIActorSystem(); if(!pASystem) { GameWarning("RegisterWithAI: no ActorSystem for %s.", pEntity->GetName()); return pH->EndFunction(); } AIObjectParams params(type, 0, entityID); bool autoDisable(true); // For most types, we need to parse the tables // For others we leave them blank switch (type) { case AIOBJECT_ACTOR: case AIOBJECT_2D_FLY: case AIOBJECT_BOAT: case AIOBJECT_CAR: case AIOBJECT_HELICOPTER: case AIOBJECT_INFECTED: case AIOBJECT_ALIENTICK: case AIOBJECT_HELICOPTERCRYSIS2: if(gEnv->pAISystem && ! gEnv->pAISystem->ParseTables(3, true, pH, params, autoDisable)) return pH->EndFunction(); default:; } // Most types check these, so just get them in advance IActor* pActor = pASystem->GetActor( pEntity->GetId() ); IVehicle* pVehicle = NULL; if( pVSystem ) pVehicle = pVSystem->GetVehicle( pEntity->GetId() ); // Set this if we've found something to create a proxy from IGameObject* pGameObject = NULL; switch(type) { case AIOBJECT_ACTOR: case AIOBJECT_2D_FLY: case AIOBJECT_INFECTED: case AIOBJECT_ALIENTICK: { // (MATT) The pActor/pVehicle test below - is it basically trying to distiguish between the two cases above? If so, separate them! {2008/02/15:19:38:08} if(!pActor) { GameWarning("RegisterWithAI: no Actor for %s.", pEntity->GetName()); return pH->EndFunction(); } pGameObject = pActor->GetGameObject(); } break; case AIOBJECT_BOAT: case AIOBJECT_CAR: { if(!pVehicle) { GameWarning("RegisterWithAI: no Vehicle for %s (Id %i).", pEntity->GetName(), pEntity->GetId()); return pH->EndFunction(); } pGameObject = pVehicle->GetGameObject(); } break; case AIOBJECT_HELICOPTER: case AIOBJECT_HELICOPTERCRYSIS2: { if(!pVehicle) { GameWarning("RegisterWithAI: no Vehicle for %s (Id %i).", pEntity->GetName(), pEntity->GetId()); return pH->EndFunction(); } pGameObject = pVehicle->GetGameObject(); params.m_moveAbility.b3DMove = true; } break; case AIOBJECT_PLAYER: { if(IsDemoPlayback()) return pH->EndFunction(); SmartScriptTable pTable; if (pH->GetParamCount() > 2) pH->GetParam(3,pTable); else return pH->EndFunction(); pGameObject = pActor->GetGameObject(); pTable->GetValue("groupid",params.m_sParamStruct.m_nGroup); const char* faction = 0; if (pTable->GetValue("esFaction", faction) && gEnv->pAISystem) { params.m_sParamStruct.factionID = gEnv->pAISystem->GetFactionMap().GetFactionID(faction); if (faction && *faction && (params.m_sParamStruct.factionID == IFactionMap::InvalidFactionID)) { GameWarning("Unknown faction '%s' being set...", faction); } } else { // Márcio: backwards compatibility int species = -1; if (!pTable->GetValue("eiSpecies", species)) pTable->GetValue("species", species); if (species > -1) params.m_sParamStruct.factionID = species; } pTable->GetValue("commrange",params.m_sParamStruct.m_fCommRange); //Luciano - added to use GROUPONLY signals SmartScriptTable pPerceptionTable; if(pTable->GetValue("Perception",pPerceptionTable)) { pPerceptionTable->GetValue( "sightrange", params.m_sParamStruct.m_PerceptionParams.sightRange); } } break; case AIOBJECT_SNDSUPRESSOR: { // (MATT) This doesn't need a proxy? {2008/02/15:19:45:58} SmartScriptTable pTable; // Properties table if (pH->GetParamCount() > 2) pH->GetParam(3,pTable); else return pH->EndFunction(); if (!pTable->GetValue("radius",params.m_moveAbility.pathRadius)) params.m_moveAbility.pathRadius = 10.f; break; } case AIOBJECT_WAYPOINT: break; /* // this block is commented out since params.m_sParamStruct is currently ignored in pEntity->RegisterInAISystem() // instead of setting the group id here, it will be set from the script right after registering default: // try to get groupid settings for anchors params.m_sParamStruct.m_nGroup = -1; params.m_sParamStruct.m_nSpecies = -1; { SmartScriptTable pTable; if ( pH->GetParamCount() > 2 ) pH->GetParam( 3, pTable ); if ( *pTable ) pTable->GetValue( "groupid", params.m_sParamStruct.m_nGroup ); } break; */ } // Remove any existing AI object pEntity->RegisterInAISystem(AIObjectParams(0)); // Register in AI to get a new AI object, deregistering the old one in the process pEntity->RegisterInAISystem(params); // (MATT) ? {2008/02/15:19:46:29} // AI object was not created (possibly AI System is disabled) if (IAIObject* aiObject = pEntity->GetAI()) { if(type==AIOBJECT_SNDSUPRESSOR) aiObject->SetRadius(params.m_moveAbility.pathRadius); else if(type>=AIANCHOR_FIRST) // if anchor - set radius { SmartScriptTable pTable; // Properties table if (pH->GetParamCount() > 2) pH->GetParam(3,pTable); else return pH->EndFunction(); float radius(0.f); pTable->GetValue("radius",radius); int groupId = -1; pTable->GetValue("groupid", groupId); aiObject->SetGroupId(groupId); aiObject->SetRadius(radius); } if (IAIActorProxy* proxy = aiObject->GetProxy()) proxy->UpdateMeAlways(!autoDisable); } return pH->EndFunction(); }
//------------------------------------------------------------------------ void CDebugGun::Update( SEntityUpdateContext& ctx, int update) { if (!IsSelected()) return; static float drawColor[4] = {1,1,1,1}; static const int dx = 5; static const int dy = 15; static const float font = 1.2f; static const float fontLarge = 1.4f; IRenderer* pRenderer = gEnv->pRenderer; IRenderAuxGeom* pAuxGeom = pRenderer->GetIRenderAuxGeom(); pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags); pRenderer->Draw2dLabel(pRenderer->GetWidth()/5.f, pRenderer->GetHeight()-35, fontLarge, drawColor, false, "Firemode: %s (%.1f)", m_fireModes[m_fireMode].first.c_str(), m_fireModes[m_fireMode].second); ray_hit rayhit; int hits = 0; unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any; if (m_fireModes[m_fireMode].first == "pierceability") { flags = (unsigned int)m_fireModes[m_fireMode].second & rwi_pierceability_mask; } // use cam, no need for firing pos/dir CCamera& cam = GetISystem()->GetViewCamera(); if (hits = gEnv->pPhysicalWorld->RayWorldIntersection(cam.GetPosition()+cam.GetViewdir(), cam.GetViewdir()*HIT_RANGE, ent_all, flags, &rayhit, 1)) { IMaterialManager* pMatMan = gEnv->p3DEngine->GetMaterialManager(); IActorSystem* pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem(); IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem(); int x = (int)(pRenderer->GetWidth() *0.5f) + dx; int y = (int)(pRenderer->GetHeight()*0.5f) + dx - dy; // draw normal ColorB colNormal(200,0,0,128); Vec3 end = rayhit.pt + 0.75f*rayhit.n; pAuxGeom->DrawLine(rayhit.pt, colNormal, end, colNormal); pAuxGeom->DrawCone(end, rayhit.n, 0.1f, 0.2f, colNormal); IEntity * pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY); if(pEntity) { pRenderer->Draw2dLabel(x, y+=dy, fontLarge, drawColor, false, pEntity->GetName()); } // material const char* matName = pMatMan->GetSurfaceType(rayhit.surface_idx)->GetName(); if (matName[0]) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%s (%i)", matName, rayhit.surface_idx); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f m", rayhit.dist); if (pEntity) { IScriptTable* pScriptTable = pEntity->GetScriptTable(); // physics if (IPhysicalEntity* pPhysEnt = pEntity->GetPhysics()) { pe_status_dynamics status; if (pPhysEnt->GetStatus(&status)) { if (status.mass > 0.f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f kg", status.mass); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "pe_type: %i", pPhysEnt->GetType()); if (status.submergedFraction > 0.f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f submerged", status.submergedFraction); if (status.v.len2() > 0.0001f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f m/s", status.v.len()); } } if (pScriptTable) { HSCRIPTFUNCTION func = 0; if (pScriptTable->GetValue("GetFrozenAmount", func) && func) { float frozen = 0.f; Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, frozen); gEnv->pScriptSystem->ReleaseFunc(func); if (frozen > 0.f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Frozen: %.2f", frozen); } } // class-specific stuff if (IActor* pActor = pActorSystem->GetActor(pEntity->GetId())) { pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i health", pActor->GetHealth()); } else if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId())) { const SVehicleStatus& status = pVehicle->GetStatus(); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f%% health", 100.f*status.health); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i passengers", status.passengerCount); if (pVehicle->GetMovement() && pVehicle->GetMovement()->IsPowered()) { pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Running"); } } else { if (pScriptTable) { HSCRIPTFUNCTION func = 0; if (pScriptTable->GetValue("GetHealth", func) && func) { float health = 0.f; if (Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, health)) { pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f health", health); } gEnv->pScriptSystem->ReleaseFunc(func); } } } } } }
void CTornado::UpdateFlow() { IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem(); assert(pVehicleSystem); float frameTime(gEnv->pTimer->GetFrameTime()); IPhysicalWorld *ppWorld = gEnv->pPhysicalWorld; Vec3 pos(GetEntity()->GetWorldPos()); //first, check the entities in range m_nextEntitiesCheck -= frameTime; if (m_nextEntitiesCheck<0.0f) { m_nextEntitiesCheck = 1.0f; Vec3 radiusVec(m_radius,m_radius,0); IPhysicalEntity **ppList = NULL; int numEnts = ppWorld->GetEntitiesInBox(pos-radiusVec,pos+radiusVec+Vec3(0,0,m_cloudHeight*0.5f),ppList,ent_sleeping_rigid|ent_rigid|ent_living); m_spinningEnts.clear(); for (int i=0;i<numEnts;++i) { // add check for spectating players... EntityId id = ppWorld->GetPhysicalEntityId(ppList[i]); CActor* pActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id)); if(!pActor || !pActor->GetSpectatorMode()) { m_spinningEnts.push_back(id); } } //OutputDistance(); } //mess entities around for (size_t i=0;i<m_spinningEnts.size();++i) { IPhysicalEntity *ppEnt = ppWorld->GetPhysicalEntityById(m_spinningEnts[i]); if (ppEnt) { pe_status_pos spos; pe_status_dynamics sdyn; if (!ppEnt->GetStatus(&spos) || !ppEnt->GetStatus(&sdyn)) continue; //gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(spos.pos,2.0f,ColorB(255,0,255,255)); Vec3 delta(pos - spos.pos); delta.z = 0.0f; float dLen(delta.len()); float forceMult(max(0.0f,(m_radius-dLen)/m_radius)); if (dLen>0.001f) delta /= dLen; else delta.zero(); Vec3 upVector(0,0,1); float spinImpulse(m_spinImpulse); float attractionImpulse(m_attractionImpulse); float upImpulse(m_upImpulse); if (ppEnt->GetType() == PE_LIVING) { upImpulse *= 0.75f; attractionImpulse *= 0.35f; spinImpulse *= 1.5f; } if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(m_spinningEnts[i])) { IVehicleMovement* pMovement = pVehicle->GetMovement(); if (pMovement && pMovement->GetMovementType() == IVehicleMovement::eVMT_Air) { SVehicleMovementEventParams params; params.fValue = forceMult; pMovement->OnEvent(IVehicleMovement::eVME_Turbulence, params); } } Vec3 spinForce( (delta % upVector) * spinImpulse ); Vec3 attractionForce(delta * attractionImpulse); Vec3 upForce(0,0,upImpulse); pe_action_impulse aimpulse; aimpulse.impulse = (spinForce + attractionForce + upForce) * (forceMult * sdyn.mass * frameTime); aimpulse.angImpulse = (upVector + (delta % upVector)) * (gf_PI * 0.33f * forceMult * sdyn.mass * frameTime); aimpulse.iApplyTime = 0; ppEnt->Action(&aimpulse); //gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(spos.pos,ColorB(255,0,255,255),spos.pos+aimpulse.impulse.GetNormalizedSafe(ZERO),ColorB(255,0,255,255)); } } }
virtual void ProcessEvent( EFlowEvent event,SActivationInfo *pActInfo ) { IVehicleSystem * pVehicleSystem = NULL; IVehicle * pVehicle = NULL; switch(event) { case eFE_Initialize: { pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, false); break; } case eFE_Activate: { if (!pActInfo->pEntity) return; pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); pVehicle = pVehicleSystem->GetVehicle(pActInfo->pEntity->GetId()); if (!pVehicleSystem || !pVehicle) return; string givenString = GetPortString(pActInfo, IN_PARTS); currentParam = givenString.substr(0,givenString.find_first_of(":")); currentSetting = givenString.substr(givenString.find_first_of(":")+1,(givenString.length()-givenString.find_first_of(":"))); column1 = 10.f; column2 = 100.f; if (IsPortActive(pActInfo,IN_SHOW)) pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, true); break; } case eFE_Update: { IRenderer * pRenderer = gEnv->pRenderer; pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem(); pVehicle = pVehicleSystem->GetVehicle(pActInfo->pEntity->GetId()); if(!pVehicleSystem || !pActInfo->pEntity || !pVehicle) return; pRenderer->Draw2dLabel(column1,10,GetPortFloat(pActInfo,IN_SIZE)+2.f,Col_Cyan,false,pActInfo->pEntity->GetName()); if(currentParam=="Seats") { loops = 0; for(uint32 i=0;i<pVehicle->GetSeatCount();i++) { IVehicleSeat * currentSeat; if(currentSetting=="All") { currentSeat = pVehicle->GetSeatById(i+1); } else { currentSeat = pVehicle->GetSeatById(pVehicle->GetSeatId(currentSetting)); i = pVehicle->GetSeatCount()-1; } loops += 1; // column 1 string pMessage = ("%s:", currentSeat->GetSeatName()); if (column2<pMessage.size()*8*GetPortFloat(pActInfo, IN_SIZE)) column2=pMessage.size()*8*GetPortFloat(pActInfo, IN_SIZE); pRenderer->Draw2dLabel(column1,(15*(float(loops+1))*GetPortFloat(pActInfo,IN_SIZE)),GetPortFloat(pActInfo,IN_SIZE),Col_Cyan,false,pMessage); // column 2 if(currentSeat->GetPassenger(true)) { pMessage = ("- %s", gEnv->pEntitySystem->GetEntity(currentSeat->GetPassenger(true))->GetName()); pRenderer->Draw2dLabel(column2,(15*(float(loops+1))*GetPortFloat(pActInfo,IN_SIZE)),GetPortFloat(pActInfo,IN_SIZE),Col_Cyan,false,pMessage); } } } else if(currentParam=="Wheels") { pRenderer->Draw2dLabel(column1,50.f,GetPortFloat(pActInfo,IN_SIZE)+1.f,Col_Red,false,"!"); } else if(currentParam=="Weapons") { loops = 0; for(int i=0;i<pVehicle->GetWeaponCount();i++) { IItemSystem * pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem(); IWeapon * currentWeapon; EntityId currentEntityId; IItem * pItem; if(currentSetting=="All") { currentEntityId = pVehicle->GetWeaponId(i+1); } else { currentEntityId = gEnv->pEntitySystem->FindEntityByName(currentSetting)->GetId(); i = pVehicle->GetWeaponCount()-1; } if(!pItemSystem->GetItem(currentEntityId)) return; pItem = pItemSystem->GetItem(currentEntityId); currentWeapon = pItem->GetIWeapon(); loops += 1; // column 1 string pMessageName = string().Format("%s", gEnv->pEntitySystem->GetEntity(currentEntityId)->GetName()); pRenderer->Draw2dLabel(column1,(15*(float(loops+1))*GetPortFloat(pActInfo,IN_SIZE)),GetPortFloat(pActInfo,IN_SIZE),Col_Cyan,false,pMessageName); if (column2<pMessageName.size()*8*GetPortFloat(pActInfo, IN_SIZE)) column2=pMessageName.size()*8*GetPortFloat(pActInfo, IN_SIZE); // column 2 string pMessageValue = string().Format("seat: %s firemode: %i", pVehicle->GetWeaponParentSeat(currentEntityId)->GetSeatName(), currentWeapon->GetCurrentFireMode()).c_str(); pRenderer->Draw2dLabel(column2,(15*(float(loops+1))*GetPortFloat(pActInfo,IN_SIZE)),GetPortFloat(pActInfo,IN_SIZE),Col_Cyan,false,pMessageValue); } } else if(currentParam=="Components") { loops = 0; for(int i=0;i<pVehicle->GetComponentCount();i++) { IVehicleComponent * currentComponent; if(currentSetting=="All") { currentComponent = pVehicle->GetComponent(i); } else { currentComponent = pVehicle->GetComponent(currentSetting); i = pVehicle->GetComponentCount()-1; } loops += 1; ColorF labelColor; labelColor = ColorF(currentComponent->GetDamageRatio(),(1.f-currentComponent->GetDamageRatio()),0.f); // column 1 string pMessageName = string().Format("%s", currentComponent->GetComponentName()).c_str(); pRenderer->Draw2dLabel(column1,(15*(float(loops+1))*GetPortFloat(pActInfo,IN_SIZE)),GetPortFloat(pActInfo,IN_SIZE),labelColor,false,pMessageName); if (column2<pMessageName.size()*8*GetPortFloat(pActInfo, IN_SIZE)) column2=pMessageName.size()*8*GetPortFloat(pActInfo, IN_SIZE); // column 2 string pMessageValue = string().Format("%5.2f (%3.2f)", currentComponent->GetDamageRatio()*currentComponent->GetMaxDamage(), currentComponent->GetDamageRatio()).c_str(); pRenderer->Draw2dLabel(column2,(15*(float(loops+1))*GetPortFloat(pActInfo,IN_SIZE)),GetPortFloat(pActInfo,IN_SIZE),labelColor,false,pMessageValue); } } else { pRenderer->Draw2dLabel(column1,50.f,GetPortFloat(pActInfo,IN_SIZE)+1.f,Col_Red,false,"no component selected!"); } break; } } };