public PublishedFile(PublishedFileId_t id, AppId_t appId) {
            Contract.Requires<ArgumentNullException>(id != null);
            Contract.Requires<ArgumentNullException>(appId != null);

            Pid = id;
            Aid = appId;
        }
		// Returns metadata for DLC by index, of range [0, GetDLCCount()]
		public static bool BGetDLCDataByIndex(int iDLC, out AppId_t pAppID, out bool pbAvailable, out string pchName, int cchNameBufferSize) {
			InteropHelp.TestIfAvailableClient();
			IntPtr pchName2 = Marshal.AllocHGlobal(cchNameBufferSize);
			bool ret = NativeMethods.ISteamApps_BGetDLCDataByIndex(iDLC, out pAppID, out pbAvailable, pchName2, cchNameBufferSize);
			pchName = ret ? InteropHelp.PtrToStringUTF8(pchName2) : null;
			Marshal.FreeHGlobal(pchName2);
			return ret;
		}
		/// <summary>
		/// <para> returns -1 if no dir was found</para>
		/// </summary>
		public static int GetAppInstallDir(AppId_t nAppID, out string pchDirectory, int cchNameMax) {
			InteropHelp.TestIfAvailableClient();
			IntPtr pchDirectory2 = Marshal.AllocHGlobal(cchNameMax);
			int ret = NativeMethods.ISteamAppList_GetAppInstallDir(nAppID, pchDirectory2, cchNameMax);
			pchDirectory = ret != -1 ? InteropHelp.PtrToStringUTF8(pchDirectory2) : null;
			Marshal.FreeHGlobal(pchDirectory2);
			return ret;
		}
Exemple #4
0
 public static int GetAppName(AppId_t nAppID, out string pchName, int cchNameMax)
 {
     InteropHelp.TestIfAvailableClient();
     IntPtr intPtr = Marshal.AllocHGlobal(cchNameMax);
     int num = NativeMethods.ISteamAppList_GetAppName(nAppID, intPtr, cchNameMax);
     pchName = ((num == -1) ? null : InteropHelp.PtrToStringUTF8(intPtr));
     Marshal.FreeHGlobal(intPtr);
     return num;
 }
		/// <summary>
		/// <para> Steam Workshop Creator API</para>
		/// <para> create new item for this app with no content attached yet</para>
		/// </summary>
		public static SteamAPICall_t CreateItem(AppId_t nConsumerAppId, EWorkshopFileType eFileType) {
			InteropHelp.TestIfAvailableGameServer();
			return (SteamAPICall_t)NativeMethods.ISteamGameServerUGC_CreateItem(nConsumerAppId, eFileType);
		}
		/// <summary>
		/// <para> start an UGC item update. Set changed properties before commiting update with CommitItemUpdate()</para>
		/// </summary>
		public static UGCUpdateHandle_t StartItemUpdate(AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID) {
			InteropHelp.TestIfAvailableGameServer();
			return (UGCUpdateHandle_t)NativeMethods.ISteamGameServerUGC_StartItemUpdate(nConsumerAppId, nPublishedFileID);
		}
			// publishing UGC
		public static SteamAPICall_t PublishWorkshopFile(string pchFile, string pchPreviewFile, AppId_t nConsumerAppId, string pchTitle, string pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, System.Collections.Generic.IList<string> pTags, EWorkshopFileType eWorkshopFileType) {
			InteropHelp.TestIfAvailableClient();
			return (SteamAPICall_t)NativeMethods.ISteamRemoteStorage_PublishWorkshopFile(pchFile, pchPreviewFile, nConsumerAppId, pchTitle, pchDescription, eVisibility, new InteropHelp.SteamParamStringArray(pTags), eWorkshopFileType);
		}
		public static SteamAPICall_t AddItemToFavorites(AppId_t nAppId, PublishedFileId_t nPublishedFileID) {
			InteropHelp.TestIfAvailableClient();
			return (SteamAPICall_t)NativeMethods.ISteamUGC_AddItemToFavorites(nAppId, nPublishedFileID);
		}
		public static extern void ISteamFriends_ActivateGameOverlayToStore(AppId_t nAppID, EOverlayToStoreFlag eFlag);
		public static extern EUserHasLicenseForAppResult ISteamGameServer_UserHasLicenseForApp(CSteamID steamID, AppId_t appID);
