public bool TryToFinishCrafting( CraftingRecipe recipe, List <CraftingIngredient> possibleIngredients, List <ItemAttributesV2> possibleTools, List <ReagentContainer> reagentContainers, CraftingActionParameters craftingActionParameters ) { CraftingStatus craftingStatus = craftingActionParameters.IgnoreToolsAndIngredients ? CanServerCraft(recipe, reagentContainers) : CanCraft(recipe, possibleIngredients, possibleTools, reagentContainers); if (craftingActionParameters.Feedback == FeedbackType.GiveAllFeedback || (craftingActionParameters.Feedback == FeedbackType.GiveOnlySuccess && craftingStatus == CraftingStatus.AllGood)) { GiveServerSidedFeedback(craftingStatus, recipe, true); } if (craftingStatus != CraftingStatus.AllGood) { return(false); } FinishCrafting(recipe, possibleIngredients, possibleTools, reagentContainers); return(true); }
/// <summary> /// Tries to start a crafting action. /// May use all reachable items. /// May use all tools that a player holds in his hands. /// May use all reachable reagents. /// </summary> /// <param name="recipe">The recipe to try to craft.</param> /// <param name="networkSide">On which side we're executing the method?</param> /// <param name="craftingActionParameters"></param> /// <returns>True if a crafting action has started, false otherwise.</returns> public void TryToStartCrafting( CraftingRecipe recipe, NetworkSide networkSide, CraftingActionParameters craftingActionParameters ) { if (networkSide == NetworkSide.Client) { CraftingStatus craftingStatus = CanClientCraft( recipe, GetPossibleIngredients(networkSide), GetPossibleTools(networkSide) ); if (craftingActionParameters.Feedback == FeedbackType.GiveAllFeedback || (craftingActionParameters.Feedback == FeedbackType.GiveOnlySuccess && craftingStatus == CraftingStatus.AllGood)) { GiveClientSidedFeedback(craftingStatus, recipe, false); } if (craftingStatus != CraftingStatus.AllGood) { return; } RequestStartCraftingAction.Send(recipe); return; } TryToStartCrafting( recipe, GetPossibleIngredients(networkSide), GetPossibleTools(networkSide), GetReagentContainers(), craftingActionParameters ); }
public bool TryToStartCrafting( CraftingRecipe recipe, List <CraftingIngredient> possibleIngredients, List <ItemAttributesV2> possibleTools, List <ReagentContainer> reagentContainers, CraftingActionParameters craftingActionParameters ) { CraftingStatus craftingStatus = craftingActionParameters.IgnoreToolsAndIngredients ? CanServerCraft(recipe, reagentContainers) : CanCraft(recipe, possibleIngredients, possibleTools, reagentContainers); if (craftingActionParameters.ShouldGiveFeedback) { GiveServerSidedFeedback(craftingStatus, recipe, false); } if (craftingStatus != CraftingStatus.AllGood) { return(false); } StartCrafting(recipe, craftingActionParameters); return(true); }
public void TryToFinishCrafting(CraftingRecipe recipe, CraftingActionParameters craftingActionParameters) { TryToFinishCrafting( recipe, GetPossibleIngredients(NetworkSide.Server), GetPossibleTools(NetworkSide.Server), GetReagentContainers(), craftingActionParameters ); }
private void StartCrafting(CraftingRecipe recipe, CraftingActionParameters craftingActionParameters) { if (recipe.CraftingTime.Approx(0)) { // ok then there is no need to create a special progress action TryToFinishCrafting(recipe, craftingActionParameters); return; } StandardProgressAction.Create( craftProgressActionConfig, () => TryToFinishCrafting(recipe, craftingActionParameters) ).ServerStartProgress(playerScript.registerTile, recipe.CraftingTime, playerScript.gameObject); }
public void TryToStartCrafting(CraftingRecipe recipe, CraftingActionParameters craftingActionParameters) { TryToStartCrafting(recipe, NetworkSide.Server, craftingActionParameters); }