public BnetGameAccount GetGameAccount(BnetGameAccountId id) { BnetGameAccount account = null; this.m_gameAccounts.TryGetValue(id, out account); return(account); }
public void SendWhisper(BnetGameAccountId gameAccount, string message) { if (!string.IsNullOrEmpty(message)) { bnet.protocol.notification.Notification notification = new bnet.protocol.notification.Notification(); notification.SetType("WHISPER"); EntityId val = new EntityId(); val.SetLow(gameAccount.GetLo()); val.SetHigh(gameAccount.GetHi()); notification.SetTargetId(val); bnet.protocol.attribute.Attribute attribute = new bnet.protocol.attribute.Attribute(); attribute.SetName("whisper"); bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant(); variant.SetStringValue(message); attribute.SetValue(variant); notification.AddAttribute(attribute); base.m_rpcConnection.QueueRequest(base.m_battleNet.NotificationService.Id, 1, notification, new RPCContextDelegate(this.WhisperSentCallback), 0); BnetGameAccountId id = BnetGameAccountId.CreateFromDll(BattleNet.GetMyGameAccountId()); BnetWhisper item = new BnetWhisper(); item.SetSpeakerId(id); item.SetReceiverId(gameAccount); item.SetMessage(message); TimeSpan elapsedTimeSinceEpoch = TimeUtils.GetElapsedTimeSinceEpoch(null); item.SetTimestampMilliseconds(elapsedTimeSinceEpoch.TotalMilliseconds); this.m_whispers.Add(item); } }
public static BnetGameAccountId CreateFromDll(BattleNet.DllEntityId src) { BnetGameAccountId id = new BnetGameAccountId(); id.CopyFrom(src); return(id); }
private void CheckForNewRank(BnetPlayer player) { MedalInfoTranslator rankPresenceField = RankMgr.Get().GetRankPresenceField(player); if (rankPresenceField != null) { BnetGameAccountId hearthstoneGameAccountId = player.GetHearthstoneGameAccountId(); int rank = rankPresenceField.GetCurrentMedal().rank; if (!this.m_lastKnownMedal.ContainsKey(hearthstoneGameAccountId)) { this.m_lastKnownMedal[hearthstoneGameAccountId] = rank; } else if ((rank <= 10) && (this.m_lastKnownMedal[hearthstoneGameAccountId] > rank)) { this.m_lastKnownMedal[hearthstoneGameAccountId] = rank; if (rank == 0) { object[] args = new object[] { "5ecaf0ff", player.GetBestName() }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_RANK_LEGEND", args)); } else { object[] objArray2 = new object[] { "5ecaf0ff", player.GetBestName(), rankPresenceField.GetCurrentMedal().rank }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_GAINED_RANK", objArray2)); } } } }
public BnetPlayer Clone() { BnetPlayer player = (BnetPlayer)base.MemberwiseClone(); if (this.m_accountId != null) { player.m_accountId = this.m_accountId.Clone(); } if (this.m_account != null) { player.m_account = this.m_account.Clone(); } if (this.m_hsGameAccount != null) { player.m_hsGameAccount = this.m_hsGameAccount.Clone(); } if (this.m_bestGameAccount != null) { player.m_bestGameAccount = this.m_bestGameAccount.Clone(); } player.m_gameAccounts = new Map <BnetGameAccountId, BnetGameAccount>(); foreach (KeyValuePair <BnetGameAccountId, BnetGameAccount> pair in this.m_gameAccounts) { BnetGameAccountId key = pair.Key.Clone(); player.m_gameAccounts.Add(key, pair.Value.Clone()); } return(player); }
public static BnetGameAccountId CreateFromNet(BnetId src) { BnetGameAccountId id = new BnetGameAccountId(); id.CopyFrom(src); return(id); }
private void OnPartyUpdate_JoinedParty(BnetEntityId partyId, BnetGameAccountId otherMemberId) { if (this.DidSendChallenge() && (this.m_challengee.GetHearthstoneGameAccount().GetId() == otherMemberId)) { if (partyId != this.m_partyId) { this.m_challengeePartyId = partyId; if (this.m_partyId != null) { this.ResolveChallengeConflict(); } } } else if (!BnetUtils.CanReceiveChallengeFrom(otherMemberId)) { Network.DeclineFriendChallenge(partyId); } else if (!this.AmIAvailable()) { Network.DeclineFriendChallenge(partyId); } else { this.HandleJoinedParty(partyId, otherMemberId); } }
public static bool HasPlayerBestNamePresence(BnetGameAccountId id) { BnetPlayer player = GetPlayer(id); string str = (player != null) ? player.GetBestName() : null; return(!string.IsNullOrEmpty(str)); }
public static void OnPlayerChallengeButtonPressed(FriendListChallengeButton challengeButton, BnetPlayer player) { SoundManager.Get().LoadAndPlay("Small_Click"); if (ChatMgr.Get().FriendListFrame.IsInEditMode) { ChatMgr.Get().FriendListFrame.ShowRemoveFriendPopup(player); } else { BnetGameAccountId hearthstoneGameAccountId = player.GetHearthstoneGameAccountId(); SpectatorManager manager = SpectatorManager.Get(); if (manager.CanSpectate(player)) { manager.SpectatePlayer(player); } else if (manager.IsSpectatingMe(hearthstoneGameAccountId)) { AlertPopup.PopupInfo info = new AlertPopup.PopupInfo { m_headerText = GameStrings.Get("GLOBAL_SPECTATOR_KICK_PROMPT_HEADER") }; object[] args = new object[] { FriendUtils.GetUniqueName(player) }; info.m_text = GameStrings.Format("GLOBAL_SPECTATOR_KICK_PROMPT_TEXT", args); info.m_showAlertIcon = true; info.m_responseDisplay = AlertPopup.ResponseDisplay.CONFIRM_CANCEL; info.m_responseCallback = new AlertPopup.ResponseCallback(FriendListFriendFrame.OnKickSpectatorDialogResponse); info.m_responseUserData = player; DialogManager.Get().ShowPopup(info); } else if (manager.CanInviteToSpectateMyGame(hearthstoneGameAccountId)) { manager.InviteToSpectateMe(player); } else if (manager.IsSpectatingPlayer(hearthstoneGameAccountId)) { if ((GameMgr.Get().IsFindingGame() || SceneMgr.Get().IsTransitioning()) || GameMgr.Get().IsTransitionPopupShown()) { return; } AlertPopup.PopupInfo info2 = new AlertPopup.PopupInfo { m_headerText = GameStrings.Get("GLOBAL_SPECTATOR_LEAVE_PROMPT_HEADER"), m_text = GameStrings.Get("GLOBAL_SPECTATOR_LEAVE_PROMPT_TEXT"), m_showAlertIcon = true, m_responseDisplay = AlertPopup.ResponseDisplay.CONFIRM_CANCEL, m_responseCallback = new AlertPopup.ResponseCallback(FriendListFriendFrame.OnLeaveSpectatingDialogResponse) }; DialogManager.Get().ShowPopup(info2); } else if (!manager.IsInvitedToSpectateMyGame(hearthstoneGameAccountId) && challengeButton.CanChallenge()) { FriendChallengeMgr.Get().SendChallenge(player); } else { return; } challengeButton.UpdateButton(); ChatMgr.Get().CloseChatUI(); } }
public static BnetGameAccountId CreateFromProtocol(EntityId src) { BnetGameAccountId id = new BnetGameAccountId(); id.SetLo(src.Low); id.SetHi(src.High); return(id); }
public static bool CanReceiveWhisperFrom(BnetGameAccountId id) { if (BnetPresenceMgr.Get().GetMyPlayer().IsBusy()) { return(false); } return(BnetFriendMgr.Get().IsFriend(id)); }
public bool Equals(BnetGameAccountId other) { if (other == null) { return(false); } return(this.m_id.Equals((BnetEntityId)other)); }
private void CreateGameAccount(BnetGameAccountId id, BattleNet.PresenceUpdate update, BnetPlayerChangelist changelist) { BnetGameAccount account = new BnetGameAccount(); this.m_gameAccounts.Add(id, account); account.SetId(id); this.UpdateGameAccount(account, update, changelist); }
public bool RemoveGameAccount(BnetGameAccountId id) { if (!this.m_gameAccounts.Remove(id)) { return(false); } this.CacheSpecialGameAccounts(); return(true); }
private BnetPlayer FindNearbyPlayer(BnetGameAccountId id, List <BnetPlayer> bnetPlayers) { int num = this.FindNearbyPlayerIndex(id, bnetPlayers); if (num < 0) { return(null); } return(bnetPlayers[num]); }
public void AddGameAccount(BnetGameAccount gameAccount) { BnetGameAccountId key = gameAccount.GetId(); if (!this.m_gameAccounts.ContainsKey(key)) { this.m_gameAccounts.Add(key, gameAccount); this.CacheSpecialGameAccounts(); } }
public BnetPlayer FindNonPendingFriend(BnetGameAccountId id) { foreach (BnetPlayer player in this.m_friends) { if (player.HasGameAccount(id)) { return(player); } } return(null); }
public static string GetPlayerBestName(BnetGameAccountId id) { BnetPlayer player = GetPlayer(id); string str = (player != null) ? player.GetBestName() : null; if (string.IsNullOrEmpty(str)) { str = GameStrings.Get("GLOBAL_PLAYER_PLAYER"); } return(str); }
private void UpdateLocal() { if (this.IsBnetPlayer()) { BnetGameAccountId myGameAccountId = BnetPresenceMgr.Get().GetMyGameAccountId(); this.m_local = myGameAccountId == this.m_gameAccountId; } else { this.m_local = this.m_gameAccountId.GetLo() == 1L; } }
private void OnPartyUpdate_CreatedParty(BnetEntityId partyId, BnetGameAccountId otherMemberId) { this.m_partyId = partyId; if ((this.m_challengeePartyId != null) && (this.m_challengeePartyId != this.m_partyId)) { this.ResolveChallengeConflict(); } else { this.m_challengeePartyId = this.m_partyId; this.UpdateChallengeSentDialog(); } }
private bool UpdateSpectateButtonState() { BnetGameAccountId hearthstoneGameAccountId = this.m_player.GetHearthstoneGameAccountId(); SpectatorManager manager = SpectatorManager.Get(); bool flag = false; string str = null; if (manager.HasInvitedMeToSpectate(hearthstoneGameAccountId)) { str = "HasInvitedMeToSpectate"; flag = true; } else if (manager.CanSpectate(this.m_player)) { str = "CanSpectateThisFriend"; } else if (manager.IsSpectatingMe(hearthstoneGameAccountId)) { str = "CurrentlySpectatingMe"; } else if (manager.CanInviteToSpectateMyGame(hearthstoneGameAccountId)) { str = "CanInviteToSpectateMe"; } else if (manager.IsSpectatingPlayer(hearthstoneGameAccountId)) { str = "CurrentlySpectatingThisFriend"; } else if (manager.IsInvitedToSpectateMyGame(hearthstoneGameAccountId)) { str = "DisabledInviteToSpectateMe"; } if (this.m_SpectatorIcon != null) { this.m_SpectatorIcon.gameObject.SetActive(str != null); if (str != null) { this.m_SpectatorIcon.CurrentState = str; this.m_AvailableIcon.SetActive(false); this.m_BusyIcon.SetActive(false); this.m_TavernBrawlChallengeIcon.SetActive(false); this.m_TavernBrawlBusyIcon.SetActive(false); } if (this.m_SpectatorIconHighlight != null) { this.m_SpectatorIconHighlight.gameObject.SetActive(flag); } } return(str != null); }
public static BnetPlayer GetPlayer(BnetGameAccountId id) { if (id == null) { return(null); } BnetPlayer player = BnetNearbyPlayerMgr.Get().FindNearbyStranger(id); if (player == null) { player = BnetPresenceMgr.Get().GetPlayer(id); } return(player); }
private int FindNearbyPlayerIndex(BnetGameAccountId id, List <BnetPlayer> bnetPlayers) { if (id != null) { for (int i = 0; i < bnetPlayers.Count; i++) { BnetPlayer player = bnetPlayers[i]; if (id == player.GetHearthstoneGameAccountId()) { return(i); } } } return(-1); }
public BnetPlayer FindFriend(BnetGameAccountId id) { BnetPlayer player = this.FindNonPendingFriend(id); if (player != null) { return(player); } player = this.FindPendingFriend(id); if (player != null) { return(player); } return(null); }
private int FindNearbyPlayerIndex(BnetPlayer bnetPlayer, List <BnetPlayer> bnetPlayers) { if (bnetPlayer == null) { return(-1); } BnetAccountId accountId = bnetPlayer.GetAccountId(); if (accountId != null) { return(this.FindNearbyPlayerIndex(accountId, bnetPlayers)); } BnetGameAccountId hearthstoneGameAccountId = bnetPlayer.GetHearthstoneGameAccountId(); return(this.FindNearbyPlayerIndex(hearthstoneGameAccountId, bnetPlayers)); }
private void CleanUpChallengeData(bool updateAvailability = true) { this.m_partyId = null; this.m_challengeePartyId = null; this.m_challengerId = null; this.m_challengerPending = false; this.m_challenger = null; this.m_challengerDeckSelected = false; this.m_challengee = null; this.m_challengeeAccepted = false; this.m_challengeeDeckSelected = false; this.m_scenarioId = 2; this.m_isChallengeTavernBrawl = false; if (updateAvailability) { this.UpdateMyAvailability(); } }
public void SetGameAccountId(BnetGameAccountId id) { this.m_gameAccountId = id; this.UpdateLocal(); this.UpdateSide(); if (this.IsDisplayable()) { this.UpdateDisplayInfo(); } else if (this.IsBnetPlayer()) { BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnBnetPlayersChanged)); if (!BnetFriendMgr.Get().IsFriend(this.m_gameAccountId) && (GameMgr.Get().IsSpectator() || (GameMgr.Get().GetReconnectType() == ReconnectType.LOGIN))) { this.RequestPlayerPresence(); } } }
private void HandleJoinedParty(BnetEntityId partyId, BnetGameAccountId otherMemberId) { this.m_partyId = partyId; this.m_challengeePartyId = partyId; this.m_challengerId = otherMemberId; this.m_challenger = BnetUtils.GetPlayer(this.m_challengerId); this.m_challengee = BnetPresenceMgr.Get().GetMyPlayer(); this.m_hasSeenDeclinedReason = false; if ((this.m_challenger == null) || !this.m_challenger.IsDisplayable()) { this.m_challengerPending = true; this.UpdateMyAvailability(); } else { this.UpdateMyAvailability(); this.FireChangedEvent(FriendChallengeEvent.I_RECEIVED_CHALLENGE, this.m_challenger); } }
private void CacheMyAccountInfo() { if (this.m_idString == null) { BnetGameAccountId myGameAccountId = BnetPresenceMgr.Get().GetMyGameAccountId(); if (myGameAccountId != null) { BnetPlayer myPlayer = BnetPresenceMgr.Get().GetMyPlayer(); if (myPlayer != null) { BnetAccountId accountId = myPlayer.GetAccountId(); if (accountId != null) { BnetBattleTag battleTag = myPlayer.GetBattleTag(); if (battleTag != null) { this.m_myGameAccountLo = myGameAccountId.GetLo(); StringBuilder builder = new StringBuilder(); builder.Append(accountId.GetHi()); builder.Append(','); builder.Append(accountId.GetLo()); builder.Append(','); builder.Append(myGameAccountId.GetHi()); builder.Append(','); builder.Append(myGameAccountId.GetLo()); builder.Append(','); builder.Append(battleTag.GetName()); builder.Append(','); builder.Append(battleTag.GetNumber()); builder.Append(','); builder.Append(BattleNet.GetVersion()); builder.Append(','); builder.Append(BattleNet.GetEnvironment()); this.m_idString = builder.ToString(); } } } } } }
public void SendChallenge(BnetPlayer player) { if (this.CanChallenge(player)) { this.m_challenger = BnetPresenceMgr.Get().GetMyPlayer(); this.m_challengerId = this.m_challenger.GetHearthstoneGameAccount().GetId(); this.m_challengee = player; this.m_hasSeenDeclinedReason = false; this.m_scenarioId = 2; this.m_isChallengeTavernBrawl = false; if (TavernBrawlManager.Get().ShouldNewFriendlyChallengeBeTavernBrawl()) { this.m_scenarioId = TavernBrawlManager.Get().CurrentMission().missionId; Enum[] args = new Enum[] { PresenceStatus.TAVERN_BRAWL_FRIENDLY_WAITING }; PresenceMgr.Get().SetStatus(args); this.m_isChallengeTavernBrawl = true; } Network.SendFriendChallenge(player.GetHearthstoneGameAccount().GetId(), this.m_scenarioId); this.UpdateMyAvailability(); this.FireChangedEvent(FriendChallengeEvent.I_SENT_CHALLENGE, player); } }