Exemple #11
0
 public static EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServer_UserHasLicenseForApp(steamID, appID));
 }
Exemple #12
0
		public static bool BUserOwnsAppInTicket(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID) {
			InteropHelp.TestIfPlatformSupported();
			return NativeMethods.BUserOwnsAppInTicket(rgubTicketDecrypted, cubTicketDecrypted, nAppID);
		}
 private void SetAppID(AppId_t other)
 {
     m_GameID = (m_GameID & ~(0xFFFFFFul << (ushort)0)) | (((ulong)(other) & 0xFFFFFFul) << (ushort)0);
 }
 public CGameID(AppId_t nAppID)
 {
     m_GameID = 0;
     SetAppID(nAppID);
 }
Exemple #15
0
 private static bool IsOurAppId(AppId_t appId)
 {
     return(!(appId != SteamUtils.GetAppID()));
 }
Exemple #16
0
        public static void Run <TGame>(GameInfo info, string[] args) where TGame : IGame, new()
        {
            bool sdlInitialised        = false;
            bool sdlImageInitialised   = false;
            bool steamworksInitialised = false;

            try
            {
                // Store info
                Info = info;

                // Get commandline arguments
                Arguments = new ProgramArguments(args);

                // Determine platform
                string platformString = SDL.SDL_GetPlatform();
                switch (platformString)
                {
                case "Windows":
                {
                    Platform = Platform.Windows;
                    break;
                }

                case "Mac OS X":
                {
                    Platform = Platform.OSX;
                    break;
                }

                case "Linux":
                {
                    Platform = Platform.Linux;
                    break;
                }

                default:
                {
                    Platform = Platform.Unknown;
                    break;
                }
                }

                // Print App Info
                if (App.Debug && App.Steam)
                {
                    Log("{0} {1} (Steam Debug build)", Info.Title, Info.Version);
                }
                else if (App.Debug)
                {
                    Log("{0} {1} (Debug build)", Info.Title, Info.Version);
                }
                else if (App.Steam)
                {
                    Log("{0} {1} (Steam build)", Info.Title, Info.Version);
                }
                else
                {
                    Log("{0} {1}", Info.Title, Info.Version);
                }
                if (!Arguments.IsEmpty)
                {
                    Log("Command Line Arguments: {0}", Arguments);
                }
                Log("Developed by {0} ({1})", Info.DeveloperName, Info.DeveloperEmail);
                Log("Platform: {0} ({1})", Platform, platformString);

                // Setup Steamworks
                if (App.Steam)
                {
                    // Relaunch game under Steam if launched externally
                    if (!App.Debug)
                    {
                        if (File.Exists("steam_appid.txt"))
                        {
                            File.Delete("steam_appid.txt");
                        }

                        AppId_t appID = (Info.SteamAppID > 0) ? new AppId_t(Info.SteamAppID) : AppId_t.Invalid;
                        if (SteamAPI.RestartAppIfNecessary(appID))
                        {
                            Log("Relaunching game in Steam");
                            return;
                        }
                    }

                    // Initialise Steamworks
                    if (!SteamAPI.Init())
                    {
                        throw new SteamworksException("SteamAPI_Init", "If you have just installed " + App.Info.Title + " for the first time, try restarting Steam");
                    }
                    Log("Steamworks initialised");
                    steamworksInitialised = true;
                }

                // Print SDL version
                SDL.SDL_version version;
                SDL.SDL_GetVersion(out version);
                Log("SDL version: {0}.{1}.{2}", version.major, version.minor, version.patch);

                // Setup SDL
                SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "1");
                SDL.SDL_SetHint(SDL.SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
                CheckSDLResult("SDL_Init", SDL.SDL_Init(
                                   SDL.SDL_INIT_VIDEO |
                                   SDL.SDL_INIT_AUDIO |
                                   SDL.SDL_INIT_GAMECONTROLLER |
                                   SDL.SDL_INIT_JOYSTICK |
                                   SDL.SDL_INIT_HAPTIC
                                   ));
                Log("SDL2 Initialised");
                sdlInitialised = true;

                CheckSDLResult("IMG_Init", SDL_image.IMG_Init(
                                   SDL_image.IMG_InitFlags.IMG_INIT_PNG
                                   ));
                sdlImageInitialised = true;
                Log("SDL2_Image initialised");

                // Determine save path
                InitSavePath();
                StartLogging();

                // Determine asset directory
                if (App.Debug)
                {
                    AssetPath = "../../assets";
                }
                else
                {
                    if (App.Platform == Platform.OSX)
                    {
                        AssetPath = "assets";
                    }
                    else
                    {
                        string basePath = SDL.SDL_GetBasePath();
                        AssetPath = Path.Combine(basePath, "assets");
                    }
                }
                if (!Directory.Exists(AssetPath))
                {
                    throw new IOException
                          (
                              "Could not locate assets directory (" + AssetPath + ")" + Environment.NewLine +
                              "This must be provided from a legal copy of " + App.Info.Title + ". Visit " + App.Info.Website + " for more info."
                          );
                }

                // Register asset types
                RegisterAssetTypes();

                // Load controller database
                var gameControllerDBPath = Path.Combine(AssetPath, "gamecontrollerdb.txt");
                if (File.Exists(gameControllerDBPath))
                {
                    try
                    {
                        CheckSDLResult("SDL_GameControllerAddMappingsFromFile", SDL.SDL_GameControllerAddMappingsFromFile(gameControllerDBPath));
                        App.Log("Loaded gamepad mappings from gamecontrollerdb.txt");
                    }
                    catch (SDLException)
                    {
                        App.Log("Error: Failed to load gamepad mappings from gamecontrollerdb.txt");
                    }
                }
                else
                {
                    App.Log("Error: gamecontrollerdb.txt not found");
                }

                // Create game
                using (var game = new Game.Game.Game())
                {
                    App.CheckOpenGLError();

                    // Main loop
                    uint lastFrameStart = SDL.SDL_GetTicks();
                    while (!game.Over)
                    {
                        // Get time
                        uint frameStart = SDL.SDL_GetTicks();
                        uint delta      = frameStart - lastFrameStart;
                        FPS = 0.8f * FPS + 0.2f * ((delta > 0) ? (1000.0f / (float)delta) : 1000.0f);
                        float dt = Math.Max((float)delta / 1000.0f, 0.0f);

                        // Handle SDL events
                        SDL.SDL_Event e;
                        while (!game.Over && SDL.SDL_PollEvent(out e) != 0)
                        {
                            // Pass event to game
                            game.HandleEvent(ref e);
                        }

                        // Handle Steamworks events
                        if (!game.Over && App.Steam)
                        {
                            SteamAPI.RunCallbacks();
                        }

                        // Update game
                        if (!game.Over)
                        {
                            game.Update(dt);
                        }

                        // Render game
                        if (!game.Over)
                        {
                            game.Render();
                            App.CheckOpenGLError();
                            RenderStats.EndFrame();
                        }

                        // Sleep if necessary
                        if (!game.Over)
                        {
                            uint minFrameTime = 1000 / MAX_FPS;
                            uint frameTime    = (SDL.SDL_GetTicks() - frameStart);
                            if (frameTime < minFrameTime)
                            {
                                // SDL.SDL_Delay(minFrameTime - frameTime);
                            }
                        }

                        // Update timer for next frame
                        lastFrameStart = frameStart;
                    }
                }
            }
#if !DEBUG
            catch (Exception e)
            {
                // Log error to console
                string message = string.Format("Game crashed with {0}: {1}", e.GetType().FullName, e.Message);
                Log(message);
                Log(e.StackTrace);
                while ((e = e.InnerException) != null)
                {
                    Log("Caused by {0}: {1}", e.GetType().FullName, e.Message);
                    Log(e.StackTrace);
                }

                // Open an emergency log file if necessary
                if (LogFile == null)
                {
                    try
                    {
                        LogFilePath = "log.txt";
                        Log("Logging to " + LogFilePath);
                        LogFile = new StreamWriter("log.txt");
                        for (int i = 0; i < EarlyLogText.Count; ++i)
                        {
                            LogFile.WriteLine(EarlyLogText[i]);
                        }
                        EarlyLogText.Clear();
                        LogFile.Flush();
                    }
                    catch (IOException)
                    {
                        Log("Failed to open log file");
                        LogFilePath = null;
                    }
                }

                // Pop up the message box
                //if( sdlInitialised ) // The docs say SDL doesn't need to be inited to call ShowSimpleMessageBox
                {
                    try
                    {
                        if (LogFilePath != null)
                        {
                            message += Environment.NewLine;
                            message += Environment.NewLine;
                            message += "Callstack written to " + LogFilePath;
                        }

                        CheckSDLResult("SDL_ShowSimpleMessageBox", SDL.SDL_ShowSimpleMessageBox(
                                           SDL.SDL_MessageBoxFlags.SDL_MESSAGEBOX_ERROR,
                                           Info.Title + " " + Info.Version,
                                           message,
                                           IntPtr.Zero
                                           ));
                    }
                    catch (SDLException e2)
                    {
                        Log(e2.Message);
                    }
                }
            }
#endif
            finally
            {
                // Shutdown SDL
                if (sdlImageInitialised)
                {
                    SDL_image.IMG_Quit();
                    Log("SDL2_Image shut down");
                }
                if (sdlInitialised)
                {
                    SDL.SDL_Quit();
                    Log("SDL2 shut down");
                }

                // Shutdown Steamworks
                if (steamworksInitialised)
                {
                    SteamAPI.Shutdown();
                    Log("Steamworks shut down");
                }

                // Close the log file
                if (LogFile != null)
                {
                    Log("Closing log file");
                    LogFile.Dispose();
                    LogFile = null;
                    Log("Log file closed");
                }

                // Quit
                Log("Quitting");
            }
        }
        //----------------------------------------------------------------------------------------------------------------------------------------------------------//
        //	Steam API setup & shutdown
        //
        //	These functions manage loading, initializing and shutdown of the steamclient.dll
        //
        //----------------------------------------------------------------------------------------------------------------------------------------------------------//

        // Detects if your executable was launched through the Steam client, and restarts your game through
        // the client if necessary. The Steam client will be started if it is not running.
        //
        // Returns: true if your executable was NOT launched through the Steam client. This function will
        //          then start your application through the client. Your current process should exit.
        //
        //          false if your executable was started through the Steam client or a steam_appid.txt file
        //          is present in your game's directory (for development). Your current process should continue.
        //
        // NOTE: This function should be used only if you are using CEG or not using Steam's DRM. Once applied
        //       to your executable, Steam's DRM will handle restarting through Steam if necessary.
        public static bool RestartAppIfNecessary(AppId_t unOwnAppID)
        {
            InteropHelp.TestIfPlatformSupported();
            return(NativeMethods.SteamAPI_RestartAppIfNecessary(unOwnAppID));
        }
 public static bool BUserOwnsAppInTicket(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID)
 {
     InteropHelp.TestIfPlatformSupported();
     return(NativeMethods.BUserOwnsAppInTicket(rgubTicketDecrypted, cubTicketDecrypted, nAppID));
 }
