CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

isteamuser.cs (19132B)


      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 
      5 // This file is automatically generated.
      6 // Changes to this file will be reverted when you update Steamworks.NET
      7 
      8 #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH
      9 	#define DISABLESTEAMWORKS
     10 #endif
     11 
     12 #if !DISABLESTEAMWORKS
     13 
     14 using System.Runtime.InteropServices;
     15 using IntPtr = System.IntPtr;
     16 
     17 namespace Steamworks {
     18 	public static class SteamUser {
     19 		/// <summary>
     20 		/// <para> returns the HSteamUser this interface represents</para>
     21 		/// <para> this is only used internally by the API, and by a few select interfaces that support multi-user</para>
     22 		/// </summary>
     23 		public static HSteamUser GetHSteamUser() {
     24 			InteropHelp.TestIfAvailableClient();
     25 			return (HSteamUser)NativeMethods.ISteamUser_GetHSteamUser(CSteamAPIContext.GetSteamUser());
     26 		}
     27 
     28 		/// <summary>
     29 		/// <para> returns true if the Steam client current has a live connection to the Steam servers.</para>
     30 		/// <para> If false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server is down/busy.</para>
     31 		/// <para> The Steam client will automatically be trying to recreate the connection as often as possible.</para>
     32 		/// </summary>
     33 		public static bool BLoggedOn() {
     34 			InteropHelp.TestIfAvailableClient();
     35 			return NativeMethods.ISteamUser_BLoggedOn(CSteamAPIContext.GetSteamUser());
     36 		}
     37 
     38 		/// <summary>
     39 		/// <para> returns the CSteamID of the account currently logged into the Steam client</para>
     40 		/// <para> a CSteamID is a unique identifier for an account, and used to differentiate users in all parts of the Steamworks API</para>
     41 		/// </summary>
     42 		public static CSteamID GetSteamID() {
     43 			InteropHelp.TestIfAvailableClient();
     44 			return (CSteamID)NativeMethods.ISteamUser_GetSteamID(CSteamAPIContext.GetSteamUser());
     45 		}
     46 
     47 		/// <summary>
     48 		/// <para> Multiplayer Authentication functions</para>
     49 		/// <para> InitiateGameConnection() starts the state machine for authenticating the game client with the game server</para>
     50 		/// <para> It is the client portion of a three-way handshake between the client, the game server, and the steam servers</para>
     51 		/// <para> Parameters:</para>
     52 		/// <para> void *pAuthBlob - a pointer to empty memory that will be filled in with the authentication token.</para>
     53 		/// <para> int cbMaxAuthBlob - the number of bytes of allocated memory in pBlob. Should be at least 2048 bytes.</para>
     54 		/// <para> CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client</para>
     55 		/// <para> CGameID gameID - the ID of the current game. For games without mods, this is just CGameID( &lt;appID&gt; )</para>
     56 		/// <para> uint32 unIPServer, uint16 usPortServer - the IP address of the game server</para>
     57 		/// <para> bool bSecure - whether or not the client thinks that the game server is reporting itself as secure (i.e. VAC is running)</para>
     58 		/// <para> return value - returns the number of bytes written to pBlob. If the return is 0, then the buffer passed in was too small, and the call has failed</para>
     59 		/// <para> The contents of pBlob should then be sent to the game server, for it to use to complete the authentication process.</para>
     60 		/// </summary>
     61 		public static int InitiateGameConnection(byte[] pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint unIPServer, ushort usPortServer, bool bSecure) {
     62 			InteropHelp.TestIfAvailableClient();
     63 			return NativeMethods.ISteamUser_InitiateGameConnection(CSteamAPIContext.GetSteamUser(), pAuthBlob, cbMaxAuthBlob, steamIDGameServer, unIPServer, usPortServer, bSecure);
     64 		}
     65 
     66 		/// <summary>
     67 		/// <para> notify of disconnect</para>
     68 		/// <para> needs to occur when the game client leaves the specified game server, needs to match with the InitiateGameConnection() call</para>
     69 		/// </summary>
     70 		public static void TerminateGameConnection(uint unIPServer, ushort usPortServer) {
     71 			InteropHelp.TestIfAvailableClient();
     72 			NativeMethods.ISteamUser_TerminateGameConnection(CSteamAPIContext.GetSteamUser(), unIPServer, usPortServer);
     73 		}
     74 
     75 		/// <summary>
     76 		/// <para> Legacy functions</para>
     77 		/// <para> used by only a few games to track usage events</para>
     78 		/// </summary>
     79 		public static void TrackAppUsageEvent(CGameID gameID, int eAppUsageEvent, string pchExtraInfo = "") {
     80 			InteropHelp.TestIfAvailableClient();
     81 			using (var pchExtraInfo2 = new InteropHelp.UTF8StringHandle(pchExtraInfo)) {
     82 				NativeMethods.ISteamUser_TrackAppUsageEvent(CSteamAPIContext.GetSteamUser(), gameID, eAppUsageEvent, pchExtraInfo2);
     83 			}
     84 		}
     85 
     86 		/// <summary>
     87 		/// <para> get the local storage folder for current Steam account to write application data, e.g. save games, configs etc.</para>
     88 		/// <para> this will usually be something like "C:\Progam Files\Steam\userdata\&lt;SteamID&gt;\&lt;AppID&gt;\local"</para>
     89 		/// </summary>
     90 		public static bool GetUserDataFolder(out string pchBuffer, int cubBuffer) {
     91 			InteropHelp.TestIfAvailableClient();
     92 			IntPtr pchBuffer2 = Marshal.AllocHGlobal(cubBuffer);
     93 			bool ret = NativeMethods.ISteamUser_GetUserDataFolder(CSteamAPIContext.GetSteamUser(), pchBuffer2, cubBuffer);
     94 			pchBuffer = ret ? InteropHelp.PtrToStringUTF8(pchBuffer2) : null;
     95 			Marshal.FreeHGlobal(pchBuffer2);
     96 			return ret;
     97 		}
     98 
     99 		/// <summary>
    100 		/// <para> Starts voice recording. Once started, use GetVoice() to get the data</para>
    101 		/// </summary>
    102 		public static void StartVoiceRecording() {
    103 			InteropHelp.TestIfAvailableClient();
    104 			NativeMethods.ISteamUser_StartVoiceRecording(CSteamAPIContext.GetSteamUser());
    105 		}
    106 
    107 		/// <summary>
    108 		/// <para> Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for</para>
    109 		/// <para> a little bit after this function is called. GetVoice() should continue to be called until it returns</para>
    110 		/// <para> k_eVoiceResultNotRecording</para>
    111 		/// </summary>
    112 		public static void StopVoiceRecording() {
    113 			InteropHelp.TestIfAvailableClient();
    114 			NativeMethods.ISteamUser_StopVoiceRecording(CSteamAPIContext.GetSteamUser());
    115 		}
    116 
    117 		/// <summary>
    118 		/// <para> Determine the size of captured audio data that is available from GetVoice.</para>
    119 		/// <para> Most applications will only use compressed data and should ignore the other</para>
    120 		/// <para> parameters, which exist primarily for backwards compatibility. See comments</para>
    121 		/// <para> below for further explanation of "uncompressed" data.</para>
    122 		/// </summary>
    123 		public static EVoiceResult GetAvailableVoice(out uint pcbCompressed) {
    124 			InteropHelp.TestIfAvailableClient();
    125 			return NativeMethods.ISteamUser_GetAvailableVoice(CSteamAPIContext.GetSteamUser(), out pcbCompressed, IntPtr.Zero, 0);
    126 		}
    127 
    128 		/// <summary>
    129 		/// <para> ---------------------------------------------------------------------------</para>
    130 		/// <para> NOTE: "uncompressed" audio is a deprecated feature and should not be used</para>
    131 		/// <para> by most applications. It is raw single-channel 16-bit PCM wave data which</para>
    132 		/// <para> may have been run through preprocessing filters and/or had silence removed,</para>
    133 		/// <para> so the uncompressed audio could have a shorter duration than you expect.</para>
    134 		/// <para> There may be no data at all during long periods of silence. Also, fetching</para>
    135 		/// <para> uncompressed audio will cause GetVoice to discard any leftover compressed</para>
    136 		/// <para> audio, so you must fetch both types at once. Finally, GetAvailableVoice is</para>
    137 		/// <para> not precisely accurate when the uncompressed size is requested. So if you</para>
    138 		/// <para> really need to use uncompressed audio, you should call GetVoice frequently</para>
    139 		/// <para> with two very large (20kb+) output buffers instead of trying to allocate</para>
    140 		/// <para> perfectly-sized buffers. But most applications should ignore all of these</para>
    141 		/// <para> details and simply leave the "uncompressed" parameters as NULL/zero.</para>
    142 		/// <para> ---------------------------------------------------------------------------</para>
    143 		/// <para> Read captured audio data from the microphone buffer. This should be called</para>
    144 		/// <para> at least once per frame, and preferably every few milliseconds, to keep the</para>
    145 		/// <para> microphone input delay as low as possible. Most applications will only use</para>
    146 		/// <para> compressed data and should pass NULL/zero for the "uncompressed" parameters.</para>
    147 		/// <para> Compressed data can be transmitted by your application and decoded into raw</para>
    148 		/// <para> using the DecompressVoice function below.</para>
    149 		/// </summary>
    150 		public static EVoiceResult GetVoice(bool bWantCompressed, byte[] pDestBuffer, uint cbDestBufferSize, out uint nBytesWritten) {
    151 			InteropHelp.TestIfAvailableClient();
    152 			return NativeMethods.ISteamUser_GetVoice(CSteamAPIContext.GetSteamUser(), bWantCompressed, pDestBuffer, cbDestBufferSize, out nBytesWritten, false, IntPtr.Zero, 0, IntPtr.Zero, 0);
    153 		}
    154 
    155 		/// <summary>
    156 		/// <para> Decodes the compressed voice data returned by GetVoice. The output data is</para>
    157 		/// <para> raw single-channel 16-bit PCM audio. The decoder supports any sample rate</para>
    158 		/// <para> from 11025 to 48000; see GetVoiceOptimalSampleRate() below for details.</para>
    159 		/// <para> If the output buffer is not large enough, then *nBytesWritten will be set</para>
    160 		/// <para> to the required buffer size, and k_EVoiceResultBufferTooSmall is returned.</para>
    161 		/// <para> It is suggested to start with a 20kb buffer and reallocate as necessary.</para>
    162 		/// </summary>
    163 		public static EVoiceResult DecompressVoice(byte[] pCompressed, uint cbCompressed, byte[] pDestBuffer, uint cbDestBufferSize, out uint nBytesWritten, uint nDesiredSampleRate) {
    164 			InteropHelp.TestIfAvailableClient();
    165 			return NativeMethods.ISteamUser_DecompressVoice(CSteamAPIContext.GetSteamUser(), pCompressed, cbCompressed, pDestBuffer, cbDestBufferSize, out nBytesWritten, nDesiredSampleRate);
    166 		}
    167 
    168 		/// <summary>
    169 		/// <para> This returns the native sample rate of the Steam voice decompressor; using</para>
    170 		/// <para> this sample rate for DecompressVoice will perform the least CPU processing.</para>
    171 		/// <para> However, the final audio quality will depend on how well the audio device</para>
    172 		/// <para> (and/or your application's audio output SDK) deals with lower sample rates.</para>
    173 		/// <para> You may find that you get the best audio output quality when you ignore</para>
    174 		/// <para> this function and use the native sample rate of your audio output device,</para>
    175 		/// <para> which is usually 48000 or 44100.</para>
    176 		/// </summary>
    177 		public static uint GetVoiceOptimalSampleRate() {
    178 			InteropHelp.TestIfAvailableClient();
    179 			return NativeMethods.ISteamUser_GetVoiceOptimalSampleRate(CSteamAPIContext.GetSteamUser());
    180 		}
    181 
    182 		/// <summary>
    183 		/// <para> Retrieve ticket to be sent to the entity who wishes to authenticate you.</para>
    184 		/// <para> pcbTicket retrieves the length of the actual ticket.</para>
    185 		/// </summary>
    186 		public static HAuthTicket GetAuthSessionTicket(byte[] pTicket, int cbMaxTicket, out uint pcbTicket) {
    187 			InteropHelp.TestIfAvailableClient();
    188 			return (HAuthTicket)NativeMethods.ISteamUser_GetAuthSessionTicket(CSteamAPIContext.GetSteamUser(), pTicket, cbMaxTicket, out pcbTicket);
    189 		}
    190 
    191 		/// <summary>
    192 		/// <para> Authenticate ticket from entity steamID to be sure it is valid and isnt reused</para>
    193 		/// <para> Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )</para>
    194 		/// </summary>
    195 		public static EBeginAuthSessionResult BeginAuthSession(byte[] pAuthTicket, int cbAuthTicket, CSteamID steamID) {
    196 			InteropHelp.TestIfAvailableClient();
    197 			return NativeMethods.ISteamUser_BeginAuthSession(CSteamAPIContext.GetSteamUser(), pAuthTicket, cbAuthTicket, steamID);
    198 		}
    199 
    200 		/// <summary>
    201 		/// <para> Stop tracking started by BeginAuthSession - called when no longer playing game with this entity</para>
    202 		/// </summary>
    203 		public static void EndAuthSession(CSteamID steamID) {
    204 			InteropHelp.TestIfAvailableClient();
    205 			NativeMethods.ISteamUser_EndAuthSession(CSteamAPIContext.GetSteamUser(), steamID);
    206 		}
    207 
    208 		/// <summary>
    209 		/// <para> Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to</para>
    210 		/// </summary>
    211 		public static void CancelAuthTicket(HAuthTicket hAuthTicket) {
    212 			InteropHelp.TestIfAvailableClient();
    213 			NativeMethods.ISteamUser_CancelAuthTicket(CSteamAPIContext.GetSteamUser(), hAuthTicket);
    214 		}
    215 
    216 		/// <summary>
    217 		/// <para> After receiving a user's authentication data, and passing it to BeginAuthSession, use this function</para>
    218 		/// <para> to determine if the user owns downloadable content specified by the provided AppID.</para>
    219 		/// </summary>
    220 		public static EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID) {
    221 			InteropHelp.TestIfAvailableClient();
    222 			return NativeMethods.ISteamUser_UserHasLicenseForApp(CSteamAPIContext.GetSteamUser(), steamID, appID);
    223 		}
    224 
    225 		/// <summary>
    226 		/// <para> returns true if this users looks like they are behind a NAT device. Only valid once the user has connected to steam</para>
    227 		/// <para> (i.e a SteamServersConnected_t has been issued) and may not catch all forms of NAT.</para>
    228 		/// </summary>
    229 		public static bool BIsBehindNAT() {
    230 			InteropHelp.TestIfAvailableClient();
    231 			return NativeMethods.ISteamUser_BIsBehindNAT(CSteamAPIContext.GetSteamUser());
    232 		}
    233 
    234 		/// <summary>
    235 		/// <para> set data to be replicated to friends so that they can join your game</para>
    236 		/// <para> CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client</para>
    237 		/// <para> uint32 unIPServer, uint16 usPortServer - the IP address of the game server</para>
    238 		/// </summary>
    239 		public static void AdvertiseGame(CSteamID steamIDGameServer, uint unIPServer, ushort usPortServer) {
    240 			InteropHelp.TestIfAvailableClient();
    241 			NativeMethods.ISteamUser_AdvertiseGame(CSteamAPIContext.GetSteamUser(), steamIDGameServer, unIPServer, usPortServer);
    242 		}
    243 
    244 		/// <summary>
    245 		/// <para> Requests a ticket encrypted with an app specific shared key</para>
    246 		/// <para> pDataToInclude, cbDataToInclude will be encrypted into the ticket</para>
    247 		/// <para> ( This is asynchronous, you must wait for the ticket to be completed by the server )</para>
    248 		/// </summary>
    249 		public static SteamAPICall_t RequestEncryptedAppTicket(byte[] pDataToInclude, int cbDataToInclude) {
    250 			InteropHelp.TestIfAvailableClient();
    251 			return (SteamAPICall_t)NativeMethods.ISteamUser_RequestEncryptedAppTicket(CSteamAPIContext.GetSteamUser(), pDataToInclude, cbDataToInclude);
    252 		}
    253 
    254 		/// <summary>
    255 		/// <para> retrieve a finished ticket</para>
    256 		/// </summary>
    257 		public static bool GetEncryptedAppTicket(byte[] pTicket, int cbMaxTicket, out uint pcbTicket) {
    258 			InteropHelp.TestIfAvailableClient();
    259 			return NativeMethods.ISteamUser_GetEncryptedAppTicket(CSteamAPIContext.GetSteamUser(), pTicket, cbMaxTicket, out pcbTicket);
    260 		}
    261 
    262 		/// <summary>
    263 		/// <para> Trading Card badges data access</para>
    264 		/// <para> if you only have one set of cards, the series will be 1</para>
    265 		/// <para> the user has can have two different badges for a series; the regular (max level 5) and the foil (max level 1)</para>
    266 		/// </summary>
    267 		public static int GetGameBadgeLevel(int nSeries, bool bFoil) {
    268 			InteropHelp.TestIfAvailableClient();
    269 			return NativeMethods.ISteamUser_GetGameBadgeLevel(CSteamAPIContext.GetSteamUser(), nSeries, bFoil);
    270 		}
    271 
    272 		/// <summary>
    273 		/// <para> gets the Steam Level of the user, as shown on their profile</para>
    274 		/// </summary>
    275 		public static int GetPlayerSteamLevel() {
    276 			InteropHelp.TestIfAvailableClient();
    277 			return NativeMethods.ISteamUser_GetPlayerSteamLevel(CSteamAPIContext.GetSteamUser());
    278 		}
    279 
    280 		/// <summary>
    281 		/// <para> Requests a URL which authenticates an in-game browser for store check-out,</para>
    282 		/// <para> and then redirects to the specified URL. As long as the in-game browser</para>
    283 		/// <para> accepts and handles session cookies, Steam microtransaction checkout pages</para>
    284 		/// <para> will automatically recognize the user instead of presenting a login page.</para>
    285 		/// <para> The result of this API call will be a StoreAuthURLResponse_t callback.</para>
    286 		/// <para> NOTE: The URL has a very short lifetime to prevent history-snooping attacks,</para>
    287 		/// <para> so you should only call this API when you are about to launch the browser,</para>
    288 		/// <para> or else immediately navigate to the result URL using a hidden browser window.</para>
    289 		/// <para> NOTE 2: The resulting authorization cookie has an expiration time of one day,</para>
    290 		/// <para> so it would be a good idea to request and visit a new auth URL every 12 hours.</para>
    291 		/// </summary>
    292 		public static SteamAPICall_t RequestStoreAuthURL(string pchRedirectURL) {
    293 			InteropHelp.TestIfAvailableClient();
    294 			using (var pchRedirectURL2 = new InteropHelp.UTF8StringHandle(pchRedirectURL)) {
    295 				return (SteamAPICall_t)NativeMethods.ISteamUser_RequestStoreAuthURL(CSteamAPIContext.GetSteamUser(), pchRedirectURL2);
    296 			}
    297 		}
    298 
    299 		/// <summary>
    300 		/// <para> gets whether the users phone number is verified</para>
    301 		/// </summary>
    302 		public static bool BIsPhoneVerified() {
    303 			InteropHelp.TestIfAvailableClient();
    304 			return NativeMethods.ISteamUser_BIsPhoneVerified(CSteamAPIContext.GetSteamUser());
    305 		}
    306 
    307 		/// <summary>
    308 		/// <para> gets whether the user has two factor enabled on their account</para>
    309 		/// </summary>
    310 		public static bool BIsTwoFactorEnabled() {
    311 			InteropHelp.TestIfAvailableClient();
    312 			return NativeMethods.ISteamUser_BIsTwoFactorEnabled(CSteamAPIContext.GetSteamUser());
    313 		}
    314 
    315 		/// <summary>
    316 		/// <para> gets whether the users phone number is identifying</para>
    317 		/// </summary>
    318 		public static bool BIsPhoneIdentifying() {
    319 			InteropHelp.TestIfAvailableClient();
    320 			return NativeMethods.ISteamUser_BIsPhoneIdentifying(CSteamAPIContext.GetSteamUser());
    321 		}
    322 
    323 		/// <summary>
    324 		/// <para> gets whether the users phone number is awaiting (re)verification</para>
    325 		/// </summary>
    326 		public static bool BIsPhoneRequiringVerification() {
    327 			InteropHelp.TestIfAvailableClient();
    328 			return NativeMethods.ISteamUser_BIsPhoneRequiringVerification(CSteamAPIContext.GetSteamUser());
    329 		}
    330 
    331 		public static SteamAPICall_t GetMarketEligibility() {
    332 			InteropHelp.TestIfAvailableClient();
    333 			return (SteamAPICall_t)NativeMethods.ISteamUser_GetMarketEligibility(CSteamAPIContext.GetSteamUser());
    334 		}
    335 
    336 		/// <summary>
    337 		/// <para> Retrieves anti indulgence / duration control for current user</para>
    338 		/// </summary>
    339 		public static SteamAPICall_t GetDurationControl() {
    340 			InteropHelp.TestIfAvailableClient();
    341 			return (SteamAPICall_t)NativeMethods.ISteamUser_GetDurationControl(CSteamAPIContext.GetSteamUser());
    342 		}
    343 	}
    344 }
    345 
    346 #endif // !DISABLESTEAMWORKS