From 8b2599be983a665cd467cf846a7a0301fd64fa1b Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sun, 23 Feb 2020 18:34:56 +0000 Subject: [PATCH] Try to define whether interfaces are shared/client/server only a bit better --- Facepunch.Steamworks/SteamApps.cs | 2 +- Facepunch.Steamworks/SteamFriends.cs | 2 +- Facepunch.Steamworks/SteamInput.cs | 2 +- Facepunch.Steamworks/SteamInventory.cs | 9 ++-- Facepunch.Steamworks/SteamMatchmaking.cs | 2 +- .../SteamMatchmakingServers.cs | 2 +- Facepunch.Steamworks/SteamMusic.cs | 2 +- Facepunch.Steamworks/SteamNetworking.cs | 2 +- .../SteamNetworkingSockets.cs | 2 +- Facepunch.Steamworks/SteamNetworkingUtils.cs | 2 +- Facepunch.Steamworks/SteamParental.cs | 2 +- Facepunch.Steamworks/SteamParties.cs | 2 +- Facepunch.Steamworks/SteamRemoteStorage.cs | 2 +- Facepunch.Steamworks/SteamScreenshots.cs | 2 +- Facepunch.Steamworks/SteamServer.cs | 2 +- Facepunch.Steamworks/SteamServerStats.cs | 2 +- Facepunch.Steamworks/SteamUgc.cs | 2 +- Facepunch.Steamworks/SteamUser.cs | 2 +- Facepunch.Steamworks/SteamUserStats.cs | 2 +- Facepunch.Steamworks/SteamUtils.cs | 2 +- Facepunch.Steamworks/SteamVideo.cs | 2 +- .../Utility/SteamInterface.cs | 50 ++++++++++++++++++- 22 files changed, 72 insertions(+), 27 deletions(-) diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs index 0319e15..3b7ff8f 100644 --- a/Facepunch.Steamworks/SteamApps.cs +++ b/Facepunch.Steamworks/SteamApps.cs @@ -11,7 +11,7 @@ namespace Steamworks /// /// Exposes a wide range of information and actions for applications and Downloadable Content (DLC). /// - public class SteamApps : SteamClass + public class SteamApps : SteamSharedClass { internal static ISteamApps Internal => Interface as ISteamApps; diff --git a/Facepunch.Steamworks/SteamFriends.cs b/Facepunch.Steamworks/SteamFriends.cs index f4f9157..31ae7fd 100644 --- a/Facepunch.Steamworks/SteamFriends.cs +++ b/Facepunch.Steamworks/SteamFriends.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamFriends : SteamClass + public class SteamFriends : SteamClientClass { internal static ISteamFriends Internal => Interface as ISteamFriends; diff --git a/Facepunch.Steamworks/SteamInput.cs b/Facepunch.Steamworks/SteamInput.cs index 03b8139..c05ae70 100644 --- a/Facepunch.Steamworks/SteamInput.cs +++ b/Facepunch.Steamworks/SteamInput.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Steamworks { - public class SteamInput : SteamClass + public class SteamInput : SteamClientClass { internal static ISteamInput Internal => Interface as ISteamInput; diff --git a/Facepunch.Steamworks/SteamInventory.cs b/Facepunch.Steamworks/SteamInventory.cs index 57c55f6..65ff914 100644 --- a/Facepunch.Steamworks/SteamInventory.cs +++ b/Facepunch.Steamworks/SteamInventory.cs @@ -12,7 +12,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamInventory : SteamClass + public class SteamInventory : SteamSharedClass { internal static ISteamInventory Internal => Interface as ISteamInventory; @@ -28,12 +28,9 @@ namespace Steamworks if ( !server ) { Dispatch.Install( x => InventoryUpdated( x ) ); - Dispatch.Install( x => LoadDefinitions() ); - } - else - { - Dispatch.Install( x => LoadDefinitions(), true ); } + + Dispatch.Install( x => LoadDefinitions(), server ); } private static void InventoryUpdated( SteamInventoryFullUpdate_t x ) diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs index 1264a2f..4ac60b4 100644 --- a/Facepunch.Steamworks/SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamMatchmaking.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Functions for clients to access matchmaking services, favorites, and to operate on game lobbies /// - public class SteamMatchmaking : SteamClass + public class SteamMatchmaking : SteamClientClass { internal static ISteamMatchmaking Internal => Interface as ISteamMatchmaking; diff --git a/Facepunch.Steamworks/SteamMatchmakingServers.cs b/Facepunch.Steamworks/SteamMatchmakingServers.cs index 8b9bd48..f9490e2 100644 --- a/Facepunch.Steamworks/SteamMatchmakingServers.cs +++ b/Facepunch.Steamworks/SteamMatchmakingServers.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Functions for clients to access matchmaking services, favorites, and to operate on game lobbies /// - public class SteamMatchmakingServers : SteamClass + public class SteamMatchmakingServers : SteamClientClass { internal static ISteamMatchmakingServers Internal => Interface as ISteamMatchmakingServers; diff --git a/Facepunch.Steamworks/SteamMusic.cs b/Facepunch.Steamworks/SteamMusic.cs index 9095887..1ef38f8 100644 --- a/Facepunch.Steamworks/SteamMusic.cs +++ b/Facepunch.Steamworks/SteamMusic.cs @@ -13,7 +13,7 @@ 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 class SteamMusic : SteamClass + public class SteamMusic : SteamClientClass { internal static ISteamMusic Internal => Interface as ISteamMusic; diff --git a/Facepunch.Steamworks/SteamNetworking.cs b/Facepunch.Steamworks/SteamNetworking.cs index ed1650a..38d2fe3 100644 --- a/Facepunch.Steamworks/SteamNetworking.cs +++ b/Facepunch.Steamworks/SteamNetworking.cs @@ -8,7 +8,7 @@ using Steamworks.Data; namespace Steamworks { - public class SteamNetworking : SteamClass + public class SteamNetworking : SteamSharedClass { internal static ISteamNetworking Internal => Interface as ISteamNetworking; diff --git a/Facepunch.Steamworks/SteamNetworkingSockets.cs b/Facepunch.Steamworks/SteamNetworkingSockets.cs index f308328..ae4f571 100644 --- a/Facepunch.Steamworks/SteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/SteamNetworkingSockets.cs @@ -8,7 +8,7 @@ using Steamworks.Data; namespace Steamworks { - public class SteamNetworkingSockets : SteamClass + public class SteamNetworkingSockets : SteamSharedClass { internal static ISteamNetworkingSockets Internal => Interface as ISteamNetworkingSockets; diff --git a/Facepunch.Steamworks/SteamNetworkingUtils.cs b/Facepunch.Steamworks/SteamNetworkingUtils.cs index 676e213..aa44ea8 100644 --- a/Facepunch.Steamworks/SteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/SteamNetworkingUtils.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamNetworkingUtils : SteamClass + public class SteamNetworkingUtils : SteamSharedClass { internal static ISteamNetworkingUtils Internal => Interface as ISteamNetworkingUtils; diff --git a/Facepunch.Steamworks/SteamParental.cs b/Facepunch.Steamworks/SteamParental.cs index 112879c..b746ca3 100644 --- a/Facepunch.Steamworks/SteamParental.cs +++ b/Facepunch.Steamworks/SteamParental.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamParental : SteamClass + public class SteamParental : SteamSharedClass { internal static ISteamParentalSettings Internal => Interface as ISteamParentalSettings; diff --git a/Facepunch.Steamworks/SteamParties.cs b/Facepunch.Steamworks/SteamParties.cs index 17d2a49..6b972d0 100644 --- a/Facepunch.Steamworks/SteamParties.cs +++ b/Facepunch.Steamworks/SteamParties.cs @@ -7,7 +7,7 @@ using Steamworks.Data; namespace Steamworks { - public class SteamParties : SteamClass + public class SteamParties : SteamClientClass { internal static ISteamParties Internal => Interface as ISteamParties; diff --git a/Facepunch.Steamworks/SteamRemoteStorage.cs b/Facepunch.Steamworks/SteamRemoteStorage.cs index f54c484..4754493 100644 --- a/Facepunch.Steamworks/SteamRemoteStorage.cs +++ b/Facepunch.Steamworks/SteamRemoteStorage.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamRemoteStorage : SteamClass + public class SteamRemoteStorage : SteamClientClass { internal static ISteamRemoteStorage Internal => Interface as ISteamRemoteStorage; diff --git a/Facepunch.Steamworks/SteamScreenshots.cs b/Facepunch.Steamworks/SteamScreenshots.cs index 41b9de8..3db167f 100644 --- a/Facepunch.Steamworks/SteamScreenshots.cs +++ b/Facepunch.Steamworks/SteamScreenshots.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamScreenshots : SteamClass + public class SteamScreenshots : SteamClientClass { internal static ISteamScreenshots Internal => Interface as ISteamScreenshots; diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index 8ddae0a..09367de 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Provides the core of the Steam Game Servers API /// - public partial class SteamServer : SteamClass + public partial class SteamServer : SteamServerClass { internal static ISteamGameServer Internal => Interface as ISteamGameServer; diff --git a/Facepunch.Steamworks/SteamServerStats.cs b/Facepunch.Steamworks/SteamServerStats.cs index 766c1f9..f848694 100644 --- a/Facepunch.Steamworks/SteamServerStats.cs +++ b/Facepunch.Steamworks/SteamServerStats.cs @@ -7,7 +7,7 @@ using Steamworks.Data; namespace Steamworks { - public class SteamServerStats : SteamClass + public class SteamServerStats : SteamServerClass { internal static ISteamGameServerStats Internal => Interface as ISteamGameServerStats; diff --git a/Facepunch.Steamworks/SteamUgc.cs b/Facepunch.Steamworks/SteamUgc.cs index db10f45..e53ebbe 100644 --- a/Facepunch.Steamworks/SteamUgc.cs +++ b/Facepunch.Steamworks/SteamUgc.cs @@ -12,7 +12,7 @@ namespace Steamworks /// Functions for accessing and manipulating Steam user information. /// This is also where the APIs for Steam Voice are exposed. /// - public class SteamUGC : SteamClass + public class SteamUGC : SteamSharedClass { internal static ISteamUGC Internal => Interface as ISteamUGC; diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs index a0d3a03..e21f221 100644 --- a/Facepunch.Steamworks/SteamUser.cs +++ b/Facepunch.Steamworks/SteamUser.cs @@ -13,7 +13,7 @@ namespace Steamworks /// Functions for accessing and manipulating Steam user information. /// This is also where the APIs for Steam Voice are exposed. /// - public class SteamUser : SteamClass + public class SteamUser : SteamClientClass { internal static ISteamUser Internal => Interface as ISteamUser; diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs index e2352d8..e01c08f 100644 --- a/Facepunch.Steamworks/SteamUserStats.cs +++ b/Facepunch.Steamworks/SteamUserStats.cs @@ -7,7 +7,7 @@ using Steamworks.Data; namespace Steamworks { - public class SteamUserStats : SteamClass + public class SteamUserStats : SteamClientClass { internal static ISteamUserStats Internal => Interface as ISteamUserStats; diff --git a/Facepunch.Steamworks/SteamUtils.cs b/Facepunch.Steamworks/SteamUtils.cs index d28d79c..0233c63 100644 --- a/Facepunch.Steamworks/SteamUtils.cs +++ b/Facepunch.Steamworks/SteamUtils.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Interface which provides access to a range of miscellaneous utility functions /// - public class SteamUtils : SteamClass + public class SteamUtils : SteamSharedClass { internal static ISteamUtils Internal => Interface as ISteamUtils; diff --git a/Facepunch.Steamworks/SteamVideo.cs b/Facepunch.Steamworks/SteamVideo.cs index 37e9732..c6eaf43 100644 --- a/Facepunch.Steamworks/SteamVideo.cs +++ b/Facepunch.Steamworks/SteamVideo.cs @@ -10,7 +10,7 @@ namespace Steamworks /// /// Undocumented Parental Settings /// - public class SteamVideo : SteamClass + public class SteamVideo : SteamClientClass { internal static ISteamVideo Internal => Interface as ISteamVideo; diff --git a/Facepunch.Steamworks/Utility/SteamInterface.cs b/Facepunch.Steamworks/Utility/SteamInterface.cs index 2c5511f..f409449 100644 --- a/Facepunch.Steamworks/Utility/SteamInterface.cs +++ b/Facepunch.Steamworks/Utility/SteamInterface.cs @@ -59,7 +59,7 @@ namespace Steamworks internal abstract void DestroyInterface( bool server ); } - public class SteamClass : SteamClass + public class SteamSharedClass : SteamClass { internal static SteamInterface Interface => InterfaceClient != null ? InterfaceClient : InterfaceServer; internal static SteamInterface InterfaceClient; @@ -90,4 +90,52 @@ namespace Steamworks } } + public class SteamClientClass : SteamClass + { + internal static SteamInterface Interface => InterfaceClient; + internal static SteamInterface InterfaceClient; + + internal override void InitializeInterface( bool server ) + { + + } + + internal virtual void SetInterface( bool server, SteamInterface iface ) + { + if ( server ) + throw new System.NotSupportedException(); + + InterfaceClient = iface; + } + + internal override void DestroyInterface( bool server ) + { + InterfaceClient = null; + } + } + + public class SteamServerClass : SteamClass + { + internal static SteamInterface Interface => InterfaceServer; + internal static SteamInterface InterfaceServer; + + internal override void InitializeInterface( bool server ) + { + + } + + internal virtual void SetInterface( bool server, SteamInterface iface ) + { + if ( !server ) + throw new System.NotSupportedException(); + + InterfaceServer = iface; + } + + internal override void DestroyInterface( bool server ) + { + InterfaceServer = null; + } + } + } \ No newline at end of file