Exemple #19
0
 public static bool InitGameServer(uint unIP, ushort usGamePort, ushort usQueryPort, uint unFlags, AppId_t nGameAppId, string pchVersionString)
 {
     InteropHelp.TestIfAvailableGameServer();
     using (InteropHelp.UTF8StringHandle pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString))
     {
         return(NativeMethods.ISteamGameServer_InitGameServer(unIP, usGamePort, usQueryPort, unFlags, nGameAppId, pchVersionString2));
     }
 }
 public static SteamAPICall_t PublishVideo(EWorkshopVideoProvider eVideoProvider, string pchVideoAccount, string pchVideoIdentifier, string pchPreviewFile, AppId_t nConsumerAppId, string pchTitle, string pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, IList<string> pTags)
 {
     InteropHelp.TestIfAvailableClient();
     SteamAPICall_t result;
     using (InteropHelp.UTF8StringHandle uTF8StringHandle = new InteropHelp.UTF8StringHandle(pchVideoAccount))
     {
         using (InteropHelp.UTF8StringHandle uTF8StringHandle2 = new InteropHelp.UTF8StringHandle(pchVideoIdentifier))
         {
             using (InteropHelp.UTF8StringHandle uTF8StringHandle3 = new InteropHelp.UTF8StringHandle(pchPreviewFile))
             {
                 using (InteropHelp.UTF8StringHandle uTF8StringHandle4 = new InteropHelp.UTF8StringHandle(pchTitle))
                 {
                     using (InteropHelp.UTF8StringHandle uTF8StringHandle5 = new InteropHelp.UTF8StringHandle(pchDescription))
                     {
                         result = (SteamAPICall_t)NativeMethods.ISteamRemoteStorage_PublishVideo(eVideoProvider, uTF8StringHandle, uTF8StringHandle2, uTF8StringHandle3, nConsumerAppId, uTF8StringHandle4, uTF8StringHandle5, eVisibility, new InteropHelp.SteamParamStringArray(pTags));
                     }
                 }
             }
         }
     }
     return result;
 }
 public static bool BIsAppInBlockList(AppId_t nAppID)
 {
     InteropHelp.TestIfAvailableClient();
     return(NativeMethods.ISteamParentalSettings_BIsAppInBlockList(CSteamAPIContext.GetSteamParentalSettings(), nAppID));
 }
        public static void GetPublishedItems(AccountID_t accountId, AppId_t WorkshopAppId, AppId_t GameAppId, GetPublishedItemsDelegate InPublishedItemsDelegate)
        {
            PublishedItems_delegate = InPublishedItemsDelegate;
            uint             nPage         = 1u;
            UGCQueryHandle_t hQuery        = SteamUGC.CreateQueryUserUGCRequest(accountId, EUserUGCList.k_EUserUGCList_Published, EUGCMatchingUGCType.k_EUGCMatchingUGCType_Items, EUserUGCListSortOrder.k_EUserUGCListSortOrder_CreationOrderDesc, WorkshopAppId, GameAppId, nPage);
            SteamAPICall_t   hSteamAPICall = SteamUGC.SendQueryUGCRequest(hQuery);

            if (hSteamAPICall != SteamAPICall_t.Invalid)
            {
                m_SteamUGCQueryCompletedCallback.Set(hSteamAPICall, null);
            }
            else
            {
                PublishedItems_delegate(EResult.k_EResultFail);
            }
        }
