Class Game
Provides access to some in-game state and easy methods and properties for changing it.
Namespace: Modding
Assembly: Assembly-CSharp.dll
Syntax
public static class Game
Fields
BlockEntityLayerMask
Declaration
public static LayerMask BlockEntityLayerMask
Field Value
Type | Description |
---|---|
UnityEngine.LayerMask |
Properties
IsSetToLocalSim
Whether the game is set to local sim instead of global sim. Does NOT indicate whether actually in simulation or not.
Declaration
public static bool IsSetToLocalSim { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsSimulating
Whether the local instance is currently in any simulation.
Settings this is equivalent to calling {Start,End}Simulation{Local,Global},
according to IsSetToLocalSim
.
Declaration
public static bool IsSimulating { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsSimulatingGlobal
Whether the local instance is participating in global simulation. Setting this is equivalent to calling {Start,End}SimulationGlobal.
Also indicates simulation in singleplayer.
Declaration
public static bool IsSimulatingGlobal { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsSimulatingLocal
Whether the local instance is currently in local simulation. Setting this is equivalent to calling {Start,End}SimulationLocal.
Never true in singleplayer; singleplayer simulation is treated as global simulation.
Declaration
public static bool IsSimulatingLocal { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsSpectator
Whether the local instance is in spectator mode.
Declaration
public static bool IsSpectator { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
BlockEntityMouseRaycast(out RaycastHit, Single)
Performs a raycast from the mouse position with a predefined layer mask to detect only blocks and entities.
Note that, in multiplayer, the blocks of machines of other players do not have colliders attached (except on the host). This means they cannot be detected with raycasts.
The parameters correspond to those of Physics.Raycast
.
Declaration
public static bool BlockEntityMouseRaycast(out RaycastHit hit, float distance)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.RaycastHit | hit | |
Single | distance |
Returns
Type | Description |
---|---|
Boolean |
BlockEntityRaycast(Ray, out RaycastHit, Single)
Performs a raycast with a predefined layer mask to detect only blocks and entities.
Note that, in multiplayer, the blocks of machines of other players do not have colliders attached (except on the host). This means they cannot be detected with raycasts.
The parameters correspond to those of Physics.Raycast
.
Declaration
public static bool BlockEntityRaycast(Ray ray, out RaycastHit hit, float distance)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | ray | |
UnityEngine.RaycastHit | hit | |
Single | distance |
Returns
Type | Description |
---|---|
Boolean |
EndSimulationGlobal()
Ends/Leaves the global simulation. No-op if not currently in any simulation.
Declaration
public static void EndSimulationGlobal()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If currently in local sim. |
EndSimulationLocal()
Ends the local simulation. No-op if not currently in any simulation.
Declaration
public static void EndSimulationLocal()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If currently in global sim. |
GetCurrentProgress()
Gets the current victory progress (in percent) of all teams.
Returns zero for all teams when not in MP game.
Declaration
public static Dictionary<MPTeam, float> GetCurrentProgress()
Returns
Type | Description |
---|---|
Dictionary<MPTeam, Single> |
GetCurrentProgress(MPTeam)
Gets the current victory progress (in percent) of the specified team.
Returns zero for all teams when not in MP game.
Declaration
public static float GetCurrentProgress(MPTeam team)
Parameters
Type | Name | Description |
---|---|---|
MPTeam | team |
Returns
Type | Description |
---|---|
Single |
GetPlaylist()
Gets a list of all levels in the current playlist.
Empty list if no playlist is set up, not in MP, or not the host.
Declaration
public static List<string> GetPlaylist()
Returns
Type | Description |
---|---|
List<String> | A list of filesystem paths to the playlist levels. |
NextPlaylistLevel()
Loads the next playlist level.
No-op if there is no playlist set up, not in MP, or not the host.
First exits simulation if currently simulating.
Declaration
public static void NextPlaylistLevel()
PreviousPlaylistLevel()
Loads the previous playlist level.
No-op if no playlist is set up, not in MP, or not the host.
First exits simulation if currently simulating.
Declaration
public static void PreviousPlaylistLevel()
Exceptions
Type | Condition |
---|---|
Exception | If currently in simulation. |
StartSimulationGlobal()
Starts/Joins the global simulation. No-op if already in global simulation. If the game is currently set to local sim, will change this setting first.
Declaration
public static void StartSimulationGlobal()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If currently in local sim. |
InvalidOperationException | If currently in spectator mode. |
StartSimulationLocal()
Starts local simulation. No-op if already in local sim. If the game is currently set to global sim, will change this settings first.
Declaration
public static void StartSimulationLocal()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If currently in global sim. |
InvalidOperationException | If currently in spectator mode. |
ToggleLocalSimState()
Toggles whether the game is set to local or global simulation.
Declaration
public static void ToggleLocalSimState()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If currently in any simulation. |