예제 #1
0
        public override void Populate(Recipe recipe)
        {
            NumCrafted = 0;

            _maxCrafts    = CraftingHelper.GetMaxNumberOfCrafts(recipe);
            NumberToCraft = 1; // Math.Min(_maxCrafts, 1);

            //if (t)
            //{
            //    t.text = _maxCrafts.ToString();
            //}

            m_output = null;

            if (OutputImage)
            {
                OutputImage.texture = null;
            }

            SetCraftCount();

            PopulateIngredients();

            base.Populate(recipe);
        }
        public override bool CheckState(FrameOperationContext fop, CanExecuteRecipeCondition condition, out object[] results)
        {
            results = null;

            if (condition.RecipeReference != null)
            {
                // First, is recipe active
                var recipe = ActivatedRecipeManager.Instance.GetRecipe(condition.RecipeReference.ObjectId);

                if (recipe != null)
                {
                    return(CraftingHelper.GetMaxNumberOfCrafts(recipe) >=
                           condition.Count.GetValueOrDefault(1));
                }
            }

            return(false);
        }
        public override bool CheckState(FrameOperationContext fop, CanCraftCollectibleCondition condition, out object[] results)
        {
            if (condition.CollectibleCount != null)
            {
                var recipes = ActivatedRecipeManager.Instance.GetRecipesForCollectible(condition.CollectibleCount.CollectibleId);

                if (recipes != null)
                {
                    var canCraft = recipes.Where(
                        r => CraftingHelper.GetMaxNumberOfCrafts(r) >= condition.CollectibleCount.Count)
                                   .ToArray();

                    if (canCraft.Length >= 1)
                    {
                        results = canCraft;
                        return(true);
                    }
                }
            }

            results = null;

            return(false);
        }