Exemple #23
0
    internal IEnumerator GetFriends()
    {
        if (_funGetFriends == null)
        {
            yield break;
        }
        _FriendsList.Clear();
        AppId_t[] appList;
        appList = new AppId_t[1];
        SteamAppList.GetInstalledApps(appList, 1);
        SteamAppList.GetNumInstalledApps();
        _FriendsCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate | EFriendFlags.k_EFriendFlagIgnoredFriend);
        for (int i = 0; i < _FriendsCount; i++)
        {
            try
            {
                SteamFriendsData data = new SteamFriendsData();
                //get steamid
                data._SteamID = SteamFriends.GetFriendByIndex(i, EFriendFlags.k_EFriendFlagImmediate | EFriendFlags.k_EFriendFlagIgnoredFriend);
                var fgi = new FriendGameInfo_t();
                //get playing game name
                bool ret = SteamFriends.GetFriendGamePlayed(data._SteamID, out fgi);
                if (ret)
                {
                    if (fgi.m_gameID.AppID() == SteamUtils.GetAppID())
                    {
                        data._PlayedGameName = "Planet Explorers";
                    }
                    else
                    {
                        data._PlayedGameName = "Another game";
                    }
                    //SteamAppList.GetAppName(fgi.m_gameID.AppID(), out data._PlayedGameName, 256);
                }
                //get player state
                data._PlayerState = SteamFriends.GetFriendPersonaState(data._SteamID);
                //get player name
                data._PlayerName = SteamFriends.GetFriendPersonaName(data._SteamID);
                //get avatar
                int  FriendAvatar = SteamFriends.GetSmallFriendAvatar(data._SteamID);
                uint ImageWidth;
                uint ImageHeight;
                ret = SteamUtils.GetImageSize(FriendAvatar, out ImageWidth, out ImageHeight);

                if (ret && ImageWidth > 0 && ImageHeight > 0)
                {
                    ret = SteamUtils.GetImageRGBA(FriendAvatar, _imageData, SteamFriendsData._imageHeight * SteamFriendsData._imageWidth * 4);

                    for (int n = 0; n < _imageData.Length; n += 4)
                    {
                        int x   = (n / 4) % SteamFriendsData._imageWidth;
                        int y   = (n / 4) / SteamFriendsData._imageHeight;
                        int tag = (SteamFriendsData._imageWidth * (SteamFriendsData._imageHeight - y - 1) + x) * 4;

                        _imageTurnData[n]     = _imageData[tag];
                        _imageTurnData[n + 1] = _imageData[tag + 1];
                        _imageTurnData[n + 2] = _imageData[tag + 2];
                        _imageTurnData[n + 3] = _imageData[tag + 3];
                    }

                    data._avatar.LoadRawTextureData(_imageTurnData);
                    data._avatar.Apply();
                }
                _FriendsList[i] = data;
            }
            catch (Exception e)
            {
                Debug.Log("SteamGetFriendsProcess GetFriends " + e.ToString());
                _funGetFriends(null, false);
            }
            yield return(0);
        }
        _funGetFriends(_FriendsList, true);
    }
		public static extern bool ISteamGameServer_InitGameServer(uint unIP, ushort usGamePort, ushort usQueryPort, uint unFlags, AppId_t nGameAppId, InteropHelp.UTF8StringHandle pchVersionString);
