/// <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 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);
        }
Exemple #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);
        }
 public static bool IsValid(CraftingStatus statis)
 {
     if (Status.Stage == 9 || Status.Stage == 10)
     {
         return(true);
     }
     return(false);
 }
        public void GiveServerSidedFeedback(
            CraftingStatus craftingStatus,
            CraftingRecipe recipe,
            bool completingCrafting
            )
        {
            switch (craftingStatus)
            {
            case CraftingStatus.AllGood:
                if (completingCrafting)
                {
                    Chat.AddExamineMsgFromServer(
                        playerScript.gameObject,
                        $"You made \"{recipe.RecipeName}\"."
                        );
                    return;
                }

                if (recipe.CraftingTime > 1)
                {
                    Chat.AddExamineMsgFromServer(
                        playerScript.gameObject,
                        $"You are trying to craft \"{recipe.RecipeName}\"..."
                        );
                }

                return;

            case CraftingStatus.NotEnoughIngredients:
                Chat.AddExamineMsgFromServer(
                    playerScript.gameObject,
                    $"You can't craft \"{recipe.RecipeName}\" because there are not enough ingredients."
                    );
                return;

            case CraftingStatus.NotEnoughTools:
                Chat.AddExamineMsgFromServer(
                    playerScript.gameObject,
                    $"You can't craft \"{recipe.RecipeName}\" because there are not enough tools."
                    );
                return;

            case CraftingStatus.NotEnoughReagents:
                Chat.AddExamineMsgFromServer(
                    playerScript.gameObject,
                    $"You can't craft \"{recipe.RecipeName}\" because there are not enough reagents."
                    );
                return;

            case CraftingStatus.NotAbleToCraft:
                Chat.AddExamineMsgFromServer(
                    playerScript.gameObject,
                    $"You can't craft \"{recipe.RecipeName}\" because your character can't craft this."
                    );
                return;

            case CraftingStatus.UnspecifiedImpossibility:
                Chat.AddExamineMsgFromServer(
                    playerScript.gameObject,
                    $"You can't craft \"{recipe.RecipeName}\"."
                    );
                return;

            default:
                Chat.AddExamineMsgFromServer(
                    playerScript.gameObject,
                    $"You can't craft \"{recipe.RecipeName}\" for some reason. " +
                    "Report this message to developers."
                    );
                return;
            }
        }