Try to define whether interfaces are shared/client/server only a bit better

This commit is contained in:
Garry Newman 2020-02-23 18:34:56 +00:00
parent c80421e9a9
commit 8b2599be98
22 changed files with 72 additions and 27 deletions

View File

@ -11,7 +11,7 @@ namespace Steamworks
/// <summary>
/// Exposes a wide range of information and actions for applications and Downloadable Content (DLC).
/// </summary>
public class SteamApps : SteamClass<SteamApps>
public class SteamApps : SteamSharedClass<SteamApps>
{
internal static ISteamApps Internal => Interface as ISteamApps;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamFriends : SteamClass<SteamFriends>
public class SteamFriends : SteamClientClass<SteamFriends>
{
internal static ISteamFriends Internal => Interface as ISteamFriends;

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Steamworks
{
public class SteamInput : SteamClass<SteamInput>
public class SteamInput : SteamClientClass<SteamInput>
{
internal static ISteamInput Internal => Interface as ISteamInput;

View File

@ -12,7 +12,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamInventory : SteamClass<SteamInventory>
public class SteamInventory : SteamSharedClass<SteamInventory>
{
internal static ISteamInventory Internal => Interface as ISteamInventory;
@ -28,12 +28,9 @@ namespace Steamworks
if ( !server )
{
Dispatch.Install<SteamInventoryFullUpdate_t>( x => InventoryUpdated( x ) );
Dispatch.Install<SteamInventoryDefinitionUpdate_t>( x => LoadDefinitions() );
}
else
{
Dispatch.Install<SteamInventoryDefinitionUpdate_t>( x => LoadDefinitions(), true );
}
Dispatch.Install<SteamInventoryDefinitionUpdate_t>( x => LoadDefinitions(), server );
}
private static void InventoryUpdated( SteamInventoryFullUpdate_t x )

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Functions for clients to access matchmaking services, favorites, and to operate on game lobbies
/// </summary>
public class SteamMatchmaking : SteamClass<SteamMatchmaking>
public class SteamMatchmaking : SteamClientClass<SteamMatchmaking>
{
internal static ISteamMatchmaking Internal => Interface as ISteamMatchmaking;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Functions for clients to access matchmaking services, favorites, and to operate on game lobbies
/// </summary>
public class SteamMatchmakingServers : SteamClass<SteamMatchmakingServers>
public class SteamMatchmakingServers : SteamClientClass<SteamMatchmakingServers>
{
internal static ISteamMatchmakingServers Internal => Interface as ISteamMatchmakingServers;

View File

@ -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
/// </summary>
public class SteamMusic : SteamClass<SteamMusic>
public class SteamMusic : SteamClientClass<SteamMusic>
{
internal static ISteamMusic Internal => Interface as ISteamMusic;

View File

@ -8,7 +8,7 @@ using Steamworks.Data;
namespace Steamworks
{
public class SteamNetworking : SteamClass<SteamNetworking>
public class SteamNetworking : SteamSharedClass<SteamNetworking>
{
internal static ISteamNetworking Internal => Interface as ISteamNetworking;

View File

@ -8,7 +8,7 @@ using Steamworks.Data;
namespace Steamworks
{
public class SteamNetworkingSockets : SteamClass<SteamNetworkingSockets>
public class SteamNetworkingSockets : SteamSharedClass<SteamNetworkingSockets>
{
internal static ISteamNetworkingSockets Internal => Interface as ISteamNetworkingSockets;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamNetworkingUtils : SteamClass<SteamNetworkingUtils>
public class SteamNetworkingUtils : SteamSharedClass<SteamNetworkingUtils>
{
internal static ISteamNetworkingUtils Internal => Interface as ISteamNetworkingUtils;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamParental : SteamClass<SteamParental>
public class SteamParental : SteamSharedClass<SteamParental>
{
internal static ISteamParentalSettings Internal => Interface as ISteamParentalSettings;

View File

@ -7,7 +7,7 @@ using Steamworks.Data;
namespace Steamworks
{
public class SteamParties : SteamClass<SteamParties>
public class SteamParties : SteamClientClass<SteamParties>
{
internal static ISteamParties Internal => Interface as ISteamParties;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamRemoteStorage : SteamClass<SteamRemoteStorage>
public class SteamRemoteStorage : SteamClientClass<SteamRemoteStorage>
{
internal static ISteamRemoteStorage Internal => Interface as ISteamRemoteStorage;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamScreenshots : SteamClass<SteamScreenshots>
public class SteamScreenshots : SteamClientClass<SteamScreenshots>
{
internal static ISteamScreenshots Internal => Interface as ISteamScreenshots;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Provides the core of the Steam Game Servers API
/// </summary>
public partial class SteamServer : SteamClass<SteamServer>
public partial class SteamServer : SteamServerClass<SteamServer>
{
internal static ISteamGameServer Internal => Interface as ISteamGameServer;

View File

@ -7,7 +7,7 @@ using Steamworks.Data;
namespace Steamworks
{
public class SteamServerStats : SteamClass<SteamServerStats>
public class SteamServerStats : SteamServerClass<SteamServerStats>
{
internal static ISteamGameServerStats Internal => Interface as ISteamGameServerStats;

View File

@ -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.
/// </summary>
public class SteamUGC : SteamClass<SteamUGC>
public class SteamUGC : SteamSharedClass<SteamUGC>
{
internal static ISteamUGC Internal => Interface as ISteamUGC;

View File

@ -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.
/// </summary>
public class SteamUser : SteamClass<SteamUser>
public class SteamUser : SteamClientClass<SteamUser>
{
internal static ISteamUser Internal => Interface as ISteamUser;

View File

@ -7,7 +7,7 @@ using Steamworks.Data;
namespace Steamworks
{
public class SteamUserStats : SteamClass<SteamUserStats>
public class SteamUserStats : SteamClientClass<SteamUserStats>
{
internal static ISteamUserStats Internal => Interface as ISteamUserStats;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Interface which provides access to a range of miscellaneous utility functions
/// </summary>
public class SteamUtils : SteamClass<SteamUtils>
public class SteamUtils : SteamSharedClass<SteamUtils>
{
internal static ISteamUtils Internal => Interface as ISteamUtils;

View File

@ -10,7 +10,7 @@ namespace Steamworks
/// <summary>
/// Undocumented Parental Settings
/// </summary>
public class SteamVideo : SteamClass<SteamVideo>
public class SteamVideo : SteamClientClass<SteamVideo>
{
internal static ISteamVideo Internal => Interface as ISteamVideo;

View File

@ -59,7 +59,7 @@ namespace Steamworks
internal abstract void DestroyInterface( bool server );
}
public class SteamClass<T> : SteamClass
public class SteamSharedClass<T> : SteamClass
{
internal static SteamInterface Interface => InterfaceClient != null ? InterfaceClient : InterfaceServer;
internal static SteamInterface InterfaceClient;
@ -90,4 +90,52 @@ namespace Steamworks
}
}
public class SteamClientClass<T> : 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<T> : 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;
}
}
}