Пример #1
0
void CInventory::Update() 
{
	if( OnServer() )
	{
		if(m_iActiveSlot!=m_iNextActiveSlot)
		{
			CObject* pActor_owner = smart_cast<CObject*>(m_pOwner);
			if (Level().CurrentViewEntity() == pActor_owner)
			{
				if(	(m_iNextActiveSlot!=NO_ACTIVE_SLOT) && 
					 ItemFromSlot(m_iNextActiveSlot)	&&
					 !g_player_hud->allow_activation(ItemFromSlot(m_iNextActiveSlot)->cast_hud_item())
				   )
				   return;
			}
			if( ActiveItem() )
			{
				CHudItem* hi = ActiveItem()->cast_hud_item();
				
				if(!hi->IsHidden())
				{
					if(hi->GetState()==CHUDState::eIdle && hi->GetNextState()==CHUDState::eIdle)
						hi->SendDeactivateItem();

					UpdateDropTasks	();
					return;
				}
			}
			
			if (GetNextActiveSlot() != NO_ACTIVE_SLOT)
			{
				PIItem tmp_next_active = ItemFromSlot(GetNextActiveSlot());
				if (tmp_next_active)
				{
					if (IsSlotBlocked(tmp_next_active))
					{
						Activate(m_iActiveSlot);
						return;
					} else
					{
						tmp_next_active->ActivateItem();
					}
				}
			}
			
//			if ( m_iActiveSlot != GetNextActiveSlot() ) {
//				LPCSTR const name = smart_cast<CGameObject const*>(m_pOwner)->cName().c_str();
//				if ( !xr_strcmp("jup_b43_stalker_assistant_pri6695", name) )
//					LogStackTrace	("");
//				Msg					("[%6d][%s] CInventory::Activate changing active slot from %d to next active slot %d", Device.dwTimeGlobal, name, m_iActiveSlot, GetNextActiveSlot() );
//			}
			m_iActiveSlot			= GetNextActiveSlot();
		}
		if((GetNextActiveSlot()!=NO_ACTIVE_SLOT) && ActiveItem() && ActiveItem()->cast_hud_item()->IsHidden())
				ActiveItem()->ActivateItem();
	}
	UpdateDropTasks	();
}