void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate || event == eFE_Initialize) { if (IsPortActive(pActInfo, INP_ACTIVE)) { bool active = GetPortBool(pActInfo, 0); if (active) m_pGF->GetIItemSystem()->RegisterListener(this); else m_pGF->GetIItemSystem()->UnregisterListener(this); } if (IsPortActive(pActInfo, INP_CHECK)) { IActor* pActor = GetInputActor( pActInfo ); if (pActor) { IInventory* pInventory = pActor->GetInventory(); if (pInventory) { IEntity* pEntityItem = gEnv->pEntitySystem->GetEntity( pInventory->GetCurrentItem() ); TriggerOutputs( pActInfo, pEntityItem ); } } } } }
void CSetEquipmentLoadoutNode ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if(event == eFE_Activate && IsPortActive(pActInfo, 0)) { if(pActInfo->pEntity) { IActor* pActor = GetInputActor( pActInfo ); CGameRules *pGameRules = g_pGame->GetGameRules(); if(pActor) { int packIndex = GetPortInt(pActInfo, eI_EquipLoadout); CEquipmentLoadout *pEquipmentLoadout = g_pGame->GetEquipmentLoadout(); if(pEquipmentLoadout) { pEquipmentLoadout->SetSelectedPackage(packIndex); pGameRules->SetPendingLoadoutChange(); } } } } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { IGameFramework* pGF = gEnv->pGame->GetIGameFramework(); if (event == eFE_Activate && IsPortActive(pActInfo,0)) { IActor* pActor = GetInputActor( pActInfo ); if (!pActor) return; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) return; const string& item = GetPortString(pActInfo, 1); IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(item); if (0 == pInventory->GetItemByClass(pClass)) { ActivateOutput(pActInfo, 0, false); } else { pGF->GetIItemSystem()->SetActorItem(pActor, item, true); ActivateOutput(pActInfo, 0, true); } } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate && IsPortActive(pActInfo,0)) { IGameFramework * pGameFramework = gEnv->pGame->GetIGameFramework(); IActor* pActor = GetInputActor( pActInfo ); if (!pActor || pActor!=gEnv->pGame->GetIGameFramework()->GetClientActor()) // to avoid some extra RMIs and object creation. Tho, this causes the node to not work properly if it is used with non players entities. (which was never intended anyway) return; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) return; const string& itemClass = GetPortString( pActInfo, 1 ); IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass( itemClass.c_str() ); EntityId id = pInventory->GetItemByClass( pClass ); if (id!=0) { pInventory->RMIReqToServer_RemoveItem( itemClass.c_str() ); // TODO: instant output activation, with delayed effective change in the inventory, it potentially could cause problems in rare situations ActivateOutput(pActInfo,0,true); } else ActivateOutput(pActInfo,0,true); } }
virtual void OnSetActorItem(IActor *pSetActor, IItem *pItem ) { IActor* pActor = GetInputActor( &m_actInfo ); if (!pActor || pActor!=pSetActor) return; TriggerOutputs( &m_actInfo, pItem ? pItem->GetEntity() : NULL ); }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate && IsPortActive(pActInfo,0)) { IActor* pActor = GetInputActor( pActInfo ); if (!pActor || pActor!=gEnv->pGame->GetIGameFramework()->GetClientActor()) // to avoid some extra RMIs and object creation. Tho, this causes the node to not work properly if it is used with non players entities. (which was never intended anyway) return; IEntitySystem* pEntSys = gEnv->pEntitySystem; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) return; const string& itemClass = GetPortString(pActInfo, 1); const char* pItemClass = itemClass.c_str(); IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(pItemClass); EntityId id = pInventory->GetItemByClass(pClass); if (id == 0 || GetPortBool(pActInfo, 3) == false) { if(gEnv->bServer) { gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GiveItem( pActor, pItemClass , false, true, true ); } else { // TODO: instant output activation, with delayed effective change in the inventory, it potentially could cause problems in rare situations pInventory->RMIReqToServer_AddItem( pItemClass ); } ActivateOutput( pActInfo, 0, true ); } else { // item already in inventory ActivateOutput(pActInfo, 0, false); } } else if (event == eFE_PrecacheResources) { const string& itemClass = GetPortString(pActInfo, 1); if (!itemClass.empty()) { IGameRules* pGameRules = CCryAction::GetCryAction()->GetIGameRulesSystem()->GetCurrentGameRules(); CRY_ASSERT_MESSAGE(pGameRules != NULL, "No game rules active, can not precache resources"); if (pGameRules) { pGameRules->PrecacheLevelResource(itemClass.c_str(), eGameResourceType_Item); } } } }
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); } } } }
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); } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate && IsPortActive(pActInfo,0)) { IActor* pActor = GetInputActor( pActInfo ); if (!pActor) return; IInventory *pInventory = pActor->GetInventory(); if (pInventory) { pInventory->ResetAmmo(); const bool removeFromWeapons = GetPortBool(pActInfo, 1); if(removeFromWeapons) { IItemSystem* pItemSystem = CCryAction::GetCryAction()->GetIItemSystem(); const size_t numItems = pInventory->GetCount(); for(size_t i=0; i<numItems; ++i) { const EntityId item = pInventory->GetItem(i); if(IItem* pItem = pItemSystem->GetItem(item)) { if(IWeapon* pWeapon = pItem->GetIWeapon()) { const size_t numFiremodes = pWeapon->GetNumOfFireModes(); for(size_t f=0; f<numFiremodes; ++f) { if(IFireMode* pFireMode = pWeapon->GetFireMode(f)) { if(IEntityClass* pAmmoType = pFireMode->GetAmmoType()) { pWeapon->SetAmmoCount(pAmmoType, 0); } } } } } } } ActivateOutput(pActInfo, 0, true); } else ActivateOutput(pActInfo, 0, false); } }
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)); } } } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate && IsPortActive(pActInfo,0)) { IGameFramework* pGF = gEnv->pGame->GetIGameFramework(); IActor* pActor = GetInputActor( pActInfo ); if (!pActor || pActor!=gEnv->pGame->GetIGameFramework()->GetClientActor()) // to avoid some extra RMIs and object creation. Tho, this causes the node to not work properly if it is used with non players entities. (which was never intended anyway) return; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) return; pInventory->RMIReqToServer_RemoveAllItems(); // TODO: instant output activation, with delayed effective change in the inventory, it potentially could cause problems in rare situations ActivateOutput(pActInfo, 0, true); } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate && IsPortActive(pActInfo, EIP_Trigger)) { IActor* pActor = GetInputActor( pActInfo ); if (!pActor) return; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) return; const bool& addPack = GetPortBool(pActInfo, EIP_AddToggle); const string& packName = GetPortString(pActInfo, EIP_EquipmentPack); const bool& selectPrimary = GetPortBool(pActInfo, EIP_SelectPrimary); if (pActor->IsPlayer()) pInventory->RMIReqToServer_AddEquipmentPack( packName.c_str(), addPack, selectPrimary ); else { if (gEnv->bServer) CCryAction::GetCryAction()->GetIItemSystem()->GetIEquipmentManager()->GiveEquipmentPack( pActor, packName.c_str(), addPack, selectPrimary ); } // TODO: instant output activation, with delayed effective change in the inventory, it potentially could cause problems in rare situations ActivateOutput(pActInfo, EOP_Done, true); } else if (event == eFE_PrecacheResources) { const string& packName = GetPortString(pActInfo, 1); if (!packName.empty()) { IGameRules* pGameRules = CCryAction::GetCryAction()->GetIGameRulesSystem()->GetCurrentGameRules(); CRY_ASSERT_MESSAGE(pGameRules != NULL, "No game rules active, can not precache resources"); if (pGameRules) { pGameRules->PrecacheLevelResource(packName.c_str(), eGameResourceType_Loadout); } } } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { if (event == eFE_Activate && IsPortActive(pActInfo,0)) { IActor* pActor = GetInputActor( pActInfo ); if (!pActor) return; IInventory *pInventory = pActor->GetInventory(); if (!pInventory) return; IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(GetPortString(pActInfo,1)); EntityId id = pInventory->GetItemByClass(pClass); ActivateOutput(pActInfo, 0, id !=0 ? true : false); ActivateOutput(pActInfo, id != 0 ? 2 : 1, true); ActivateOutput(pActInfo, 3, id); } }
void CFlashUIGetEquippedAccessoriesNode::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 object via the ID CGameObject * pGameObject = (CGameObject*)gEnv->pEntitySystem->GetEntity(item)->GetProxy(ENTITY_PROXY_USER); const char* ext = pGameObject->GetEntity()->GetClass()->GetName(); IItem* pWeapon = (IItem*)pGameObject->QueryExtension(pGameObject->GetEntity()->GetClass()->GetName()); //If the weapon exists, return all equipped attachments in a comma seperated string if(pWeapon) { //All equipped accessories for this weapon weapons accessories = static_cast<CItem*>(pWeapon)->GetAttachedAccessoriesString(); } } } //return, if 'accesories' is empty, it has no attachments, or something was invalid ActivateOutput(pActInfo, eO_OnCall, true); ActivateOutput(pActInfo, eO_Args, accessories); } }
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); } }