isteamgameserverapps.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 SteamGameServerApps {
  14. public static bool BIsSubscribed() {
  15. InteropHelp.TestIfAvailableGameServer();
  16. return NativeMethods.ISteamApps_BIsSubscribed(CSteamGameServerAPIContext.GetSteamApps());
  17. }
  18. public static bool BIsLowViolence() {
  19. InteropHelp.TestIfAvailableGameServer();
  20. return NativeMethods.ISteamApps_BIsLowViolence(CSteamGameServerAPIContext.GetSteamApps());
  21. }
  22. public static bool BIsCybercafe() {
  23. InteropHelp.TestIfAvailableGameServer();
  24. return NativeMethods.ISteamApps_BIsCybercafe(CSteamGameServerAPIContext.GetSteamApps());
  25. }
  26. public static bool BIsVACBanned() {
  27. InteropHelp.TestIfAvailableGameServer();
  28. return NativeMethods.ISteamApps_BIsVACBanned(CSteamGameServerAPIContext.GetSteamApps());
  29. }
  30. public static string GetCurrentGameLanguage() {
  31. InteropHelp.TestIfAvailableGameServer();
  32. return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamApps_GetCurrentGameLanguage(CSteamGameServerAPIContext.GetSteamApps()));
  33. }
  34. public static string GetAvailableGameLanguages() {
  35. InteropHelp.TestIfAvailableGameServer();
  36. return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamApps_GetAvailableGameLanguages(CSteamGameServerAPIContext.GetSteamApps()));
  37. }
  38. /// <summary>
  39. /// <para> only use this member if you need to check ownership of another game related to yours, a demo for example</para>
  40. /// </summary>
  41. public static bool BIsSubscribedApp(AppId_t appID) {
  42. InteropHelp.TestIfAvailableGameServer();
  43. return NativeMethods.ISteamApps_BIsSubscribedApp(CSteamGameServerAPIContext.GetSteamApps(), appID);
  44. }
  45. /// <summary>
  46. /// <para> Takes AppID of DLC and checks if the user owns the DLC &amp; if the DLC is installed</para>
  47. /// </summary>
  48. public static bool BIsDlcInstalled(AppId_t appID) {
  49. InteropHelp.TestIfAvailableGameServer();
  50. return NativeMethods.ISteamApps_BIsDlcInstalled(CSteamGameServerAPIContext.GetSteamApps(), appID);
  51. }
  52. /// <summary>
  53. /// <para> returns the Unix time of the purchase of the app</para>
  54. /// </summary>
  55. public static uint GetEarliestPurchaseUnixTime(AppId_t nAppID) {
  56. InteropHelp.TestIfAvailableGameServer();
  57. return NativeMethods.ISteamApps_GetEarliestPurchaseUnixTime(CSteamGameServerAPIContext.GetSteamApps(), nAppID);
  58. }
  59. /// <summary>
  60. /// <para> Checks if the user is subscribed to the current app through a free weekend</para>
  61. /// <para> This function will return false for users who have a retail or other type of license</para>
  62. /// <para> Before using, please ask your Valve technical contact how to package and secure your free weekened</para>
  63. /// </summary>
  64. public static bool BIsSubscribedFromFreeWeekend() {
  65. InteropHelp.TestIfAvailableGameServer();
  66. return NativeMethods.ISteamApps_BIsSubscribedFromFreeWeekend(CSteamGameServerAPIContext.GetSteamApps());
  67. }
  68. /// <summary>
  69. /// <para> Returns the number of DLC pieces for the running app</para>
  70. /// </summary>
  71. public static int GetDLCCount() {
  72. InteropHelp.TestIfAvailableGameServer();
  73. return NativeMethods.ISteamApps_GetDLCCount(CSteamGameServerAPIContext.GetSteamApps());
  74. }
  75. /// <summary>
  76. /// <para> Returns metadata for DLC by index, of range [0, GetDLCCount()]</para>
  77. /// </summary>
  78. public static bool BGetDLCDataByIndex(int iDLC, out AppId_t pAppID, out bool pbAvailable, out string pchName, int cchNameBufferSize) {
  79. InteropHelp.TestIfAvailableGameServer();
  80. IntPtr pchName2 = Marshal.AllocHGlobal(cchNameBufferSize);
  81. bool ret = NativeMethods.ISteamApps_BGetDLCDataByIndex(CSteamGameServerAPIContext.GetSteamApps(), iDLC, out pAppID, out pbAvailable, pchName2, cchNameBufferSize);
  82. pchName = ret ? InteropHelp.PtrToStringUTF8(pchName2) : null;
  83. Marshal.FreeHGlobal(pchName2);
  84. return ret;
  85. }
  86. /// <summary>
  87. /// <para> Install/Uninstall control for optional DLC</para>
  88. /// </summary>
  89. public static void InstallDLC(AppId_t nAppID) {
  90. InteropHelp.TestIfAvailableGameServer();
  91. NativeMethods.ISteamApps_InstallDLC(CSteamGameServerAPIContext.GetSteamApps(), nAppID);
  92. }
  93. public static void UninstallDLC(AppId_t nAppID) {
  94. InteropHelp.TestIfAvailableGameServer();
  95. NativeMethods.ISteamApps_UninstallDLC(CSteamGameServerAPIContext.GetSteamApps(), nAppID);
  96. }
  97. /// <summary>
  98. /// <para> Request legacy cd-key for yourself or owned DLC. If you are interested in this</para>
  99. /// <para> data then make sure you provide us with a list of valid keys to be distributed</para>
  100. /// <para> to users when they purchase the game, before the game ships.</para>
  101. /// <para> You'll receive an AppProofOfPurchaseKeyResponse_t callback when</para>
  102. /// <para> the key is available (which may be immediately).</para>
  103. /// </summary>
  104. public static void RequestAppProofOfPurchaseKey(AppId_t nAppID) {
  105. InteropHelp.TestIfAvailableGameServer();
  106. NativeMethods.ISteamApps_RequestAppProofOfPurchaseKey(CSteamGameServerAPIContext.GetSteamApps(), nAppID);
  107. }
  108. /// <summary>
  109. /// <para> returns current beta branch name, 'public' is the default branch</para>
  110. /// </summary>
  111. public static bool GetCurrentBetaName(out string pchName, int cchNameBufferSize) {
  112. InteropHelp.TestIfAvailableGameServer();
  113. IntPtr pchName2 = Marshal.AllocHGlobal(cchNameBufferSize);
  114. bool ret = NativeMethods.ISteamApps_GetCurrentBetaName(CSteamGameServerAPIContext.GetSteamApps(), pchName2, cchNameBufferSize);
  115. pchName = ret ? InteropHelp.PtrToStringUTF8(pchName2) : null;
  116. Marshal.FreeHGlobal(pchName2);
  117. return ret;
  118. }
  119. /// <summary>
  120. /// <para> signal Steam that game files seems corrupt or missing</para>
  121. /// </summary>
  122. public static bool MarkContentCorrupt(bool bMissingFilesOnly) {
  123. InteropHelp.TestIfAvailableGameServer();
  124. return NativeMethods.ISteamApps_MarkContentCorrupt(CSteamGameServerAPIContext.GetSteamApps(), bMissingFilesOnly);
  125. }
  126. /// <summary>
  127. /// <para> return installed depots in mount order</para>
  128. /// </summary>
  129. public static uint GetInstalledDepots(AppId_t appID, DepotId_t[] pvecDepots, uint cMaxDepots) {
  130. InteropHelp.TestIfAvailableGameServer();
  131. return NativeMethods.ISteamApps_GetInstalledDepots(CSteamGameServerAPIContext.GetSteamApps(), appID, pvecDepots, cMaxDepots);
  132. }
  133. /// <summary>
  134. /// <para> returns current app install folder for AppID, returns folder name length</para>
  135. /// </summary>
  136. public static uint GetAppInstallDir(AppId_t appID, out string pchFolder, uint cchFolderBufferSize) {
  137. InteropHelp.TestIfAvailableGameServer();
  138. IntPtr pchFolder2 = Marshal.AllocHGlobal((int)cchFolderBufferSize);
  139. uint ret = NativeMethods.ISteamApps_GetAppInstallDir(CSteamGameServerAPIContext.GetSteamApps(), appID, pchFolder2, cchFolderBufferSize);
  140. pchFolder = ret != 0 ? InteropHelp.PtrToStringUTF8(pchFolder2) : null;
  141. Marshal.FreeHGlobal(pchFolder2);
  142. return ret;
  143. }
  144. /// <summary>
  145. /// <para> returns true if that app is installed (not necessarily owned)</para>
  146. /// </summary>
  147. public static bool BIsAppInstalled(AppId_t appID) {
  148. InteropHelp.TestIfAvailableGameServer();
  149. return NativeMethods.ISteamApps_BIsAppInstalled(CSteamGameServerAPIContext.GetSteamApps(), appID);
  150. }
  151. /// <summary>
  152. /// <para> returns the SteamID of the original owner. If this CSteamID is different from ISteamUser::GetSteamID(),</para>
  153. /// <para> the user has a temporary license borrowed via Family Sharing</para>
  154. /// </summary>
  155. public static CSteamID GetAppOwner() {
  156. InteropHelp.TestIfAvailableGameServer();
  157. return (CSteamID)NativeMethods.ISteamApps_GetAppOwner(CSteamGameServerAPIContext.GetSteamApps());
  158. }
  159. /// <summary>
  160. /// <para> Returns the associated launch param if the game is run via steam://run/&lt;appid&gt;//?param1=value1&amp;param2=value2&amp;param3=value3 etc.</para>
  161. /// <para> Parameter names starting with the character '@' are reserved for internal use and will always return and empty string.</para>
  162. /// <para> Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game,</para>
  163. /// <para> but it is advised that you not param names beginning with an underscore for your own features.</para>
  164. /// <para> Check for new launch parameters on callback NewUrlLaunchParameters_t</para>
  165. /// </summary>
  166. public static string GetLaunchQueryParam(string pchKey) {
  167. InteropHelp.TestIfAvailableGameServer();
  168. using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) {
  169. return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamApps_GetLaunchQueryParam(CSteamGameServerAPIContext.GetSteamApps(), pchKey2));
  170. }
  171. }
  172. /// <summary>
  173. /// <para> get download progress for optional DLC</para>
  174. /// </summary>
  175. public static bool GetDlcDownloadProgress(AppId_t nAppID, out ulong punBytesDownloaded, out ulong punBytesTotal) {
  176. InteropHelp.TestIfAvailableGameServer();
  177. return NativeMethods.ISteamApps_GetDlcDownloadProgress(CSteamGameServerAPIContext.GetSteamApps(), nAppID, out punBytesDownloaded, out punBytesTotal);
  178. }
  179. /// <summary>
  180. /// <para> return the buildid of this app, may change at any time based on backend updates to the game</para>
  181. /// </summary>
  182. public static int GetAppBuildId() {
  183. InteropHelp.TestIfAvailableGameServer();
  184. return NativeMethods.ISteamApps_GetAppBuildId(CSteamGameServerAPIContext.GetSteamApps());
  185. }
  186. /// <summary>
  187. /// <para> Request all proof of purchase keys for the calling appid and asociated DLC.</para>
  188. /// <para> A series of AppProofOfPurchaseKeyResponse_t callbacks will be sent with</para>
  189. /// <para> appropriate appid values, ending with a final callback where the m_nAppId</para>
  190. /// <para> member is k_uAppIdInvalid (zero).</para>
  191. /// </summary>
  192. public static void RequestAllProofOfPurchaseKeys() {
  193. InteropHelp.TestIfAvailableGameServer();
  194. NativeMethods.ISteamApps_RequestAllProofOfPurchaseKeys(CSteamGameServerAPIContext.GetSteamApps());
  195. }
  196. public static SteamAPICall_t GetFileDetails(string pszFileName) {
  197. InteropHelp.TestIfAvailableGameServer();
  198. using (var pszFileName2 = new InteropHelp.UTF8StringHandle(pszFileName)) {
  199. return (SteamAPICall_t)NativeMethods.ISteamApps_GetFileDetails(CSteamGameServerAPIContext.GetSteamApps(), pszFileName2);
  200. }
  201. }
  202. /// <summary>
  203. /// <para> Get command line if game was launched via Steam URL, e.g. steam://run/&lt;appid&gt;//&lt;command line&gt;/.</para>
  204. /// <para> This method of passing a connect string (used when joining via rich presence, accepting an</para>
  205. /// <para> invite, etc) is preferable to passing the connect string on the operating system command</para>
  206. /// <para> line, which is a security risk. In order for rich presence joins to go through this</para>
  207. /// <para> path and not be placed on the OS command line, you must set a value in your app's</para>
  208. /// <para> configuration on Steam. Ask Valve for help with this.</para>
  209. /// <para> If game was already running and launched again, the NewUrlLaunchParameters_t will be fired.</para>
  210. /// </summary>
  211. public static int GetLaunchCommandLine(out string pszCommandLine, int cubCommandLine) {
  212. InteropHelp.TestIfAvailableGameServer();
  213. IntPtr pszCommandLine2 = Marshal.AllocHGlobal(cubCommandLine);
  214. int ret = NativeMethods.ISteamApps_GetLaunchCommandLine(CSteamGameServerAPIContext.GetSteamApps(), pszCommandLine2, cubCommandLine);
  215. pszCommandLine = ret != -1 ? InteropHelp.PtrToStringUTF8(pszCommandLine2) : null;
  216. Marshal.FreeHGlobal(pszCommandLine2);
  217. return ret;
  218. }
  219. /// <summary>
  220. /// <para> Check if user borrowed this game via Family Sharing, If true, call GetAppOwner() to get the lender SteamID</para>
  221. /// </summary>
  222. public static bool BIsSubscribedFromFamilySharing() {
  223. InteropHelp.TestIfAvailableGameServer();
  224. return NativeMethods.ISteamApps_BIsSubscribedFromFamilySharing(CSteamGameServerAPIContext.GetSteamApps());
  225. }
  226. }
  227. }
  228. #endif // !DISABLESTEAMWORKS