/// ---------------------------------------------
/// Ultimate Inventory System.
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.UltimateInventorySystem.Crafting.Processors
{
using Opsive.Shared.Utility;
using Opsive.UltimateInventorySystem.Core;
using Opsive.UltimateInventorySystem.Core.DataStructures;
using Opsive.UltimateInventorySystem.Core.InventoryCollections;
using Opsive.UltimateInventorySystem.DeadFear;
using System;
using System.Collections.Generic;
using TinyIoC;
using UnityEngine;
using EventHandler = Opsive.Shared.Events.EventHandler;
public class ServerCraftingProcessor : SimpleCraftingProcessor
{
private IoCRef<IClientInventoryBridge> refInventoryBridge = new IoCRef<IClientInventoryBridge>();
internal IClientInventoryBridge iBridge => refInventoryBridge.Ref;
/// <summary>
/// Check if the parameters are valid to craft an item.
/// </summary>
/// <param name="recipe">The recipe.</param>
/// <param name="inventory">The inventory containing the items.</param>
/// <param name="quantity">The quantity to craft.</param>
/// <param name="selectedIngredients">The item infos selected.</param>
/// <returns>True if you can craft.</returns>
protected override bool CanCraftInternal(CraftingRecipe recipe, IInventory inventory,
ListSlice<ItemInfo> selectedIngredients, int quantity)
{
return base.CanCraftInternal(recipe, inventory, selectedIngredients, quantity);
}
/// <summary>
/// Craft the items.
/// </summary>
/// <param name="recipe">The recipe.</param>
/// <param name="inventory">The inventory containing the items.</param>
/// <param name="selectedIngredients">The item infos selected.</param>
/// <param name="quantity">The quantity to craft.</param>
/// <returns>True if you can craft.</returns>
protected override CraftingResult CraftInternal(CraftingRecipe recipe, IInventory inventory,
ListSlice<ItemInfo> selectedIngredients, int quantity)
{
if (CanCraftInternal(recipe, inventory, selectedIngredients, quantity) == false)
{
return new CraftingResult(null, false);
}
// Send message to server to craft recipe
iBridge.CraftRecipe(recipe.ID, quantity);
return new CraftingResult(null, false);
}
}
}