/// <summary> /// Gets an item from a TradeEvent, and passes it into the UserHandler's implemented OnUserRemoveItem([...]) routine. /// Passes in null items if something went wrong. /// </summary> /// <param name="tradeEvent">TradeEvent to get item from</param> /// <returns></returns> private void FireOnUserRemoveItem(TradeEvent tradeEvent) { ulong itemID = (ulong) tradeEvent.assetid; Inventory.Item item; if (OtherInventory != null) { item = OtherInventory.GetItem(itemID); if (item != null) { Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); if (schemaItem == null) { // TODO: Add log (counldn't find item in CurrentSchema) } OnUserRemoveItem(schemaItem, item); } else { // TODO: Log this (Couldn't find item in user's inventory can't find item in CurrentSchema item = new Inventory.Item() { Id = itemID, AppId = tradeEvent.appid, ContextId = tradeEvent.contextid }; OnUserRemoveItem(null, item); } } else { var schemaItem = GetItemFromPrivateBp(tradeEvent, itemID); if (schemaItem == null) { // TODO: Add log (counldn't find item in CurrentSchema) } OnUserRemoveItem(schemaItem, null); } }
/// <summary> /// Gets an item from a TradeEvent, and passes it into the UserHandler's implemented OnUserAddItem([...]) routine. /// Passes in null items if something went wrong. /// </summary> /// <param name="tradeEvent">TradeEvent to get item from</param> /// <returns></returns> private void FireOnUserAddItem(TradeEvent tradeEvent) { ulong itemID = tradeEvent.assetid; Inventory.Item item; if (OtherInventory != null) { item = OtherInventory.GetItem(itemID); if (item != null) { Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); if (schemaItem == null) { Console.WriteLine("User added an unknown item to the trade."); } OnUserAddItem(schemaItem, item); } else { item = new Inventory.Item() { Id=itemID, AppId=tradeEvent.appid, ContextId=tradeEvent.contextid }; //Console.WriteLine("User added a non TF2 item to the trade."); OnUserAddItem(null, item); } } else { var schemaItem = GetItemFromPrivateBp(tradeEvent, itemID); if (schemaItem == null) { Console.WriteLine("User added an unknown item to the trade."); } OnUserAddItem(schemaItem, null); // todo: figure out what to send in with Inventory item..... } }