示例#1
0
//------------------------------------------------------------------------
void CItem::SetViewMode(int mode)
{
	m_stats.viewmode = mode;

	if(mode & eIVM_FirstPerson)
	{
		SetHand(m_stats.hand);

		if(!m_parentId)
		{
			uint32 flags = GetEntity()->GetFlags();

			if(!m_stats.mounted)
				flags &= ~ENTITY_FLAG_CASTSHADOW;
			else
				flags |= ENTITY_FLAG_CASTSHADOW;

			//GetEntity()->SetFlags(flags|ENTITY_FLAG_RECVSHADOW);
			DrawSlot(eIGS_FirstPerson, true, !m_stats.mounted);
		}
		else
			DrawSlot(eIGS_FirstPerson, false, false);
	}
	else
	{
		SetGeometry(eIGS_FirstPerson, 0);
	}

	if(mode & eIVM_ThirdPerson)
	{
		DrawSlot(eIGS_ThirdPerson, true);

		if(!m_stats.mounted)
			CopyRenderFlags(GetOwner());
	}
	else
		DrawSlot(eIGS_ThirdPerson, false);

	for(TAccessoryMap::iterator it = m_accessories.begin(); it != m_accessories.end(); it++)
	{
		IItem *pItem = m_pGameFramework->GetIItemSystem()->GetItem(it->second);

		if(pItem)
		{
			CItem *pCItem = static_cast<CItem *>(pItem);

			if(pCItem)
				pCItem->SetViewMode(mode);
		}
	}
}
示例#2
0
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select/* =true */, bool keepHistory/* =true */, const char *setup /*= NULL*/)
{
    CActor *pActor=GetActor(pickerId);
    if (!pActor)
        return;

    TriggerRespawn();

    GetEntity()->EnablePhysics(false);
    Physicalize(false, false);

    bool soundEnabled = IsSoundEnabled();
    EnableSound(sound);

    SetViewMode(0);
    SetOwnerId(pickerId);

    CopyRenderFlags(GetOwner());

    Hide(true);
    m_stats.dropped = false;
    m_stats.detached = false;
    m_stats.brandnew = false;


    IInventory *pInventory = pActor->GetInventory();
    if (!pInventory)
        {
            GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName());
            return;
        }

    if (!pActor->IsPlayer() || pActor->IsClient() || gEnv->bMultiplayer)
        {
            bool hasAccessory = pInventory->HasAccessory(GetEntity()->GetClass());
            bool hasAccessoryForThisWeapon = pInventory->HasAccessory(GetEntity()->GetClass());

            if (!hasAccessoryForThisWeapon)
                pInventory->AddAccessory(GetEntity()->GetClass());
            if (!hasAccessory)
                ProcessAccessoryAmmoCapacities(pInventory, true);
            if (!hasAccessoryForThisWeapon)
                ProcessAccessoryAmmo(pInventory);
        }

    OnPickedUp(pickerId, m_sharedparams->params.unique);

    if (select)
        {
            PlayAction(GetFragmentIds().pickedup);
        }

    EnableSound(soundEnabled);

    bool isLocalEntity = GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY) ? true : false;

    if (IsServer() && !IsDemoPlayback())
        {
            if(!gEnv->bMultiplayer || isLocalEntity)
                RemoveEntity();
            else if(g_pGame->GetGameRules())
                g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg
        }

    if (IsServer())
        {
            GetGameObject()->SetNetworkParent(pickerId);
            if (!isLocalEntity)
                {
                    pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());
                }
        }
}
示例#3
0
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char *setup)
{
	CActor *pActor=GetActor(pickerId);
	if (!pActor)
		return;

	if(!CheckAmmoRestrictions(pickerId))
	{
		if (IsServer())
			g_pGame->GetGameRules()->SendTextMessage(eTextMessageCenter, "@ammo_maxed_out", eRMI_ToClientChannel, pActor->GetChannelId(), (string("@")+GetEntity()->GetClass()->GetName()).c_str());
		return;
	}

	TriggerRespawn();

	GetEntity()->EnablePhysics(false);
	Physicalize(false, false);

	bool soundEnabled = IsSoundEnabled();
	EnableSound(sound);

	SetViewMode(0);		
	SetOwnerId(pickerId);

	CopyRenderFlags(GetOwner());

	Hide(true);
	m_stats.dropped = false;
	m_stats.brandnew = false;


	IInventory *pInventory = pActor->GetInventory();
	if (!pInventory)
	{
		GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName());
		return;
	}

	if(!pInventory->HasAccessory(GetEntity()->GetClass()))
	{
		pInventory->AddAccessory(GetEntity()->GetClass());
	}

	OnPickedUp(pickerId, m_sharedparams->params.unique);	

	PlayAction(g_pItemStrings->pickedup);

	EnableSound(soundEnabled);

	if (IsServer() && !IsDemoPlayback())
	{
		if(!gEnv->bMultiplayer)
			RemoveEntity();
		else if(g_pGame->GetGameRules())
			g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg
	}

	if (IsServer())
	{
		GetGameObject()->SetNetworkParent(pickerId);
		if ((GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY)) == 0)
		{
			pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());

			const char *displayName=GetDisplayName();
}
	}
}