public void Initialize() { if (!SteamManager.initializedMain) { return; } m_GameRichPresenceJoinRequested = Steamworks.Callback <GameRichPresenceJoinRequested_t> .Create(OnGameRichPresenceJoinRequested); m_PersonaStateChange = Steamworks.Callback <PersonaStateChange_t> .Create(OnPersonaStateChange); EFriendFlags friendFlags = EFriendFlags.k_EFriendFlagImmediate; int friendsCount = SteamFriends.GetFriendCount(friendFlags); for (int friendIndex = 0; friendIndex < friendsCount; ++friendIndex) { CSteamID friendSteamId = SteamFriends.GetFriendByIndex(friendIndex, friendFlags); if (!friendSteamId.IsValid()) { continue; } SteamFriend steamFriend = new SteamFriend(friendSteamId); m_Friends.Add(friendSteamId, steamFriend); } }
private void OnPersonaStateChange(PersonaStateChange_t i_Params) { CSteamID steamId = new CSteamID(i_Params.m_ulSteamID); SteamFriend steamFriend = Internal_GetFriend(steamId); if (steamFriend != null) { bool isMyFriend = SteamFriends.HasFriend(steamId, EFriendFlags.k_EFriendFlagImmediate); if (isMyFriend) { steamFriend.Refresh(); } else { m_Friends.Remove(steamId); } } else { steamFriend = new SteamFriend(steamId); m_Friends.Add(steamId, steamFriend); } RaiseFriendsChangedEvent(); }
// Token: 0x06001AF5 RID: 6901 RVA: 0x0007ECCC File Offset: 0x0007CECC private static void OnInvitedToGame(SteamFriend steamFriend, string connectString) { Debug.LogFormat("OnGameRichPresenceJoinRequested connectString=\"{0}\" steamFriend=\"{1}\"", new object[] { connectString, steamFriend.Name }); string[] array = connectString.Split(new char[] { ' ' }); if (array.Length >= 2) { CSteamID csteamID; if (array[0] == "+connect_steamworks_p2p" && CSteamID.TryParse(array[1], out csteamID)) { if (!SteamworksLobbyManager.ownsLobby) { SteamworksLobbyManager.LeaveLobby(); } Console.instance.SubmitCmd(null, "connect_steamworks_p2p " + csteamID.value, false); } CSteamID csteamID2; if (array[0] == "+steam_lobby_join" && CSteamID.TryParse(array[1], out csteamID2)) { if (!SteamworksLobbyManager.ownsLobby) { SteamworksLobbyManager.LeaveLobby(); } Console.instance.SubmitCmd(null, "steam_lobby_join " + csteamID2.value, false); } } }
private FriendAvatar InstantiateFriendAvatar(SteamFriend friend) { FriendAvatar tmp = Instantiate(friendAvatarPrefab, layoutFriends, false).GetComponent <FriendAvatar>(); tmp.gameObject.name = friend.Name; tmp.steamID = friend.Id; return(tmp); }
private LobbyAvatar InstantiateLobbyAvatar(SteamFriend friend) { LobbyAvatar tmp = Instantiate(lobbyAvatarPrefab, layoutLobby, false).GetComponent <LobbyAvatar>(); tmp.gameObject.name = friend.Name; tmp.steamID = friend.Id; return(tmp); }
/// <summary> /// FriendList SelectedIndexChanged handler, verifies valid selection and that selected friend is online. /// If validation is successful, the send button is enabled, otherwise it is disabled. /// </summary> /// <param name="sender">N/A (Not Used) (See MSDN)</param> /// <param name="e">N/A (Not Used) (See MSDN)</param> private void FriendListSelectedIndexChanged(object sender, EventArgs e) { bool validSelection = friendList.SelectedItems.Count > 0; SteamFriend friend = validSelection ? SteamManager.FriendList.GetFriendBySteamId(friendList.SelectedItems[0].Tag.ToString()) : null; bool validFriend = friend != null && friend.IsOnline(); if (validSelection && validFriend) { sendButton.Enabled = true; } else { sendButton.Enabled = false; } }
public void InviteFriend(Friend i_Friend, string i_Args) { if (i_Friend == null) { return; } if (!SteamManager.initializedMain) { return; } SteamFriend steamFriend = (SteamFriend)i_Friend; CSteamID friendId = steamFriend.steamId; SteamFriends.InviteUserToGame(friendId, i_Args); }
GameObject InsertFriend(SteamFriend friend) { GameObject go = Instantiate(friendPrefab); go.transform.SetParent(container.transform, false); Facepunch.Steamworks.Image image = friend.GetAvatar(Friends.AvatarSize.Small); var texture = Utils.ConvertSteamImage(image); var rawImage = go.GetComponentInChildren <RawImage>(); if (rawImage != null) { rawImage.texture = texture; } go.GetComponentInChildren <Text>().text = friend.Name; go.name = "Friend_" + friend.Name; go.GetComponentInChildren <Button>().onClick.AddListener(delegate { InviteFriend(friend.Id); }); return(go); }
void UpdateParty() { Debug.Log("Update Party!"); if (!Client.Instance.Lobby.IsValid) { Debug.Log("derp!?"); Client.Instance.Lobby.Create(Lobby.Type.Invisible, maxPartySize); return; } else { Debug.Log("Herp!?"); ulong[] memberIds = Client.Instance.Lobby.GetMemberIDs(); foreach (ulong memberId in memberIds) { SteamFriend friend = Client.Instance.Friends.Get(memberId); GameObject go = Instantiate(partyPlayerPrefab); go.transform.SetParent(container.transform, false); go.transform.SetSiblingIndex(go.transform.GetSiblingIndex() - 1); go.GetComponent <RawImage>().texture = Utils.ConvertSteamImage(friend.GetAvatar(Friends.AvatarSize.Small)); } } }
private void bwFetcher_DoWork(object sender, DoWorkEventArgs e) { ProgressReport pr = new ProgressReport(); pr.type = "taskstart"; pr.status = "Connecting to Steam API..."; bwFetcher.ReportProgress(0, pr); List<SteamFriend> friends = new List<SteamFriend>(); List<SteamUserTile> controls = new List<SteamUserTile>(); using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", "D0EEFB98C8993BA3AC91A55879D28D91")) { steamUser.Timeout = (int)TimeSpan.FromSeconds(20).TotalMilliseconds; KeyValue results = steamUser.GetFriendList(steamid: _steamid, method: WebRequestMethods.Http.Get, secure: true); pr.status = "Fetching friends..."; bwFetcher.ReportProgress(0, pr); foreach (var f in results.Children[0].Children) { SteamFriend friend = new SteamFriend(); friend.steamid = f.Children[0].Value; friend.relationship = f.Children[1].Value; friend.friend_since = f.Children[2].Value; friends.Add(friend); } pr.type = "friendscount"; pr.value = friends.Count; bwFetcher.ReportProgress(0, pr); string ssteamids = ""; int count = 0; int handled = 0; int batchdone = 0; do { ssteamids += friends[count].steamid; count++; handled++; if (handled == 100 || count == friends.Count) { //Get user info steamUser.Timeout = (int)TimeSpan.FromSeconds(20).TotalMilliseconds; KeyValue result = steamUser.GetPlayerSummaries(steamids: ssteamids, MethodAccessException: WebRequestMethods.Http.Get, secure: true); for (int k = 0; k < handled; k++) { int index = (100 * batchdone) + k; friends[index].name = FetchKeyValue(result.Children[0].Children[0].Children[k], "personaname"); friends[index].profileurl = FetchKeyValue(result.Children[0].Children[0].Children[k], "profileurl"); friends[index].avatar = FetchKeyValue(result.Children[0].Children[0].Children[k], "avatarmedium"); } handled = 0; ssteamids = ""; batchdone++; } else { ssteamids += ","; } bwFetcher.ReportProgress(count, pr); } while (count < friends.Count); //Creating user tiles int num = 0; pr.type = "taskstart"; pr.status = "Creating tiles...."; bwFetcher.ReportProgress(0, pr); pr.type = "friendscount"; pr.value = friends.Count; bwFetcher.ReportProgress(0, pr); foreach (var friend in friends) { SteamUserTile tile = new SteamUserTile(); tile.SteamName = friend.name; tile.SteamProfile = friend.profileurl; tile.Avatar = friend.avatar; tile.Top = 5 + (85 * num); controls.Add(tile); num++; bwFetcher.ReportProgress(num, pr); } this.Friends = friends; this.Tiles = controls; } }