public static void Shutdown()
        {
            if (!IsValid)
            {
                return;
            }

            Cleanup();

            SteamAPI.Shutdown();
        }
示例#2
0
        /// <summary>
        /// Initialize the steam client.
        /// If asyncCallbacks is false you need to call RunCallbacks manually every frame.
        /// </summary>
        public static void Init(uint appid, bool asyncCallbacks = true)
        {
            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;

            //
            // Dispatch is responsible for pumping the
            // event loop.
            //
            Dispatch.Init();
            Dispatch.ClientPipe = SteamAPI.GetHSteamPipe();
            Console.WriteLine($"Dispatch.ClientPipe = {Dispatch.ClientPipe.Value}");

            AddInterface <SteamApps>();
            AddInterface <SteamFriends>();
            AddInterface <SteamInput>();
            AddInterface <SteamInventory>();
            AddInterface <SteamMatchmaking>();
            AddInterface <SteamMatchmakingServers>();
            AddInterface <SteamMusic>();
            AddInterface <SteamNetworking>();
            AddInterface <SteamNetworkingSockets>();
            AddInterface <SteamNetworkingUtils>();
            AddInterface <SteamParental>();
            AddInterface <SteamParties>();
            AddInterface <SteamRemoteStorage>();
            AddInterface <SteamScreenshots>();
            AddInterface <SteamUGC>();
            AddInterface <SteamUser>();
            AddInterface <SteamUserStats>();
            AddInterface <SteamUtils>();
            AddInterface <SteamVideo>();

            if (asyncCallbacks)
            {
                //
                // This will keep looping in the background every 16 ms
                // until we shut down.
                //
                Dispatch.LoopClientAsync();
            }
        }
示例#3
0
        /// <summary>
        /// Checks if your executable was launched through Steam and relaunches it through Steam if it wasn't.
        /// <para>
        ///  This returns true then it starts the Steam client if required and launches your game again through it,
        ///  and you should quit your process as soon as possible. This effectively runs steam://run/AppId so it
        ///  may not relaunch the exact executable that called it, as it will always relaunch from the version
        ///  installed in your Steam library folder/
        ///  Note that during development, when not launching via Steam, this might always return true.
        ///  </para>
        /// </summary>
        public static bool RestartAppIfNecessary(uint appid)
        {
            if (developmentBuild)
            {
                return(false);
            }

            // Having these here would probably mean it always returns false?

            //System.Environment.SetEnvironmentVariable( "SteamAppId", appid.ToString() );
            //System.Environment.SetEnvironmentVariable( "SteamGameId", appid.ToString() );

            return(SteamAPI.RestartAppIfNecessary(appid));
        }
示例#4
0
        internal static async void RunCallbacksAsync()
        {
            while (IsValid)
            {
                await Task.Delay(16);

                try
                {
                    SteamAPI.RunCallbacks();
                }
                catch (System.Exception)
                {
                    // TODO - error outputs
                }
            }
        }
        public static void RunCallbacks()
        {
            if (!IsValid)
            {
                return;
            }

            try
            {
                SteamAPI.RunCallbacks();
            }
            catch (System.Exception e)
            {
                OnCallbackException?.Invoke(e);
            }
        }
        // OnApplicationQuit gets called too early to shutdown the SteamAPI.
        // Because the SteamManager should be persistent and never disabled or destroyed we can shutdown the SteamAPI here.
        // Thus it is not recommended to perform any Steamworks work in other OnDestroy functions as the order of execution can not be garenteed upon Shutdown. Prefer OnDisable().
        protected virtual void OnDestroy()
        {
            if (s_instance != this)
            {
                return;
            }

            s_instance = null;

            if (!m_bInitialized)
            {
                return;
            }

            SteamAPI.Shutdown();
        }
 public static void RunCallbacks()
 {
     try
     {
         SteamAPI.RunCallbacks();
     }
     catch (Exception exception1)
     {
         Exception          exception           = exception1;
         Action <Exception> onCallbackException = SteamClient.OnCallbackException;
         if (onCallbackException != null)
         {
             onCallbackException(exception);
         }
         else
         {
         }
     }
 }
        public virtual void InitClient()
        {
            var user = SteamAPI.GetHSteamUser();

            Self = SteamInternal.FindOrCreateUserInterface(user, InterfaceName);

            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Couldn't find interface {InterfaceName}");
            }

            VTable = Marshal.ReadIntPtr(Self, 0);
            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Invalid VTable for {InterfaceName}");
            }

            InitInternals();
        }
