diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs
index eb46653..278d7a1 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamApps : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamApps();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamApps_BIsSubscribed")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs
index fa8e95e..0188c05 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamFriends : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamFriends();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamFriends_GetPersonaName")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs
index 3b90e70..f425d2f 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamGameServer : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamGameServer();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamGameServer_InitGameServer")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs
index a070403..0a67589 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServerStats.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamGameServerStats : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamGameServerStats();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamGameServerStats_RequestUserStats")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamInput.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamInput.cs
index 2e252d0..0c336b0 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamInput.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamInput.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamInput : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamInput();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamInput_Init")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs
index 79cf2f0..bace70d 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamInventory.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamInventory : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamInventory();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamInventory_GetResultStatus")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs
index 79160c4..7f10927 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmaking.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamMatchmaking : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamMatchmaking();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmaking_GetFavoriteGameCount")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs
index a4f0216..7ddd68f 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServers.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamMatchmakingServers : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamMatchmakingServers();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingServers_RequestInternetServerList")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs
index 4f41280..4fe8529 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamMusic : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamMusic();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMusic_BIsEnabled")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs
index 1145e4a..282a4cb 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworking.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamNetworking : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamNetworking();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_SendP2PPacket")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs
index a5b5525..502f6b6 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingSockets.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamNetworkingSockets : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamNetworkingSockets();
}
}
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs
index 0d5b117..a2e8f69 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamNetworkingUtils : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamNetworkingUtils();
}
}
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs
index 983ef4b..723c1c2 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamParentalSettings : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamParentalSettings();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamParentalSettings_BIsParentalLockEnabled")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs
index b26f09f..0675fd4 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamParties.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamParties : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamParties();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamParties_GetNumActiveBeacons")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs
index e174094..bbeb026 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamRemoteStorage.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamRemoteStorage : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamRemoteStorage();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamRemoteStorage_FileWrite")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs
index 5320b8d..b652613 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamScreenshots.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamScreenshots : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamScreenshots();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamScreenshots_WriteScreenshot")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs
index dbd4449..7fff137 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUGC.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamUGC : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamUGC();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamUGC_CreateQueryUserUGCRequest")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs
index 752b07e..3f09e24 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamUser : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamUser();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamUser_GetHSteamUser")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs
index cfd59bc..fabae7b 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamUserStats : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamUserStats();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamUserStats_RequestCurrentStats")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs
index a25a908..ee035d5 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUtils.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamUtils : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamUtils();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamUtils_GetSecondsSinceAppActive")]
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs
index 1b5d16f..89ec095 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamVideo.cs
@@ -9,14 +9,7 @@ namespace Steamworks
{
internal class ISteamVideo : SteamInterface
{
- public override void InitInternals()
- {
- }
- internal override void Shutdown()
- {
- base.Shutdown();
-
- }
+ public override IntPtr GetInterfacePointer() => GetApi.SteamVideo();
#region FunctionMeta
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamVideo_GetVideoURL")]
diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs
index 54b57c5..fcfffb5 100644
--- a/Facepunch.Steamworks/SteamApps.cs
+++ b/Facepunch.Steamworks/SteamApps.cs
@@ -11,27 +11,16 @@ namespace Steamworks
///
/// Exposes a wide range of information and actions for applications and Downloadable Content (DLC).
///
- public static class SteamApps
+ public class SteamApps : SteamClass
{
- static ISteamApps _internal;
- internal static ISteamApps Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamApps();
- _internal.Init();
- }
+ internal static ISteamApps Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
-
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamApps();
}
+
internal static void InstallEvents()
{
diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs
index e7fd15c..f5fe724 100644
--- a/Facepunch.Steamworks/SteamClient.cs
+++ b/Facepunch.Steamworks/SteamClient.cs
@@ -29,22 +29,24 @@ 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();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
+ AddInterface();
if ( asyncCallbacks )
{
@@ -52,24 +54,29 @@ namespace Steamworks
}
}
- static List openIterfaces = new List();
+ internal static void AddInterface() where T : SteamClass, new()
+ {
+ var t = new T();
+ }
+
+ static List openInterfaces = new List();
internal static void WatchInterface( SteamInterface steamInterface )
{
- if ( openIterfaces.Contains( steamInterface ) )
+ if ( openInterfaces.Contains( steamInterface ) )
throw new System.Exception( "openIterfaces already contains interface!" );
- openIterfaces.Add( steamInterface );
+ openInterfaces.Add( steamInterface );
}
internal static void ShutdownInterfaces()
{
- foreach ( var e in openIterfaces )
+ foreach ( var e in openInterfaces )
{
- e.Shutdown();
+ e.ShutdownInterface();
}
- openIterfaces.Clear();
+ openInterfaces.Clear();
}
public static Action OnCallbackException;
@@ -97,8 +104,6 @@ namespace Steamworks
{
if ( !IsValid ) return;
- SteamInput.Shutdown();
-
Cleanup();
SteamAPI.Shutdown();
@@ -111,22 +116,6 @@ namespace Steamworks
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();
}
diff --git a/Facepunch.Steamworks/SteamFriends.cs b/Facepunch.Steamworks/SteamFriends.cs
index cd0ca45..8785d74 100644
--- a/Facepunch.Steamworks/SteamFriends.cs
+++ b/Facepunch.Steamworks/SteamFriends.cs
@@ -10,29 +10,16 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamFriends
+ public class SteamFriends : SteamClass
{
- static ISteamFriends _internal;
- internal static ISteamFriends Internal
+ internal static ISteamFriends Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
{
- get
- {
- SteamClient.ValidCheck();
+ Internal = new ISteamFriends();
- if ( _internal == null )
- {
- _internal = new ISteamFriends();
- _internal.Init();
-
- richPresence = new Dictionary();
- }
-
- return _internal;
- }
- }
- internal static void Shutdown()
- {
- _internal = null;
+ richPresence = new Dictionary();
}
static Dictionary richPresence;
diff --git a/Facepunch.Steamworks/SteamInput.cs b/Facepunch.Steamworks/SteamInput.cs
index ab83cfd..75b91e5 100644
--- a/Facepunch.Steamworks/SteamInput.cs
+++ b/Facepunch.Steamworks/SteamInput.cs
@@ -3,44 +3,18 @@ using System.Collections.Generic;
namespace Steamworks
{
- public static class SteamInput
+ public class SteamInput : SteamClass
{
+ internal static ISteamInput Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
+ {
+ Internal = new ISteamInput();
+ }
+
internal const int STEAM_CONTROLLER_MAX_COUNT = 16;
- static ISteamInput _internal;
- internal static ISteamInput Internal
- {
- get
- {
- SteamClient.ValidCheck();
-
- if ( _internal == null )
- {
- _internal = new ISteamInput();
- _internal.Init();
- }
-
- return _internal;
- }
- }
-
- internal static void Shutdown()
- {
- if ( _internal != null && _internal.IsValid )
- {
- _internal.Shutdown();
- }
-
- _internal = null;
- }
-
- internal static void InstallEvents()
- {
- Internal.Init();
- Internal.RunFrame();
-
- // None?
- }
///
/// You shouldn't really need to call this because it get called by RunCallbacks on SteamClient
diff --git a/Facepunch.Steamworks/SteamInventory.cs b/Facepunch.Steamworks/SteamInventory.cs
index 784db4a..f93389c 100644
--- a/Facepunch.Steamworks/SteamInventory.cs
+++ b/Facepunch.Steamworks/SteamInventory.cs
@@ -12,27 +12,18 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamInventory
+ public class SteamInventory : SteamClass
{
- static ISteamInventory _internal;
- internal static ISteamInventory Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamInventory();
- _internal.Init();
- }
+ internal static ISteamInventory Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
- }
+ Internal = new ISteamInventory();
+ InstallEvents();
+ }
+
internal static void InstallEvents()
{
SteamInventoryFullUpdate_t.Install( x => InventoryUpdated( x ) );
diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs
index 71c2c22..5cb974a 100644
--- a/Facepunch.Steamworks/SteamMatchmaking.cs
+++ b/Facepunch.Steamworks/SteamMatchmaking.cs
@@ -10,37 +10,25 @@ namespace Steamworks
///
/// Functions for clients to access matchmaking services, favorites, and to operate on game lobbies
///
- public static class SteamMatchmaking
+ public class SteamMatchmaking : SteamClass
{
+ internal static ISteamMatchmaking Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
+ {
+ Internal = new ISteamMatchmaking();
+
+ InstallEvents();
+ }
+
+
///
/// Maximum number of characters a lobby metadata key can be
///
internal static int MaxLobbyKeyLength => 255;
- static ISteamMatchmaking _internal;
-
- internal static ISteamMatchmaking Internal
- {
- get
- {
- SteamClient.ValidCheck();
-
- if ( _internal == null )
- {
- _internal = new ISteamMatchmaking();
- _internal.Init();
- }
-
- return _internal;
- }
- }
-
- internal static void Shutdown()
- {
- _internal = null;
- }
-
internal static void InstallEvents()
{
LobbyInvite_t.Install( x => OnLobbyInvite?.Invoke( new Friend( x.SteamIDUser ), new Lobby( x.SteamIDLobby ) ) );
diff --git a/Facepunch.Steamworks/SteamMusic.cs b/Facepunch.Steamworks/SteamMusic.cs
index ac45724..108f97a 100644
--- a/Facepunch.Steamworks/SteamMusic.cs
+++ b/Facepunch.Steamworks/SteamMusic.cs
@@ -13,27 +13,16 @@ namespace Steamworks
/// when an important cut scene is shown, and start playing afterwards.
/// Nothing uses Steam Music though so this can probably get fucked
///
- public static class SteamMusic
+ public class SteamMusic : SteamClass
{
- static ISteamMusic _internal;
- internal static ISteamMusic Internal
- {
- get
- {
- SteamClient.ValidCheck();
+ internal static ISteamMusic Internal;
+ internal override SteamInterface Interface => Internal;
- if ( _internal == null )
- {
- _internal = new ISteamMusic();
- _internal.Init();
- }
-
- return _internal;
- }
- }
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamMusic();
+
+ InstallEvents();
}
internal static void InstallEvents()
diff --git a/Facepunch.Steamworks/SteamNetworking.cs b/Facepunch.Steamworks/SteamNetworking.cs
index 41b592d..4ca18ba 100644
--- a/Facepunch.Steamworks/SteamNetworking.cs
+++ b/Facepunch.Steamworks/SteamNetworking.cs
@@ -8,26 +8,16 @@ using Steamworks.Data;
namespace Steamworks
{
- public static class SteamNetworking
+ public class SteamNetworking : SteamClass
{
- static ISteamNetworking _internal;
- internal static ISteamNetworking Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamNetworking();
- _internal.Init();
- }
+ internal static ISteamNetworking Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
-
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamNetworking();
+
+ InstallEvents();
}
internal static void InstallEvents()
diff --git a/Facepunch.Steamworks/SteamNetworkingSockets.cs b/Facepunch.Steamworks/SteamNetworkingSockets.cs
index 03db4ac..02ff24c 100644
--- a/Facepunch.Steamworks/SteamNetworkingSockets.cs
+++ b/Facepunch.Steamworks/SteamNetworkingSockets.cs
@@ -8,24 +8,19 @@ using Steamworks.Data;
namespace Steamworks
{
- public static class SteamNetworkingSockets
+ public class SteamNetworkingSockets : SteamClass
{
- static ISteamNetworkingSockets _internal;
- internal static ISteamNetworkingSockets Internal
+ internal static ISteamNetworkingSockets Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
{
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamNetworkingSockets();
- _internal.Init();
+ Internal = new ISteamNetworkingSockets();
- SocketInterfaces = new Dictionary();
- ConnectionInterfaces = new Dictionary();
- }
+ SocketInterfaces = new Dictionary();
+ ConnectionInterfaces = new Dictionary();
- return _internal;
- }
+ InstallEvents();
}
#region SocketInterface
@@ -74,13 +69,6 @@ namespace Steamworks
}
#endregion
- internal static void Shutdown()
- {
- _internal = null;
- SocketInterfaces = null;
- ConnectionInterfaces = null;
- }
-
internal static void InstallEvents( bool server = false )
{
SteamNetConnectionStatusChangedCallback_t.Install( x => ConnectionStatusChanged( x ), server );
diff --git a/Facepunch.Steamworks/SteamNetworkingUtils.cs b/Facepunch.Steamworks/SteamNetworkingUtils.cs
index 6ea3cdc..3726ffc 100644
--- a/Facepunch.Steamworks/SteamNetworkingUtils.cs
+++ b/Facepunch.Steamworks/SteamNetworkingUtils.cs
@@ -10,26 +10,14 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamNetworkingUtils
+ public class SteamNetworkingUtils : SteamClass
{
- static ISteamNetworkingUtils _internal;
- internal static ISteamNetworkingUtils Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamNetworkingUtils();
- _internal.InitUserless();
- }
+ internal static ISteamNetworkingUtils Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
-
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamNetworkingUtils();
}
///
diff --git a/Facepunch.Steamworks/SteamParental.cs b/Facepunch.Steamworks/SteamParental.cs
index 4be1016..96ac0a9 100644
--- a/Facepunch.Steamworks/SteamParental.cs
+++ b/Facepunch.Steamworks/SteamParental.cs
@@ -10,29 +10,18 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamParental
+ public class SteamParental : SteamClass
{
- static ISteamParentalSettings _internal;
- internal static ISteamParentalSettings Internal
- {
- get
- {
- SteamClient.ValidCheck();
+ internal static ISteamParentalSettings Internal;
+ internal override SteamInterface Interface => Internal;
- if ( _internal == null )
- {
- _internal = new ISteamParentalSettings();
- _internal.Init();
- }
-
- return _internal;
- }
- }
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamParentalSettings();
+ InstallEvents();
}
+
internal static void InstallEvents()
{
SteamParentalSettingsChanged_t.Install( x => OnSettingsChanged?.Invoke() );
diff --git a/Facepunch.Steamworks/SteamParties.cs b/Facepunch.Steamworks/SteamParties.cs
index d2555c1..755f38a 100644
--- a/Facepunch.Steamworks/SteamParties.cs
+++ b/Facepunch.Steamworks/SteamParties.cs
@@ -7,25 +7,15 @@ using Steamworks.Data;
namespace Steamworks
{
- public static class SteamParties
+ public class SteamParties : SteamClass
{
- static ISteamParties _internal;
- internal static ISteamParties Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamParties();
- _internal.Init();
- }
+ internal static ISteamParties Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamParties();
+ InstallEvents();
}
internal static void InstallEvents()
diff --git a/Facepunch.Steamworks/SteamRemoteStorage.cs b/Facepunch.Steamworks/SteamRemoteStorage.cs
index d559ffa..9dfc33d 100644
--- a/Facepunch.Steamworks/SteamRemoteStorage.cs
+++ b/Facepunch.Steamworks/SteamRemoteStorage.cs
@@ -10,26 +10,14 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamRemoteStorage
+ public class SteamRemoteStorage : SteamClass
{
- static ISteamRemoteStorage _internal;
- internal static ISteamRemoteStorage Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamRemoteStorage();
- _internal.Init();
- }
+ internal static ISteamRemoteStorage Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
-
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamRemoteStorage();
}
///
diff --git a/Facepunch.Steamworks/SteamScreenshots.cs b/Facepunch.Steamworks/SteamScreenshots.cs
index 6b83fe5..8a546c2 100644
--- a/Facepunch.Steamworks/SteamScreenshots.cs
+++ b/Facepunch.Steamworks/SteamScreenshots.cs
@@ -10,27 +10,15 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamScreenshots
+ public class SteamScreenshots : SteamClass
{
- static ISteamScreenshots _internal;
- internal static ISteamScreenshots Internal
- {
- get
- {
- SteamClient.ValidCheck();
+ internal static ISteamScreenshots Internal;
+ internal override SteamInterface Interface => Internal;
- if ( _internal == null )
- {
- _internal = new ISteamScreenshots();
- _internal.Init();
- }
-
- return _internal;
- }
- }
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamScreenshots();
+ InstallEvents();
}
internal static void InstallEvents()
diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs
index d9771b6..cbe61b6 100644
--- a/Facepunch.Steamworks/SteamServer.cs
+++ b/Facepunch.Steamworks/SteamServer.cs
@@ -144,12 +144,6 @@ namespace Steamworks
_internal = null;
ShutdownInterfaces();
- SteamNetworkingUtils.Shutdown();
- SteamNetworkingSockets.Shutdown();
- SteamInventory.Shutdown();
-
- SteamServerStats.Shutdown();
-
SteamGameServer.Shutdown();
}
diff --git a/Facepunch.Steamworks/SteamServerStats.cs b/Facepunch.Steamworks/SteamServerStats.cs
index e75ad17..a6c74a7 100644
--- a/Facepunch.Steamworks/SteamServerStats.cs
+++ b/Facepunch.Steamworks/SteamServerStats.cs
@@ -7,26 +7,14 @@ using Steamworks.Data;
namespace Steamworks
{
- public static class SteamServerStats
+ public class SteamServerStats : SteamClass
{
- static ISteamGameServerStats _internal;
- internal static ISteamGameServerStats Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamGameServerStats();
- _internal.InitServer();
- }
+ internal static ISteamGameServerStats Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
-
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamGameServerStats();
}
///
@@ -36,7 +24,7 @@ namespace Steamworks
///
public static async Task RequestUserStats( SteamId steamid )
{
- var r = await Internal.RequestUserStats( steamid );
+ var r = await Internal.RequestUserStats( steamid ).GetAsync();
if ( !r.HasValue ) return Result.Fail;
return r.Value.Result;
}
@@ -56,7 +44,7 @@ namespace Steamworks
///
public static bool SetFloat( SteamId steamid, string name, float stat )
{
- return Internal.SetUserStat( steamid, name, stat );
+ return Internal.SetUserStat0( steamid, name, stat );
}
///
@@ -68,7 +56,7 @@ namespace Steamworks
{
int data = defaultValue;
- if ( !Internal.GetUserStat1( steamid, name, ref data ) )
+ if ( !Internal.GetUserStat( steamid, name, ref data ) )
return defaultValue;
return data;
@@ -83,7 +71,7 @@ namespace Steamworks
{
float data = defaultValue;
- if ( !Internal.GetUserStat2( steamid, name, ref data ) )
+ if ( !Internal.GetUserStat0( steamid, name, ref data ) )
return defaultValue;
return data;
@@ -127,7 +115,7 @@ namespace Steamworks
///
public static async Task StoreUserStats( SteamId steamid )
{
- var r = await Internal.StoreUserStats( steamid );
+ var r = await Internal.StoreUserStats( steamid ).GetAsync();
if ( !r.HasValue ) return Result.Fail;
return r.Value.Result;
}
diff --git a/Facepunch.Steamworks/SteamUgc.cs b/Facepunch.Steamworks/SteamUgc.cs
index b230ed4..fe8f838 100644
--- a/Facepunch.Steamworks/SteamUgc.cs
+++ b/Facepunch.Steamworks/SteamUgc.cs
@@ -12,21 +12,15 @@ namespace Steamworks
/// Functions for accessing and manipulating Steam user information.
/// This is also where the APIs for Steam Voice are exposed.
///
- public static class SteamUGC
+ public class SteamUGC : SteamClass
{
- static ISteamUGC _internal;
- internal static ISteamUGC Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamUGC();
- _internal.Init();
- }
+ internal static ISteamUGC Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
+ internal override void InitializeInterface()
+ {
+ Internal = new ISteamUGC();
+ InstallEvents();
}
internal static void InstallEvents()
@@ -39,11 +33,6 @@ namespace Steamworks
///
public static event Action OnDownloadItemResult;
- internal static void Shutdown()
- {
- _internal = null;
- }
-
public static async Task DeleteFileAsync( PublishedFileId fileId )
{
var r = await Internal.DeleteItem( fileId );
diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs
index 0f0d06a..af6b7e9 100644
--- a/Facepunch.Steamworks/SteamUser.cs
+++ b/Facepunch.Steamworks/SteamUser.cs
@@ -13,31 +13,18 @@ namespace Steamworks
/// Functions for accessing and manipulating Steam user information.
/// This is also where the APIs for Steam Voice are exposed.
///
- public static class SteamUser
+ public class SteamUser : SteamClass
{
- static ISteamUser _internal;
- internal static ISteamUser Internal
+ internal static ISteamUser Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
{
- get
- {
- SteamClient.ValidCheck();
+ Internal = new ISteamUser();
+ InstallEvents();
- if ( _internal == null )
- {
- _internal = new ISteamUser();
- _internal.Init();
-
- richPresence = new Dictionary();
-
- SampleRate = OptimalSampleRate;
- }
-
- return _internal;
- }
- }
- internal static void Shutdown()
- {
- _internal = null;
+ richPresence = new Dictionary();
+ SampleRate = OptimalSampleRate;
}
static Dictionary richPresence;
diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs
index 241ff42..10d2ad5 100644
--- a/Facepunch.Steamworks/SteamUserStats.cs
+++ b/Facepunch.Steamworks/SteamUserStats.cs
@@ -7,29 +7,17 @@ using Steamworks.Data;
namespace Steamworks
{
- public static class SteamUserStats
+ public class SteamUserStats : SteamClass
{
- static ISteamUserStats _internal;
- internal static ISteamUserStats Internal
+ internal static ISteamUserStats Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
{
- get
- {
- SteamClient.ValidCheck();
+ Internal = new ISteamUserStats();
- if ( _internal == null )
- {
- _internal = new ISteamUserStats();
- _internal.Init();
-
- RequestCurrentStats();
- }
-
- return _internal;
- }
- }
- internal static void Shutdown()
- {
- _internal = null;
+ InstallEvents();
+ RequestCurrentStats();
}
public static bool StatsRecieved { get; internal set; }
diff --git a/Facepunch.Steamworks/SteamUtils.cs b/Facepunch.Steamworks/SteamUtils.cs
index 40d0cb3..2e08195 100644
--- a/Facepunch.Steamworks/SteamUtils.cs
+++ b/Facepunch.Steamworks/SteamUtils.cs
@@ -10,26 +10,16 @@ namespace Steamworks
///
/// Interface which provides access to a range of miscellaneous utility functions
///
- public static class SteamUtils
+ public class SteamUtils : SteamClass
{
- static ISteamUtils _internal;
- internal static ISteamUtils Internal
- {
- get
- {
- if ( _internal == null )
- {
- _internal = new ISteamUtils();
- _internal.Init();
- }
+ internal static ISteamUtils Internal;
+ internal override SteamInterface Interface => Internal;
- return _internal;
- }
- }
-
- internal static void Shutdown()
+ internal override void InitializeInterface()
{
- _internal = null;
+ Internal = new ISteamUtils();
+
+ InstallEvents();
}
internal static void InstallEvents()
diff --git a/Facepunch.Steamworks/SteamVideo.cs b/Facepunch.Steamworks/SteamVideo.cs
index 2d2a632..4f75a52 100644
--- a/Facepunch.Steamworks/SteamVideo.cs
+++ b/Facepunch.Steamworks/SteamVideo.cs
@@ -10,28 +10,16 @@ namespace Steamworks
///
/// Undocumented Parental Settings
///
- public static class SteamVideo
+ public class SteamVideo : SteamClass
{
- static ISteamVideo _internal;
- internal static ISteamVideo Internal
+ internal static ISteamVideo Internal;
+ internal override SteamInterface Interface => Internal;
+
+ internal override void InitializeInterface()
{
- get
- {
- SteamClient.ValidCheck();
+ Internal = new ISteamVideo();
- if ( _internal == null )
- {
- _internal = new ISteamVideo();
- _internal.Init();
- }
-
- return _internal;
- }
- }
-
- internal static void Shutdown()
- {
- _internal = null;
+ InstallEvents();
}
internal static void InstallEvents()
diff --git a/Facepunch.Steamworks/Utility/GetApi.cs b/Facepunch.Steamworks/Utility/GetApi.cs
new file mode 100644
index 0000000..3f9258d
--- /dev/null
+++ b/Facepunch.Steamworks/Utility/GetApi.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Steamworks
+{
+ internal static class GetApi
+ {
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamClient" )]
+ internal static extern IntPtr SteamClient();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamUser" )]
+ internal static extern IntPtr SteamUser();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamFriends" )]
+ internal static extern IntPtr SteamFriends();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamUtils" )]
+ internal static extern IntPtr SteamUtils();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMatchmaking" )]
+ internal static extern IntPtr SteamMatchmaking();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMatchmakingServerListResponse" )]
+ internal static extern IntPtr SteamMatchmakingServerListResponse();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMatchmakingPingResponse" )]
+ internal static extern IntPtr SteamMatchmakingPingResponse();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMatchmakingPlayersResponse" )]
+ internal static extern IntPtr SteamMatchmakingPlayersResponse();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMatchmakingRulesResponse" )]
+ internal static extern IntPtr SteamMatchmakingRulesResponse();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMatchmakingServers" )]
+ internal static extern IntPtr SteamMatchmakingServers();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamGameSearch" )]
+ internal static extern IntPtr SteamGameSearch();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamParties" )]
+ internal static extern IntPtr SteamParties();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamRemoteStorage" )]
+ internal static extern IntPtr SteamRemoteStorage();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamUserStats" )]
+ internal static extern IntPtr SteamUserStats();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamApps" )]
+ internal static extern IntPtr SteamApps();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamNetworking" )]
+ internal static extern IntPtr SteamNetworking();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamScreenshots" )]
+ internal static extern IntPtr SteamScreenshots();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMusic" )]
+ internal static extern IntPtr SteamMusic();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamMusicRemote" )]
+ internal static extern IntPtr SteamMusicRemote();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamHTTP" )]
+ internal static extern IntPtr SteamHTTP();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamInput" )]
+ internal static extern IntPtr SteamInput();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamController" )]
+ internal static extern IntPtr SteamController();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamUGC" )]
+ internal static extern IntPtr SteamUGC();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamAppList" )]
+ internal static extern IntPtr SteamAppList();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamHTMLSurface" )]
+ internal static extern IntPtr SteamHTMLSurface();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamInventory" )]
+ internal static extern IntPtr SteamInventory();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamVideo" )]
+ internal static extern IntPtr SteamVideo();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamParentalSettings" )]
+ internal static extern IntPtr SteamParentalSettings();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer" )]
+ internal static extern IntPtr SteamGameServer();
+ [DllImport( Platform.LibraryName, EntryPoint = "SteamGameServerStats" )]
+ internal static extern IntPtr SteamGameServerStats();
+ }
+}
\ No newline at end of file
diff --git a/Facepunch.Steamworks/Utility/SteamInterface.cs b/Facepunch.Steamworks/Utility/SteamInterface.cs
index d9d10ba..9806e88 100644
--- a/Facepunch.Steamworks/Utility/SteamInterface.cs
+++ b/Facepunch.Steamworks/Utility/SteamInterface.cs
@@ -11,103 +11,32 @@ namespace Steamworks
{
internal abstract class SteamInterface
{
+ public abstract IntPtr GetInterfacePointer();
+
public IntPtr Self;
- public IntPtr VTable;
- public virtual string InterfaceName => null;
- public bool IsValid => Self != IntPtr.Zero && VTable != IntPtr.Zero;
+ public bool IsValid => Self != IntPtr.Zero;
- public void Init()
+ internal void SetupInterface()
{
- if ( SteamClient.IsValid )
- {
- InitClient();
- return;
- }
-
- if ( SteamServer.IsValid )
- {
- InitServer();
- return;
- }
-
- throw new System.Exception( "Trying to initialize Steam Interface but Steam not initialized" );
+ Self = GetInterfacePointer();
}
- public void InitClient()
- {
-
- //
- // There's an issue for us using FindOrCreateUserInterface on Rust.
- // We have a different appid for our staging branch, but we use Rust's
- // appid so we can still test with the live data/setup. The issue is
- // if we run the staging branch and get interfaces using FindOrCreate
- // then some callbacks don't work. I assume this is because these interfaces
- // have already been initialized using the old appid pipe, but since I
- // can't see inside Steam this is just a gut feeling. Either way using
- // CreateInterface doesn't seem to have caused any fires, so we'll just use that.
- //
-
- //
- // var pipe = SteamAPI.GetHSteamPipe();
- //
-
- Self = SteamInternal.CreateInterface( InterfaceName );
-
- if ( Self == IntPtr.Zero )
- {
- var user = SteamAPI.GetHSteamUser();
- Self = SteamInternal.FindOrCreateUserInterface( user, InterfaceName );
- }
-
- if ( Self == IntPtr.Zero )
- throw new System.Exception( $"Couldn't find interface {InterfaceName}" );
-
- VTable = Marshal.ReadIntPtr( Self, 0 );
- if ( Self == IntPtr.Zero )
- throw new System.Exception( $"Invalid VTable for {InterfaceName}" );
-
- InitInternals();
- SteamClient.WatchInterface( this );
- }
-
- public void InitServer()
- {
- var user = SteamGameServer.GetHSteamUser();
- Self = SteamInternal.FindOrCreateGameServerInterface( user, InterfaceName );
-
- if ( Self == IntPtr.Zero )
- throw new System.Exception( $"Couldn't find server interface {InterfaceName}" );
-
- VTable = Marshal.ReadIntPtr( Self, 0 );
- if ( Self == IntPtr.Zero )
- throw new System.Exception( $"Invalid VTable for server {InterfaceName}" );
-
- InitInternals();
- SteamServer.WatchInterface( this );
- }
-
- public virtual void InitUserless()
- {
- Self = SteamInternal.FindOrCreateUserInterface( 0, InterfaceName );
-
- if ( Self == IntPtr.Zero )
- throw new System.Exception( $"Couldn't find interface {InterfaceName}" );
-
- VTable = Marshal.ReadIntPtr( Self, 0 );
- if ( Self == IntPtr.Zero )
- throw new System.Exception( $"Invalid VTable for {InterfaceName}" );
-
- InitInternals();
- }
-
- internal virtual void Shutdown()
+ internal void ShutdownInterface()
{
Self = IntPtr.Zero;
- VTable = IntPtr.Zero;
+ }
+ }
+ public abstract class SteamClass
+ {
+ internal abstract void InitializeInterface();
+ internal void DestroyInterface()
+ {
+ Interface.ShutdownInterface();
}
- public abstract void InitInternals();
+ internal abstract SteamInterface Interface { get; }
}
+
}
\ No newline at end of file
diff --git a/Generator/CodeWriter/ClassVTable.cs b/Generator/CodeWriter/ClassVTable.cs
index 74f79e6..092225e 100644
--- a/Generator/CodeWriter/ClassVTable.cs
+++ b/Generator/CodeWriter/ClassVTable.cs
@@ -25,11 +25,7 @@ namespace Generator
{
StartBlock( $"internal class {className} : SteamInterface" );
{
- //WriteLine( $"public override string InterfaceName => \"{clss.InterfaceString}\";" );
- //WriteLine();
-
- WriteFunctionPointerReader();
-
+ WriteLine( $"public override IntPtr GetInterfacePointer() => GetApi.{className.Substring( 1 )}();" );
WriteLine();
var functions = def.methods.Where( x => x.ClassName == className );
@@ -50,22 +46,6 @@ namespace Generator
System.IO.File.WriteAllText( $"{filename}", sb.ToString() );
}
-
- void WriteFunctionPointerReader()
- {
- StartBlock( $"public override void InitInternals()" );
- {
- }
- EndBlock();
-
- StartBlock( $"internal override void Shutdown()" );
- {
- WriteLine( $"base.Shutdown();" );
- WriteLine( "" );
- }
- EndBlock();
- }
-
private void WriteFunction( SteamApiDefinition.MethodDef func )
{
var returnType = BaseType.Parse( func.ReturnType );