Files
sbox-public/engine/Sandbox.GameInstance/GameInstanceDll.Config.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

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 );
}
}