示例#9
0
        public static void Shutdown()
        {
            Event.DisposeAllClient();

            initialized = false;

            SteamApps.Shutdown();
            SteamUtils.Shutdown();
            SteamParental.Shutdown();
            SteamMusic.Shutdown();
            SteamVideo.Shutdown();
            SteamUser.Shutdown();
            SteamFriends.Shutdown();
            SteamScreenshots.Shutdown();
            SteamUserStats.Shutdown();
            SteamInventory.Shutdown();

            SteamAPI.Shutdown();
        }
 public void InitClient()
 {
     this.Self = SteamInternal.CreateInterface(this.InterfaceName);
     if (this.Self == IntPtr.Zero)
     {
         HSteamUser hSteamUser = SteamAPI.GetHSteamUser();
         this.Self = SteamInternal.FindOrCreateUserInterface(hSteamUser, this.InterfaceName);
     }
     if (this.Self == IntPtr.Zero)
     {
         throw new Exception(String.Concat("Couldn't find interface ", this.InterfaceName));
     }
     this.VTable = Marshal.ReadIntPtr(this.Self, 0);
     if (this.Self == IntPtr.Zero)
     {
         throw new Exception(String.Concat("Invalid VTable for ", this.InterfaceName));
     }
     this.InitInternals();
     SteamClient.WatchInterface(this);
 }
        public void InitClient()
        {
            //
            // There's an issue for us using FindOrCreateUserInterface on Rust.
            // We have a different appid for our staging branch, but we use Rust's
            // appid so we can still test with the live data/setup. The issue is
            // if we run the staging branch and get interfaces using FindOrCreate
            // then some callbacks don't work. I assume this is because these interfaces
            // have already been initialized using the old appid pipe, but since I
            // can't see inside Steam this is just a gut feeling. Either way using
            // CreateInterface doesn't seem to have caused any fires, so we'll just use that.
            //

            //
            // var pipe = SteamAPI.GetHSteamPipe();
            //

            Self = SteamInternal.CreateInterface(InterfaceName);

            if (Self == IntPtr.Zero)
            {
                var user = SteamAPI.GetHSteamUser();
                Self = SteamInternal.FindOrCreateUserInterface(user, InterfaceName);
            }

            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Couldn't find interface {InterfaceName}");
            }

            VTable = Marshal.ReadIntPtr(Self, 0);
            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Invalid VTable for {InterfaceName}");
            }

            InitInternals();
            SteamClient.WatchInterface(this);
        }
示例#12
0
        public SteamInterface(bool server = false)
        {
            //
            // If teh client isn't initialized but the server is,
            // try to open this interface in server mode
            //
            if (!SteamClient.IsValid && SteamServer.IsValid)
            {
                server = true;
            }

            var hUser = server ?
                        SteamGameServer.GetHSteamUser() :
                        SteamAPI.GetHSteamUser();

            if (hUser == 0)
            {
                throw new System.Exception("Steamworks is uninitialized");
            }

            Self = server ?
                   SteamInternal.FindOrCreateGameServerInterface(hUser, InterfaceName) :
                   SteamInternal.FindOrCreateUserInterface(hUser, InterfaceName);

            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Couldn't find interface {InterfaceName} (server:{server})");
            }


            VTable = Marshal.ReadIntPtr(Self, 0);
            if (Self == IntPtr.Zero)
            {
                throw new System.Exception($"Invalid VTable for {InterfaceName}");
            }

            InitInternals();
        }
 public static void Shutdown()
 {
     Event.DisposeAllClient();
     SteamClient.initialized = false;
     SteamClient.ShutdownInterfaces();
     SteamApps.Shutdown();
     SteamUtils.Shutdown();
     SteamParental.Shutdown();
     SteamMusic.Shutdown();
     SteamVideo.Shutdown();
     SteamUser.Shutdown();
     SteamFriends.Shutdown();
     SteamScreenshots.Shutdown();
     SteamUserStats.Shutdown();
     SteamInventory.Shutdown();
     SteamNetworking.Shutdown();
     SteamMatchmaking.Shutdown();
     SteamParties.Shutdown();
     SteamNetworkingUtils.Shutdown();
     SteamNetworkingSockets.Shutdown();
     Base.Shutdown();
     SteamAPI.Shutdown();
 }
        public static void Init(uint appid)
        {
            if (IntPtr.Size != 8)
            {
                throw new System.Exception("Only 64bit processes are currently supported");
            }

            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;


            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();
            SteamNetworking.InstallEvents();
            SteamMatchmaking.InstallEvents();
            SteamParties.InstallEvents();
            SteamNetworkingSockets.InstallEvents();

            RunCallbacksAsync();
        }
