コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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
                );
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void TryToFinishCrafting(CraftingRecipe recipe, CraftingActionParameters craftingActionParameters)
 {
     TryToFinishCrafting(
         recipe,
         GetPossibleIngredients(NetworkSide.Server),
         GetPossibleTools(NetworkSide.Server),
         GetReagentContainers(),
         craftingActionParameters
         );
 }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void TryToStartCrafting(CraftingRecipe recipe, CraftingActionParameters craftingActionParameters)
 {
     TryToStartCrafting(recipe, NetworkSide.Server, craftingActionParameters);
 }