public async Task GetExchanges() { var result = await SteamInventory.WaitForDefinitions(5); Assert.IsTrue(result); foreach (var def in SteamInventory.Definitions) { var exchangelist = def.GetRecipes(); if (exchangelist == null) { continue; } foreach (var exchange in exchangelist) { Assert.AreEqual(exchange.Result, def); Console.WriteLine($"{def.Name}:"); foreach (var item in exchange.Ingredients) { Console.WriteLine($" {item.Count} x {item.Definition.Name}"); } Console.WriteLine($""); } } }
internal static Ingredient FromString(string part) { var i = new Ingredient(); i.Count = 1; try { if (part.Contains("x")) { var idx = part.IndexOf('x'); int count = 0; if (int.TryParse(part.Substring(idx + 1), out count)) { i.Count = count; } part = part.Substring(0, idx); } i.DefinitionId = int.Parse(part); i.Definition = SteamInventory.FindDefinition(i.DefinitionId); } catch (System.Exception) { return(i); } return(i); }
public async Task GetAllItems() { await SteamInventory.WaitForDefinitions(); var result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); Assert.IsTrue(result.Value.ItemCount > 0); using ( result ) { var items = result.Value.GetItems(true); Assert.IsNotNull(items); foreach (var item in items) { Console.WriteLine($"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def?.Name} /[{item.IsNoTrade}|{item.IsRemoved}|{item.IsConsumed}] "); foreach (var prop in item.Properties) { Console.WriteLine($" {prop.Key} : {prop.Value}"); } } } }
public static void Init(uint appid) { if (IntPtr.Size != 8) { throw new System.Exception("Only 64bit processes are currently supported"); } System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString()); System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString()); if (!SteamAPI.Init()) { throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId."); } AppId = appid; initialized = true; SteamApps.InstallEvents(); SteamUtils.InstallEvents(); SteamParental.InstallEvents(); SteamMusic.InstallEvents(); SteamVideo.InstallEvents(); SteamUser.InstallEvents(); SteamFriends.InstallEvents(); SteamScreenshots.InstallEvents(); SteamUserStats.InstallEvents(); SteamInventory.InstallEvents(); RunCallbacksAsync(); }
internal static InventoryRecipe.Ingredient FromString(string part) { InventoryRecipe.Ingredient ingredient; InventoryRecipe.Ingredient ingredient1 = new InventoryRecipe.Ingredient() { Count = 1 }; try { if (part.Contains("x")) { int num = part.IndexOf('x'); int num1 = 0; if (Int32.TryParse(part.Substring(num + 1), out num1)) { ingredient1.Count = num1; } part = part.Substring(0, num); } ingredient1.DefinitionId = Int32.Parse(part); ingredient1.Definition = SteamInventory.FindDefinition(ingredient1.DefinitionId); } catch (Exception exception) { ingredient = ingredient1; return(ingredient); } ingredient = ingredient1; return(ingredient); }
public static void Shutdown() { Event.DisposeAllClient(); initialized = false; ShutdownInterfaces(); 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(); SteamAPI.Shutdown(); }
public static void Init(uint appid) { System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString()); System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString()); if (!SteamAPI.Init()) { throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId."); } AppId = appid; 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(); RunCallbacksAsync(); }
public async Task Deserialize() { await SteamInventory.WaitForDefinitions(); byte[] data; int itemCount; // Serialize { var result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); itemCount = result.Value.ItemCount; data = result.Value.Serialize(); Assert.IsNotNull(data); result.Value.Dispose(); } await Task.Delay(2000); // Deserialize { var result = await SteamInventory.DeserializeAsync(data); Assert.IsTrue(result.HasValue); Assert.AreEqual(itemCount, result.Value.ItemCount); result.Value.Dispose(); } }
public async Task GetDefinitionsWithPrices() { var defs = await SteamInventory.GetDefinitionsWithPricesAsync(); foreach (var def in defs) { Console.WriteLine($"[{def.Id:0000000000}] {def.Name} [{def.LocalPriceFormatted}]"); } }
internal static void InstallEvents() { SteamInventory.InstallEvents(); ValidateAuthTicketResponse_t.Install(x => OnValidateAuthTicketResponse?.Invoke(x.SteamID, x.OwnerSteamID, x.AuthSessionResponse), true); SteamServersConnected_t.Install(x => OnSteamServersConnected?.Invoke(), true); SteamServerConnectFailure_t.Install(x => OnSteamServerConnectFailure?.Invoke(x.Result, x.StillRetrying), true); SteamServersDisconnected_t.Install(x => OnSteamServersDisconnected?.Invoke(x.Result), true); }
internal static void InstallEvents() { SteamInventory.InstallEvents(); //SteamNetworkingSockets.InstallEvents(true); Dispatch.Install <ValidateAuthTicketResponse_t>(x => OnValidateAuthTicketResponse?.Invoke(x.SteamID, x.OwnerSteamID, x.AuthSessionResponse), true); Dispatch.Install <SteamServersConnected_t>(x => OnSteamServersConnected?.Invoke(), true); Dispatch.Install <SteamServerConnectFailure_t>(x => OnSteamServerConnectFailure?.Invoke(x.Result, x.StillRetrying), true); Dispatch.Install <SteamServersDisconnected_t>(x => OnSteamServersDisconnected?.Invoke(x.Result), true); }
public async Task LoadItemDefinitionsAsync() { var result = await SteamInventory.WaitForDefinitions(5); Assert.IsTrue(result); result = await SteamInventory.WaitForDefinitions(5); Assert.IsTrue(result); }
public static void Shutdown() { Event.DisposeAllServer(); SteamServer.initialized = false; SteamServer._internal = null; SteamServer.ShutdownInterfaces(); SteamNetworkingUtils.Shutdown(); SteamNetworkingSockets.Shutdown(); SteamInventory.Shutdown(); SteamGameServer.Shutdown(); }
public async Task GetDefinitions() { await SteamInventory.WaitForDefinitions(); Assert.IsNotNull(SteamInventory.Definitions); foreach (var def in SteamInventory.Definitions) { Console.WriteLine($"[{def.Id:0000000000}] {def.Name} [{def.Type}]"); } }
public async Task Serialize() { await SteamInventory.WaitForDefinitions(); var result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); var data = result.Value.Serialize(); Assert.IsNotNull(data); Console.WriteLine(string.Join("", data.Select(x => x.ToString("x")))); }
public async Task Items() { SteamInventory.GetAllItems(); await SteamInventory.WaitForDefinitions(); while (SteamInventory.Items == null) { await Task.Delay(10); } Assert.IsNotNull(SteamInventory.Items); foreach (var item in SteamInventory.Items) { Console.WriteLine($"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def.Name}"); } }
internal static void InstallEvents() { SteamInventory.InstallEvents(); ValidateAuthTicketResponse_t.Install((ValidateAuthTicketResponse_t x) => { Action <SteamId, SteamId, AuthResponse> onValidateAuthTicketResponse = SteamServer.OnValidateAuthTicketResponse; if (onValidateAuthTicketResponse != null) { onValidateAuthTicketResponse(x.SteamID, x.OwnerSteamID, x.AuthSessionResponse); } else { } }, true); SteamServersConnected_t.Install((SteamServersConnected_t x) => { Action onSteamServersConnected = SteamServer.OnSteamServersConnected; if (onSteamServersConnected != null) { onSteamServersConnected(); } else { } }, true); SteamServerConnectFailure_t.Install((SteamServerConnectFailure_t x) => { Action <Result, bool> onSteamServerConnectFailure = SteamServer.OnSteamServerConnectFailure; if (onSteamServerConnectFailure != null) { onSteamServerConnectFailure(x.Result, x.StillRetrying); } else { } }, true); SteamServersDisconnected_t.Install((SteamServersDisconnected_t x) => { Action <Result> onSteamServersDisconnected = SteamServer.OnSteamServersDisconnected; if (onSteamServersDisconnected != null) { onSteamServersDisconnected(x.Result); } else { } }, true); }
public static void Shutdown() { Event.DisposeAllClient(); initialized = false; SteamApps.Shutdown(); SteamUtils.Shutdown(); SteamParental.Shutdown(); SteamMusic.Shutdown(); SteamVideo.Shutdown(); SteamUser.Shutdown(); SteamFriends.Shutdown(); SteamScreenshots.Shutdown(); SteamUserStats.Shutdown(); SteamInventory.Shutdown(); SteamAPI.Shutdown(); }
public async Task GetAllItems() { await SteamInventory.WaitForDefinitions(); var result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); using ( result ) { var items = result?.GetItems(true); foreach (var item in items) { Console.WriteLine($"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def?.Name} "); foreach (var prop in item.Properties) { Console.WriteLine($" {prop.Key} : {prop.Value}"); } } } }
public async Task GetAllItemsMultipleTimes() { await SteamInventory.WaitForDefinitions(); var fresult = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(fresult.HasValue); Assert.IsTrue(fresult.Value.ItemCount > 0); await Task.Delay(1000); var result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); Assert.IsTrue(result.Value.GetItems().Length == fresult.Value.ItemCount); await Task.Delay(1000); result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); Assert.IsTrue(result.Value.ItemCount == fresult.Value.ItemCount); }
public async Task GetItemSpecialProperties() { await SteamInventory.WaitForDefinitions(); var result = await SteamInventory.GetAllItemsAsync(); Assert.IsTrue(result.HasValue); Assert.IsTrue(result.Value.ItemCount > 0); using ( result ) { var items = result.Value.GetItems(true); Assert.IsNotNull(items); foreach (var item in items) { Console.WriteLine($"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def?.Name} "); Console.WriteLine($" Acquired: {item.Acquired}"); Console.WriteLine($" Origin: {item.Origin}"); } } }