MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / SetActorItem

Method SetActorItem

Code/CryEngine/CryAction/ItemSystem.cpp:713–771  ·  view source on GitHub ↗

------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

711
712//------------------------------------------------------------------------
713void CItemSystem::SetActorItem(IActor* pActor, EntityId itemId, bool keepHistory)
714{
715 if (!pActor)
716 return;
717 IInventory* pInventory = pActor->GetInventory();
718 if (!pInventory)
719 return;
720
721 EntityId currentItemId = pInventory->GetCurrentItem();
722
723 IItem* pItem = GetItem(itemId);
724
725 if (currentItemId == itemId)
726 {
727 if (keepHistory)
728 pInventory->SetLastItem(currentItemId);
729
730 if (pItem)
731 pItem->Select(true);
732 return;
733 }
734
735 if (currentItemId)
736 {
737 IItem* pCurrentItem = GetItem(currentItemId);
738 if (pCurrentItem)
739 {
740 pInventory->SetCurrentItem(0);
741 pCurrentItem->Select(false);
742 if (keepHistory)
743 pInventory->SetLastItem(currentItemId);
744 }
745 }
746
747 for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
748 {
749 notifier->OnSetActorItem(pActor, pItem);
750 }
751
752 if (pItem == NULL && itemId != 0)
753 {
754#ifndef _RELEASE
755 IEntity* pEntity = gEnv->pEntitySystem->GetEntity(itemId);
756 CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "%s tried to select item ID %u but that ID does not belong to an item, it belongs to %s", pActor->GetEntity()->GetName(), itemId, pEntity ? pEntity->GetEntityTextDescription() : "nothing");
757#endif
758 return;
759 }
760
761 CCryAction::GetCryAction()->GetIGameplayRecorder()->Event(pActor->GetEntity(), GameplayEvent(eGE_ItemSelected, 0, 0, (void*)(EXPAND_PTR)itemId));
762 pActor->NotifyCurrentItemChanged(pItem);
763
764 if (!pItem)
765 return;
766
767 pInventory->SetCurrentItem(itemId);
768
769 pItem->SetHand(IItem::eIH_Right);
770 pItem->Select(true);

Callers 15

GiveEquipmentPackMethod · 0.45
ProcessEventMethod · 0.45
HolsterItemMethod · 0.45
IMPLEMENT_RMIFunction · 0.45
ProcessEventMethod · 0.45
StartUseMethod · 0.45
DropMethod · 0.45
SelectItemMethod · 0.45
FinishReviveMethod · 0.45
DebugGunMethod · 0.45
RefGunMethod · 0.45
ProcessEventMethod · 0.45

Calls 15

CryWarningFunction · 0.85
SetLastItemMethod · 0.80
SetCurrentItemMethod · 0.80
GetIGameplayRecorderMethod · 0.80
SetHandMethod · 0.80
FindClassMethod · 0.80
GetClassRegistryMethod · 0.80
GameplayEventClass · 0.70
GetItemFunction · 0.50
GetInventoryMethod · 0.45

Tested by

no test coverage detected