public static abstract sealed class Sandbox.Game
Provides global access to core game state, utilities, and operations for S&box. The `Sandbox.Game` class exposes static properties and methods to query and control the running game, such as checking if the game is running, getting your steamid, taking screenshots, and managing game sessions.
Related Guides
Broader workflow and conceptual references connected to this API.
There are various interfaces that can be given to components for specific purposes.
You can create variables and commands that you can run from the console.
The mount system is extensible - anyone can write a mount to add support for a new game or engine and contribute it to s&box via pull request. A mount detects a game's install directory via Steam, scans its files, and converts assets into s&box compatible assets, all at runtime.
You can find information about how to install and use SteamCMD here <https://developer.valvesoftware.com/wiki/SteamCMD> to install the s&box Dedicated Server.
Standard .NET file access is restricted to prevent rogue access to your files, this means you can not use System.IO.File or variants directly.
Open S&box and make a new project. You can select 'Addon' as your template since we're only going to publish a model.
Methods
Showing 8 methods
public static bool ChangeScene(Sandbox.SceneLoadOptions options)
Change the active scene and optionally bring all connected clients to the new scene (broadcast the scene change.) If we're in a networking session, then only the host can change the scene.
Parameters
options: The `Sandbox.SceneLoadOptions` to use which also specifies which scene to load.
Returns
Whether the scene was changed successfully.
public static void Close()
Close the current game.
public static Sandbox.WebSurface CreateWebSurface()
Create a limited web surface
public static void Disconnect()
Disconnect from the current game session
public static void Load(string gameIdent, bool keepClients)
Load a game. You can configure the new game with LaunchArguments before calling this.
public static void SetRandomSeed(int seed)
Set the seed for Game.Random
public static void TakeHighResScreenshot(int width, int height)
Capture a high resolution screenshot using the active scene camera.
public static void TakeScreenshot()
Capture a screenshot. Saves it in Steam.
No results match this filter.
Properties
Showing 20 properties
public static Sandbox.Scene Sandbox.Game.ActiveScene { get; set; }
The current scene that is being played.
public static ulong Sandbox.Game.AppId { get; set; }
Steam AppId of S&box.
public static bool Sandbox.Game.CheatsEnabled { get; set; }
This has to be in Game.dll so the codegen will get generated for it
public static Sandbox.CookieContainer Sandbox.Game.Cookies { get; set; }
Allows access to the cookies for the current game. The cookies are used to store persistent data across game sessions, such as user preferences or session data. Internally the cookies are encoded to JSON and stored in a file on disk.
public static string Sandbox.Game.Ident { get; set; }
Returns the current game's ident - ie facepunch.sandbox
public static bool Sandbox.Game.InGame { get; set; }
Return true if we're in a game (ie, not in the main menu)
public static bool Sandbox.Game.IsClosing { get; set; }
Set to true when the game is closing
public static bool Sandbox.Game.IsEditor { get; set; }
Returns true if the game is running with the editor enabled
public static bool Sandbox.Game.IsMainMenuVisible { get; set; }
Returns true if the main menu is visible. Note that this will work serverside too but will only return the state of the host.
public static bool Sandbox.Game.IsPaused { get; set; }
Indicates whether the game is currently paused.
public static bool Sandbox.Game.IsPlaying { get; set; }
Indicates whether the game is currently running and actively playing a scene.
public static bool Sandbox.Game.IsRecordingVideo { get; set; }
True if we're currently recording a video (using the video command, or F6)
public static bool Sandbox.Game.IsRunningInVR { get; set; }
Return true if we're running in VR
public static bool Sandbox.Game.IsRunningOnHandheld { get; set; }
Return true if we're running on a handheld device (the deck). Will always be false serverside.
public static Sandbox.LanguageContainer Sandbox.Game.Language { get; set; }
Lets you get translated phrases from the localization system
public static Sandbox.PhysicsTraceBuilder Sandbox.Game.PhysicsTrace { get; set; }
Trace against the physics in the current scene
public static System.Random Sandbox.Game.Random { get; set; }
A shared random that is automatically seeded on tick
public static Sandbox.SceneTrace Sandbox.Game.SceneTrace { get; set; }
Trace against the physics and hitboxes in the current scene
public static Sandbox.Internal.TypeLibrary Sandbox.Game.TypeLibrary { get; set; }
Provides access to the global `Sandbox.Internal.TypeLibrary` for the current game context. The `TypeLibrary` is a runtime reflection system that describes types, their members, and relationships in the game and engine assemblies. It allows you to find and create types by name and id. It's basically a sandboxed version of the .net reflection system.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Game |