Exemplo n.º 1
0
	virtual bool IsFriendInSameParty(const TSharedPtr< const IFriendItem >& FriendItem) const override
	{
		if (GetOnlineIdentity().IsValid() && GetPartyInterface().IsValid())
		{
			TSharedPtr<const FUniqueNetId> LocalUserId = GetOnlineIdentity()->GetUniquePlayerId(LocalControllerIndex);
			if (LocalUserId.IsValid())
			{
				IOnlinePartyPtr PartyInt = GetPartyInterface();
				if (PartyInt.IsValid())
				{
					TArray<TSharedRef<const FOnlinePartyId>> JoinedParties;
					if (PartyInt->GetJoinedParties(*LocalUserId, JoinedParties))
					{
						if (JoinedParties.Num() > 0)
						{
							TSharedPtr<IOnlinePartyJoinInfo> FriendPartyJoinInfo = GetPartyJoinInfo(FriendItem);
							if (FriendPartyJoinInfo.IsValid())
							{
								for (auto PartyId : JoinedParties)
								{
									if (*PartyId == *FriendPartyJoinInfo->GetPartyId())
									{
										return true;
									}
								}
							}
							else
							{
								// Party might be private, search manually
								TSharedRef<const FUniqueNetId> FriendUserId = FriendItem->GetUniqueID();
								for (auto PartyId : JoinedParties)
								{
									TSharedPtr<FOnlinePartyMember> PartyMemberId = PartyInt->GetPartyMember(*LocalUserId, *PartyId, *FriendUserId);
									if (PartyMemberId.IsValid())
									{
										return true;
									}
								}
							}
						}
					}
				}
			}
		}

		return false;
	}
Exemplo n.º 2
0
bool FFriendItem::IsGameJoinable() const
{
	if (OnlineFriend.IsValid())
	{
		const FOnlineUserPresence& FriendPresence = OnlineFriend->GetPresence();
		const bool bIsOnline = FriendPresence.Status.State != EOnlinePresenceState::Offline;
		if (bIsOnline)
		{
			const bool bIsGameJoinable = FriendPresence.bIsJoinable && !FriendsAndChatManager.Pin()->IsFriendInSameSession(AsShared());
			if (bIsGameJoinable)
			{
				return true;
			}
			//@todo samz1 - determine if party is joinable
			const bool bIsPartyJoinable = GetPartyJoinInfo().IsValid() && !FriendsAndChatManager.Pin()->IsFriendInSameParty(AsShared());
			if (bIsPartyJoinable)
			{
				return true;
			}
		}
	}
	return false;
}
bool FFriendPartyInviteItem::CanJoinParty() const
{
	TSharedPtr<IOnlinePartyJoinInfo> PartyInfo = GetPartyJoinInfo();
	return PartyInfo.IsValid() && !PartyInfo->IsInvalidForJoin() && !GameAndPartyService->IsFriendInSameParty(AsShared());
}