示例#15
0
        /// <summary>
        /// Initialize the steam client.
        /// If asyncCallbacks is false you need to call RunCallbacks manually every frame.
        /// </summary>
        public static void Init(uint appid, bool asyncCallbacks = true)
        {
            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;

            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();
            SteamNetworking.InstallEvents();
            SteamMatchmaking.InstallEvents();
            SteamParties.InstallEvents();
            SteamNetworkingSockets.InstallEvents();
            SteamInput.InstallEvents();
            SteamUGC.InstallEvents();

            if (asyncCallbacks)
            {
                RunCallbacksAsync();
            }
        }
        protected virtual void Awake()
        {
            // Only one instance of SteamManager at a time!
            if (s_instance != null)
            {
                Destroy(gameObject);
                return;
            }
            s_instance = this;

            if (s_EverInitialized)
            {
                // This is almost always an error.
                // The most common case where this happens is when SteamManager gets destroyed because of Application.Quit(),
                // and then some Steamworks code in some other OnDestroy gets called afterwards, creating a new SteamManager.
                // You should never call Steamworks functions in OnDestroy, always prefer OnDisable if possible.
                throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");
            }

            // We want our SteamManager Instance to persist across scenes.
            DontDestroyOnLoad(gameObject);

            if (!Packsize.Test())
            {
                Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
            }

            if (!DllCheck.Test())
            {
                Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
            }

            try {
                // If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the
                // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM.

                // Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and
                // remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)".
                // See the Valve documentation for more information: https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
                if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid))
                {
                    Application.Quit();
                    return;
                }
            }
            catch (System.DllNotFoundException e) {     // We catch this exception here, as it will be the first occurrence of it.
                Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e, this);

                Application.Quit();
                return;
            }

            // Initializes the Steamworks API.
            // If this returns false then this indicates one of the following conditions:
            // [*] The Steam client isn't running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
            // [*] The Steam client couldn't determine the App ID of game. If you're running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
            // [*] Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
            // [*] Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
            // [*] Your App ID is not completely set up, i.e. in Release State: Unavailable, or it's missing default packages.
            // Valve's documentation for this is located here:
            // https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
            m_bInitialized = SteamAPI.Init();
            if (!m_bInitialized)
            {
                Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);

                return;
            }

            s_EverInitialized = true;
        }
 internal static void UnregisterCallback(IntPtr intPtr)
 {
     SteamAPI.UnregisterCallback(intPtr);
 }
 internal static void RegisterCallback(IntPtr intPtr, int callbackId)
 {
     SteamAPI.RegisterCallback(intPtr, callbackId);
 }
