本文整理汇总了C++中CGameObject::QueryExtension方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::QueryExtension方法的具体用法?C++ CGameObject::QueryExtension怎么用?C++ CGameObject::QueryExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::QueryExtension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEvent
void CFlashUIInventoryNode::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
if(event == eFE_Activate && IsPortActive(pActInfo, 0))
{
IActor* pActor = GetInputActor( pActInfo );
if(pActor)
{
IInventory* pInventory = pActor->GetInventory();
if(pInventory)
{
string weapons = "";
bool first = true;
int inv_cap = gEnv->pConsole->GetCVar("i_inventory_capacity")->GetIVal();
for (int i = 0; i < inv_cap; i++)
{
const char* weaponName = pInventory->GetItemString(i);
if(strcmp(weaponName, "") != 0)
{
bool selectable = false;
//Get the weapon and check if it is a selectable item
IEntityClassRegistry *pRegistry = gEnv->pEntitySystem->GetClassRegistry();
EntityId item = pInventory->GetItemByClass(pRegistry->FindClass(weaponName));
IEntity* pEntity = gEnv->pEntitySystem->GetEntity(item);
if(pEntity)
{
CGameObject * pGameObject = (CGameObject*)pEntity->GetProxy(ENTITY_PROXY_USER);
CItem* pItem = (CItem*)pGameObject->QueryExtension(pGameObject->GetEntity()->GetClass()->GetName());
if(pItem)
{
selectable = pItem->CanSelect();
}
}
if(selectable)
{
if(!first)
weapons.append(",");
first = false;
weapons.append(weaponName);
}
}
}
ActivateOutput(pActInfo, eO_OnCall, true);
ActivateOutput(pActInfo, eO_Args, weapons);
}
}
}
}
示例2: GetInputActor
void CFlashUIGetCompatibleAccessoriesNode ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
if(event == eFE_Activate && IsPortActive(pActInfo, 0))
{
string accessories = "";
IActor* pActor = GetInputActor( pActInfo );
if(pActor)
{
IInventory* pInventory = pActor->GetInventory();
if(pInventory)
{
//Get the item ID via the Input string
const string weapon_name = GetPortString(pActInfo, eI_Weapon);
IEntityClassRegistry *pRegistery = gEnv->pEntitySystem->GetClassRegistry();
EntityId item = pInventory->GetItemByClass(pRegistery->FindClass(weapon_name));
//Fetch the actual weapon via the ID
IEntity* pEntity = gEnv->pEntitySystem->GetEntity(item);
if(pEntity)
{
CGameObject * pGameObject = (CGameObject*)pEntity->GetProxy(ENTITY_PROXY_USER);
const char* ext = pGameObject->GetEntity()->GetClass()->GetName();
CWeapon* pWeapon = (CWeapon*)pGameObject->QueryExtension(pGameObject->GetEntity()->GetClass()->GetName());
//If the weapon exists, ask for all compatible accessories
if(pWeapon)
{
//All compatible accessories for this weapon
const DynArray<string> pCompatibleAccessoriesVec = pWeapon->GetCompatibleAccessories();
bool first = true;
DynArray<string>::const_iterator it;
for (it = pCompatibleAccessoriesVec.begin(); it != pCompatibleAccessoriesVec.end(); it++)
{
if (!first)
accessories.append(",");
accessories.append((*it));
first = false;
}
}
}
}
}
//return, if 'accessories' is empty, it has no compatible attachments, or the weapon/inventory was invalid
ActivateOutput(pActInfo, eO_OnCall, true);
ActivateOutput(pActInfo, eO_Args, accessories);
}
}
示例3: if
void CFlashUICheckAccessoryState ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
if(event == eFE_Activate && IsPortActive(pActInfo, 0))
{
IActor* pActor = GetInputActor( pActInfo );
bool is_equipped = false;
bool is_inInventory = false;
if(pActor)
{
IInventory* pInventory = pActor->GetInventory();
if(pInventory)
{
IEntityClassRegistry *pRegistry = gEnv->pEntitySystem->GetClassRegistry();
//Find the accessory's class in the registry
const string accessory_name = GetPortString(pActInfo, eI_Accessory);
IEntityClass* pClass = pRegistry->FindClass(accessory_name);
//Check if its in inventory
if(pInventory->HasAccessory(pClass) != 0)
{
is_inInventory = true;
}
//if it is, check if its equipped as well
if(is_inInventory)
{
//Get the weapon ID via the Input string
const char* weapon_name = GetPortString(pActInfo, eI_Weapon).c_str();
EntityId item = pInventory->GetItemByClass(pRegistry->FindClass(weapon_name));
//Fetch the actual weapon via the ID
IEntity* pEntity = gEnv->pEntitySystem->GetEntity(item);
if(pEntity)
{
CGameObject * pGameObject = (CGameObject*)pEntity->GetProxy(ENTITY_PROXY_USER);
const char* ext = pGameObject->GetEntity()->GetClass()->GetName();
CWeapon* pWeapon = (CWeapon*)pGameObject->QueryExtension(pGameObject->GetEntity()->GetClass()->GetName());
bool selectable = pWeapon->CanSelect();
if(pWeapon)
{
if(pWeapon->GetAccessory(pClass->GetName()) != 0)
{
is_equipped = true;
}
}
}
}
}
}
if(!is_inInventory)
ActivateOutput(pActInfo, eO_DontHave, true);
else if(is_equipped)
ActivateOutput(pActInfo, eO_Equipped, true);
else
ActivateOutput(pActInfo, eO_InInventory, true);
}
}