This commit is contained in:
Garry Newman 2016-11-03 13:53:06 +00:00
parent c27df08194
commit 2fef034547
3 changed files with 15 additions and 36 deletions

View File

@ -6,6 +6,9 @@ using Facepunch.Steamworks.Interop;
namespace Facepunch.Steamworks
{
/// <summary>
/// Implements shared functionality between Steamworks.Client and Steamworks.Server
/// </summary>
public class BaseSteamworks : IDisposable
{
/// <summary>
@ -17,6 +20,12 @@ namespace Facepunch.Steamworks
public Inventory Inventory { get; internal set; }
public Workshop Workshop { get; internal set; }
internal Action OnUpdate;
internal Interop.NativeInterface native;
private List<SteamNative.CallbackHandle> CallbackHandles = new List<SteamNative.CallbackHandle>();
public virtual void Dispose()
{
foreach ( var h in CallbackHandles )
@ -50,42 +59,30 @@ namespace Facepunch.Steamworks
}
}
public void SetupCommonInterfaces()
protected void SetupCommonInterfaces()
{
Networking = new Steamworks.Networking( this, native.networking );
Inventory = new Steamworks.Inventory( native.inventory, IsGameServer );
Workshop = new Steamworks.Workshop( this, native.ugc, native.remoteStorage );
}
/// <summary>
/// Returns true if this instance has initialized properly.
/// If this returns false you should Dispose and throw an error.
/// </summary>
public bool IsValid
{
get { return native != null; }
}
internal Interop.NativeInterface native;
internal virtual bool IsGameServer { get { return false; } }
public enum MessageType : int
{
Message = 0,
Warning = 1
}
/// <summary>
/// Called with a message from Steam
/// </summary>
public Action<MessageType, string> OnMessage;
private List<SteamNative.CallbackHandle> CallbackHandles = new List<SteamNative.CallbackHandle>();
internal void RegisterCallbackHandle( SteamNative.CallbackHandle handle )
{
CallbackHandles.Add( handle );
}
public Action OnUpdate;
public virtual void Update()
{
Inventory.Update();

View File

@ -63,14 +63,6 @@ namespace Facepunch.Steamworks
Update();
}
private void InternalOnWarning( int nSeverity, System.Text.StringBuilder text )
{
if ( OnMessage != null )
{
OnMessage( ( MessageType)nSeverity, text.ToString() );
}
}
/// <summary>
/// Should be called at least once every frame
/// </summary>

View File

@ -81,16 +81,6 @@ namespace Facepunch.Steamworks
}
private void InternalOnWarning( int nSeverity, string text )
{
if ( OnMessage != null )
{
OnMessage( ( MessageType)nSeverity, text.ToString() );
}
Console.WriteLine( "STEAM: {0}", text );
}
/// <summary>
/// Should be called at least once every frame
/// </summary>