I’m working on a game that uses MonoGame and is coming to Steam at some point, and I’m looking now how to make Achievements, Steam Cloud and other stuff. Steamworks.NET seems way to go for this, but I can’t seem to find any guides on how to use Steamworks.NET with MonoGame.
Have you guys used Steamworks.NET, or are there tutorials on how to setup and use it?
Steamworks.NET was designed to be as close as possible to the original C++ API, as such the documentation provided from Valve largely covers usage of Steamworks.NET. Niceties and C# Idioms can be easily implemented on top of Steamworks.NET.
and there is a link to documentation from that repo too.
Hey DedruPooru and other people who are struggeling with the integration of Steamworks.Net into a MonoGame project!
Fortunately it’s very easy to integrate Steamworks.Net into a MonoGame project.
Unfortunately I don’t have time to write a detailed tutorial but I created a repo on GitHub with a small description on how to integrate the Steamworks.Net dlls into a MonoGame project.
Feel free to check it out here:
I hope this helps you and other people in the future.
I’m currently working on a solution that lets you swap Steamworks with Lidgren on demand, since you don’t know if your game makes Steam-Greenlight when you start it and maybe you’d want to sell it on other platforms as well and you’d like your players to be able to play with each other cross-platform…
But I’m afraid it’s only in the drafting-phase.
Maybe you find some time to check it out…
I like your idea of easy swapping the network environment and I’m curious about the further development. Would be cool to have something handy and easy to use
Oh and just in case you missed the news: Valve is also swapping his service Steam Greenlight this spring ('17) with their new service called “Steam Direct”.
Read this: http://steamcommunity.com/games/593110/announcements/detail/558846854614253751 to know more about it. I don’t want to be off-topic, just a quick note for you.
Again thanks and good luck with your interesting project!
Thx sqrMin1 for the linked article… I’ve read that before and, frankly, I don’t think that it will work out.
They will charge a fee, ok. They don’t tell how much it will be, not so ok.
But I think that regardless of the fee the amount of rubbish that will get published there will increase and the community will react on that…
I’m interested in how that will unfold.
Nevertheless developers will still want to use the Steam-servers or not, or they will want to enable players without access to steam-servers to play the game.
So nothing will change for the planned library…
But at the current amount of spare-time I’ve left to spend on that project it will likely take me forever anyways.
I’ll second the need for a Steamworks.NET tutorial as applied to XNA/Monogame. The Steam and .NET documentation leave a lot to be desired while all of the engine folk have easy buttons to make this stuff happen more or less automatically. A list of steamworks.NET methods, what they do, and how they work would be helpful.
Just setting things up has a lot of pitfalls. Here’s what I had to do to get things working:
The Standalone zip will have a Windows x86 folder. In Visual Studio reference the Steamworks.NET.dll in this folder to your main project (the versions in the other folders are 64 bit and will break things). Build.
Add the following to the folder containing your game’s .exe (either debug or release if testing, or what you are actually shipping)
a) Add the steam_appid.txt file and change the contents to your game’s Steam ID
b) For XNA or Monogame Windows add from the Standalone Windows x86 folder: Steam_api.dll and CSteamworks.dll (again, don’t take the 64 bit version of Steam_api.dll - it will break things).
c) For Linux add libsteam_api.so and libCSteamworks.so from the OSX-Linux x64 folder.
d) For Mac add the CSteamworks.bundle folder from the OSX-Linux x64 folder. Remember the other Source Code .zip that was originally downloaded? Open that up and add Steamworks.NET.dll.config from the Standalone folder.
The above setup works for Windows 32 and 64, Mac 64, and Linux 64. I’m not sure what will happen with Linux 32 bit.
The game should now phone home to Steam automatically, but it is important to test.
Add “using Steamworks” to any relevant classes.
Set up a global bool isSteamRunning so we can ignore steam stuff if the client isn’t running.
In the game’s Initialize(), check if the client is running with “if (SteamAPI.Init())” and if so set your isSteamRunning to true.
Prior to the game’s shutdown, add “SteamAPI.Shutdown();”.
Tie a funny picture or text to isSteamRunning and run the game. If your funny picture shows up, then your game is tied into Steam.
My only implementation was to have the game push achievements to Steam. Most of these worker bee steamworks methods will crash the game if steam isn’t running so be sure to check isSteamRunning each time. It wouldn’t hurt to also put these in a try catch for an edge case where the steam client closes while the game continues. Here’s all you need for pushing achievements to Steam:
“SteamUserStats.SetAchievement(“ID_of_achievement”);”. The ID is the first column/name that you set in Steam. This line immediately pushes the achievement to steam and it will immediately be reflected in the client. For some reason it will delay the achievement time stamp and pop up (icon in corner of screen) until the game is closed. The fix is to follow with:
“SteamUserStats.StoreStats();”. This will immediately time stamp the achievement and immediately create the screen corner pop up.
While testing, you’ll want to use “SteamUserStats.ClearAchievement(“ID_of_achievement”);” This clears the achievement flag for your account so that you can retest. Make sure to comment out or delete before shipping.
I finally got around to implementing Steam, but I can’t even get it running before I run into problems…
The examples run just fine. I even made empty project and added only the necessary lines and DLLs but it still crashes.
I have tried both stable MonoGame 3.6 and latest Development Build for Visual Studio.
An unhandled exception of type 'System.BadImageFormatException' occurred in Test.exe
Additional information: Could not load file or assembly 'Steamworks.NET, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
If the examples run fine, then you need to check in your test project if you add and reference the right assemblies.
I assume you are on windows:
Please try to take the assemblies from the folder “Windows-x86”, which you can find here and add them as new files to your project root.
Choose “copy if newer” in the “copy to output directory”-field.
Finally you need to add the “Steamworks.NET.dll” as a reference in your test project and change the number in the “steam_appid.txt” to the steam app id of your game / software.
Please check in the “Build” tab of your “Properties” if the “Conditional compilation symbols” shows “WINDOWS”. If not you need to type it in.
The only thing that (I think) was missing was the “WINDOWS” in Conditional compilation symbols. It was LINUX so I changed it to WINDOWS.
…but it didn’t help.
Still, thanks for helping me.
If you have time, here’s my test project that keeps crashing: https://files.fm/u/xuzavw7m
I’m sorry that this is unclear in my repo description. As soon as I have time, I will add this information to the readme.md file.
Now it should work for you. If not or if you need further help, then please reply. Would be also nice if you reply when this solution worked for you.
PS: the last screenshot is in german, but I think you will understand what you should do
PPS: don’t forget to add the “WINDOWS” constant to your Release configuration as you did for your Debug configuration before, like you statet in your last post.
I added x86 platform via Visual Studio’s Configuration Manager instead of manually editing the files.
Now I just have to start implementing this to the Main Project…
I recently updated the repo with a new sample project: AchievementHunter!
It’s a simple sample (game) which shows you the correct way of implementing achievements and stats as well as storing them on the steam server. It’s based upon the Steamworks Example ‘SpaceWar’ included with the Steamworks SDK.
You shouldn’t implement just the bare basic of achievement unlocking and storing without error handling and checking if you received the correct data from the steam servers before. Because it’s also possible that you receive achievement and stats data from a different game on steam, which leads to incorrect data and in the worst case it leads to game crashes.
That’s why I created this sample project; to show you how to do achievement unlocking, stats updating and storing everything on the steam server without errors or crashes.
thanks for the nice work! This project really helps to get me started with Steamworks. However, I am currently not able to start to the Steam overlay in the HelloSteamWorks.Net project. Any suggestions?
What exactly do you mean? Do you mean that you can’t just open the steam overlay or are you having problems to call the steam overlay programmatically?