本文整理汇总了C++中CItem::GetEntityId方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetEntityId方法的具体用法?C++ CItem::GetEntityId怎么用?C++ CItem::GetEntityId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetEntityId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUsed
//------------------------------------------------------------------------
int CScriptBind_Item::OnUsed(IFunctionHandler *pH, ScriptHandle userId)
{
CItem *pItem = GetItem(pH);
if (!pItem)
return pH->EndFunction();
if (pItem->CanUse((EntityId)userId.n))
{
CActor *pActor=GetActor((EntityId)userId.n);
if (pActor)
{
pActor->UseItem(pItem->GetEntityId());
return pH->EndFunction(true);
}
}
else if (pItem->CanPickUp((EntityId)userId.n))
{
CActor *pActor=GetActor((EntityId)userId.n);
if (pActor)
{
pActor->PickUpItem(pItem->GetEntityId(), true);
return pH->EndFunction(true);
}
}
return pH->EndFunction();
}
示例2: OnUsed
//------------------------------------------------------------------------
int CScriptBind_Item::OnUsed(IFunctionHandler *pH, ScriptHandle userId)
{
CItem *pItem = GetItem(pH);
if (!pItem)
return pH->EndFunction();
CActor *pActor = GetActor((EntityId)userId.n);
if (!pActor)
return pH->EndFunction();
if (pItem->CanUse((EntityId)userId.n))
{
if(IEntity* pParent = pItem->GetEntity()->GetParent())
{
IVehicle* pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(pParent->GetId());
if(pVehicle)
{
CPlayer* pPlayer = static_cast<CPlayer*>(pActor);
IInteractor* pInteractor = pPlayer->GetInteractor();
return pH->EndFunction( pVehicle->OnUsed((EntityId)userId.n, pInteractor->GetOverSlotIdx()) );
}
}
pActor->UseItem(pItem->GetEntityId());
return pH->EndFunction(true);
}
else if (pItem->CanPickUp((EntityId)userId.n))
{
//Should be always the client...
if (pActor->IsClient())
{
CPlayer* pClientPlayer = static_cast<CPlayer*>(pActor);
const SInteractionInfo& interactionInfo = pClientPlayer->GetCurrentInteractionInfo();
bool expectedItem = (interactionInfo.interactiveEntityId == pItem->GetEntityId());
bool expectedInteraction = (interactionInfo.interactionType == eInteraction_PickupItem) ||
(interactionInfo.interactionType == eInteraction_ExchangeItem);
if (!expectedItem || !expectedInteraction)
{
return pH->EndFunction();
}
if (interactionInfo.interactionType == eInteraction_ExchangeItem)
{
IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
CItem* pCurrentItem = static_cast<CItem*>(pActor->GetCurrentItem());
CItem* pExchangeItem = static_cast<CItem*>(pItemSystem->GetItem(interactionInfo.swapEntityId));
if (pExchangeItem && pCurrentItem)
pExchangeItem->ScheduleExchangeToNextItem(pActor, pItem, pCurrentItem);
}
else
{
pActor->PickUpItem(pItem->GetEntityId(), true, true);
}
}
else
{
pActor->PickUpItem(pItem->GetEntityId(), true, true);
}
return pH->EndFunction(true);
}
return pH->EndFunction();
}
示例3: GetTeam
IMPLEMENT_RMI(CGameRules, ClEnteredGame)
{
CPlayer *pClientActor = static_cast<CPlayer*>(m_pGameFramework->GetClientActor());
if (pClientActor)
{
IEntity *pClientEntity = pClientActor->GetEntity();
const EntityId clientEntityId = pClientEntity->GetId();
if(!gEnv->bServer)
{
int status[2];
status[0] = GetTeam(clientEntityId);
status[1] = pClientActor->GetSpectatorMode();
m_pGameplayRecorder->Event(pClientEntity, GameplayEvent(eGE_Connected, 0, 0, (void*)status));
}
if (g_pGame->GetHostMigrationState() != CGame::eHMS_NotMigrating)
{
eHostMigrationState hostMigrationState = g_pGame->GetGameLobby()->GetMatchMakingHostMigrationState();
if (hostMigrationState < eHMS_ReconnectClient)
{
CryLog("CGameRules::ClEnteredGame() received a left over message from previous server, ignoring it");
return true;
}
CryLog("CGameRules::ClEnteredGame() We have our client actor ('%s'), send migration params", pClientEntity->GetName());
// Request various bits
GetGameObject()->InvokeRMI(SvHostMigrationRequestSetup(), *m_pHostMigrationParams, eRMI_ToServer);
SAFE_DELETE(m_pHostMigrationParams);
pClientActor->GetEntity()->SetPos(m_pHostMigrationClientParams->m_position);
pClientActor->SetViewRotation(m_pHostMigrationClientParams->m_viewQuat);
if (m_pHostMigrationClientParams->m_hasValidVelocity)
{
pe_action_set_velocity actionVel;
actionVel.v = m_pHostMigrationClientParams->m_velocity;
actionVel.w.zero();
IPhysicalEntity *pPhysicalEntity = pClientEntity->GetPhysics();
if (pPhysicalEntity)
{
pPhysicalEntity->Action(&actionVel);
}
}
CPlayerMovementController *pPMC = static_cast<CPlayerMovementController *>(pClientActor->GetMovementController());
if (pPMC)
{
// Force an update through so that the aim direction gets set correctly
pPMC->PostUpdate(0.f);
}
if (m_pHostMigrationClientParams->m_pSelectedItemClass)
{
CItem *pItem = pClientActor->GetItemByClass(m_pHostMigrationClientParams->m_pSelectedItemClass);
if (pItem)
{
EntityId itemId = pItem->GetEntityId();
if (pClientActor->GetCurrentItemId() != itemId)
{
pClientActor->SelectItem(itemId, false);
}
}
}
m_pHostMigrationClientParams->m_doneEnteredGame = true;
if (m_pHostMigrationClientParams->IsDone())
{
SAFE_DELETE(m_pHostMigrationClientParams);
}
if (!gEnv->bServer)
{
// todo: ui
}
m_hostMigrationClientHasRejoined = true;
}
else
{
NOTIFY_UI_MP( EnteredGame() );
}
}
return true;
}
示例4:
CItemSelectAction::CItemSelectAction(int priority, FragmentID fragmentID, const TagState &fragTags, CItem& _item)
: BaseClass(priority, fragmentID, fragTags)
, m_ItemID(_item.GetEntityId())
, m_bSelected(false)
{}