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 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); } } } }