本文整理汇总了C++中IWeapon::GetCurrentFireMode方法的典型用法代码示例。如果您正苦于以下问题:C++ IWeapon::GetCurrentFireMode方法的具体用法?C++ IWeapon::GetCurrentFireMode怎么用?C++ IWeapon::GetCurrentFireMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWeapon
的用法示例。
在下文中一共展示了IWeapon::GetCurrentFireMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: ProcessEvent
//.........这里部分代码省略.........
// 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;
}
}
};
示例3: Update
void CHUDCrosshair::Update(float fDeltaTime)
{
if(m_bBroken)
return;
IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
IItemSystem *pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
if(!pClientActor || !pItemSystem)
return;
IInventory *pInventory = pClientActor->GetInventory();
if(!pInventory)
return;
IItem *pItem = pItemSystem->GetItem(pInventory->GetCurrentItem());
IWeapon *pWeapon = NULL;
IWeapon *pSlaveWeapon = NULL;
const float fAlternateIronSight = 0.03f;
if(pItem)
{
pWeapon = pItem->GetIWeapon();
if(pItem->IsDualWieldMaster())
{
if(IItem *pSlave=pItem->GetDualWieldSlave())
pSlaveWeapon = pSlave->GetIWeapon();
}
}
else if(IVehicle *pVehicle=pClientActor->GetLinkedVehicle())
{
pItem = pItemSystem->GetItem(pVehicle->GetCurrentWeaponId(pClientActor->GetEntityId()));
if(pItem)
pWeapon = pItem->GetIWeapon();
}
if(pWeapon)
{
float fMinSpread = 0.0f;
float fMaxSpread = 0.0f;
m_spread = 0.0f;
if(IFireMode *pFireMode=pWeapon->GetFireMode(pWeapon->GetCurrentFireMode()))
{
fMinSpread = pFireMode->GetMinSpread();
fMaxSpread = pFireMode->GetMaxSpread();
m_spread = pFireMode->GetSpread();
}
if(pSlaveWeapon)
{
if(IFireMode *pSlaveFireMode=pSlaveWeapon->GetFireMode(pSlaveWeapon->GetCurrentFireMode()))
{
fMinSpread += pSlaveFireMode->GetMinSpread();
fMaxSpread += pSlaveFireMode->GetMaxSpread();
m_spread += pSlaveFireMode->GetSpread();
}
}
CPlayer *pPlayer = static_cast<CPlayer*>(pClientActor);
if(pPlayer && pPlayer->GetNanoSuit() && pPlayer->GetNanoSuit()->GetMode() == NANOMODE_STRENGTH)
m_spread *=0.5;
if(g_pGameCVars->hud_iAlternateCrosshairSpread)
{
if(m_spread < fMinSpread)
m_spread = min(m_spread,g_pGameCVars->hud_fAlternateCrosshairSpreadCrouch) / g_pGameCVars->hud_fAlternateCrosshairSpreadCrouch;
else
m_spread = min(m_spread,g_pGameCVars->hud_fAlternateCrosshairSpreadNeutral) / g_pGameCVars->hud_fAlternateCrosshairSpreadNeutral;
}
else
{
m_spread = min((m_spread-fMinSpread),15.0f) / 15.0f;
IZoomMode *pZoomMode = pWeapon->GetZoomMode(pWeapon->GetCurrentZoomMode());
if(pZoomMode && !pZoomMode->IsToggle() && (pZoomMode->IsZoomed() || pZoomMode->IsZooming()))
{
m_spread -= fAlternateIronSight;
}
else
{
m_spread = min(m_spread,1.0f);
m_spread = max(m_spread,0.0f);
}
}
}
if(m_animCrossHair.GetVisible() && !g_pHUD->InSpectatorMode())
{
//also disables the damage indicator
if(/*g_pGameCVars->hud_crosshair>0 && m_iCrosshair > 0 &&*/ (g_pGameCVars->g_difficultyLevel<4 || gEnv->bMultiplayer))
{
m_animCrossHair.GetFlashPlayer()->Advance(fDeltaTime);
m_animCrossHair.GetFlashPlayer()->Render();
}
//.........这里部分代码省略.........