void CActor::PickupModeUpdate() { if(!m_bPickupMode) return; // kUSE key pressed if(!IsGameTypeSingle()) return; //подбирание объекта if( m_pObjectWeLookingAt && m_pObjectWeLookingAt->cast_inventory_item() && m_pObjectWeLookingAt->cast_inventory_item()->Useful() && m_pUsableObject && !m_pUsableObject->nonscript_usable() && !Level().m_feel_deny.is_object_denied(m_pObjectWeLookingAt) ) { m_pUsableObject->use(this); Game().SendPickUpEvent(ID(), m_pObjectWeLookingAt->ID()); } feel_touch_update (Position(), m_fPickupInfoRadius); CFrustum frustum; frustum.CreateFromMatrix(Device.mFullTransform, FRUSTUM_P_LRTB|FRUSTUM_P_FAR); for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++) { if (CanPickItem(frustum, Device.vCameraPosition, *it)) PickupInfoDraw(*it); } }
void CActor::PickupModeUpdate() { if(!m_bPickupMode) return; if (GameID() != GAME_SINGLE) return; //подбирание объекта if(inventory().m_pTarget && inventory().m_pTarget->Useful() && m_pUsableObject && m_pUsableObject->nonscript_usable() && !Level().m_feel_deny.is_object_denied(smart_cast<CGameObject*>(inventory().m_pTarget)) ) { NET_Packet P; u_EventGen(P, GE_OWNERSHIP_TAKE, ID()); P.w_u16(inventory().m_pTarget->object().ID()); u_EventSend(P); } //. ????? GetNearest ????? feel_touch_update (Position(), /*inventory().GetTakeDist()*/m_fPickupInfoRadius); CFrustum frustum; frustum.CreateFromMatrix(Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR); //. slow (ray-query test) for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++) if (CanPickItem(frustum,Device.vCameraPosition,*it)) PickupInfoDraw(*it); }
void CActor::PickupModeUpdate_COD () { if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode) return; if (!g_Alive() || eacFirstEye != cam_active) { CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(NULL); return; }; CFrustum frustum; frustum.CreateFromMatrix (Device.mFullTransform, FRUSTUM_P_LRTB|FRUSTUM_P_FAR); ISpatialResult.clear_not_free (); g_SpatialSpace->q_frustum (ISpatialResult, 0, STYPE_COLLIDEABLE, frustum); float maxlen = 1000.0f; CInventoryItem* pNearestItem = NULL; for (u32 o_it=0; o_it<ISpatialResult.size(); o_it++) { ISpatial* spatial = ISpatialResult[o_it]; CInventoryItem* pIItem = smart_cast<CInventoryItem*> (spatial->dcast_CObject ()); if (0 == pIItem) continue; if (pIItem->object().H_Parent() != NULL) continue; if (!pIItem->CanTake()) continue; if ( smart_cast<CExplosiveRocket*>( &pIItem->object() ) ) continue; CGrenade* pGrenade = smart_cast<CGrenade*> (spatial->dcast_CObject ()); if (pGrenade && !pGrenade->Useful()) continue; CMissile* pMissile = smart_cast<CMissile*> (spatial->dcast_CObject ()); if (pMissile && !pMissile->Useful()) continue; Fvector A, B, tmp; pIItem->object().Center (A); if (A.distance_to_sqr(Position())>4) continue; tmp.sub(A, cam_Active()->vPosition); B.mad(cam_Active()->vPosition, cam_Active()->vDirection, tmp.dotproduct(cam_Active()->vDirection)); float len = B.distance_to_sqr(A); if (len > 1) continue; if (maxlen>len && !pIItem->object().getDestroy()) { maxlen = len; pNearestItem = pIItem; }; } if(pNearestItem) { CFrustum frustum; frustum.CreateFromMatrix (Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR); if (!CanPickItem(frustum, Device.vCameraPosition, &pNearestItem->object())) pNearestItem = NULL; } if (pNearestItem && pNearestItem->cast_game_object()) { if (Level().m_feel_deny.is_object_denied(pNearestItem->cast_game_object())) pNearestItem = NULL; } if (pNearestItem && pNearestItem->cast_game_object()) { if(!pNearestItem->cast_game_object()->getVisible()) pNearestItem = NULL; } CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(pNearestItem); if (pNearestItem && m_bPickupMode) { CUsableScriptObject* pUsableObject = smart_cast<CUsableScriptObject*>(pNearestItem); if(pUsableObject && (!m_pUsableObject)) pUsableObject->use(this); //подбирание объекта Game().SendPickUpEvent(ID(), pNearestItem->object().ID()); } };