void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player) { cItem & DraggingItem = a_Player.GetDraggingItem(); // Get the current recipe: cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player); const cItem & Result = Recipe.GetResult(); cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1; cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize); // If possible, craft: if (DraggingItem.IsEmpty()) { DraggingItem = Result; Recipe.ConsumeIngredients(Grid); Grid.CopyToItems(PlayerSlots); HandleCraftItem(Result, a_Player); } else if (DraggingItem.IsEqual(Result)) { cItemHandler * Handler = ItemHandler(Result.m_ItemType); if (DraggingItem.m_ItemCount + Result.m_ItemCount <= Handler->GetMaxStackSize()) { DraggingItem.m_ItemCount += Result.m_ItemCount; Recipe.ConsumeIngredients(Grid); Grid.CopyToItems(PlayerSlots); HandleCraftItem(Result, a_Player); } } // Get the new recipe and update the result slot: UpdateRecipe(a_Player); // We're done. Send all changes to the client and bail out: m_ParentWindow.BroadcastWholeWindow(); }
void cSlotAreaCrafting::DropClickedResult(cPlayer & a_Player) { // Get the current recipe: cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player); const cItem & Result = Recipe.GetResult(); cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1; cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize); a_Player.TossPickup(Result); Recipe.ConsumeIngredients(Grid); Grid.CopyToItems(PlayerSlots); HandleCraftItem(Result, a_Player); UpdateRecipe(a_Player); }