Skip to content

Commit

Permalink
xrGame/Inventory.cpp: fix show detector after item's animations
Browse files Browse the repository at this point in the history
  • Loading branch information
ChugunovRoman committed Dec 14, 2024
1 parent 9f77430 commit 0cc68f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/xrGame/CustomDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ void CCustomDetector::OnAnimationEnd(u32 state)
case eShowing:
{
SwitchState(eIdle);
m_bDetectorActive = true;
if (IsUsingCondition() && m_fDecayRate > 0.f)
this->SetCondition(-m_fDecayRate);
if (g_player_hud[0]->attached_item())
Expand Down Expand Up @@ -268,6 +269,7 @@ void CCustomDetector::OnAnimationEnd(u32 state)
g_player_hud[1]->detach_item(this);
g_player_hud[0]->after_detach_item_idx(this);
g_player_hud[0]->set_bone_visible("l_clavicle", TRUE, FALSE);
m_bDetectorActive = false;
}
break;
}
Expand All @@ -276,7 +278,7 @@ void CCustomDetector::OnAnimationEnd(u32 state)
void CCustomDetector::UpdateXForm() { CInventoryItem::UpdateXForm(); }
void CCustomDetector::OnActiveItem()
{
m_bDetectorActive = true;
m_bDetectorActive = false;
}
void CCustomDetector::OnHiddenItem()
{
Expand Down
11 changes: 7 additions & 4 deletions src/xrGame/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,10 +1186,13 @@ bool CInventory::Eat(PIItem pIItem)
{
if (CCustomDetector* detector = smart_cast<CCustomDetector*>(Actor()->inventory().ItemFromSlot(DETECTOR_SLOT)))
{
detector->HideDetector(CCustomDetector::eQuick);
CEatableItemObject* pItemToEatObj = smart_cast<CEatableItemObject*>(pIItem);
if (pItemToEatObj)
pItemToEatObj->SetRestoreDetector(true);
if (detector->IsActive())
{
detector->HideDetector(CCustomDetector::eQuick);
CEatableItemObject* pItemToEatObj = smart_cast<CEatableItemObject*>(pIItem);
if (pItemToEatObj)
pItemToEatObj->SetRestoreDetector(true);
}
}

CurrentGameUI()->GetActorMenu().HideDialog();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/eatable_item_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void CEatableItemObject::RestoreSlot()
if (restor_detector)
{
if (CCustomDetector* detector = smart_cast<CCustomDetector*>(Actor()->inventory().ItemFromSlot(DETECTOR_SLOT)))
detector->ShowDetector(CCustomDetector::eNone);
detector->ShowDetector(CCustomDetector::eFast);
}

restor_detector = false;
Expand Down

0 comments on commit 0cc68f8

Please sign in to comment.