mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using Sandbox.Utility;
|
|
|
|
namespace Sandbox;
|
|
|
|
internal partial class GameInstanceDll
|
|
{
|
|
/// <summary>
|
|
/// Read the json configurations from the network table and apply them.
|
|
/// To encourage a single path, this is called on the host too - even if they're
|
|
/// not hosting a multiplayer game!
|
|
/// </summary>
|
|
void UpdateConfigFromNetworkTable()
|
|
{
|
|
if ( ConfigTable.Entries.TryGetValue( "input", out var inputEntry ) )
|
|
{
|
|
var inputConfig = inputEntry.ReadJson<InputSettings>();
|
|
Input.ReadConfig( inputConfig );
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when loading a game or when a localproject has been modified while playing a game.
|
|
/// </summary>
|
|
public void UpdateProjectConfig( Package package )
|
|
{
|
|
var inputSettings = ProjectSettings.Input;
|
|
if ( inputSettings is null )
|
|
{
|
|
inputSettings = new InputSettings();
|
|
inputSettings.InitDefault();
|
|
}
|
|
|
|
ConfigTable.SetJson( "input", inputSettings );
|
|
|
|
UpdateConfigFromNetworkTable();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when the config for a game project has been changed.
|
|
/// We might need to update the config table.
|
|
/// </summary>
|
|
public void OnProjectConfigChanged( Package package )
|
|
{
|
|
if ( IGameInstance.Current is null )
|
|
return;
|
|
|
|
UpdateProjectConfig( package );
|
|
}
|
|
}
|