Exemple #25
0
 public SteamWorkshopQueryImpl(BaseMonoBehaviour content)
 {
     //初始化appid
     this.mAppId   = new AppId_t(uint.Parse(CommonInfo.Steam_App_Id));
     this.mContent = content;
 }
			// Gets metadata for a file after it has been downloaded. This is the same metadata given in the RemoteStorageDownloadUGCResult_t call result
		public static bool GetUGCDetails(UGCHandle_t hContent, out AppId_t pnAppID, out string ppchName, out int pnFileSizeInBytes, out CSteamID pSteamIDOwner) {
			InteropHelp.TestIfAvailableClient();
			IntPtr ppchName2;
			bool ret = NativeMethods.ISteamRemoteStorage_GetUGCDetails(hContent, out pnAppID, out ppchName2, out pnFileSizeInBytes, out pSteamIDOwner);
			ppchName = ret ? InteropHelp.PtrToStringUTF8(ppchName2) : null;
			return ret;
		}
Exemple #27
0
 protected App(AppId_t id)
 {
     Id           = id;
     _steamInfo   = SteamHelper.TryGetSteamAppById(Id.m_AppId);
     _directories = SystemExtensions.CreateLazy(GetDirectories);
 }
		public static SteamAPICall_t PublishVideo(EWorkshopVideoProvider eVideoProvider, string pchVideoAccount, string pchVideoIdentifier, string pchPreviewFile, AppId_t nConsumerAppId, string pchTitle, string pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, System.Collections.Generic.IList<string> pTags) {
			InteropHelp.TestIfAvailableClient();
			return (SteamAPICall_t)NativeMethods.ISteamRemoteStorage_PublishVideo(eVideoProvider, pchVideoAccount, pchVideoIdentifier, pchPreviewFile, nConsumerAppId, pchTitle, pchDescription, eVisibility, new InteropHelp.SteamParamStringArray(pTags));
		}
		/// <summary>
		/// <para> returns the details of the game server</para>
		/// <para> iGame is of range [0,GetFavoriteGameCount())</para>
		/// <para> *pnIP, *pnConnPort are filled in the with IP:port of the game server</para>
		/// <para> *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections</para>
		/// <para> *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added</para>
		/// </summary>
		public static bool GetFavoriteGame(int iGame, out AppId_t pnAppID, out uint pnIP, out ushort pnConnPort, out ushort pnQueryPort, out uint punFlags, out uint pRTime32LastPlayedOnServer) {
			InteropHelp.TestIfAvailableClient();
			return NativeMethods.ISteamMatchmaking_GetFavoriteGame(iGame, out pnAppID, out pnIP, out pnConnPort, out pnQueryPort, out punFlags, out pRTime32LastPlayedOnServer);
		}
		/// <summary>
		/// <para> Query UGC associated with a user. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1.</para>
		/// </summary>
		public static UGCQueryHandle_t CreateQueryUserUGCRequest(AccountID_t unAccountID, EUserUGCList eListType, EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint unPage) {
			InteropHelp.TestIfAvailableGameServer();
			return (UGCQueryHandle_t)NativeMethods.ISteamGameServerUGC_CreateQueryUserUGCRequest(unAccountID, eListType, eMatchingUGCType, eSortOrder, nCreatorAppID, nConsumerAppID, unPage);
		}
		public static HServerListRequest RequestLANServerList(AppId_t iApp, ISteamMatchmakingServerListResponse pRequestServersResponse) {
			InteropHelp.TestIfAvailableClient();
			return (HServerListRequest)NativeMethods.ISteamMatchmakingServers_RequestLANServerList(iApp, (IntPtr)pRequestServersResponse);
		}
		/// <summary>
		/// <para> Query for all matching UGC. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1.</para>
		/// </summary>
		public static UGCQueryHandle_t CreateQueryAllUGCRequest(EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint unPage) {
			InteropHelp.TestIfAvailableGameServer();
			return (UGCQueryHandle_t)NativeMethods.ISteamGameServerUGC_CreateQueryAllUGCRequest(eQueryType, eMatchingeMatchingUGCTypeFileType, nCreatorAppID, nConsumerAppID, unPage);
		}
		public static HServerListRequest RequestSpectatorServerList(AppId_t iApp, MatchMakingKeyValuePair_t[] ppchFilters, uint nFilters, ISteamMatchmakingServerListResponse pRequestServersResponse) {
			InteropHelp.TestIfAvailableClient();
			return (HServerListRequest)NativeMethods.ISteamMatchmakingServers_RequestSpectatorServerList(iApp, new MMKVPMarshaller(ppchFilters), nFilters, (IntPtr)pRequestServersResponse);
		}
		public static SteamAPICall_t RemoveItemFromFavorites(AppId_t nAppId, PublishedFileId_t nPublishedFileID) {
			InteropHelp.TestIfAvailableGameServer();
			return (SteamAPICall_t)NativeMethods.ISteamGameServerUGC_RemoveItemFromFavorites(nAppId, nPublishedFileID);
		}
