From 503e0529c0079bf985569f324fdb7d4dfac291bd Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 28 Sep 2016 15:13:31 +0100 Subject: [PATCH] Way for a client to manually create an ItemDefinition playtimegenerator types aren't sent to the client --- Facepunch.Steamworks.Test/Client.cs | 9 ++++++--- Facepunch.Steamworks/Client/Inventory.cs | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Facepunch.Steamworks.Test/Client.cs b/Facepunch.Steamworks.Test/Client.cs index c267219..2f19acb 100644 --- a/Facepunch.Steamworks.Test/Client.cs +++ b/Facepunch.Steamworks.Test/Client.cs @@ -112,8 +112,6 @@ namespace Facepunch.Steamworks.Test } } - - [TestMethod] public void InventoryDefinitions() { @@ -121,7 +119,12 @@ namespace Facepunch.Steamworks.Test { Assert.IsNotNull( client.Inventory.Definitions ); Assert.AreNotEqual( 0, client.Inventory.Definitions.Length ); - } + + foreach ( var i in client.Inventory.Definitions ) + { + Console.WriteLine( "{0}: {1}", i.Id, i.Name ); + } + } } [TestMethod] diff --git a/Facepunch.Steamworks/Client/Inventory.cs b/Facepunch.Steamworks/Client/Inventory.cs index e5b9932..96bb3e7 100644 --- a/Facepunch.Steamworks/Client/Inventory.cs +++ b/Facepunch.Steamworks/Client/Inventory.cs @@ -66,6 +66,14 @@ namespace Facepunch.Steamworks } } + public Definition CreateDefinition( int id ) + { + return new Definition( id ) + { + client = client + }; + } + internal void LoadItemDefinitions() { // @@ -79,12 +87,7 @@ namespace Facepunch.Steamworks Definitions = ids.Select( x => { - var d = new Definition() - { - client = client, - Id = x - }; - + var d = CreateDefinition( x ); d.SetupCommonProperties(); return d; @@ -229,6 +232,11 @@ namespace Facepunch.Steamworks public DateTime Created; public DateTime Modified; + internal Definition( int id ) + { + Id = id; + } + public T GetProperty( string name ) { string val = string.Empty;