本文整理汇总了C++中CItem::CanUse方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::CanUse方法的具体用法?C++ CItem::CanUse怎么用?C++ CItem::CanUse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::CanUse方法的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: CanUse
//------------------------------------------------------------------------
int CScriptBind_Item::CanUse(IFunctionHandler *pH, ScriptHandle userId)
{
CItem *pItem = GetItem(pH);
if (!pItem)
return pH->EndFunction();
return pH->EndFunction(pItem->CanUse((EntityId)userId.n));
}
示例3: CanUseVehicle
//------------------------------------------------------------------------
int CScriptBind_Item::CanUseVehicle(IFunctionHandler *pH, ScriptHandle userId)
{
CItem *pItem = GetItem(pH);
if (!pItem)
return pH->EndFunction();
IEntity* pParent = pItem->GetEntity()->GetParent();
if(pParent)
{
IVehicle* pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(pParent->GetId());
if(pVehicle)
{
return pH->EndFunction(pVehicle->IsUsable((EntityId)userId.n));
}
}
return pH->EndFunction(pItem->CanUse((EntityId)userId.n));
}
示例4: 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();
}