示例#19
0
        internal static FailureReason Init()
        {
            HSteamUser hSteamUser    = SteamAPI.GetHSteamUser();
            HSteamPipe hSteamPipe    = SteamAPI.GetHSteamPipe();
            var        failureReason = FailureReason.None;

            if (hSteamPipe == (HSteamPipe)0)
            {
                failureReason |= FailureReason.hSteamPipe;
            }

            using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMCLIENT_INTERFACE_VERSION)) {
                m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(pchVersionString);
            }

            if (m_pSteamClient == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamClient;
            }

            m_pSteamUser = SteamClient.GetISteamUser(hSteamUser, hSteamPipe, Constants.STEAMUSER_INTERFACE_VERSION);
            if (m_pSteamUser == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamUser;
            }

            m_pSteamFriends = SteamClient.GetISteamFriends(hSteamUser, hSteamPipe, Constants.STEAMFRIENDS_INTERFACE_VERSION);
            if (m_pSteamFriends == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamFriends;
            }

            m_pSteamUtils = SteamClient.GetISteamUtils(hSteamPipe, Constants.STEAMUTILS_INTERFACE_VERSION);
            if (m_pSteamUtils == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamUtils;
            }

            m_pSteamMatchmaking = SteamClient.GetISteamMatchmaking(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKING_INTERFACE_VERSION);
            if (m_pSteamMatchmaking == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamMatchmaking;
            }

            m_pSteamMatchmakingServers = SteamClient.GetISteamMatchmakingServers(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION);
            if (m_pSteamMatchmakingServers == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamMatchmakingServers;
            }

            m_pSteamUserStats = SteamClient.GetISteamUserStats(hSteamUser, hSteamPipe, Constants.STEAMUSERSTATS_INTERFACE_VERSION);
            if (m_pSteamUserStats == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamUserStats;
            }

            m_pSteamApps = SteamClient.GetISteamApps(hSteamUser, hSteamPipe, Constants.STEAMAPPS_INTERFACE_VERSION);
            if (m_pSteamApps == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamApps;
            }

            m_pSteamNetworking = SteamClient.GetISteamNetworking(hSteamUser, hSteamPipe, Constants.STEAMNETWORKING_INTERFACE_VERSION);
            if (m_pSteamNetworking == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamNetworking;
            }

            m_pSteamRemoteStorage = SteamClient.GetISteamRemoteStorage(hSteamUser, hSteamPipe, Constants.STEAMREMOTESTORAGE_INTERFACE_VERSION);
            if (m_pSteamRemoteStorage == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamRemoteStorage;
            }

            m_pSteamScreenshots = SteamClient.GetISteamScreenshots(hSteamUser, hSteamPipe, Constants.STEAMSCREENSHOTS_INTERFACE_VERSION);
            if (m_pSteamScreenshots == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamScreenshots;
            }

            m_pSteamGameSearch = SteamClient.GetISteamGameSearch(hSteamUser, hSteamPipe, Constants.STEAMGAMESEARCH_INTERFACE_VERSION);
            if (m_pSteamGameSearch == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamGameSearch;
            }

            m_pSteamHTTP = SteamClient.GetISteamHTTP(hSteamUser, hSteamPipe, Constants.STEAMHTTP_INTERFACE_VERSION);
            if (m_pSteamHTTP == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamHTTP;
            }

            m_pSteamUGC = SteamClient.GetISteamUGC(hSteamUser, hSteamPipe, Constants.STEAMUGC_INTERFACE_VERSION);
            if (m_pSteamUGC == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamUGC;
            }

            m_pSteamAppList = SteamClient.GetISteamAppList(hSteamUser, hSteamPipe, Constants.STEAMAPPLIST_INTERFACE_VERSION);
            if (m_pSteamAppList == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamAppList;
            }

            m_pSteamMusic = SteamClient.GetISteamMusic(hSteamUser, hSteamPipe, Constants.STEAMMUSIC_INTERFACE_VERSION);
            if (m_pSteamMusic == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamMusic;
            }

            m_pSteamMusicRemote = SteamClient.GetISteamMusicRemote(hSteamUser, hSteamPipe, Constants.STEAMMUSICREMOTE_INTERFACE_VERSION);
            if (m_pSteamMusicRemote == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamMusicRemote;
            }

            m_pSteamHTMLSurface = SteamClient.GetISteamHTMLSurface(hSteamUser, hSteamPipe, Constants.STEAMHTMLSURFACE_INTERFACE_VERSION);
            if (m_pSteamHTMLSurface == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamHTMLSurface;
            }

            m_pSteamInventory = SteamClient.GetISteamInventory(hSteamUser, hSteamPipe, Constants.STEAMINVENTORY_INTERFACE_VERSION);
            if (m_pSteamInventory == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamInventory;
            }

            m_pSteamVideo = SteamClient.GetISteamVideo(hSteamUser, hSteamPipe, Constants.STEAMVIDEO_INTERFACE_VERSION);
            if (m_pSteamVideo == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamVideo;
            }

            m_pSteamParentalSettings = SteamClient.GetISteamParentalSettings(hSteamUser, hSteamPipe, Constants.STEAMPARENTALSETTINGS_INTERFACE_VERSION);
            if (m_pSteamParentalSettings == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamParentalSettings;
            }

            m_pSteamInput = SteamClient.GetISteamInput(hSteamUser, hSteamPipe, Constants.STEAMINPUT_INTERFACE_VERSION);
            if (m_pSteamInput == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamInput;
            }

            m_pSteamParties = SteamClient.GetISteamParties(hSteamUser, hSteamPipe, Constants.STEAMPARTIES_INTERFACE_VERSION);
            if (m_pSteamParties == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamParties;
            }

            m_pSteamRemotePlay = SteamClient.GetISteamRemotePlay(hSteamUser, hSteamPipe, Constants.STEAMREMOTEPLAY_INTERFACE_VERSION);
            if (m_pSteamRemotePlay == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamRemotePlay;
            }

            using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMNETWORKINGUTILS_INTERFACE_VERSION))
            {
                m_pSteamNetworkingUtils =
                    NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pchVersionString) != IntPtr.Zero ?
                    NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pchVersionString) :
                    NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pchVersionString);
            }

            if (m_pSteamNetworkingUtils == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamNetworkingUtils;
            }

            using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMNETWORKINGSOCKETS_INTERFACE_VERSION))
            {
                m_pSteamNetworkingSockets =
                    NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pchVersionString);
            }

            if (m_pSteamNetworkingSockets == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamNetworkingSockets;
            }

            using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMNETWORKINGMESSAGES_INTERFACE_VERSION))
            {
                m_pSteamNetworkingMessages =
                    NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pchVersionString);
            }

            if (m_pSteamNetworkingMessages == IntPtr.Zero)
            {
                failureReason |= FailureReason.m_pSteamNetworkingMessages;
            }

            return(failureReason);
        }
