Class SteamSystem¶
Namespace: Apogee.Steam
Assembly: Apogee.Steam.dll
The game's connection to Steam: the user, the overlay, achievements, stats and leaderboards, rich presence, cloud files and Workshop items. Steam's library is Valve's redistributable
and is in the repository; the client is the player's. When Steam is not running, or the game was not started with an app id,
public sealed class SteamSystem : EngineObject, IDisposable
Inheritance¶
object ← EngineObject ← SteamSystem
Implements¶
Inherited Members¶
EngineObject.IsAdopted, EngineObject.Handle, EngineObject.IsDestroyed, EngineObject.Class, EngineObject.Adopt(), EngineObject.TryGet(SlotHandle, out EngineObject), EngineObject.Destroy(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks¶
Call
Constructors¶
SteamSystem(SteamOptions?)¶
Starts Steam. If it cannot be started the system is inactive,
public SteamSystem(SteamOptions? options = null)
Parameters¶
options SteamOptions?
Properties¶
AchievementStored¶
An achievement was unlocked or progressed, with its name and progress (0 and 0 for a plain unlock).
public Signal<string, int, int> AchievementStored { get; }
Property Value¶
AppId¶
The game's Steam app id (0 when Steam is not running).
public int AppId { get; }
Property Value¶
BuildId¶
The build of the game Steam installed (changes with every upload to a branch).
public int BuildId { get; }
Property Value¶
Class¶
What the registry knows about this object's class.
public override ClassInfo Class { get; }
Property Value¶
Country¶
The player's country (two letters), from their address.
public string Country { get; }
Property Value¶
IsActive¶
True when Steam started: the calls are real. False means every call does nothing.
public bool IsActive { get; }
Property Value¶
IsBigPicture¶
Steam is in Big Picture mode (or the Deck's game mode).
public bool IsBigPicture { get; }
Property Value¶
IsCloudEnabled¶
Whether the cloud works: Steam is running, and the player has the cloud on for their account and for this game.
public bool IsCloudEnabled { get; }
Property Value¶
IsOverlayEnabled¶
Whether the overlay works in this run (Steam is running and the player did not switch it off).
public bool IsOverlayEnabled { get; }
Property Value¶
IsSteamDeck¶
The game runs on a Steam Deck (Steam sets the SteamDeck environment variable there).
public bool IsSteamDeck { get; }
Property Value¶
IsSubscribed¶
Whether the player owns the game (false for a family-shared or free-weekend copy that Steam still lets them play:
public bool IsSubscribed { get; }
Property Value¶
Language¶
The language the player chose for the game in Steam, as Steam names it (english, french, schinese…); "" when Steam is not running.
public string Language { get; }
Property Value¶
LeaderboardFound¶
A leaderboard was looked up by name (true when it exists).
public Signal<string, bool> LeaderboardFound { get; }
Property Value¶
OverlayActivated¶
The overlay opened (true) or closed: pause the game while it is open.
public Signal<bool> OverlayActivated { get; }
Property Value¶
RestartRequested¶
True when
public bool RestartRequested { get; }
Property Value¶
ScoreUploaded¶
A score was sent: the leaderboard, whether it worked, and the player's new global rank (0 when unchanged or failed).
public Signal<string, bool, int> ScoreUploaded { get; }
Property Value¶
ScoresDownloaded¶
Entries arrived: the leaderboard, then for each entry the player's id, global rank and score, in rank order.
public Signal<string, string[], int[], int[]> ScoresDownloaded { get; }
Property Value¶
Signal<string, string[], int[], int[]>
ShutdownRequested¶
Steam wants the game to exit (the client is shutting down).
public Signal ShutdownRequested { get; }
Property Value¶
StatsReceived¶
The player's stats and achievements arrived from Steam (true) or could not be loaded.
public Signal<bool> StatsReceived { get; }
Property Value¶
StatsStored¶
A
public Signal<bool> StatsStored { get; }
Property Value¶
Status¶
What state Steam is in, in words a player can read: running, off, or why it did not start.
public string Status { get; }
Property Value¶
TextInputDismissed¶
Steam's on-screen keyboard closed, with whether the text was submitted and the text.
public Signal<bool, string> TextInputDismissed { get; }
Property Value¶
UiLanguage¶
The language of Steam's own interface.
public string UiLanguage { get; }
Property Value¶
UserId¶
The player's SteamID64 as a decimal string, "" when Steam is not running.
public string UserId { get; }
Property Value¶
UserName¶
The player's Steam name.
public string UserName { get; }
Property Value¶
WorkshopItemDownloaded¶
A download that
public Signal<string, bool> WorkshopItemDownloaded { get; }
Property Value¶
WorkshopItemInstalled¶
A Workshop item finished installing or updating on the disk (its id). Mods are read when the game starts: tell the player to restart for it to apply.
public Signal<string> WorkshopItemInstalled { get; }
Property Value¶
WorkshopSubscribed¶
A
public Signal<string, bool> WorkshopSubscribed { get; }
Property Value¶
WorkshopUnsubscribed¶
An
public Signal<string, bool> WorkshopUnsubscribed { get; }
Property Value¶
Methods¶
Achievement(string)¶
Whether the achievement is unlocked (false when Steam is not running, or the name is not one of the game's).
public bool Achievement(string name)
Parameters¶
name string
Returns¶
AchievementNames()¶
The names of the game's achievements, as set up in Steamworks.
public string[] AchievementNames()
Returns¶
string[]
AchievementProgress(string, int, int)¶
Shows a progress pop-up for an achievement that counts (current of max) without unlocking it; it also stores the progress.
public bool AchievementProgress(string name, int current, int max)
Parameters¶
name string
current int
max int
Returns¶
ActivateOverlay(string)¶
Opens a part of the overlay: friends, community, players, settings, officialgamegroup, stats or achievements; "" opens it as Shift+Tab does.
public void ActivateOverlay(string dialog = "")
Parameters¶
dialog string
AddScreenshot(string, int, int)¶
Adds a screenshot file the game wrote (a JPEG, PNG or TGA on the disk) to the player's Steam library. False when Steam refused it.
public bool AddScreenshot(string path, int width, int height)
Parameters¶
path string
width int
height int
Returns¶
AddTimelineEvent(string, string, string, int, float, bool)¶
Marks a moment in the player's Steam timeline (the game recording): a title, a description, one of Steam's icon names
(steam_achievement, steam_death, steam_marker…), a priority among the icons, and an offset in seconds from now (negative: something that just happened). A featured
event is offered first as a clip.
public void AddTimelineEvent(string title, string description = "", string icon = "steam_marker", int priority = 0, float offsetSeconds = 0, bool featured = false)
Parameters¶
title string
description string
icon string
priority int
offsetSeconds float
featured bool
ClearAchievement(string)¶
Locks an achievement again (for testing).
public bool ClearAchievement(string name)
Parameters¶
name string
Returns¶
ClearRichPresence()¶
Removes all of this game's rich presence.
public void ClearRichPresence()
CloudQuota()¶
The cloud space of the game for this player, in bytes: the total, then what is left. 0 and 0 without Steam.
public (long Total, long Available) CloudQuota()
Returns¶
CreateCloudSource(string)¶
The files to mount as cloud://: the Steam Cloud when it works, and otherwise a plain folder (fallback, writable) so that a game saves the same way with or without
Steam. Saves made in the folder are not copied into the cloud later: choose by what the game ships on.
public IFileSource CreateCloudSource(string fallback)
Parameters¶
fallback string
Returns¶
CreateInactive()¶
Makes an inactive Steam system from a script, which touches nothing of Steam: for testing the game's own code that expects a steam global. A game's real one is the global steam.
public static SteamSystem CreateInactive()
Returns¶
Dispose()¶
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
DownloadScores(string, int, int, string)¶
Asks for the entries from rank from to to (1 is the best) of kind (global, around_user, where the range is
relative to the player, or friends);
public void DownloadScores(string leaderboard, int from = 1, int to = 10, string kind = "global")
Parameters¶
leaderboard string
from int
to int
kind string
DownloadWorkshopItem(string)¶
Asks Steam to download (or update) an item now, ahead of the others;
public bool DownloadWorkshopItem(string itemId)
Parameters¶
itemId string
Returns¶
FindLeaderboard(string)¶
Looks a leaderboard up by name;
public void FindLeaderboard(string name)
Parameters¶
name string
InstalledWorkshopItems()¶
The folders of the subscribed items that are installed, with the item id of each: the mods Steam brought. An item that is still downloading is not listed.
public IReadOnlyList<(string ItemId, string Folder)> InstalledWorkshopItems()
Returns¶
IReadOnlyList<(string ItemId, string Folder)>
IsDlcInstalled(int)¶
The DLC appId is owned and installed.
public bool IsDlcInstalled(int appId)
Parameters¶
appId int
Returns¶
IsInstalled()¶
Whether Steam's library can be loaded.
public static bool IsInstalled()
Returns¶
OnDestroyed()¶
protected override void OnDestroyed()
OpenStore(int)¶
Opens the store page of an app in the overlay (the game's own page, or a DLC's).
public void OpenStore(int appId)
Parameters¶
appId int
OpenWebPage(string)¶
Opens the overlay's browser on a web page.
public void OpenWebPage(string url)
Parameters¶
url string
OwnsDlc(int)¶
The player owns the DLC appId.
public bool OwnsDlc(int appId)
Parameters¶
appId int
Returns¶
ResetAllStats(bool)¶
Resets every stat, and the achievements too when asked. For testing a new player.
public bool ResetAllStats(bool achievements)
Parameters¶
achievements bool
Returns¶
SetRichPresence(string, string)¶
Sets a rich presence key, which friends see in their list (status is the line shown; others are for steam_display localization). An empty value removes the key.
public bool SetRichPresence(string key, string value)
Parameters¶
key string
value string
Returns¶
SetStatFloat(string, float)¶
Sets a float stat in memory;
public bool SetStatFloat(string name, float value)
Parameters¶
name string
value float
Returns¶
SetStatInt(string, int)¶
Sets an integer stat in memory;
public bool SetStatInt(string name, int value)
Parameters¶
name string
value int
Returns¶
SetTimelineMode(string)¶
Tells the timeline what the game is doing: playing, staging (a lobby, a briefing), menus or loading; the recording skips menus and loading screens.
public void SetTimelineMode(string mode)
Parameters¶
mode string
SetTimelineState(string)¶
Sets the line of text that describes what the player is doing now on the timeline (a tooltip); "" clears it.
public void SetTimelineState(string description)
Parameters¶
description string
ShowTextInput(string, int, bool, bool)¶
Opens Steam's on-screen keyboard (the overlay's, for a Deck or a controller) for a line of text;
public bool ShowTextInput(string description, int maxLength = 128, bool multiline = false, bool password = false)
Parameters¶
description string
maxLength int
multiline bool
password bool
Returns¶
StatFloat(string)¶
The value of a float stat (0 when there is none).
public float StatFloat(string name)
Parameters¶
name string
Returns¶
StatInt(string)¶
The value of an integer stat (0 when there is none).
public int StatInt(string name)
Parameters¶
name string
Returns¶
StoreStats()¶
Sends the changed stats and achievements to Steam;
public bool StoreStats()
Returns¶
Subscribe(string)¶
Subscribes to a Workshop item (Steam downloads it);
public void Subscribe(string itemId)
Parameters¶
itemId string
SubscribedItems()¶
The ids of the Workshop items the player is subscribed to.
public string[] SubscribedItems()
Returns¶
string[]
TriggerScreenshot()¶
Asks Steam to take a screenshot of the game's window (the player's screenshot key does it too).
public void TriggerScreenshot()
UnlockAchievement(string)¶
Unlocks an achievement and sends it to Steam at once (it shows the pop-up). False when there is no such achievement or Steam is not running.
public bool UnlockAchievement(string name)
Parameters¶
name string
Returns¶
Unsubscribe(string)¶
Unsubscribes from a Workshop item (Steam deletes it);
public void Unsubscribe(string itemId)
Parameters¶
itemId string
Update()¶
Once a frame: runs Steam's callbacks and call results and emits their signals. Nothing else runs on another thread.
public void Update()
UploadProgress()¶
The upload in progress: its stage, and the bytes sent of the bytes to send. Stage is "" when nothing is uploading.
public (string Stage, ulong Sent, ulong Total) UploadProgress()
Returns¶
(string Stage, ulong Sent, ulong Total)
UploadScore(string, int, bool)¶
Sends a score; keepBest the leaderboard keeps the player's better score (by the leaderboard's sort order), otherwise this one replaces it.
public void UploadScore(string leaderboard, int score, bool keepBest = true)
Parameters¶
leaderboard string
score int
keepBest bool
UploadWorkshopItem(WorkshopUpload, Action<WorkshopUploadResult>)¶
Publishes a mod folder as a Workshop item, or updates one (done runs from
public void UploadWorkshopItem(WorkshopUpload upload, Action<WorkshopUploadResult> done)
Parameters¶
upload WorkshopUpload
done Action<WorkshopUploadResult>
WorkshopItemFolder(string)¶
The folder an installed item is in, or "" when it is not installed (yet).
public string WorkshopItemFolder(string itemId)
Parameters¶
itemId string