Skip to content

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, is false and every call does nothing and returns something inert, so a game works the same without it.

public sealed class SteamSystem : EngineObject, IDisposable

Inheritance

object ← EngineObject ← SteamSystem

Implements

IDisposable

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 once a frame: it pumps Steam's callbacks (manual dispatch, all on the calling thread) and turns them into signals. Steam's ids (users, Workshop items) are 64-bit and cross into scripts as decimal strings, because a script number cannot hold them. Mods cannot use this object: it is the game's.

Constructors

SteamSystem(SteamOptions?)

Starts Steam. If it cannot be started the system is inactive, says why, and the reason is logged once.

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

Signal<string, int, int>

AppId

The game's Steam app id (0 when Steam is not running).

public int AppId { get; }

Property Value

int

BuildId

The build of the game Steam installed (changes with every upload to a branch).

public int BuildId { get; }

Property Value

int

Class

What the registry knows about this object's class.

public override ClassInfo Class { get; }

Property Value

ClassInfo

Country

The player's country (two letters), from their address.

public string Country { get; }

Property Value

string

IsActive

True when Steam started: the calls are real. False means every call does nothing.

public bool IsActive { get; }

Property Value

bool

IsBigPicture

Steam is in Big Picture mode (or the Deck's game mode).

public bool IsBigPicture { get; }

Property Value

bool

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

bool

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

bool

IsSteamDeck

The game runs on a Steam Deck (Steam sets the SteamDeck environment variable there).

public bool IsSteamDeck { get; }

Property Value

bool

IsSubscribed

Whether the player owns the game (false for a family-shared or free-weekend copy that Steam still lets them play: is about that account).

public bool IsSubscribed { get; }

Property Value

bool

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

string

LeaderboardFound

A leaderboard was looked up by name (true when it exists).

public Signal<string, bool> LeaderboardFound { get; }

Property Value

Signal<string, bool>

OverlayActivated

The overlay opened (true) or closed: pause the game while it is open.

public Signal<bool> OverlayActivated { get; }

Property Value

Signal<bool>

RestartRequested

True when was set and the game was not started by Steam: Steam is starting it again, and this process should exit.

public bool RestartRequested { get; }

Property Value

bool

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

Signal<string, bool, int>

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

Signal

StatsReceived

The player's stats and achievements arrived from Steam (true) or could not be loaded.

public Signal<bool> StatsReceived { get; }

Property Value

Signal<bool>

StatsStored

A finished.

public Signal<bool> StatsStored { get; }

Property Value

Signal<bool>

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

string

TextInputDismissed

Steam's on-screen keyboard closed, with whether the text was submitted and the text.

public Signal<bool, string> TextInputDismissed { get; }

Property Value

Signal<bool, string>

UiLanguage

The language of Steam's own interface.

public string UiLanguage { get; }

Property Value

string

UserId

The player's SteamID64 as a decimal string, "" when Steam is not running.

public string UserId { get; }

Property Value

string

UserName

The player's Steam name.

public string UserName { get; }

Property Value

string

WorkshopItemDownloaded

A download that started ended: the item id and whether it worked.

public Signal<string, bool> WorkshopItemDownloaded { get; }

Property Value

Signal<string, bool>

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

Signal<string>

WorkshopSubscribed

A finished: the item id and whether it worked.

public Signal<string, bool> WorkshopSubscribed { get; }

Property Value

Signal<string, bool>

WorkshopUnsubscribed

An finished: the item id and whether it worked.

public Signal<string, bool> WorkshopUnsubscribed { get; }

Property Value

Signal<string, bool>

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

bool

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

bool

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

bool

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

bool

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

(long Total, long Available)

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

IFileSource

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

SteamSystem

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); follows, with no entries when it failed.

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; follows. False when Steam refused.

public bool DownloadWorkshopItem(string itemId)

Parameters

itemId string

Returns

bool

FindLeaderboard(string)

Looks a leaderboard up by name; follows. The other leaderboard calls do this by themselves when they need to.

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

bool

IsInstalled()

Whether Steam's library can be loaded.

public static bool IsInstalled()

Returns

bool

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

bool

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

bool

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

bool

SetStatFloat(string, float)

Sets a float stat in memory; sends the changes.

public bool SetStatFloat(string name, float value)

Parameters

name string

value float

Returns

bool

SetStatInt(string, int)

Sets an integer stat in memory; sends the changes.

public bool SetStatInt(string name, int value)

Parameters

name string

value int

Returns

bool

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; follows. False when it cannot be shown (the overlay is off).

public bool ShowTextInput(string description, int maxLength = 128, bool multiline = false, bool password = false)

Parameters

description string

maxLength int

multiline bool

password bool

Returns

bool

StatFloat(string)

The value of a float stat (0 when there is none).

public float StatFloat(string name)

Parameters

name string

Returns

float

StatInt(string)

The value of an integer stat (0 when there is none).

public int StatInt(string name)

Parameters

name string

Returns

int

StoreStats()

Sends the changed stats and achievements to Steam; says when it is done. Do not call it more than once a few minutes: Steam limits it.

public bool StoreStats()

Returns

bool

Subscribe(string)

Subscribes to a Workshop item (Steam downloads it); follows.

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

bool

Unsubscribe(string)

Unsubscribes from a Workshop item (Steam deletes it); follows.

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; follows. With 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 with the outcome. This makes something public under the player's name: only the runtime's upload command calls it, after the author asked for it.

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

Returns

string