int32 UPartyBeaconState::GetTeamForCurrentPlayer(const FUniqueNetId& PlayerId) const { int32 TeamNum = INDEX_NONE; if (PlayerId.IsValid()) { for (int32 ResIdx = 0; ResIdx < Reservations.Num(); ResIdx++) { const FPartyReservation& Reservation = Reservations[ResIdx]; for (int32 PlayerIdx = 0; PlayerIdx < Reservation.PartyMembers.Num(); PlayerIdx++) { // find the player id in the existing list of reservations if (*Reservation.PartyMembers[PlayerIdx].UniqueId == PlayerId) { TeamNum = Reservation.TeamNum; break; } } } UE_LOG(LogBeacon, Display, TEXT("Assigning player %s to team %d"), *PlayerId.ToString(), TeamNum); } else { UE_LOG(LogBeacon, Display, TEXT("Invalid player when attempting to find team assignment")); } return TeamNum; }
virtual void FireEvent_FriendRemoved(const FUniqueNetId& LocalUserId, const IFriendItem& Friend, const FString& RemoveReason) const override { static const FString EventName = TEXT("Social.FriendRemoved"); if (AnalyticsProvider.IsValid()) { if (LocalUserId.IsValid()) { TArray<FAnalyticsEventAttribute> Attributes; Attributes.Add(FAnalyticsEventAttribute(TEXT("User"), LocalUserId.ToString())); Attributes.Add(FAnalyticsEventAttribute(TEXT("Friend"), Friend.GetUniqueID()->ToString())); Attributes.Add(FAnalyticsEventAttribute(TEXT("RemoveReason"), RemoveReason)); AddPresenceAttributes(LocalUserId, Attributes); AnalyticsProvider->RecordEvent(EventName, Attributes); } } }
virtual void FireEvent_SendGameInvite(const FUniqueNetId& LocalUserId, const FUniqueNetId& ToUser) const override { static const FString EventName = TEXT("Social.GameInvite.Send"); if (AnalyticsProvider.IsValid()) { if (LocalUserId.IsValid()) { TArray<FAnalyticsEventAttribute> Attributes; Attributes.Add(FAnalyticsEventAttribute(TEXT("User"), LocalUserId.ToString())); Attributes.Add(FAnalyticsEventAttribute(TEXT("Friend"), ToUser.ToString())); AddPresenceAttributes(LocalUserId, Attributes); AnalyticsProvider->RecordEvent(EventName, Attributes); } } }
virtual void FireEvent_RecordToggleChat(const FUniqueNetId& LocalUserId, const FString& Channel, bool bEnabled) const override { static const FString EventName = TEXT("Social.Chat.Toggle"); if (AnalyticsProvider.IsValid()) { if (LocalUserId.IsValid()) { TArray<FAnalyticsEventAttribute> Attributes; Attributes.Add(FAnalyticsEventAttribute(TEXT("User"), LocalUserId.ToString())); Attributes.Add(FAnalyticsEventAttribute(TEXT("Channel"), Channel)); Attributes.Add(FAnalyticsEventAttribute(TEXT("bEnabled"), bEnabled)); AddPresenceAttributes(LocalUserId, Attributes); AnalyticsProvider->RecordEvent(EventName, Attributes); } } }
int32 APartyBeaconHost::GetTeamForCurrentPlayer(const FUniqueNetId& PlayerId) const { int32 TeamNum = INDEX_NONE; if (PlayerId.IsValid()) { if (State) { TeamNum = State->GetTeamForCurrentPlayer(PlayerId); } } else { UE_LOG(LogBeacon, Display, TEXT("Invalid player when attempting to find team assignment")); } return TeamNum; }
virtual void FireEvent_AddFriend(const FUniqueNetId& LocalUserId, const FString& FriendName, const FUniqueNetId& FriendId, EFindFriendResult::Type Result, bool bRecentPlayer) const override { static const FString EventName = TEXT("Social.AddFriend"); if (AnalyticsProvider.IsValid()) { if (LocalUserId.IsValid()) { TArray<FAnalyticsEventAttribute> Attributes; Attributes.Add(FAnalyticsEventAttribute(TEXT("User"), LocalUserId.ToString())); Attributes.Add(FAnalyticsEventAttribute(TEXT("Friend"), FriendId.ToString())); Attributes.Add(FAnalyticsEventAttribute(TEXT("FriendName"), FriendName)); Attributes.Add(FAnalyticsEventAttribute(TEXT("Result"), EFindFriendResult::ToString(Result))); Attributes.Add(FAnalyticsEventAttribute(TEXT("bRecentPlayer"), bRecentPlayer)); AddPresenceAttributes(LocalUserId, Attributes); AnalyticsProvider->RecordEvent(EventName, Attributes); } } }
void UAmethystGameInstance::HandleControllerPairingChanged(int GameUserIndex, const FUniqueNetId& PreviousUser, const FUniqueNetId& NewUser) { if (CurrentState == AmethystGameInstanceState::WelcomeScreen) { // Don't care about pairing changes at welcome screen return; } #if Amethyst_CONSOLE_UI && PLATFORM_XBOXONE if (IgnorePairingChangeForControllerId != -1 && GameUserIndex == IgnorePairingChangeForControllerId) { // We were told to ignores IgnorePairingChangeForControllerId = -1; // Reset now so there there is no chance this remains in a bad state return; } if (PreviousUser.IsValid() && !NewUser.IsValid()) { // Treat this as a disconnect or signout, which is handled somewhere else return; } if (!PreviousUser.IsValid() && NewUser.IsValid()) { // Treat this as a signin ULocalPlayer * ControlledLocalPlayer = FindLocalPlayerFromControllerId(GameUserIndex); if (ControlledLocalPlayer != NULL && !ControlledLocalPlayer->GetCachedUniqueNetId().IsValid()) { // If a player that previously selected "continue without saving" signs into this controller, move them back to welcome screen HandleSignInChangeMessaging(); } return; } // Find the local player currently being controlled by this controller ULocalPlayer * ControlledLocalPlayer = FindLocalPlayerFromControllerId(GameUserIndex); // See if the newly assigned profile is in our local player list ULocalPlayer * NewLocalPlayer = FindLocalPlayerFromUniqueNetId(NewUser); // If the local player being controlled is not the target of the pairing change, then give them a chance // to continue controlling the old player with this controller if (ControlledLocalPlayer != nullptr && ControlledLocalPlayer != NewLocalPlayer) { UAmethystGameViewportClient * AmethystViewport = Cast<UAmethystGameViewportClient>(GetGameViewportClient()); if (AmethystViewport != nullptr) { AmethystViewport->ShowDialog( nullptr, EAmethystDialogType::Generic, NSLOCTEXT("ProfileMessages", "PairingChanged", "Your controller has been paired to another profile, would you like to switch to this new profile now? Selecting YES will sign out of the previous profile."), NSLOCTEXT("DialogButtons", "YES", "A - YES"), NSLOCTEXT("DialogButtons", "NO", "B - NO"), FOnClicked::CreateUObject(this, &UAmethystGameInstance::OnPairingUseNewProfile), FOnClicked::CreateUObject(this, &UAmethystGameInstance::OnPairingUsePreviousProfile) ); } } #endif }