isteamgameserverstats.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // This file is provided under The MIT License as part of Steamworks.NET.
  2. // Copyright (c) 2013-2019 Riley Labrecque
  3. // Please see the included LICENSE.txt for additional information.
  4. // This file is automatically generated.
  5. // Changes to this file will be reverted when you update Steamworks.NET
  6. #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH
  7. #define DISABLESTEAMWORKS
  8. #endif
  9. #if !DISABLESTEAMWORKS
  10. using System.Runtime.InteropServices;
  11. using IntPtr = System.IntPtr;
  12. namespace Steamworks {
  13. public static class SteamGameServerStats {
  14. /// <summary>
  15. /// <para> downloads stats for the user</para>
  16. /// <para> returns a GSStatsReceived_t callback when completed</para>
  17. /// <para> if the user has no stats, GSStatsReceived_t.m_eResult will be set to k_EResultFail</para>
  18. /// <para> these stats will only be auto-updated for clients playing on the server. For other</para>
  19. /// <para> users you'll need to call RequestUserStats() again to refresh any data</para>
  20. /// </summary>
  21. public static SteamAPICall_t RequestUserStats(CSteamID steamIDUser) {
  22. InteropHelp.TestIfAvailableGameServer();
  23. return (SteamAPICall_t)NativeMethods.ISteamGameServerStats_RequestUserStats(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser);
  24. }
  25. /// <summary>
  26. /// <para> requests stat information for a user, usable after a successful call to RequestUserStats()</para>
  27. /// </summary>
  28. public static bool GetUserStat(CSteamID steamIDUser, string pchName, out int pData) {
  29. InteropHelp.TestIfAvailableGameServer();
  30. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  31. return NativeMethods.ISteamGameServerStats_GetUserStat(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, out pData);
  32. }
  33. }
  34. public static bool GetUserStat(CSteamID steamIDUser, string pchName, out float pData) {
  35. InteropHelp.TestIfAvailableGameServer();
  36. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  37. return NativeMethods.ISteamGameServerStats_GetUserStat0(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, out pData);
  38. }
  39. }
  40. public static bool GetUserAchievement(CSteamID steamIDUser, string pchName, out bool pbAchieved) {
  41. InteropHelp.TestIfAvailableGameServer();
  42. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  43. return NativeMethods.ISteamGameServerStats_GetUserAchievement(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, out pbAchieved);
  44. }
  45. }
  46. /// <summary>
  47. /// <para> Set / update stats and achievements.</para>
  48. /// <para> Note: These updates will work only on stats game servers are allowed to edit and only for</para>
  49. /// <para> game servers that have been declared as officially controlled by the game creators.</para>
  50. /// <para> Set the IP range of your official servers on the Steamworks page</para>
  51. /// </summary>
  52. public static bool SetUserStat(CSteamID steamIDUser, string pchName, int nData) {
  53. InteropHelp.TestIfAvailableGameServer();
  54. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  55. return NativeMethods.ISteamGameServerStats_SetUserStat(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, nData);
  56. }
  57. }
  58. public static bool SetUserStat(CSteamID steamIDUser, string pchName, float fData) {
  59. InteropHelp.TestIfAvailableGameServer();
  60. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  61. return NativeMethods.ISteamGameServerStats_SetUserStat0(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, fData);
  62. }
  63. }
  64. public static bool UpdateUserAvgRateStat(CSteamID steamIDUser, string pchName, float flCountThisSession, double dSessionLength) {
  65. InteropHelp.TestIfAvailableGameServer();
  66. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  67. return NativeMethods.ISteamGameServerStats_UpdateUserAvgRateStat(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, flCountThisSession, dSessionLength);
  68. }
  69. }
  70. public static bool SetUserAchievement(CSteamID steamIDUser, string pchName) {
  71. InteropHelp.TestIfAvailableGameServer();
  72. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  73. return NativeMethods.ISteamGameServerStats_SetUserAchievement(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2);
  74. }
  75. }
  76. public static bool ClearUserAchievement(CSteamID steamIDUser, string pchName) {
  77. InteropHelp.TestIfAvailableGameServer();
  78. using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) {
  79. return NativeMethods.ISteamGameServerStats_ClearUserAchievement(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2);
  80. }
  81. }
  82. /// <summary>
  83. /// <para> Store the current data on the server, will get a GSStatsStored_t callback when set.</para>
  84. /// <para> If the callback has a result of k_EResultInvalidParam, one or more stats</para>
  85. /// <para> uploaded has been rejected, either because they broke constraints</para>
  86. /// <para> or were out of date. In this case the server sends back updated values.</para>
  87. /// <para> The stats should be re-iterated to keep in sync.</para>
  88. /// </summary>
  89. public static SteamAPICall_t StoreUserStats(CSteamID steamIDUser) {
  90. InteropHelp.TestIfAvailableGameServer();
  91. return (SteamAPICall_t)NativeMethods.ISteamGameServerStats_StoreUserStats(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser);
  92. }
  93. }
  94. }
  95. #endif // !DISABLESTEAMWORKS