(965c31410) v0.10.4.0

This commit is contained in:
Joonas Rikkonen
2020-07-30 13:00:09 +03:00
parent eeac247a8e
commit 4978af3d60
539 changed files with 45803 additions and 25359 deletions
+48 -81
View File
@@ -17,6 +17,9 @@ namespace Steamworks
/// </summary>
public static void Init( uint appid, bool asyncCallbacks = true )
{
if ( initialized )
throw new System.Exception( "Calling SteamClient.Init but is already initialized" );
System.Environment.SetEnvironmentVariable( "SteamAppId", appid.ToString() );
System.Environment.SetEnvironmentVariable( "SteamGameId", appid.ToString() );
@@ -29,76 +32,69 @@ namespace Steamworks
initialized = true;
SteamApps.InstallEvents();
SteamUtils.InstallEvents();
SteamParental.InstallEvents();
SteamMusic.InstallEvents();
SteamVideo.InstallEvents();
SteamUser.InstallEvents();
SteamFriends.InstallEvents();
SteamScreenshots.InstallEvents();
SteamUserStats.InstallEvents();
SteamInventory.InstallEvents();
SteamNetworking.InstallEvents();
SteamMatchmaking.InstallEvents();
SteamParties.InstallEvents();
SteamNetworkingSockets.InstallEvents();
SteamInput.InstallEvents();
SteamUGC.InstallEvents();
//
// Dispatch is responsible for pumping the
// event loop.
//
Dispatch.Init();
Dispatch.ClientPipe = SteamAPI.GetHSteamPipe();
AddInterface<SteamApps>();
AddInterface<SteamFriends>();
AddInterface<SteamInput>();
AddInterface<SteamInventory>();
AddInterface<SteamMatchmaking>();
AddInterface<SteamMatchmakingServers>();
AddInterface<SteamMusic>();
AddInterface<SteamNetworking>();
AddInterface<SteamNetworkingSockets>();
AddInterface<SteamNetworkingUtils>();
AddInterface<SteamParental>();
AddInterface<SteamParties>();
AddInterface<SteamRemoteStorage>();
AddInterface<SteamScreenshots>();
AddInterface<SteamUGC>();
AddInterface<SteamUser>();
AddInterface<SteamUserStats>();
AddInterface<SteamUtils>();
AddInterface<SteamVideo>();
AddInterface<SteamRemotePlay>();
if ( asyncCallbacks )
{
RunCallbacksAsync();
//
// This will keep looping in the background every 16 ms
// until we shut down.
//
Dispatch.LoopClientAsync();
}
}
static List<SteamInterface> openIterfaces = new List<SteamInterface>();
internal static void WatchInterface( SteamInterface steamInterface )
internal static void AddInterface<T>() where T : SteamClass, new()
{
if ( openIterfaces.Contains( steamInterface ) )
throw new System.Exception( "openIterfaces already contains interface!" );
openIterfaces.Add( steamInterface );
var t = new T();
t.InitializeInterface( false );
openInterfaces.Add( t );
}
static readonly List<SteamClass> openInterfaces = new List<SteamClass>();
internal static void ShutdownInterfaces()
{
foreach ( var e in openIterfaces )
foreach ( var e in openInterfaces )
{
e.Shutdown();
e.DestroyInterface( false );
}
openIterfaces.Clear();
openInterfaces.Clear();
}
public static Action<Exception> OnCallbackException;
public static bool IsValid => initialized;
internal static async void RunCallbacksAsync()
{
while ( IsValid )
{
await Task.Delay( 16 );
try
{
RunCallbacks();
}
catch ( System.Exception e )
{
OnCallbackException?.Invoke( e );
}
}
}
public static void Shutdown()
{
if ( !IsValid ) return;
SteamInput.Shutdown();
Cleanup();
SteamAPI.Shutdown();
@@ -106,45 +102,16 @@ namespace Steamworks
internal static void Cleanup()
{
Dispatch.ShutdownClient();
initialized = false;
Event.DisposeAllClient();
ShutdownInterfaces();
SteamInput.Shutdown();
SteamApps.Shutdown();
SteamUtils.Shutdown();
SteamParental.Shutdown();
SteamMusic.Shutdown();
SteamVideo.Shutdown();
SteamUser.Shutdown();
SteamFriends.Shutdown();
SteamScreenshots.Shutdown();
SteamUserStats.Shutdown();
SteamInventory.Shutdown();
SteamNetworking.Shutdown();
SteamMatchmaking.Shutdown();
SteamParties.Shutdown();
SteamNetworkingUtils.Shutdown();
SteamNetworkingSockets.Shutdown();
ServerList.Base.Shutdown();
}
internal static void RegisterCallback( IntPtr intPtr, int callbackId )
{
SteamAPI.RegisterCallback( intPtr, callbackId );
}
public static void RunCallbacks()
{
if ( !IsValid ) return;
SteamAPI.RunCallbacks();
}
internal static void UnregisterCallback( IntPtr intPtr )
{
SteamAPI.UnregisterCallback( intPtr );
if ( Dispatch.ClientPipe != 0 )
Dispatch.Frame( Dispatch.ClientPipe );
}
/// <summary>