Exemple #35
0
 public static bool BIsTicketForApp(byte[] rgubTicketDecrypted, uint cubTicketDecrypted, AppId_t nAppID)
 {
     InteropHelp.TestIfPlatformSupported();
     return(NativeMethods.SteamEncryptedAppTicket_BIsTicketForApp(rgubTicketDecrypted, cubTicketDecrypted, nAppID));
 }
		/// <summary>
		/// <para> adds the game server to the local list; updates the time played of the server if it already exists in the list</para>
		/// </summary>
		public static int AddFavoriteGame(AppId_t nAppID, uint nIP, ushort nConnPort, ushort nQueryPort, uint unFlags, uint rTime32LastPlayedOnServer) {
			InteropHelp.TestIfAvailableClient();
			return NativeMethods.ISteamMatchmaking_AddFavoriteGame(nAppID, nIP, nConnPort, nQueryPort, unFlags, rTime32LastPlayedOnServer);
		}
		public static extern uint ISteamApps_GetAppInstallDir(AppId_t appID, IntPtr pchFolder, uint cchFolderBufferSize);
		/// <summary>
		/// <para> removes the game server from the local storage; returns true if one was removed</para>
		/// </summary>
		public static bool RemoveFavoriteGame(AppId_t nAppID, uint nIP, ushort nConnPort, ushort nQueryPort, uint unFlags) {
			InteropHelp.TestIfAvailableClient();
			return NativeMethods.ISteamMatchmaking_RemoveFavoriteGame(nAppID, nIP, nConnPort, nQueryPort, unFlags);
		}
		public static extern bool ISteamApps_BIsAppInstalled(AppId_t appID);
 public static bool GetUGCDetails(UGCHandle_t hContent, out AppId_t pnAppID, out string ppchName, out int pnFileSizeInBytes, out CSteamID pSteamIDOwner)
 {
     InteropHelp.TestIfAvailableClient();
     IntPtr nativeUtf;
     bool flag = NativeMethods.ISteamRemoteStorage_GetUGCDetails(hContent, out pnAppID, out nativeUtf, out pnFileSizeInBytes, out pSteamIDOwner);
     ppchName = ((!flag) ? null : InteropHelp.PtrToStringUTF8(nativeUtf));
     return flag;
 }
		public static extern bool SteamAPI_RestartAppIfNecessary(AppId_t unOwnAppID);
 public static SteamAPICall_t PublishWorkshopFile(string pchFile, string pchPreviewFile, AppId_t nConsumerAppId, string pchTitle, string pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, IList<string> pTags, EWorkshopFileType eWorkshopFileType)
 {
     InteropHelp.TestIfAvailableClient();
     SteamAPICall_t result;
     using (InteropHelp.UTF8StringHandle uTF8StringHandle = new InteropHelp.UTF8StringHandle(pchFile))
     {
         using (InteropHelp.UTF8StringHandle uTF8StringHandle2 = new InteropHelp.UTF8StringHandle(pchPreviewFile))
         {
             using (InteropHelp.UTF8StringHandle uTF8StringHandle3 = new InteropHelp.UTF8StringHandle(pchTitle))
             {
                 using (InteropHelp.UTF8StringHandle uTF8StringHandle4 = new InteropHelp.UTF8StringHandle(pchDescription))
                 {
                     result = (SteamAPICall_t)NativeMethods.ISteamRemoteStorage_PublishWorkshopFile(uTF8StringHandle, uTF8StringHandle2, nConsumerAppId, uTF8StringHandle3, uTF8StringHandle4, eVisibility, new InteropHelp.SteamParamStringArray(pTags), eWorkshopFileType);
                 }
             }
         }
     }
     return result;
 }
		public static extern bool ISteamApps_GetDlcDownloadProgress(AppId_t nAppID, out ulong punBytesDownloaded, out ulong punBytesTotal);