示例#20
0
        internal static bool Init()
        {
            HSteamUser hSteamUser = SteamAPI.GetHSteamUser();
            HSteamPipe hSteamPipe = SteamAPI.GetHSteamPipe();

            if (hSteamPipe == (HSteamPipe)0)
            {
                return(false);
            }
            using (InteropHelp.UTF8StringHandle ver = new InteropHelp.UTF8StringHandle("SteamClient020"))
            {
                m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(ver);
            }
            if (m_pSteamClient == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamUser = SteamClient.GetISteamUser(hSteamUser, hSteamPipe, "SteamUser021");
            if (m_pSteamUser == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamFriends = SteamClient.GetISteamFriends(hSteamUser, hSteamPipe, "SteamFriends017");
            if (m_pSteamFriends == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamUtils = SteamClient.GetISteamUtils(hSteamPipe, "SteamUtils009");
            if (m_pSteamUtils == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamMatchmaking = SteamClient.GetISteamMatchmaking(hSteamUser, hSteamPipe, "SteamMatchMaking009");
            if (m_pSteamMatchmaking == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamMatchmakingServers = SteamClient.GetISteamMatchmakingServers(hSteamUser, hSteamPipe, "SteamMatchMakingServers002");
            if (m_pSteamMatchmakingServers == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamUserStats = SteamClient.GetISteamUserStats(hSteamUser, hSteamPipe, "STEAMUSERSTATS_INTERFACE_VERSION012");
            if (m_pSteamUserStats == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamApps = SteamClient.GetISteamApps(hSteamUser, hSteamPipe, "STEAMAPPS_INTERFACE_VERSION008");
            if (m_pSteamApps == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamNetworking = SteamClient.GetISteamNetworking(hSteamUser, hSteamPipe, "SteamNetworking006");
            if (m_pSteamNetworking == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamRemoteStorage = SteamClient.GetISteamRemoteStorage(hSteamUser, hSteamPipe, "STEAMREMOTESTORAGE_INTERFACE_VERSION014");
            if (m_pSteamRemoteStorage == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamScreenshots = SteamClient.GetISteamScreenshots(hSteamUser, hSteamPipe, "STEAMSCREENSHOTS_INTERFACE_VERSION003");
            if (m_pSteamScreenshots == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamGameSearch = SteamClient.GetISteamGameSearch(hSteamUser, hSteamPipe, "SteamMatchGameSearch001");
            if (m_pSteamGameSearch == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamHTTP = SteamClient.GetISteamHTTP(hSteamUser, hSteamPipe, "STEAMHTTP_INTERFACE_VERSION003");
            if (m_pSteamHTTP == IntPtr.Zero)
            {
                return(false);
            }
            m_pController = SteamClient.GetISteamController(hSteamUser, hSteamPipe, "SteamController007");
            if (m_pController == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamUGC = SteamClient.GetISteamUGC(hSteamUser, hSteamPipe, "STEAMUGC_INTERFACE_VERSION014");
            if (m_pSteamUGC == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamAppList = SteamClient.GetISteamAppList(hSteamUser, hSteamPipe, "STEAMAPPLIST_INTERFACE_VERSION001");
            if (m_pSteamAppList == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamMusic = SteamClient.GetISteamMusic(hSteamUser, hSteamPipe, "STEAMMUSIC_INTERFACE_VERSION001");
            if (m_pSteamMusic == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamMusicRemote = SteamClient.GetISteamMusicRemote(hSteamUser, hSteamPipe, "STEAMMUSICREMOTE_INTERFACE_VERSION001");
            if (m_pSteamMusicRemote == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamHTMLSurface = SteamClient.GetISteamHTMLSurface(hSteamUser, hSteamPipe, "STEAMHTMLSURFACE_INTERFACE_VERSION_005");
            if (m_pSteamHTMLSurface == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamInventory = SteamClient.GetISteamInventory(hSteamUser, hSteamPipe, "STEAMINVENTORY_INTERFACE_V003");
            if (m_pSteamInventory == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamVideo = SteamClient.GetISteamVideo(hSteamUser, hSteamPipe, "STEAMVIDEO_INTERFACE_V002");
            if (m_pSteamVideo == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamParentalSettings = SteamClient.GetISteamParentalSettings(hSteamUser, hSteamPipe, "STEAMPARENTALSETTINGS_INTERFACE_VERSION001");
            if (m_pSteamParentalSettings == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamInput = SteamClient.GetISteamInput(hSteamUser, hSteamPipe, "SteamInput001");
            if (m_pSteamInput == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamParties = SteamClient.GetISteamParties(hSteamUser, hSteamPipe, "SteamParties002");
            if (m_pSteamParties == IntPtr.Zero)
            {
                return(false);
            }
            m_pSteamRemotePlay = SteamClient.GetISteamRemotePlay(hSteamUser, hSteamPipe, "STEAMREMOTEPLAY_INTERFACE_VERSION001");
            if (m_pSteamRemotePlay == IntPtr.Zero)
            {
                return(false);
            }
            using (InteropHelp.UTF8StringHandle pszVersion = new InteropHelp.UTF8StringHandle("SteamNetworkingUtils003"))
            {
                m_pSteamNetworkingUtils = ((NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pszVersion) != IntPtr.Zero) ? NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pszVersion) : NativeMethods.SteamInternal_FindOrCreateGameServerInterface(hSteamUser, pszVersion));
            }
            if (m_pSteamNetworkingUtils == IntPtr.Zero)
            {
                return(false);
            }
            using (InteropHelp.UTF8StringHandle pszVersion2 = new InteropHelp.UTF8StringHandle("SteamNetworkingSockets008"))
            {
                m_pSteamNetworkingSockets = NativeMethods.SteamInternal_FindOrCreateUserInterface(hSteamUser, pszVersion2);
            }
            if (m_pSteamNetworkingSockets == IntPtr.Zero)
            {
                return(false);
            }
            return(true);
        }
示例#21
0
 public static bool InitSafe()
 {
     return(SteamAPI.Init());
 }
示例#22
0
 public static void RunCallbacks()
 {
     SteamAPI.RunCallbacks();
 }
示例#23
0
        internal static bool Init()
        {
            HSteamUser hSteamUser = SteamAPI.GetHSteamUser();
            HSteamPipe hSteamPipe = SteamAPI.GetHSteamPipe();

            if (hSteamPipe == (HSteamPipe)0)
            {
                return(false);
            }

            using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMCLIENT_INTERFACE_VERSION)) {
                m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(pchVersionString);
            }

            if (m_pSteamClient == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUser = SteamClient.GetISteamUser(hSteamUser, hSteamPipe, Constants.STEAMUSER_INTERFACE_VERSION);
            if (m_pSteamUser == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamFriends = SteamClient.GetISteamFriends(hSteamUser, hSteamPipe, Constants.STEAMFRIENDS_INTERFACE_VERSION);
            if (m_pSteamFriends == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUtils = SteamClient.GetISteamUtils(hSteamPipe, Constants.STEAMUTILS_INTERFACE_VERSION);
            if (m_pSteamUtils == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMatchmaking = SteamClient.GetISteamMatchmaking(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKING_INTERFACE_VERSION);
            if (m_pSteamMatchmaking == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMatchmakingServers = SteamClient.GetISteamMatchmakingServers(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION);
            if (m_pSteamMatchmakingServers == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUserStats = SteamClient.GetISteamUserStats(hSteamUser, hSteamPipe, Constants.STEAMUSERSTATS_INTERFACE_VERSION);
            if (m_pSteamUserStats == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamApps = SteamClient.GetISteamApps(hSteamUser, hSteamPipe, Constants.STEAMAPPS_INTERFACE_VERSION);
            if (m_pSteamApps == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamNetworking = SteamClient.GetISteamNetworking(hSteamUser, hSteamPipe, Constants.STEAMNETWORKING_INTERFACE_VERSION);
            if (m_pSteamNetworking == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamRemoteStorage = SteamClient.GetISteamRemoteStorage(hSteamUser, hSteamPipe, Constants.STEAMREMOTESTORAGE_INTERFACE_VERSION);
            if (m_pSteamRemoteStorage == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamScreenshots = SteamClient.GetISteamScreenshots(hSteamUser, hSteamPipe, Constants.STEAMSCREENSHOTS_INTERFACE_VERSION);
            if (m_pSteamScreenshots == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamGameSearch = SteamClient.GetISteamGameSearch(hSteamUser, hSteamPipe, Constants.STEAMGAMESEARCH_INTERFACE_VERSION);
            if (m_pSteamGameSearch == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamHTTP = SteamClient.GetISteamHTTP(hSteamUser, hSteamPipe, Constants.STEAMHTTP_INTERFACE_VERSION);
            if (m_pSteamHTTP == IntPtr.Zero)
            {
                return(false);
            }

            m_pController = SteamClient.GetISteamController(hSteamUser, hSteamPipe, Constants.STEAMCONTROLLER_INTERFACE_VERSION);
            if (m_pController == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUGC = SteamClient.GetISteamUGC(hSteamUser, hSteamPipe, Constants.STEAMUGC_INTERFACE_VERSION);
            if (m_pSteamUGC == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamAppList = SteamClient.GetISteamAppList(hSteamUser, hSteamPipe, Constants.STEAMAPPLIST_INTERFACE_VERSION);
            if (m_pSteamAppList == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMusic = SteamClient.GetISteamMusic(hSteamUser, hSteamPipe, Constants.STEAMMUSIC_INTERFACE_VERSION);
            if (m_pSteamMusic == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMusicRemote = SteamClient.GetISteamMusicRemote(hSteamUser, hSteamPipe, Constants.STEAMMUSICREMOTE_INTERFACE_VERSION);
            if (m_pSteamMusicRemote == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamHTMLSurface = SteamClient.GetISteamHTMLSurface(hSteamUser, hSteamPipe, Constants.STEAMHTMLSURFACE_INTERFACE_VERSION);
            if (m_pSteamHTMLSurface == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamInventory = SteamClient.GetISteamInventory(hSteamUser, hSteamPipe, Constants.STEAMINVENTORY_INTERFACE_VERSION);
            if (m_pSteamInventory == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamVideo = SteamClient.GetISteamVideo(hSteamUser, hSteamPipe, Constants.STEAMVIDEO_INTERFACE_VERSION);
            if (m_pSteamVideo == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamParentalSettings = SteamClient.GetISteamParentalSettings(hSteamUser, hSteamPipe, Constants.STEAMPARENTALSETTINGS_INTERFACE_VERSION);
            if (m_pSteamParentalSettings == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamInput = SteamClient.GetISteamInput(hSteamUser, hSteamPipe, Constants.STEAMINPUT_INTERFACE_VERSION);
            if (m_pSteamInput == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamParties = SteamClient.GetISteamParties(hSteamUser, hSteamPipe, Constants.STEAMPARTIES_INTERFACE_VERSION);
            if (m_pSteamParties == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamRemotePlay = SteamClient.GetISteamRemotePlay(hSteamUser, hSteamPipe, Constants.STEAMREMOTEPLAY_INTERFACE_VERSION);
            if (m_pSteamRemotePlay == IntPtr.Zero)
            {
                return(false);
            }

            return(true);
        }
示例#24
0
        internal static bool Init()
        {
            HSteamUser hSteamUser = SteamAPI.GetHSteamUser();
            HSteamPipe hSteamPipe = SteamAPI.GetHSteamPipe();

            if (hSteamPipe == (HSteamPipe)0)
            {
                return(false);
            }

            using (var pchVersionString = new InteropHelp.UTF8StringHandle(Constants.STEAMCLIENT_INTERFACE_VERSION)) {
                m_pSteamClient = NativeMethods.SteamInternal_CreateInterface(pchVersionString);
            }

            if (m_pSteamClient == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUser = SteamClient.GetISteamUser(hSteamUser, hSteamPipe, Constants.STEAMUSER_INTERFACE_VERSION);
            if (m_pSteamUser == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamFriends = SteamClient.GetISteamFriends(hSteamUser, hSteamPipe, Constants.STEAMFRIENDS_INTERFACE_VERSION);
            if (m_pSteamFriends == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUtils = SteamClient.GetISteamUtils(hSteamPipe, Constants.STEAMUTILS_INTERFACE_VERSION);
            if (m_pSteamUtils == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMatchmaking = SteamClient.GetISteamMatchmaking(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKING_INTERFACE_VERSION);
            if (m_pSteamMatchmaking == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMatchmakingServers = SteamClient.GetISteamMatchmakingServers(hSteamUser, hSteamPipe, Constants.STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION);
            if (m_pSteamMatchmakingServers == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUserStats = SteamClient.GetISteamUserStats(hSteamUser, hSteamPipe, Constants.STEAMUSERSTATS_INTERFACE_VERSION);
            if (m_pSteamUserStats == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamApps = SteamClient.GetISteamApps(hSteamUser, hSteamPipe, Constants.STEAMAPPS_INTERFACE_VERSION);
            if (m_pSteamApps == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamNetworking = SteamClient.GetISteamNetworking(hSteamUser, hSteamPipe, Constants.STEAMNETWORKING_INTERFACE_VERSION);
            if (m_pSteamNetworking == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamRemoteStorage = SteamClient.GetISteamRemoteStorage(hSteamUser, hSteamPipe, Constants.STEAMREMOTESTORAGE_INTERFACE_VERSION);
            if (m_pSteamRemoteStorage == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamScreenshots = SteamClient.GetISteamScreenshots(hSteamUser, hSteamPipe, Constants.STEAMSCREENSHOTS_INTERFACE_VERSION);
            if (m_pSteamScreenshots == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamHTTP = SteamClient.GetISteamHTTP(hSteamUser, hSteamPipe, Constants.STEAMHTTP_INTERFACE_VERSION);
            if (m_pSteamHTTP == IntPtr.Zero)
            {
                return(false);
            }

            // Unified Messages are deprecated in latest Steamworks.  Additionally, this API fails to initialize on Mac platforms.
            // If this problem should become evident on other platforms, it may be wise to remove this entire section of code for
            // those platforms (if not all) as well.
            #if !UNITY_EDITOR_OSX && !UNITY_STANDALONE_OSX
            m_pSteamUnifiedMessages = SteamClient.GetISteamUnifiedMessages(hSteamUser, hSteamPipe, Constants.STEAMUNIFIEDMESSAGES_INTERFACE_VERSION);
            if (m_pSteamUnifiedMessages == IntPtr.Zero)
            {
                return(false);
            }
            #endif

            m_pController = SteamClient.GetISteamController(hSteamUser, hSteamPipe, Constants.STEAMCONTROLLER_INTERFACE_VERSION);
            if (m_pController == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamUGC = SteamClient.GetISteamUGC(hSteamUser, hSteamPipe, Constants.STEAMUGC_INTERFACE_VERSION);
            if (m_pSteamUGC == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamAppList = SteamClient.GetISteamAppList(hSteamUser, hSteamPipe, Constants.STEAMAPPLIST_INTERFACE_VERSION);
            if (m_pSteamAppList == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMusic = SteamClient.GetISteamMusic(hSteamUser, hSteamPipe, Constants.STEAMMUSIC_INTERFACE_VERSION);
            if (m_pSteamMusic == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamMusicRemote = SteamClient.GetISteamMusicRemote(hSteamUser, hSteamPipe, Constants.STEAMMUSICREMOTE_INTERFACE_VERSION);
            if (m_pSteamMusicRemote == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamHTMLSurface = SteamClient.GetISteamHTMLSurface(hSteamUser, hSteamPipe, Constants.STEAMHTMLSURFACE_INTERFACE_VERSION);
            if (m_pSteamHTMLSurface == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamInventory = SteamClient.GetISteamInventory(hSteamUser, hSteamPipe, Constants.STEAMINVENTORY_INTERFACE_VERSION);
            if (m_pSteamInventory == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamVideo = SteamClient.GetISteamVideo(hSteamUser, hSteamPipe, Constants.STEAMVIDEO_INTERFACE_VERSION);
            if (m_pSteamVideo == IntPtr.Zero)
            {
                return(false);
            }

            m_pSteamParentalSettings = SteamClient.GetISteamParentalSettings(hSteamUser, hSteamPipe, Constants.STEAMPARENTALSETTINGS_INTERFACE_VERSION);
            if (m_pSteamParentalSettings == IntPtr.Zero)
            {
                return(false);
            }

            return(true);
        }