From bc658d0a31b06ae257510be76e0989f70cb98d17 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 16 Apr 2019 21:56:29 +0100 Subject: [PATCH] Update README.md --- README.md | 84 +++++++++++++++++++------------------------------------ 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 99837f6..5257565 100644 --- a/README.md +++ b/README.md @@ -162,79 +162,53 @@ SteamUtils.IsSteamInBigPictureMode; ## Client -Compile the Facepunch.Steamworks project and add the library to your Unity project. To create a client you can do this. +To initialize a client you can do this. ```csharp -var client = new Facepunch.Steamworks.Client( 252490 ); +using Steamworks; + +// ... + +try +{ + SteamClient.Init( 4000 ); +} +catch ( System.Exception e ) +{ + // Couldn't init for some reason (steam is closed etc) +} ``` -Replace 252490 with the appid of your game. This should be a singleton - you should only create one client, right at the start of your game. +Replace 4000 with the appid of your game. You shouldn't call any Steam functions before you initialize. -The client is disposable, so when you're closing your game should probably call.. +When you're done, when you're closing your game, just shutdown. ```csharp -client.Dispose(); +SteamClient.Shutdown(); ``` -Or use it in a using block if you can. - - ## Server To create a server do this. ```csharp -ServerInit options = new ServerInit("GameDirectoryName", "GameDescription"); -``` - -```csharp -var server = new Facepunch.Steamworks.Server(252490, options); -``` - -This will register a secure server for game 252490, any ip, port 28015. Again, more usage in the Facepunch.Steamworks.Test project. - -## Lobby - -To create a Lobby do this. -```csharp -client.Lobby.Create(Steamworks.Lobby.Type.Public, 10); -``` - -Created lobbies are auto-joined, but if you want to find a friend's lobby, you'd call -```csharp -client.LobbyList.Refresh(); -//wait for the callback -client.LobbyList.OnLobbiesUpdated = () => +var serverInit = new SteamServerInit( "gmod", "Garry Mode" ) { - if (client.LobbyList.Finished) - { - foreach (LobbyList.Lobby lobby in client.LobbyList.Lobbies) - { - Console.WriteLine($"Found Lobby: {lobby.Name}"); - } - } + GamePort = 28015, + Secure = true, + QueryPort = 28016 }; -//join a lobby you found -client.Lobby.Join(LobbyList.Lobbies[0]); + +try +{ + Steamworks.SteamServer.Init( 4000, serverInit ); +} +catch ( System.Exception ) +{ + // Couldn't init for some reason (dll errors, blocked ports) +} ``` -Your can find more examples of Lobby functionality in the Lobby.cs file in the test project. Sending chat messages, assinging lobby data and member data, etc. - - -# Unity - -Yeah this works under Unity. That's half the point of it. - -There's another repo with an example project with it working in Unity. You can find it [here](https://github.com/Facepunch/Facepunch.Steamworks.Unity/blob/master/Assets/Scripts/SteamTest.cs). - -The TLDR is before you create the Client or the Server, call this to let Facepunch.Steamworks know which platform we're on - because it can't tell the difference between osx and linux by itself. - -```csharp -Facepunch.Steamworks.Config.ForUnity( Application.platform.ToString() ); -``` - -You'll also want to put steam_api64.dll and steam_appid.txt (on windows 64) in your project root next to Assets, and use an editor script like [this](https://github.com/Facepunch/Facepunch.Steamworks.Unity/blob/master/Assets/Scripts/Editor/CopySteamLibraries.cs) to copy them into standalone builds. - # Help Wanna help? Go for it, pull requests, bug reports, yes, do it.