本文整理汇总了C++中IActor::GetCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ IActor::GetCurrentItem方法的具体用法?C++ IActor::GetCurrentItem怎么用?C++ IActor::GetCurrentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActor
的用法示例。
在下文中一共展示了IActor::GetCurrentItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CanDrawCrosshair
bool CBitmapUi::CanDrawCrosshair() const
{
assert( m_pGameFramework != NULL );
if ( ! g_pGameCVars->g_show_crosshair )
{
return false;
}
IActor* pPlayer = m_pGameFramework->GetClientActor();
if ( pPlayer == NULL )
{
return false;
}
bool isPlayerDead = pPlayer->IsDead();
if ( isPlayerDead )
{
return false;
}
bool thirdPersonMode = pPlayer->IsThirdPerson();
bool crosshairEnabledInThirdPerson = ( g_pGameCVars->g_show_crosshair_tp != 0 );
if ( thirdPersonMode && ! crosshairEnabledInThirdPerson )
{
return false;
}
IItem* pItem = pPlayer->GetCurrentItem();
if ( pItem == NULL )
{
return false;
}
IWeapon* pWeapon = pItem->GetIWeapon();
if ( pWeapon == NULL )
{
return false;
}
bool carryingMeleeWeapon = pWeapon->CanMeleeAttack();
if ( carryingMeleeWeapon )
{
return false;
}
bool isWeaponZoomed = pWeapon->IsZoomed();
bool usingWeaponSightForAiming = ( ! thirdPersonMode && isWeaponZoomed );
if ( usingWeaponSightForAiming )
{
return false;
}
return true;
}
示例2: ProcessEvent
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
switch (event)
{
case (eFE_Activate):
{
if (!IsPortActive(pActInfo, 0))
return;
IItemSystem* pItemSys = CCryAction::GetCryAction()->GetIItemSystem();
// get actor
IActor* pActor = CCryAction::GetCryAction()->GetClientActor();
if (!pActor)
return;
IInventory *pInventory = pActor->GetInventory();
if (!pInventory)
return;
IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(GetPortString(pActInfo,1));
IItem* pItem = pItemSys->GetItem(pInventory->GetItemByClass(pClass));
if (!pItem || !pItem->GetIWeapon())
{
pItem = pActor->GetCurrentItem();
if (!pItem || pItem->GetEntity()->GetClass() != pClass || !pItem->GetIWeapon())
{
GameWarning("[flow] CFlowNode_WeaponAmmo: No item/weapon %s!", GetPortString(pActInfo,1).c_str());
return;
}
}
IWeapon *pWeapon = pItem->GetIWeapon();
const string& ammoType = GetPortString(pActInfo,2);
IEntityClass* pAmmoClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoType.c_str());
CRY_ASSERT(pAmmoClass);
IFireMode* pCurrentFireMode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode());
if (pCurrentFireMode)
{
int clipSize = pCurrentFireMode->GetClipSize();
int ammo = pWeapon->GetAmmoCount(pAmmoClass) + GetPortInt(pActInfo,3);
ammo = CLAMP(ammo, 0, clipSize);
pWeapon->SetAmmoCount(pAmmoClass, ammo);
}
ActivateOutput(pActInfo, 0, pWeapon->GetAmmoCount(pAmmoClass));
}
break;
}
}
示例3: ProcessEvent
void ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
{
if (event == eFE_Activate && (IsPortActive(pActInfo, IN_GET) || IsPortActive(pActInfo, IN_SET)))
{
IActor* pActor = GetInputActor(pActInfo);
if (!pActor)
return;
IInventory *pInventory = pActor->GetInventory();
if (pInventory)
{
const string& ammoType = GetPortString(pActInfo, IN_AMMOTYPE);
IEntityClass* pAmmoClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoType.c_str());
if (pAmmoClass)
{
if (IsPortActive(pActInfo, IN_SET))
{
const bool bAdd = GetPortBool(pActInfo, IN_ADD);
const int ammoAmount = GetPortInt(pActInfo, IN_AMMOCOUNT);
pInventory->SetAmmoCount(pAmmoClass, bAdd ? (ammoAmount + pInventory->GetAmmoCount(pAmmoClass)) : (ammoAmount));
}
int magazineAmmo = 0;
int inventoryAmmo = pInventory->GetAmmoCount(pAmmoClass);
if (IItem* pItem = pActor->GetCurrentItem())
{
IWeapon* pCurrentWeapon = GetWeapon(pItem->GetEntityId());
if (pCurrentWeapon)
{
magazineAmmo = pCurrentWeapon->GetAmmoCount(pAmmoClass);
}
}
ActivateOutput(pActInfo, OUT_MAGAZINE, magazineAmmo);
ActivateOutput(pActInfo, OUT_INVENTORY, inventoryAmmo);
ActivateOutput(pActInfo, OUT_TOTAL, (magazineAmmo + inventoryAmmo));
}
}
}
}
示例4: GetCoachIndexPlayerIsOn
int CFlowConvoyNode::GetCoachIndexPlayerIsOn()
{
IPhysicalEntity *pGroundCollider=NULL;
IActor *pPlayerActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
// if player use a mounted weapon on the train, the GroundCollider check not good
if(m_coachIndex>=0)
{//player can catch mounted weapon on the train if he were on it before
CItem *pCurrentItem=static_cast<CItem *>(pPlayerActor->GetCurrentItem());
if ( pCurrentItem != NULL && pCurrentItem->IsMounted())
return m_coachIndex; // give back the last m_coachIndex, it should be valid
}
IPhysicalEntity *pPhysicalEntity=pPlayerActor->GetEntity()->GetPhysics();
if (pPhysicalEntity)
{
pe_status_living livStat;
if(pPhysicalEntity->GetStatus(&livStat))
pGroundCollider=livStat.pGroundCollider;
}
if(!pGroundCollider)
return -1;
for (size_t i = 0; i < m_coaches.size(); ++i)
{
if(m_coaches[i].m_pEntity->GetPhysics()==pGroundCollider)
return i;
else
{//attached objects
IEntity *pCoachEntity=m_coaches[i].m_pEntity;
for (int j = 0; j < pCoachEntity->GetChildCount(); ++j)
{
if(pCoachEntity->GetChild(j)->GetPhysics()==pGroundCollider)
return i;
}
}
}
return -1;
}
示例5: SerializeInventoryForLevelChange
//.........这里部分代码省略.........
string itemName;
ser.Value("numOfItems", numItems);
for(int i = 0; i < numItems; ++i)
{
ser.BeginGroup("Items");
bool nextItemExists = false;
ser.Value("nextItemExists", nextItemExists);
if(nextItemExists)
{
ser.Value("ItemName", itemName);
EntityId id = m_pGameFrameWork->GetIItemSystem()->GiveItem(pActor, itemName.c_str(), false, false, false);
IItem *pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(id);
if(pItem)
{
//actual serialization
pItem->SerializeLTL(ser);
}
else
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Couldn't spawn inventory item %s, got id %i.", itemName.c_str(), id);
}
ser.EndGroup();
}
ser.Value("CurrentItemName", itemName);
if(stricmp(itemName.c_str(), "none"))
{
currentItemNameOnReading = itemName;
IEntityClass *pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(itemName.c_str());
if(pClass)
{
if(IItem* pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(GetItemByClass(pClass)))
{
if (pActor->GetCurrentItem() && pActor->GetCurrentItem() != pItem)
pActor->GetCurrentItem()->Select(false);
pItem->Select(true);
m_stats.currentItemId = pItem->GetEntityId();
}
else
m_stats.currentItemId = m_pGameFrameWork->GetIItemSystem()->GiveItem(pActor, itemName.c_str(), false, true, false);
}
}
}
else
{
numItems = m_stats.slots.size();
ser.Value("numOfItems", numItems);
for(int i = 0; i < numItems; ++i)
{
ser.BeginGroup("Items");
IItem *pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(m_stats.slots[i]);
bool nextItem = true;
if(pItem)
{
ser.Value("nextItemExists", nextItem);
ser.Value("ItemName", pItem->GetEntity()->GetClass()->GetName());
pItem->SerializeLTL(ser);
}
else
{
nextItem = false;
ser.Value("nextItemExists", nextItem);
}
ser.EndGroup();
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:67,代码来源:Inventory.cpp
示例6: ViewFirstPerson
//
// Extract the various modifiers out into their own function.
//
// Aim is to make the code easier to understand and modify, as
// well as to ease the addition of new modifiers.
//
void CPlayerView::ViewFirstPerson(SViewParams &viewParams)
{
//headbob
Ang3 angOffset(0,0,0);
Vec3 weaponOffset(0,0,0);
Ang3 weaponAngleOffset(0,0,0);
// jump/land spring effect. Adjust the eye and weapon pos as required.
FirstPersonJump(viewParams,weaponOffset,weaponAngleOffset);
//float standSpeed(GetStanceMaxSpeed(STANCE_STAND));
Vec3 vSpeed(0,0,0);
if (m_in.standSpeed>0.001f)
vSpeed = (m_in.stats_velocity / m_in.standSpeed);
float vSpeedLen(vSpeed.len());
if (vSpeedLen>1.5f)
vSpeed = vSpeed / vSpeedLen * 1.5f;
float speedMul(0);
if (m_in.standSpeed>0.001f)
speedMul=(m_in.stats_flatSpeed / m_in.standSpeed * 1.1f);
speedMul = min(1.5f,speedMul);
bool crawling(m_in.stance==STANCE_PRONE /*&& m_in.stats_flatSpeed>0.1f*/ && m_in.stats_onGround>0.1f);
bool weaponZoomed = false;
bool weaponZomming = false;
//Not crawling while in zoom mode
IActor *owner = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_in.entityId);
if(owner && owner->IsPlayer())
{
IItem *pItem = owner->GetCurrentItem();
if(pItem)
{
CWeapon *pWeapon = static_cast<CWeapon*>(pItem->GetIWeapon());
if(pWeapon)
{
weaponZoomed = pWeapon->IsZoomed();
weaponZomming = pWeapon->IsZooming();
if(weaponZoomed||weaponZomming||pWeapon->IsModifying())
crawling = false;
}
}
}
// On the ground.
if (m_in.stats_inAir < 0.1f /*&& m_in.stats_inWater < 0.1f*/)
{
//--- Bobbing.
// bobCycle is a speed varying time step running (looping) from 0 to 1
// this feeds into a sin eqn creating a double horizontal figure of 8.
// ( a lissajous figure with the vertical freq twice the horz freq ).
// To tweak the total speed of the curve:
// To tweak the effect speed has on the curve:
float kSpeedToBobFactor=1.15f;//0.9f
// To tweak the width of the bob:
float kBobWidth=0.1f;
// To tweak the height of the bob:
float kBobHeight=0.05f;
// To tweak the scale of strafing lag: (may need to manually adjust the strafing angle offsets as well.)
const float kStrafeHorzScale=0.05f;
kBobWidth = 0.15f;
kBobHeight = 0.06f;
m_io.stats_bobCycle += m_in.frameTime * kSpeedToBobFactor * speedMul;// * (m_in.bSprinting?1.25f:1.0f);
//if player is standing set the bob to rest. (bobCycle reaches 1.0f within 1 second)
if (speedMul < 0.1f)
m_io.stats_bobCycle = min(m_io.stats_bobCycle + m_in.frameTime * 1.0f,1.0f);
// bobCycle loops between 0 and 1
if (m_io.stats_bobCycle>1.0f)
m_io.stats_bobCycle = m_io.stats_bobCycle - 1.0f;
if (crawling)
kBobWidth *= 2.0f * speedMul;
else if (m_in.bSprinting)
kBobWidth *= 1.25f * speedMul;
//set the bob offset
Vec3 bobDir(cry_sinf(m_io.stats_bobCycle*gf_PI*2.0f)*kBobWidth*speedMul,0,cry_sinf(m_io.stats_bobCycle*gf_PI*4.0f)*kBobHeight*speedMul);
//not the bob offset for the weapon
bobDir *= 0.25f;
//if player is strafing shift a bit the weapon on left/right
if (speedMul > 0.01f)
{
// right vector dot speed vector
//.........这里部分代码省略.........
示例7: ViewThirdPerson
void CPlayerView::ViewThirdPerson(SViewParams &viewParams)
{
if (m_in.thirdPersonYaw>0.001f)
{
viewParams.rotation *= Quat::CreateRotationXYZ(Ang3(0,0,m_in.thirdPersonYaw * gf_PI/180.0f));
m_io.viewQuatFinal = viewParams.rotation;
}
if (g_pGameCVars->goc_enable)
{
Vec3 target(g_pGameCVars->goc_targetx, g_pGameCVars->goc_targety, g_pGameCVars->goc_targetz);
static Vec3 current(target);
Interpolate(current, target, 5.0f, m_in.frameTime);
// make sure we don't clip through stuff that much
Vec3 offsetX(0,0,0);
Vec3 offsetY(0,0,0);
Vec3 offsetZ(0,0,0);
offsetX = m_io.viewQuatFinal.GetColumn0() * current.x;
offsetY = m_io.viewQuatFinal.GetColumn1() * current.y;
offsetZ = m_io.viewQuatFinal.GetColumn2() * current.z;
IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_in.entityId);
if (pActor)
{
static ray_hit hit;
IPhysicalEntity* pSkipEntities[10];
int nSkip = 0;
IItem* pItem = pActor->GetCurrentItem();
if (pItem)
{
CWeapon* pWeapon = (CWeapon*)pItem->GetIWeapon();
if (pWeapon)
nSkip = CSingle::GetSkipEntities(pWeapon, pSkipEntities, 10);
}
float oldLen = offsetY.len();
Vec3 start = m_io.baseQuat * m_io.eyeOffsetView + viewParams.position+offsetX+offsetZ;
if (gEnv->pPhysicalWorld->RayWorldIntersection(start, offsetY, ent_static|ent_terrain|ent_rigid,
rwi_ignore_noncolliding | rwi_stop_at_pierceable, &hit, 1, pSkipEntities, nSkip))
{
offsetY = hit.pt - start;
if (offsetY.len()> 0.25f)
{
offsetY -= offsetY.GetNormalized()*0.25f;
}
current.y = current.y * (hit.dist/oldLen);
}
}
//viewParams.position += m_io.viewQuatFinal.GetColumn0() * current.x; // right
//viewParams.position += m_io.viewQuatFinal.GetColumn1() * current.y; // back
//viewParams.position += m_io.viewQuatFinal.GetColumn2() * current.z; // up
viewParams.position += offsetX + offsetY + offsetZ;
}
else
{
if (m_io.bUsePivot)
viewParams.position += m_io.viewQuatFinal.GetColumn1() * m_in.params_viewDistance + m_io.viewQuatFinal.GetColumn2() * (0.25f + m_in.params_viewHeightOffset);
else
{
viewParams.position += m_io.viewQuatFinal.GetColumn1() * -m_in.thirdPersonDistance + m_io.viewQuatFinal.GetColumn2() * (0.25f + m_in.params_viewHeightOffset);
}
}
}
示例8: ViewDeathCamTarget
void CPlayerView::ViewDeathCamTarget(SViewParams &viewParams)
{
CActor* pTarget = (CActor*)g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_in.stats_spectatorTarget);
if(!pTarget)
return;
Matrix34 targetWorldTM = pTarget->GetEntity()->GetWorldTM();
Vec3 camPos = viewParams.position;
static float offset = 1.5f;
camPos.z += offset;
float heightOffset = 1.5f;
const SStanceInfo* pSI = pTarget->GetStanceInfo(pTarget->GetStance());
if(pSI)
{
heightOffset = pSI->viewOffset.z;
}
Vec3 targetPos = targetWorldTM.GetTranslation();
targetPos.z += heightOffset;
int thisFrameId = gEnv->pRenderer->GetFrameID();
static int frameNo(thisFrameId);
static Vec3 oldCamPos(camPos);
static Vec3 oldTargetPos(targetPos);
static EntityId lastSpectatorTarget(m_in.stats_spectatorTarget);
static float oldFOVScale(1.0f);
// if more than a few frames have passed since our last update, invalidate the positions
if(thisFrameId - frameNo > 5)
{
oldCamPos = viewParams.position; // interpolate from current camera pos
oldTargetPos = targetPos;
oldFOVScale = 1.0f;
}
// if target changed, reset positions
if(lastSpectatorTarget != m_in.stats_spectatorTarget)
{
oldCamPos = camPos;
oldTargetPos = targetPos;
lastSpectatorTarget = m_in.stats_spectatorTarget;
oldFOVScale = 1.0f;
}
frameNo = thisFrameId;
// slight zoom after 2s
float timeNow = gEnv->pTimer->GetCurrTime();
float distSq = (targetPos - camPos).GetLengthSquared();
float scale = 1.0f;
if(timeNow - m_in.deathTime > 1.0f && distSq > 2500.0f)
{
// 1.0f at 50m, 0.3f at 100m+
scale = 1.0f - (distSq - 2500.0f)/25000.0f;
scale = CLAMP(scale, 0.3f, 1.0f);
}
Interpolate(oldCamPos, camPos, 5.0f, viewParams.frameTime);
Interpolate(oldTargetPos, targetPos, 5.0f, viewParams.frameTime);
Interpolate(oldFOVScale, scale, 0.5f, viewParams.frameTime);
viewParams.position = oldCamPos;
Vec3 dir = (oldTargetPos - oldCamPos).GetNormalizedSafe();
Matrix33 rotation = Matrix33::CreateRotationVDir(dir);
dir.z = 0.0f;
// quick ray check to make sure there's not a wall in the way...
IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_in.entityId);
if (pActor)
{
static ray_hit hit;
IPhysicalEntity* pSkipEntities[10];
int nSkip = 0;
IItem* pItem = pActor->GetCurrentItem();
if (pItem)
{
CWeapon* pWeapon = (CWeapon*)pItem->GetIWeapon();
if (pWeapon)
nSkip = CSingle::GetSkipEntities(pWeapon, pSkipEntities, 10);
}
if (gEnv->pPhysicalWorld->RayWorldIntersection(viewParams.position, -dir, ent_static|ent_terrain|ent_rigid,
rwi_ignore_noncolliding | rwi_stop_at_pierceable, &hit, 1, pSkipEntities, nSkip))
{
dir.zero();
}
}
viewParams.position -= dir;
viewParams.fov = m_in.defaultFov*oldFOVScale*(gf_PI/180.0f);;
viewParams.rotation = GetQuatFromMat33(rotation);
m_io.bUsePivot = true;
m_io.stats_bobCycle = 0.0;
}
示例9: OnPromoteToServer
//------------------------------------------------------------------------
bool CGameRules::OnPromoteToServer(SHostMigrationInfo& hostMigrationInfo, uint32& state)
{
if (!g_pGame->GetIGameFramework()->ShouldMigrateNub(hostMigrationInfo.m_session))
{
return true;
}
CryLogAlways("[Host Migration]: CGameRules::OnPromoteToServer() started");
// Server time will change after we migrate (change from old server time to new server time)
m_gameStartedTime.SetValue(m_gameStartedTime.GetValue() - m_cachedServerTime.GetValue());
m_gameStartTime.SetValue(m_gameStartTime.GetValue() - m_cachedServerTime.GetValue());
// If this migration has reset (we're not the original anticipated host, remove any entities from the first attempt
if (!m_hostMigrationCachedEntities.empty())
{
HostMigrationRemoveDuplicateDynamicEntities();
}
// Now we know we're the server, remove the actors for anyone we know isn't going to migrate
CGameLobby *pGameLobby = g_pGame->GetGameLobby();
CRY_ASSERT(pGameLobby);
if (pGameLobby)
{
TPlayers playersToRemove;
IActorSystem *pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem();
playersToRemove.reserve(pActorSystem->GetActorCount());
IActorIteratorPtr actorIt = pActorSystem->CreateActorIterator();
IActor *pActor;
while (pActor = actorIt->Next())
{
if (pActor->IsPlayer())
{
CRY_ASSERT(pActor->GetChannelId());
SCryMatchMakingConnectionUID conId = pGameLobby->GetConnectionUIDFromChannelID((int) pActor->GetChannelId());
if (pGameLobby->GetSessionNames().Find(conId) == SSessionNames::k_unableToFind)
{
CryLog(" player '%s' has not got a corresponding CGameLobby entry, removing actor", pActor->GetEntity()->GetName());
playersToRemove.push_back(pActor->GetEntityId());
}
}
}
const int numPlayersToRemove = playersToRemove.size();
for (int i = 0; i < numPlayersToRemove; ++ i)
{
FakeDisconnectPlayer(playersToRemove[i]);
}
}
for (uint32 i = 0; i < MAX_PLAYERS; ++ i)
{
m_migratedPlayerChannels[i] = 0;
}
IItemSystem *pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
IEntityItPtr it = gEnv->pEntitySystem->GetEntityIterator();
it->MoveFirst();
for (uint32 i = 0; i < m_hostMigrationItemMaxCount; ++ i)
{
m_pHostMigrationItemInfo[i].Reset();
}
uint32 itemIndex = 0;
IEntity *pEntity = NULL;
while (pEntity = it->Next())
{
IItem *pItem = pItemSystem->GetItem(pEntity->GetId());
if (pItem)
{
if (pItem->GetOwnerId())
{
IEntity *pOwner = gEnv->pEntitySystem->GetEntity(pItem->GetOwnerId());
if (pOwner)
{
EntityId currentItemId = 0;
IActor *pOwnerActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pOwner->GetId());
if (pOwnerActor)
{
IItem *pCurrentItem = pOwnerActor->GetCurrentItem();
currentItemId = pCurrentItem ? pCurrentItem->GetEntityId() : 0;
}
CryLog("[CG] Item '%s' is owned by '%s'", pEntity->GetName(), pOwner->GetName());
//m_pHostMigrationItemInfo[itemIndex].Set(pEntity->GetId(), pOwner->GetId(), pItem->IsUsed(), (pItem->GetEntityId() == currentItemId));
itemIndex ++;
if (itemIndex >= m_hostMigrationItemMaxCount)
{
CRY_ASSERT(itemIndex < m_hostMigrationItemMaxCount);
break;
}
}
}
//.........这里部分代码省略.........
示例10: UpdateCrosshair
void CHUDCrosshair::UpdateCrosshair()
{
IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
if(!pClientActor)
return;
int iNewFriendly = 0;
if(pClientActor->GetLinkedVehicle())
{
// JanM/MichaelR:
// Get status from the VehicleWeapon, which raycasts considering the necessary SkipEntities (in contrast to WorldQuery)
// Julien: this is now done in MP as well
iNewFriendly = g_pHUD->GetVehicleInterface()->GetFriendlyFire();
}
else
{
if(!gEnv->bMultiplayer)
{
CWeapon *pWeapon = g_pHUD->GetCurrentWeapon();
if(pWeapon)
{
iNewFriendly = pWeapon->IsWeaponLowered() && pWeapon->IsPendingFireRequest();
if(iNewFriendly && pWeapon->GetEntity()->GetClass() == CItem::sTACGunFleetClass)
iNewFriendly = 0;
}
else{
//Two handed pickups need the red X as well
CPlayer *pPlayer= static_cast<CPlayer*>(pClientActor);
if(CWeapon *pOffHand = static_cast<CWeapon*>(pPlayer->GetItemByClass(CItem::sOffHandClass)))
iNewFriendly = pOffHand->IsWeaponLowered();
}
}
else
{
EntityId uiCenterId = pClientActor->GetGameObject()->GetWorldQuery()->GetLookAtEntityId();
if(uiCenterId)
{
iNewFriendly = IsFriendlyEntity(gEnv->pEntitySystem->GetEntity(uiCenterId));
}
}
}
// SNH: if player is carrying a claymore or mine, ask the weapon whether it is possible to place it currently
// (takes into account player speed / stance / aim direction).
// So 'friendly' is a bit of a misnomer here, but we want the "don't/can't fire" crosshair...
if(iNewFriendly != 1 && g_pHUD)
{
CWeapon *pWeapon = g_pHUD->GetCurrentWeapon();
if(pWeapon)
{
static IEntityClass* pClaymoreClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("Claymore");
static IEntityClass* pAVMineClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("AVMine");
IEntityClass* pClass = pWeapon->GetEntity()->GetClass();
if(pClass == pClaymoreClass || pClass == pAVMineClass)
{
if(IFireMode* pfm = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode()))
{
if(!pfm->IsFiring())
iNewFriendly = pWeapon->CanFire() ? 0 : 1;
}
}
}
}
if(iNewFriendly != m_iFriendlyTarget)
{
m_iFriendlyTarget = iNewFriendly;
//m_animCrossHair.Invoke("setFriendly", m_iFriendlyTarget);
if(iNewFriendly)
m_animFriendCross.SetVisible(true);
else
m_animFriendCross.SetVisible(false);
}
if(m_animInterActiveIcons.GetVisible())
{
m_bHideUseIconTemp = false;
CItem *pItem = static_cast<CItem*>(pClientActor->GetCurrentItem());
if(pItem)
{
IWeapon *pWeapon = pItem->GetIWeapon();
if(pWeapon)
{
CItem::SStats stats = pItem->GetStats();
if(stats.mounted && stats.used)
m_bHideUseIconTemp = true;
}
}
if(!m_bHideUseIconTemp)
{
EntityId offHandId = pClientActor->GetInventory()->GetItemByClass(CItem::sOffHandClass);
IItem *pOffHandItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(offHandId);
if(pOffHandItem)
{
COffHand *pOffHand = static_cast<COffHand*>(pOffHandItem);
uint32 offHandState = pOffHand->GetOffHandState();
if(offHandState == eOHS_HOLDING_OBJECT || offHandState == eOHS_THROWING_OBJECT ||
offHandState == eOHS_HOLDING_NPC || offHandState == eOHS_THROWING_NPC)
m_bHideUseIconTemp = true;
//.........这里部分代码省略.........