示例#1
0
 public bool CheckRequirements(WIBlueprint blueprint, List <List <InventorySquareCrafting> > rows, InventorySquareCraftingResult resultSquare, ref int numCraftableItems)
 {
     numCraftableItems = Globals.NumItemsPerStack;
     if (CheckRequirementsRow(blueprint, rows [0], ref numCraftableItems) &&
         CheckRequirementsRow(blueprint, rows [1], ref numCraftableItems) &&
         CheckRequirementsRow(blueprint, rows [2], ref numCraftableItems))
     {
         resultSquare.RequirementsMet = true;
     }
     else
     {
         numCraftableItems            = 0;
         resultSquare.RequirementsMet = false;
     }
     resultSquare.NumItemsPossible = numCraftableItems;
     return(resultSquare.RequirementsMet);
 }
示例#2
0
        public IEnumerator CraftItems(
            WIBlueprint blueprint,
            CraftingItem craftingItem,
            int totalItems,
            List <List <InventorySquareCrafting> > rows,
            InventorySquareCraftingResult resultSquare)
        {
            int    currentItem          = 0;
            double startTime            = 0f;
            double endTime              = 0f;
            double timeOffset           = 0f;
            double timeMultiplier       = 1f;
            double craftTime            = 0f;
            double craftSkillUsageValue = 0f;

            mProgressValue = 0f;

            UseStart(true);

            //here we go with the crafting...
            while (currentItem < totalItems && !mCancelled)
            {
                craftTime            = blueprint.BaseCraftTime * EffectTime;
                craftSkillUsageValue = 1.0f;                //TODO apply modifiers

                startTime = WorldClock.RealTime;
                endTime   = startTime + craftTime;

                if (totalItems > 1)
                {
                    timeOffset     = (float)(currentItem - 1) / (float)totalItems;
                    timeMultiplier = 1.0f / totalItems;
                    //crafting time is reduced in proportion to the number of items you're crafting at once
                }
                //ok, if we can consume the requirements, we're good to go

                if (!ConsumeRequirements(rows))
                {
                    //Debug.Log ("Couldn't consume requirements");
                    break;
                }
                else
                {
                    while (WorldClock.RealTime < endTime && !ProgressCanceled)
                    {
                        double normalizedProgress = (WorldClock.RealTime - startTime) / (endTime - startTime);
                        mProgressValue = (float)((normalizedProgress * timeMultiplier) + timeOffset);                        //make sure it doesn't accidentally stop
                        mProgressValue = Mathf.Clamp(mProgressValue, 0.001f, 0.999f);
                        yield return(null);
                    }

                    if (!ProgressCanceled)
                    {
                        resultSquare.NumItemsCrafted++;
                        currentItem++;
                    }
                }
                yield return(null);
            }
            //just in case
            mProgressValue = 1.0f;

            UseFinish();
            yield break;
        }
示例#3
0
 public void LoadBlueprintsRows(List <List <InventorySquareCrafting> > rows, WIBlueprint blueprint, InventorySquareCraftingResult resultSquare)
 {
     LoadBlueprintRow(rows [0], blueprint.Row1, blueprint.Strictness);
     LoadBlueprintRow(rows [1], blueprint.Row2, blueprint.Strictness);
     LoadBlueprintRow(rows [2], blueprint.Row3, blueprint.Strictness);
     resultSquare.RequirementsMet = false;
 }