Exemple #44
0
		// SteamAPI_RestartAppIfNecessary ensures that your executable was launched through Steam.
		//
		// Returns true if the current process should terminate. Steam is now re-launching your application.
		//
		// Returns false if no action needs to be taken. This means that your executable was started through
		// the Steam client, or a steam_appid.txt file is present in your game's directory (for development).
		// Your current process should continue if false is returned.
		//
		// NOTE: If you use the Steam DRM wrapper on your primary executable file, this check is unnecessary
		// since the DRM wrapper will ensure that your application was launched properly through Steam.
		public static bool RestartAppIfNecessary(AppId_t unOwnAppID) {
			InteropHelp.TestIfPlatformSupported();
			return NativeMethods.SteamAPI_RestartAppIfNecessary(unOwnAppID);
		}
        public static void InitCallbacks()
        {
            RimWorldAppId = SteamUtils.GetAppID();

            sessionReq = Callback <P2PSessionRequest_t> .Create(req =>
            {
                var session = Multiplayer.session;
                if (session?.localSettings != null && session.localSettings.steam && !session.pendingSteam.Contains(req.m_steamIDRemote))
                {
                    if (MultiplayerMod.settings.autoAcceptSteam)
                    {
                        SteamNetworking.AcceptP2PSessionWithUser(req.m_steamIDRemote);
                    }
                    else
                    {
                        session.pendingSteam.Add(req.m_steamIDRemote);
                    }

                    session.knownUsers.Add(req.m_steamIDRemote);
                    session.NotifyChat();

                    SteamFriends.RequestUserInformation(req.m_steamIDRemote, true);
                }
            });

            friendRchpUpdate = Callback <FriendRichPresenceUpdate_t> .Create(update =>
            {
            });

            gameJoinReq = Callback <GameRichPresenceJoinRequested_t> .Create(req =>
            {
            });

            personaChange = Callback <PersonaStateChange_t> .Create(change =>
            {
            });

            p2pFail = Callback <P2PSessionConnectFail_t> .Create(fail =>
            {
                var session = Multiplayer.session;
                if (session == null)
                {
                    return;
                }

                var remoteId = fail.m_steamIDRemote;
                var error    = (EP2PSessionError)fail.m_eP2PSessionError;

                if (Multiplayer.Client is SteamBaseConn clientConn && clientConn.remoteId == remoteId)
                {
                    clientConn.OnError(error);
                }

                var server = Multiplayer.LocalServer;
                if (server == null)
                {
                    return;
                }

                server.Enqueue(() =>
                {
                    var conn = server.players.Select(p => p.conn).OfType <SteamBaseConn>().FirstOrDefault(c => c.remoteId == remoteId);
                    if (conn != null)
                    {
                        conn.OnError(error);
                    }
                });
            });
        }