-
Notifications
You must be signed in to change notification settings - Fork 0
/
Friends.cs
47 lines (38 loc) · 1.28 KB
/
Friends.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Steamworksnt.SteamworksApi;
namespace Steamworksnt
{
public static class Friends
{
private static readonly IntPtr iSteamFriends = Api.SteamAPI_SteamFriends_v017();
public static List<SteamUser> GetFriends()
{
var friends = new List<SteamUser>();
int friendCount = Api.SteamAPI_ISteamFriends_GetFriendCount(
iSteamFriends,
EFriendFlags.k_EFriendFlagImmediate
);
for (int i = 0; i < friendCount; i++)
{
friends.Add(GetSteamUserByIndex(i));
}
return friends;
}
private static SteamUser GetSteamUserByIndex(int i)
{
ulong friendSteamId = Api.SteamAPI_ISteamFriends_GetFriendByIndex(
iSteamFriends,
i,
EFriendFlags.k_EFriendFlagImmediate
);
IntPtr displayNamePtr = Api.SteamAPI_ISteamFriends_GetFriendPersonaName(
iSteamFriends,
friendSteamId
);
string displayName = Marshal.PtrToStringUTF8(displayNamePtr);
return new SteamUser(friendSteamId, displayName);
}
}
}